Make Protocol.from_dict work; it was previously broken due to the sim_setup step
Add from_json and to_json methods to Protocol, and a unit test that ensures they go back and forth consistently
Getting this to pass required some fixes to SegmentationMethod dict conversion:
Slightly narrowed the set of fields grabbed by SegmentationMethod.to_dict
Ensured that SegmentationMethod.from_dict knows how to construct Material objects when it needs to
Add from_json and to_json methods to Transducer, and a unit test that ensures they go back and forth consistently
Make sure it is possible to create a default protocol; it was not possible because it was trying to internally instantiate an abstract focal pattern
I see there is a custom JSONEncoder in openlifu.util.json, and I considered adding functionality there or re-using that in some way. But I opted not to because there isn't an openlifu-wide consistent method of serializing and deserializing to files; we are currently a bit all over the place with some classes doing their own thing and other classes using openlifu.util.json. So for now I'd rather just have Protocol and Transducer define their own personal serialization functions so that we can use them in SlicerOpenLIFU, and then later if there is interest we can revamp the serialization functionality across all of openlifu to be a bit more streamlined and consistent.
Close #85
Protocol.from_dict
work; it was previously broken due to thesim_setup
stepfrom_json
andto_json
methods toProtocol
, and a unit test that ensures they go back and forth consistentlySegmentationMethod
dict conversion:SegmentationMethod.to_dict
SegmentationMethod.from_dict
knows how to constructMaterial
objects when it needs tofrom_json
andto_json
methods toTransducer
, and a unit test that ensures they go back and forth consistentlyI see there is a custom
JSONEncoder
inopenlifu.util.json
, and I considered adding functionality there or re-using that in some way. But I opted not to because there isn't an openlifu-wide consistent method of serializing and deserializing to files; we are currently a bit all over the place with some classes doing their own thing and other classes usingopenlifu.util.json
. So for now I'd rather just haveProtocol
andTransducer
define their own personal serialization functions so that we can use them in SlicerOpenLIFU, and then later if there is interest we can revamp the serialization functionality across all of openlifu to be a bit more streamlined and consistent.