alihaydaroglu / suite3d

Fast, accurate, volumetric cell detection. Developed for Light Beads Microscopy, usable for other volumetric 2P. In development
6 stars 0 forks source link

calculate_corr_map crash #21

Closed oterocoronel closed 1 year ago

oterocoronel commented 1 year ago

I was running this:

vmap, mean_img, max_img = job.calculate_corr_map(svd_info)

and it ran through all the batches, but eventually crashed:

Calculated corr map in 217.49 seconds
      Saving to /home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/s3d-Coconut-Demo/iters/batch0013
      Running batch 15 of 15
         Reconstructing from svd
(448, 200, 160000)
         Reconstructed in 235.09 seconds
      Loaded and swapped, idx 5600 to 5800
      Calculating corr map
         Rolling mean filter
         Stdev over time
         Sharr creation
         Sub and conv
         Vmap
   Calculated corr map in 114.40 seconds
      Saving to /home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/s3d-Coconut-Demo/iters/batch0014
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Cell In[13], line 1
----> 1 vmap, mean_img, max_img = job.calculate_corr_map(svd_info)

File /mnt/MarmoScope_Windows10/FreiwaldSync/MarmoScope/Analysis/SantiVersions/suite2p_LBM/s2p-lbm/suite2p/suite2p/suite3d/job.py:310, in Job.calculate_corr_map(self, mov, save, return_mov_filt, crop, svd_info, iter_limit, parent_dir, update_main_params, svs, us)
    306         self.log("Cropped movie to shape: %s" % str(mov.shape))
    307     out =  calculate_corrmap(mov, self.params, self.dirs, self.log, return_mov_filt=return_mov_filt, save=save,
    308                             iter_limit=iter_limit, iter_dir_tag=iter_dir_tag, mov_sub_dir_tag=mov_sub_dir_tag)
--> 310 return out, mov_sub_dir, iter_dir

UnboundLocalError: local variable 'iter_dir' referenced before assignment
alihaydaroglu commented 1 year ago

Ah, this was a recent careless change on my part. I will fix it. You should be able to run the following steps without a problem though since all results are already saved to disk.

oterocoronel commented 1 year ago

This function is used just for calculating a correlation map for a given set of parameters, right? i.e., is it okay to skip this cell altogether if I already ran the one sweeping for different parameters?

alihaydaroglu commented 1 year ago

No, you need to run this to have a correlation map of the full dataset. The sweep only does the first few batches of the data with each parameter set (defined by n_test_iters), but this function calculates it on all of the batches. The intended use is to run the sweep, select the best parameters, and then run this function.

Though the error is OK to ignore since it's just on the return value, all the results are saved to disk earlier in the execution of this function

alihaydaroglu commented 1 year ago

The subsequent steps also expect the outputs to be in the location calculate_corr_map will save them

alihaydaroglu commented 1 year ago

fixed here: https://github.com/alihaydaroglu/s2p-lbm/commit/542c62e86969582d4372a12a7abac09653005bb4