Skip to content

Commit d54143d

Browse files
Update Transducer asset path getter to handle TransducerArray
For the changes towards #380 and #381
1 parent 72eaa5a commit d54143d

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/openlifu/db/database.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -819,25 +819,24 @@ def get_transducer_absolute_filepaths(self, transducer_id:str) -> Dict[str,str |
819819
None if no transducer body is available.
820820
"""
821821
transducer_metadata_filepath = self.get_transducer_filename(transducer_id)
822-
with open(transducer_metadata_filepath) as f:
823-
transducer = json.load(f)
824-
transducer_filepaths_dict = {
825-
"id": transducer["id"],
826-
"name": transducer["name"],
827-
}
828-
if "registration_surface_filename" in transducer and transducer["registration_surface_filename"] is not None:
829-
transducer_filepaths_dict["registration_surface_abspath"] = str(
830-
Path(transducer_metadata_filepath).parent/transducer["registration_surface_filename"]
831-
)
832-
else:
833-
transducer_filepaths_dict["registration_surface_abspath"] = None
834-
if "transducer_body_filename" in transducer and transducer["transducer_body_filename"] is not None:
835-
transducer_filepaths_dict["transducer_body_abspath"] = str(
836-
Path(transducer_metadata_filepath).parent/transducer["transducer_body_filename"]
837-
)
838-
else:
839-
transducer_filepaths_dict["transducer_body_abspath"] = None
840-
return transducer_filepaths_dict
822+
transducer = self.load_transducer(transducer_id, convert_array=True)
823+
824+
transducer_filepaths_dict = {
825+
"id": transducer.id,
826+
"name": transducer.name,
827+
"registration_surface_abspath" : None,
828+
"transducer_body_abspath" : None,
829+
}
830+
831+
if transducer.registration_surface_filename is not None:
832+
transducer_filepaths_dict["registration_surface_abspath"] = str(
833+
Path(transducer_metadata_filepath).parent/(transducer.registration_surface_filename)
834+
)
835+
if transducer.transducer_body_filename is not None:
836+
transducer_filepaths_dict["transducer_body_abspath"] = str(
837+
Path(transducer_metadata_filepath).parent/(transducer.transducer_body_filename)
838+
)
839+
return transducer_filepaths_dict
841840

842841
def load_standoff(self, transducer_id, standoff_id="standoff"):
843842
raise NotImplementedError("Standoff is not yet implemented")

0 commit comments

Comments
 (0)