@@ -110,6 +110,20 @@ def estimate_n_pixels_per_process(n_processes: int, T: int, dims: tuple[int, ...
110110 return npx_per_proc
111111
112112
113+ def fix_multid_subindices (movie_path : str , subindices : Union [list , tuple ]) -> Union [list , tuple ]:
114+ """
115+ Make multidimensional subindices that work for the given file type for caiman.load, given that
116+ some file types expect subindices as a list and others don't explicitly support multi-D subindices
117+ and therefore they must be passed as a tuple to work correctly.
118+ """
119+ _ , ext = os .path .splitext (movie_path )
120+ if ext in ['.tif' , '.tiff' , '.btf' , '.avi' , '.mkv' ]:
121+ # formats that expect multi-D subindices as a list
122+ return list (subindices )
123+ else :
124+ return tuple (subindices )
125+
126+
113127R = TypeVar ('R' )
114128class ColumnMappingFunction (Generic [R ]):
115129 """
@@ -133,7 +147,7 @@ def _helper(self, args: tuple) -> R:
133147 else :
134148 logging .debug (f'In column mapping kernel, cols = { col_slice .start } to { col_slice .stop } ' )
135149
136- mov : cm .movie = cm .load (movie_path , subindices = subindices , var_name_hdf5 = var_name_hdf5 )
150+ mov : cm .movie = cm .load (movie_path , subindices = fix_multid_subindices ( movie_path , subindices ) , var_name_hdf5 = var_name_hdf5 )
137151 T , * dims = mov .shape
138152
139153 # flatten to pixels x time
@@ -324,7 +338,7 @@ def save_correlation_parallel(uuid, movie_path: Union[str, Path], output_dir: Pa
324338
325339def chunk_correlation_helper (args : tuple [str , ChunkDims ]) -> np .ndarray :
326340 movie_path , dims_input = args
327- mov = cm .load (movie_path , subindices = ( slice (None ),) + dims_input )
341+ mov = cm .load (movie_path , subindices = fix_multid_subindices ( movie_path , ( slice (None ),) + dims_input ) )
328342 return local_correlations (mov , swap_dim = False )
329343
330344
0 commit comments