@@ -104,16 +104,17 @@ def get_processed_root_data_dir() -> Union[str, pathlib.Path]:
104104 return get_imaging_root_data_dir ()[0 ]
105105
106106
107- def get_image_files (scan_key : dict , file_type : str ) -> list :
108- """Retrieve the list of image files associated with a given Scan.
107+ def get_calcium_imaging_files (scan_key : dict , acq_software : str ) -> list :
108+ """Retrieve the list of absolute paths of the calcium imaging files associated with a given Scan and a given acquisition software (e.g. .tif, .sbx, etc.) .
109109
110110 Args:
111111 scan_key: Primary key of a Scan entry.
112+ acq_software: name of the acquisition software, matching AcquisitionSoftware entry (i.e. "ScanImage" "Scanbox", "NIS", or "PrairieView")
112113
113114 Returns:
114115 A list of full file paths.
115116 """
116- return _linking_module .get_image_files (scan_key , file_type )
117+ return _linking_module .get_calcium_imaging_files (scan_key , acq_software )
117118
118119
119120# ----------------------------- Table declarations ----------------------
@@ -289,12 +290,12 @@ def make(self, key):
289290 """Populate the ScanInfo with the information parsed from image files."""
290291
291292 acq_software = (Scan & key ).fetch1 ("acq_software" )
293+ scan_filepaths = get_calcium_imaging_files (key , acq_software )
292294
293295 if acq_software == "ScanImage" :
294296 import scanreader
295297
296298 # Read the scan
297- scan_filepaths = get_image_files (key , "*.tif" )
298299 scan = scanreader .read_scan (scan_filepaths )
299300
300301 # Insert in ScanInfo
@@ -370,7 +371,6 @@ def make(self, key):
370371 import sbxreader
371372
372373 # Read the scan
373- scan_filepaths = get_image_files (key , "*.sbx" )
374374 sbx_meta = sbxreader .sbx_get_metadata (scan_filepaths [0 ])
375375 sbx_matinfo = sbxreader .sbx_get_info (scan_filepaths [0 ])
376376 is_multiROI = bool (
@@ -429,7 +429,6 @@ def make(self, key):
429429 import nd2
430430
431431 # Read the scan
432- scan_filepaths = get_image_files (key , "*.nd2" )
433432 nd2_file = nd2 .ND2File (scan_filepaths [0 ])
434433 is_multiROI = False # MultiROI to be implemented later
435434
@@ -519,7 +518,6 @@ def estimate_nd2_scan_duration(nd2_scan_obj):
519518 elif acq_software == "PrairieView" :
520519 from element_interface import prairie_view_loader
521520
522- scan_filepaths = get_image_files (key , "*.tif" )
523521 PVScan_info = prairie_view_loader .get_prairieview_metadata (
524522 scan_filepaths [0 ]
525523 )
@@ -612,30 +610,31 @@ def make(self, key):
612610 acq_software , nchannels = (Scan * ScanInfo & key ).fetch1 (
613611 "acq_software" , "nchannels"
614612 )
613+ scan_filepaths = get_calcium_imaging_files (key , acq_software )
615614
616615 if acq_software == "ScanImage" :
617616 import scanreader
618617
619618 # Switch from FYXCT to TCYX
620- data = scanreader .read_scan (get_image_files ( key , "*.tif" ))[
621- key [ "field_idx" ]
622- ]. transpose ( 3 , 2 , 0 , 1 )
619+ data = scanreader .read_scan (scan_filepaths )[ key [ "field_idx" ]]. transpose (
620+ 3 , 2 , 0 , 1
621+ )
623622 elif acq_software == "Scanbox" :
624623 from sbxreader import sbx_memmap
625624
626625 # Switch from TFCYX to TCYX
627- data = sbx_memmap (get_image_files ( key , "*.sbx" ) )[:, key ["field_idx" ]]
626+ data = sbx_memmap (scan_filepaths )[:, key ["field_idx" ]]
628627 elif acq_software == "NIS" :
629628 import nd2
630629
631- nd2_file = nd2 .ND2File (get_image_files ( key , "*.nd2" ) [0 ])
630+ nd2_file = nd2 .ND2File (scan_filepaths [0 ])
632631
633632 nd2_dims = {k : i for i , k in enumerate (nd2_file .sizes )}
634633
635634 valid_dimensions = "TZCYX"
636635 assert set (nd2_dims ) <= set (
637636 valid_dimensions
638- ), f"Unknown dimensions { set (nd2_dims )- set (valid_dimensions )} in file { get_image_files ( key , '*.nd2' ) [0 ]} ."
637+ ), f"Unknown dimensions { set (nd2_dims )- set (valid_dimensions )} in file { scan_filepaths [0 ]} ."
639638
640639 # Sort the dimensions in the order of TZCYX, skipping the missing ones.
641640 data = nd2_file .asarray ().transpose (
0 commit comments