@@ -49,12 +49,11 @@ def main(batch_path, uuid, data_path: str = None):
4949 Yr , dims , T = cm .load_memmap (fname_new )
5050 images = np .reshape (Yr .T , [T ] + list (dims ), order = 'F' )
5151
52- mean_projection_path = str (Path (input_movie_path ).parent .joinpath (f'{ uuid } _mean_projection.npy' ))
53- std_projection_path = str (Path (input_movie_path ).parent .joinpath (f'{ uuid } _std_projection.npy' ))
54- max_projection_path = str (Path (input_movie_path ).parent .joinpath (f'{ uuid } _max_projection.npy' ))
55- np .save (mean_projection_path , np .mean (images , axis = 0 ))
56- np .save (std_projection_path , np .std (images , axis = 0 ))
57- np .save (max_projection_path , np .max (images , axis = 0 ))
52+ proj_paths = dict ()
53+ for proj_type in ['mean' , 'std' , 'max' ]:
54+ p_img = getattr (np , f'nan{ proj_type } ' )(images , axis = 0 )
55+ proj_paths [proj_type ] = Path (input_movie_path ).parent .joinpath (f'{ uuid } _{ proj_type } .npy' )
56+ np .save (str (proj_paths [proj_type ]), p_img )
5857
5958 downsample_ratio = params ['downsample_ratio' ]
6059 # in fname new load in memmap order C
@@ -63,11 +62,11 @@ def main(batch_path, uuid, data_path: str = None):
6362 images [::downsample_ratio ], swap_dim = False , gSig = gSig
6463 )
6564
66- pnr_output_path = str ( Path (input_movie_path ).parent .joinpath (f"{ uuid } _pn.npy" ).resolve () )
67- cn_output_path = str ( Path (input_movie_path ).parent .joinpath (f"{ uuid } _cn.npy" ).resolve () )
65+ pnr_output_path = Path (input_movie_path ).parent .joinpath (f"{ uuid } _pn.npy" ).resolve ()
66+ cn_output_path = Path (input_movie_path ).parent .joinpath (f"{ uuid } _cn.npy" ).resolve ()
6867
69- np .save (str (cn_output_path ), cn_filter , allow_pickle = False )
7068 np .save (str (pnr_output_path ), pnr , allow_pickle = False )
69+ np .save (str (cn_output_path ), cn_filter , allow_pickle = False )
7170
7271 d = dict () # for output
7372
@@ -92,13 +91,17 @@ def main(batch_path, uuid, data_path: str = None):
9291 print ("evaluating components" )
9392 cnm .estimates .evaluate_components (images , cnm .params , dview = dview )
9493
95- output_path = str ( Path (input_movie_path ).parent .joinpath (f"{ uuid } .hdf5" ).resolve () )
96- cnm .save (output_path )
94+ output_path = Path (input_movie_path ).parent .joinpath (f"{ uuid } .hdf5" ).resolve ()
95+ cnm .save (str ( output_path ) )
9796
9897 if data_path is not None :
9998 cnmf_hdf5_path = Path (output_path ).relative_to (data_path )
99+ for proj_type in proj_paths .keys ():
100+ d [f"{ proj_type } -projection-path" ] = proj_paths [proj_type ].relative_to (data_path )
100101 else :
101102 cnmf_hdf5_path = output_path
103+ for proj_type in proj_paths .keys ():
104+ d [f"{ proj_type } -projection-path" ] = proj_paths [proj_type ]
102105
103106 d .update (
104107 {
@@ -108,8 +111,8 @@ def main(batch_path, uuid, data_path: str = None):
108111
109112 if data_path is not None :
110113 cnmfe_memmap_path = Path (fname_new ).relative_to (data_path )
111- cn_output_path = Path ( cn_output_path ) .relative_to (data_path )
112- pnr_output_path = Path ( pnr_output_path ) .relative_to (data_path )
114+ cn_output_path = cn_output_path .relative_to (data_path )
115+ pnr_output_path = pnr_output_path .relative_to (data_path )
113116 else :
114117 cnmfe_memmap_path = fname_new
115118
@@ -118,15 +121,12 @@ def main(batch_path, uuid, data_path: str = None):
118121 "cnmf-memmap-path" : cnmfe_memmap_path ,
119122 "corr-img-path" : cn_output_path ,
120123 "pnr-image-path" : pnr_output_path ,
121- "mean-projection-path" : mean_projection_path ,
122- "std-projection-path" : std_projection_path ,
123- "max-projection-path" : max_projection_path ,
124124 "success" : True ,
125125 "traceback" : None
126126 }
127127 )
128128
129- print (d )
129+ print (f"Final output dict: \n { d } " )
130130
131131 except :
132132 d = {"success" : False , "traceback" : traceback .format_exc ()}
0 commit comments