diff --git a/src/cmlibs/exporter/flatmapsvg.py b/src/cmlibs/exporter/flatmapsvg.py index b87f092..3bc67ca 100644 --- a/src/cmlibs/exporter/flatmapsvg.py +++ b/src/cmlibs/exporter/flatmapsvg.py @@ -1007,16 +1007,25 @@ def _define_background_regions(boundaries, view_box): cervical_min_y = min_y + brain_height thoracic_min_y = cervical_min_y + cervical_height lumbar_min_y = thoracic_min_y + thoracic_height - brain_rect = f'.id(brain_region)' - cervical_rect = f'.id(cervical_region)' - thoracic_rect = f'.id(thoracic_region)' - lumbar_rect = f'.id(lumbar_region)' - features = { - "brain_region": {"name": "Brain"}, - "cervical_region": {"name": "Cervical C1-C7"}, - "thoracic_region": {"name": "Thoracic T1-T12"}, - "lumbar_region": {"name": "Lumbar L1-"} - } + + brain_rect = '' + cervical_rect = '' + thoracic_rect = '' + lumbar_rect = '' + features = {} + if width > 0: + if brain_height > 0: + features["brain_region"] = {"name": "Brain"} + brain_rect = f'.id(brain_region)' + if cervical_height > 0: + features["cervical_region"] = {"name": "Cervical C1-C7"} + cervical_rect = f'.id(cervical_region)' + if thoracic_height > 0: + features["thoracic_region"] = {"name": "Thoracic T1-T12"} + thoracic_rect = f'.id(thoracic_region)' + if lumbar_height > 0: + features["lumbar_region"] = {"name": "Lumbar L1-"} + lumbar_rect = f'.id(lumbar_region)' return f'{brain_rect}{cervical_rect}{thoracic_rect}{lumbar_rect}', features diff --git a/tests/resources/properties.json b/tests/resources/properties.json new file mode 100644 index 0000000..79e3f35 --- /dev/null +++ b/tests/resources/properties.json @@ -0,0 +1,297 @@ +{ + "features": { + "brain_region": { + "name": "Brain" + }, + "marker_10001": { + "colour": "orange", + "label": "Label 'right level of superior border of jugular foramen on the vagus nerve' for term 'UBERON:9947841' was not found during lookup.", + "models": "UBERON:9947841" + }, + "marker_10002": { + "colour": "orange", + "label": "Label 'right level of inferior border of jugular foramen on the vagus nerve' for term 'UBERON:9936083' was not found during lookup.", + "models": "UBERON:9936083" + }, + "marker_10003": { + "colour": "orange", + "label": "Label 'right level of angle of the mandible on the vagus nerve' for term 'UBERON:9986030' was not found during lookup.", + "models": "UBERON:9986030" + }, + "marker_10004": { + "colour": "orange", + "label": "Label 'right level of carotid bifurcation on the vagus nerve' for term 'UBERON:9936336' was not found during lookup.", + "models": "UBERON:9936336" + }, + "marker_10005": { + "colour": "orange", + "label": "Label 'right level of laryngeal prominence on the vagus nerve' for term 'UBERON:9931228' was not found during lookup.", + "models": "UBERON:9931228" + }, + "marker_10006": { + "colour": "orange", + "label": "Label 'right level of superior border of the clavicle on the vagus nerve' for term 'UBERON:9968398' was not found during lookup.", + "models": "UBERON:9968398" + }, + "marker_10007": { + "colour": "orange", + "label": "Label 'right level of jugular notch on the vagus nerve' for term 'UBERON:9967307' was not found during lookup.", + "models": "UBERON:9967307" + }, + "marker_10008": { + "colour": "orange", + "label": "Label 'right level of sternal angle on the vagus nerve' for term 'UBERON:9987408' was not found during lookup.", + "models": "UBERON:9987408" + }, + "nerve_feature_01": { + "label": "Label 'Right hypoglossal nerve' for term 'ILX:987654' was not found during lookup." + }, + "nerve_feature_02": { + "label": "Label 'Right spinal accessory nerve' for term 'ILX:345678' was not found during lookup." + }, + "nerve_feature_03": { + "label": "Label 'cardiovascular/cardiopulmonary branch of right cervical vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_04": { + "label": "Label 'cardiovascular/cardiopulmonary branch of right thoracic vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_08": { + "label": "Label 'right A branch of cervical vagus nerve to sympathetic chain, cardiovascular, and pulmonary structures' for term '' was not found during lookup." + }, + "nerve_feature_09": { + "label": "Label 'right A branch of thoracic vagus nerve to esophageal plexus' for term '' was not found during lookup." + }, + "nerve_feature_10": { + "label": "Label 'right A cardiovascular branch of cervical vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_11": { + "label": "Label 'right A cardiovascular branch of cranial nerve bundle' for term '' was not found during lookup." + }, + "nerve_feature_12": { + "label": "Label 'right A lateral pulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_13": { + "label": "Label 'right A medial pulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_14": { + "label": "Label 'right A thoracic cardiopulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_15": { + "label": "Label 'right B branch of thoracic vagus nerve to esophageal plexus' for term '' was not found during lookup." + }, + "nerve_feature_16": { + "label": "Label 'right B cardiovascular branch of cranial nerve bundle' for term '' was not found during lookup." + }, + "nerve_feature_17": { + "label": "Label 'right B lateral pulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_18": { + "label": "Label 'right B medial pulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_19": { + "label": "Label 'right B thoracic cardiopulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_20": { + "label": "Label 'right C branch of thoracic vagus nerve to esophageal plexus' for term '' was not found during lookup." + }, + "nerve_feature_21": { + "label": "Label 'right C lateral pulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_22": { + "label": "Label 'right C medial pulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_23": { + "label": "Label 'right C thoracic cardiopulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_24": { + "label": "Label 'right D branch of thoracic vagus nerve to esophageal plexus' for term '' was not found during lookup." + }, + "nerve_feature_25": { + "label": "Label 'right D lateral pulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_26": { + "label": "Label 'right D medial pulmonary branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_27": { + "label": "Label 'right E branch of thoracic vagus nerve to esophageal plexus' for term '' was not found during lookup." + }, + "nerve_feature_28": { + "label": "Label 'right F branch of thoracic vagus nerve to esophageal plexus' for term '' was not found during lookup." + }, + "nerve_feature_29": { + "label": "Label 'right G branch of thoracic vagus nerve to esophageal plexus' for term '' was not found during lookup." + }, + "nerve_feature_30": { + "label": "Label 'right H branch of thoracic vagus nerve to esophageal plexus' for term '' was not found during lookup." + }, + "nerve_feature_31": { + "label": "Label 'right I branch of thoracic vagus nerve to esophageal plexus' for term '' was not found during lookup." + }, + "nerve_feature_32": { + "label": "Label 'right J branch of thoracic vagus nerve to esophageal plexus' for term '' was not found during lookup." + }, + "nerve_feature_33": { + "label": "Label 'right branch between cranial nerve bundle and superior cervical ganglion' for term '' was not found during lookup." + }, + "nerve_feature_35": { + "label": "Label 'right branch of cervical vagus nerve to sympathetic chain, cardiovascular, and pulmonary structures' for term '' was not found during lookup." + }, + "nerve_feature_36": { + "label": "Label 'right cardiovascular branch of cervical vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_38": { + "label": "Label 'right cervical vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_39": { + "label": "Label 'right cranial nerve bundle to cervical spinal nerve' for term '' was not found during lookup." + }, + "nerve_feature_42": { + "label": "Label 'right pharyngeal branch of cranial nerve bundle' for term '' was not found during lookup." + }, + "nerve_feature_43": { + "label": "Label 'right recurrent laryngeal nerve' for term '' was not found during lookup." + }, + "nerve_feature_44": { + "label": "Label 'right superior laryngeal nerve' for term '' was not found during lookup." + }, + "nerve_feature_46": { + "label": "Label 'right thoracic vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_47": { + "label": "Label 'right unknown branch of vagus nerve' for term '' was not found during lookup." + }, + "nerve_feature_48": { + "label": "Label 'right vagus nerve' for term '' was not found during lookup." + } + }, + "networks": [ + { + "centrelines": [ + { + "id": "nerve_feature_38" + }, + { + "id": "nerve_feature_48" + }, + { + "id": "nerve_feature_46" + }, + { + "id": "nerve_feature_01", + "models": "ILX:987654" + }, + { + "id": "nerve_feature_02", + "models": "ILX:345678" + }, + { + "id": "nerve_feature_03" + }, + { + "id": "nerve_feature_04" + }, + { + "id": "nerve_feature_08" + }, + { + "id": "nerve_feature_35" + }, + { + "id": "nerve_feature_09" + }, + { + "id": "nerve_feature_10" + }, + { + "id": "nerve_feature_36" + }, + { + "id": "nerve_feature_11" + }, + { + "id": "nerve_feature_12" + }, + { + "id": "nerve_feature_13" + }, + { + "id": "nerve_feature_14" + }, + { + "id": "nerve_feature_15" + }, + { + "id": "nerve_feature_16" + }, + { + "id": "nerve_feature_17" + }, + { + "id": "nerve_feature_18" + }, + { + "id": "nerve_feature_19" + }, + { + "id": "nerve_feature_20" + }, + { + "id": "nerve_feature_21" + }, + { + "id": "nerve_feature_22" + }, + { + "id": "nerve_feature_23" + }, + { + "id": "nerve_feature_24" + }, + { + "id": "nerve_feature_25" + }, + { + "id": "nerve_feature_26" + }, + { + "id": "nerve_feature_27" + }, + { + "id": "nerve_feature_28" + }, + { + "id": "nerve_feature_29" + }, + { + "id": "nerve_feature_30" + }, + { + "id": "nerve_feature_31" + }, + { + "id": "nerve_feature_32" + }, + { + "id": "nerve_feature_33" + }, + { + "id": "nerve_feature_39" + }, + { + "id": "nerve_feature_42" + }, + { + "id": "nerve_feature_43" + }, + { + "id": "nerve_feature_44" + }, + { + "id": "nerve_feature_47" + } + ], + "id": "vagus", + "type": "nerve" + } + ] +} \ No newline at end of file diff --git a/tests/resources/vagus.svg b/tests/resources/vagus.svg new file mode 100644 index 0000000..ac94166 --- /dev/null +++ b/tests/resources/vagus.svg @@ -0,0 +1,270 @@ + + + + .id(brain_region) + + + .id(nerve_feature_38) + + + .id(nerve_feature_38_outline) + + + .id(nerve_feature_48) + + + .id(nerve_feature_48_outline) + + + .id(nerve_feature_46) + + + .id(nerve_feature_46_outline) + + + .id(nerve_feature_01) + + + .id(nerve_feature_01_outline) + + + .id(nerve_feature_02) + + + .id(nerve_feature_02_outline) + + + .id(nerve_feature_03) + + + .id(nerve_feature_03_outline) + + + .id(nerve_feature_04) + + + .id(nerve_feature_04_outline) + + + .id(nerve_feature_08) + + + .id(nerve_feature_08_outline) + + + .id(nerve_feature_35) + + + .id(nerve_feature_35_outline) + + + .id(nerve_feature_09) + + + .id(nerve_feature_09_outline) + + + .id(nerve_feature_10) + + + .id(nerve_feature_10_outline) + + + .id(nerve_feature_36) + + + .id(nerve_feature_36_outline) + + + .id(nerve_feature_11) + + + .id(nerve_feature_11_outline) + + + .id(nerve_feature_12) + + + .id(nerve_feature_12_outline) + + + .id(nerve_feature_13) + + + .id(nerve_feature_13_outline) + + + .id(nerve_feature_14) + + + .id(nerve_feature_14_outline) + + + .id(nerve_feature_15) + + + .id(nerve_feature_15_outline) + + + .id(nerve_feature_16) + + + .id(nerve_feature_16_outline) + + + .id(nerve_feature_17) + + + .id(nerve_feature_17_outline) + + + .id(nerve_feature_18) + + + .id(nerve_feature_18_outline) + + + .id(nerve_feature_19) + + + .id(nerve_feature_19_outline) + + + .id(nerve_feature_20) + + + .id(nerve_feature_20_outline) + + + .id(nerve_feature_21) + + + .id(nerve_feature_21_outline) + + + .id(nerve_feature_22) + + + .id(nerve_feature_22_outline) + + + .id(nerve_feature_23) + + + .id(nerve_feature_23_outline) + + + .id(nerve_feature_24) + + + .id(nerve_feature_24_outline) + + + .id(nerve_feature_25) + + + .id(nerve_feature_25_outline) + + + .id(nerve_feature_26) + + + .id(nerve_feature_26_outline) + + + .id(nerve_feature_27) + + + .id(nerve_feature_27_outline) + + + .id(nerve_feature_28) + + + .id(nerve_feature_28_outline) + + + .id(nerve_feature_29) + + + .id(nerve_feature_29_outline) + + + .id(nerve_feature_30) + + + .id(nerve_feature_30_outline) + + + .id(nerve_feature_31) + + + .id(nerve_feature_31_outline) + + + .id(nerve_feature_32) + + + .id(nerve_feature_32_outline) + + + .id(nerve_feature_33) + + + .id(nerve_feature_33_outline) + + + .id(nerve_feature_39) + + + .id(nerve_feature_39_outline) + + + .id(nerve_feature_42) + + + .id(nerve_feature_42_outline) + + + .id(nerve_feature_43) + + + .id(nerve_feature_43_outline) + + + .id(nerve_feature_44) + + + .id(nerve_feature_44_outline) + + + .id(nerve_feature_47) + + + .id(nerve_feature_47_outline) + + + .id(marker_10001) + + + .id(marker_10002) + + + .id(marker_10003) + + + .id(marker_10004) + + + .id(marker_10005) + + + .id(marker_10006) + + + .id(marker_10007) + + + .id(marker_10008) + + diff --git a/tests/test_flatmapsvg.py b/tests/test_flatmapsvg.py index 55a630a..83750b2 100644 --- a/tests/test_flatmapsvg.py +++ b/tests/test_flatmapsvg.py @@ -91,7 +91,7 @@ def test_flatmap_svg_user_mesh(self): tree = ET.parse(flatmap_svg_file) root = tree.getroot() - self.assertEqual(92, len(root)) + self.assertEqual(89, len(root)) with open(properties_file) as f: content = json.load(f)