Skip to content

Commit 73035be

Browse files
committed
Modify SegmentationMethod.from_dict to handle water/tissue (#290)
- Also update associated JSON files to include the `ref_material` for all `SegmentationMethod`s, even if it is not intended to change.
1 parent b151fc9 commit 73035be

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/openlifu/seg/seg_method.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ def from_dict(d: dict) -> SegmentationMethod:
5353
for k, v in materials_dict.items()
5454
}
5555

56+
# Ignore ref_material if class is `UniformWater` or `UniformTissue`
57+
if short_classname in ["UniformWater", "UniformTissue"]:
58+
d.pop("ref_material")
5659
class_constructor = getattr(seg_methods, short_classname)
5760
return class_constructor(**d)
5861

tests/resources/example_db/protocols/example_protocol/example_protocol.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
"specific_heat": 1012,
7171
"thermal_conductivity": 0.025
7272
}
73-
}
73+
},
74+
"ref_material": "water"
7475
},
7576
"sim_setup": {
7677
"dims": ["lat", "ele", "ax"],

tests/resources/example_db/subjects/example_subject/sessions/example_session/runs/example_run/example_run_protocol_snapshot.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
"specific_heat": 1012,
6969
"thermal_conductivity": 0.025
7070
}
71-
}
71+
},
72+
"ref_material": "water"
7273
},
7374
"sim_setup": {
7475
"dims": ["lat", "ele", "ax"],

0 commit comments

Comments
 (0)