@@ -189,12 +189,12 @@ def __call__(self, movie_path: str, dview: Optional[Cluster], var_name_hdf5='mov
189189 return map_fn (self ._helper , map_args )
190190
191191
192- def _save_c_order_mmap_in_chunks_kernel (Yr_chunk : np .ndarray , pixel_slice : slice , mmap_fname : str ):
192+ def _save_c_order_mmap_in_chunks_kernel (Yr_chunk : np .ndarray , pixel_slice : slice , mmap_fname : str , add_to_movie : float ):
193193 """
194194 Alternative to cm.save_memmap that can load from non-mmap files and uses chunks
195195 Based on caiman.mmapping.save_portion
196196 """
197- c_order_copy = np .ascontiguousarray (Yr_chunk , dtype = np .float32 ) # pixels x time
197+ c_order_copy = np .ascontiguousarray (Yr_chunk , dtype = np .float32 ) + np . float32 ( add_to_movie ) # pixels x time
198198 tot_frames = c_order_copy .shape [1 ]
199199
200200 with open (mmap_fname , 'r+b' ) as f :
@@ -212,8 +212,12 @@ def _save_c_order_mmap_in_chunks_kernel(Yr_chunk: np.ndarray, pixel_slice: slice
212212 raise Exception ('Internal error in mmapping: Actual position does not match computed position' )
213213save_c_order_mmap_in_chunks = ColumnMappingFunction (_save_c_order_mmap_in_chunks_kernel )
214214
215- def save_c_order_mmap_parallel (movie_path : str , base_name : str , dview : Optional [Cluster ], var_name_hdf5 = 'mov' ) -> str :
216- """Alternative to cm.save_memmap that hopefully does better with memory"""
215+ def save_c_order_mmap_parallel (movie_path : str , base_name : str , dview : Optional [Cluster ],
216+ var_name_hdf5 = 'mov' , add_to_movie = 0.0001 ) -> str :
217+ """
218+ Alternative to cm.save_memmap that hopefully does better with memory
219+ add_to_movie=0.0001 emulates default behavior of save_memmap
220+ """
217221 # get name of mmap file and create it
218222 dims , tot_frames = get_file_size (movie_path , var_name_hdf5 = var_name_hdf5 )
219223 assert isinstance (tot_frames , int ) # non-type-stable interface...
@@ -229,7 +233,7 @@ def save_c_order_mmap_parallel(movie_path: str, base_name: str, dview: Optional[
229233 big_mov = np .memmap (mmap_fname , mode = 'w+' , dtype = np .float32 , shape = (d , tot_frames ), order = 'C' )
230234
231235 # parallel load/save call
232- save_c_order_mmap_in_chunks (movie_path , dview , var_name_hdf5 , mmap_fname )
236+ save_c_order_mmap_in_chunks (movie_path , dview , var_name_hdf5 , mmap_fname , add_to_movie )
233237
234238 # clean up
235239 del big_mov
0 commit comments