OpenwaterHealth / OpenLIFU-python

focused ultrasound toolbox
GNU Affero General Public License v3.0
12 stars 2 forks source link

Enable adding a volume to a subject #91

Closed ebrahimebrahim closed 2 months ago

ebrahimebrahim commented 2 months ago

Appending a volume ID to the list of volume IDs in a subject json is easy, and could be done by just reading the subject, modifying it, and then writing it back using Subject.to_file (once #90 is done). However this is not the right level of api to expose. SlicerOpenLIFU for example should not normally be relying on the file I/O that is internal to openlifu.Database. So we really need to use Databse.add_volume. But the latter is very broken: it assumes there is a type (perhaps called “Volume”) that has attributes “id” and “to_json”. The “to_json” was expected to give the actual volume data, which could then be written out to a json file. Several problems: there is no such “Volume” type, there is no Database.write_volume_ids, and of course json is not a good way to represent raw volume data on disk.

Database.add_volume should be fixed, but this is a nontrivial fix that touches on openlifu.Database as a whole.

Depends on #90

ebrahimebrahim commented 2 months ago

To clarify this a bit, the ultimate goal is to have a method Database.add_volume with inputs

db = Database(...)
db.add_volume(subject, filepath, volume_id, volume_name)
"id" : ...
"name" : ...
"filename" : ...

Then Database.add_volume should

There should also be a simple Database.get_volume_info(self, subject, volume_id) method that returns the dictionary of metadata along with the absolute filepath to the volume file.

ebrahimebrahim commented 2 months ago

Closed via #123