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

ROIs at the edges of the FOV #22

Closed oterocoronel closed 1 year ago

oterocoronel commented 1 year ago

image

oterocoronel commented 1 year ago

Also, I did not get many ROIs from regions where I was expecting more. I will try reducing the threshold to see if I get more, but that's not really related to this issue.

image

alihaydaroglu commented 1 year ago

Can you share a print of the params, the log, and a screenshot of the correlation map without any cells overlaid? Thanks.

alihaydaroglu commented 1 year ago

If you want, send me the registered_fused_data folder and I can take a look today or tomorrow. Might be easier for me to debug directly.

oterocoronel commented 1 year ago

image

image

log.txt Params:


{'fs': 4.48165,
 'tau': 0.1,
 'planes': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14]),
 'notch_filt': None,
 'n_init_files': 5,
 'init_file_pool': None,
 'init_file_sample_method': 'even',
 'init_n_frames': None,
 'enforce_positivity': True,
 'subtract_crosstalk': False,
 'override_crosstalk': 0,
 'crosstalk_percentile': 99.5,
 'crosstalk_sigma': 0.01,
 'crosstalk_n_planes': 10,
 'nonrigid': True,
 'smooth_sigma': 1.15,
 'maxregshift': 0.15,
 'reg_filter_pcorr': 1,
 'generate_sample_registered_bins': False,
 'tif_batch_size': 1,
 'n_skip': 1,
 'fuse_crop': ((0, 15), (0, 1300), (0, 1300)),
 'split_tif_size': 100,
 'svd_crop': ((0, 15), (0, 1300), (0, 1300)),
 'svd_time_crop': (None, None),
 'n_svd_comp': 200,
 'svd_block_shape': (4, 200, 200),
 'svd_block_overlaps': (2, 100, 100),
 'svd_pix_chunk': 80000,
 'svd_time_chunk': 4000,
 'svd_save_time_chunk': 400,
 'svd_save_comp_chunk': 100,
 'n_svd_blocks_per_batch': 1,
 'npil_filt_type': 'gaussian',
 'npil_filt_xy': 5.0,
 'npil_filt_z': 1.0,
 'conv_filt_type': 'gaussian',
 'conv_filt_xy': 1.0,
 'conv_filt_z': 0.75,
 'intensity_thresh': 0.4,
 'temporal_hpf': 400,
 't_batch_size': 400,
 'mproc_batchsize': 25,
 'n_proc_corr': 16,
 'dtype': numpy.float32,
 'patch_size_xy': (120, 120),
 'patch_overlap_xy': (25, 25),
 'activity_thresh': 4.0,
 'percentile': 99.0,
 'extend_thresh': 0.2,
 'roi_ext_iterations': 2,
 'max_iter': 10000,
 'detection_timebin': 1,
 'detection_time_crop': (None, None),
 'allow_overlap': False,
 'recompute_v': None,
 'normalize_vmap': False,
 'max_pix': 250,
 'npil_coeff': 0.7,
 'dcnv_baseline': 'maximin',
 'dcnv_win_baseline': 60,
 'dcnv_sig_baseline': 10,
 'dcnv_prctile_baseline': 8,
 'dcnv_batchsize': 3000,
 'subjects_dir': None,
 'subject': None,
 'expnum': None,
 'date': None,
 'tifs': ['/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00001.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00002.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00003.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00004.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00005.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00006.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00007.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00009.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00010.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00011.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00012.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00013.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00014.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00015.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00017.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00018.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00019.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00020.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00021.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00022.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00023.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00025.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00026.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00027.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00028.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00029.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00030.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00031.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00008.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00016.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00024.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00032.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00040.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00048.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00033.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00034.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00035.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00036.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00037.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00038.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00039.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00041.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00042.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00043.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00044.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00045.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00046.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00047.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00049.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00050.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00051.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00052.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00053.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00054.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00055.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00056.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00057.tif',
  '/home/freiwald/Data/analysis_2pRAM/Dali/20230620d/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW/154951tUTC_Max15_depth400um_fov2628x2600um_res3p00x3p00umpx_fr04p482Hz_pow299p9mW_00001_00058.tif'],
 'n_svd_comps': 200,
 'peak_thresh': 5.8}
oterocoronel commented 1 year ago

I'm thinking that maybe it would be a good idea to crop out the edges before doing the SVDs in the patches? Otherwise, many components will just represent spurious information from edges/motion-correction. I assume that's what job.params['svd_crop'] does. I can exclude the ~5 pixels on each side and give it a try

alihaydaroglu commented 1 year ago

oh yes, try with that. I always use svd_crop before doing the svd to crop the empty parts at the edge of the frame, I don't run into this issue. Let me know what happens. One way to see if this will happen before running cell detection is to just look at the correlation maps from the sweep and see if the edges are bright (they shouldn't be)

alihaydaroglu commented 1 year ago

You'll also notice some bright-er patches around the area where the strips are fused. This is kind of an open problem, usually playing with the npil_filt_xy or the conv_filt_xy parameters can reduce/remove these strips. I find that with good parameters the effects disappear/are very small by the end of processing, but it would be ideal if they weren't there at any parameter setting. I'm open to better ideas about how to handle the fusing to remove these artifacts.

oterocoronel commented 1 year ago

Yeah, right now we have calibrated the 2pRAM so the overlap between MROIs is practically zero, you can kind of see it in the maps I'm showing. So I just set the fused pixels to 1, and the edges show up a little bright in the correlation map. You got better results with a larger overlap and then fusing over ~10 pixels?

I have been thinking about the handling of the edges in the FOV. A couple of things:

1) I noticed that the deeper planes are maintained almost intact after alignment, while the shallower planes are cropped in the left-most MROI.

Example deep plane:

image

Example shallow plane:

image

I would imagine that they should be similarly handled, regardless of whether you are taking the x,y pixels where you have all depths (in this case the deeper planes should be cropped at the right edge) or at least one depth (no need to crop at all, this is the behavior I would prefer, and padding with NaNs or zeros at the missing depths).

2) Correct me if I'm wrong, but right now the cropping tools are applied to the whole aligned volume, right? This means that if you crop the 5 left-most pixels in the volume, you are going to remove the actual edges of the MROIs in the planes at one depth, but not in the other ones because of the lateral offsets. You can see that in this shallow plane, I was getting some edge artifacts despite trimming the volume by 6 pixels in each x-y edge:

image

I am thinking that it would be nice if there was something to trim the edges of each plane individually (and not trim the whole volume) right after motion correction

alihaydaroglu commented 1 year ago

Currently, the entire volume is aligned (e.g. the plane-to-plane xy shifts are corrected) during the registration step. Without any cropping there will be dark strips at two edges (e.g. top and right), and the size of the dark strips will increase as you go from plane 0 -> 14 and decrease 15 -> 29 (since the planes are aligned to the deepest plane).

any cropping that happens after registration will happen to the entire volume, so you're right, if each plane is cropped by the same amount, the number of pixels from the edge of the MROI that are removed will be different for each plane.

alihaydaroglu commented 1 year ago

As far as I understand, your suggestion is to crop the same amount off the edge of the MROI for each plane, and I guess replace it with 0s or NaNs? This might fix it, but I'm not sure that it will.

I am not exactly sure of the cause of these bright spots at the edge of the FOV. I think it's probably because this strip of pixels at the edge is neighbored in the plane above by a strip of 0s, and these constant 0s somehow end up affecting the filtering/normalization steps in weird ways. If this is the case, cropping edges of the MROIs from movies before doing the correlation map won't fix it, since you still have regions where you have data on one plane and 0s on the other. My current method is to crop the volume such that every xy coordinate has data on all z planes, and I don't see these issues at the edges. I know it sucks to throw away sizable chunks of data like that, I'll keep working on it here: https://github.com/alihaydaroglu/s2p-lbm/issues/11

In the meantime, just for sanity, can you confirm that if you aggressively crop the FOV such that all xy pixels have data in all planes, you don't see the same issue?

alihaydaroglu commented 1 year ago

As a stop-gap I can add the option to crop the edges of MROIs after the correlation map, which should get rid of the bright strips without removing a big chunk of the volume.

oterocoronel commented 1 year ago

Okay, I was thinking that the correlation artifact may be introduced during motion correction, perhaps when the missing values (due to animal movement) are filled with either copies of other values or 0, causing an increased local correlation

oterocoronel commented 1 year ago

Yes, trimming the volume after the SVD decomposition does remove the correlation artifacts at the edges of the FOV (and prevents the detection of false ROIs there)

oterocoronel commented 1 year ago

You're saying that you are keeping the x-y pixels where you have all the planes, but as I scroll through the planes and look at the right edge of the volume there are some x-y pixels that show up with cells in the deeper planes but they are black for the shallower planes. That's what I was trying to show when I uploaded a screenshot of a deep plane, you can see that that plane is not being cropped at all (compared to significant cropping in a shallower plane). My understanding is that if the shallowest planes is being cropped by X pixels in the left-most MROI, then deepest plane should be cropped by X pixels in the right-most MROI

alihaydaroglu commented 1 year ago

Putting the conclusions from our chat here for what I need to implement:

oterocoronel commented 1 year ago

Have there been any changes addressing this? I ran the pipeline and found that the overhanging MROI from one side was placed on the other side. Notice the right-most MROI:

image

Different plane, also notice the right-most MROI:

image

Side view (from where I used to see the diagonal edge hanging over):

image

alihaydaroglu commented 1 year ago

woah that's weird... I haven't started working on this issue yet, I can't think of any changes I made to cause this... @oterocoronel What exactly is the image seen? Is this the summary['ref_img_3d'] or is it the temporal mean of the registered movie?

oterocoronel commented 1 year ago

It seems like it happened during registration. The reference image looks fine (showing plane 14 here):

image

But the average frame after registration looks weird (same plane 14):

image

Also, registered plane 1 looks like this:

image

But the reference image for plane 1 looks 'better':

image

alihaydaroglu commented 1 year ago

ok, this is pretty weird, sorry about that. I am pretty sure the default behaviour for suite2p registration is to fill the empty pixels with 0s, though it seems like somehow it is wrapping around. I'm working on some other changes to registration as well, I'll make sure to address this

oterocoronel commented 1 year ago

I would think that this issue is due to some error in the reconstruction of the images (i.e. MROI metadata and placing on the canvas) based on some recent commit, and not because of the registration/mc itself. These artifacts are present in the correlation maps now, but they are not present in the screenshots I shared on this thread before the last update (i.e., before updating/pulling a couple days ago).

alihaydaroglu commented 1 year ago

I can't seem to reproduce this issue on my end with the latest version... though looking through the s2p registration code I found that they use np.roll to do the shifting of each frame, which does wraparound by default, so now I'm not sure why mine doesn't haha.

alihaydaroglu commented 1 year ago

The wraparound issue and the fusing issues should be resolved in the GPU registration in the new update. Also with the new update, you don't lose the strip at the edge because of the registration. You might have to re-run the init step on your data to use properly (it will try to estimate the overlap between strips in this step) . If you don't have any overlap when fusing successive strips, you can set the fuse_shift_override to 1 (or 0 if you're brave... it should work)

oterocoronel commented 1 year ago

I ran the GPU registration and found that the lateral shifts in the vertical axis of the image are handled correctly, but the horizontal axis has an 'overhanging' issue where at the left some of the image is missing for shallower planes and at the right there is a dark band in all planes.

This is plane 1:

image

This is plane 14, you can see that half of the first MROI is missing:

image

I think that the issue is that the top-left corner of plane 1 might be placed on the pixel with coordinates (0,0), but this should also consider the maximum shifts across all planes (and their signs). For the vertical axis it probably works well in this example because the plane offsets makes shallower planes move towards the bottom of the image (positive direction of Y axis). But for the horizontal axis, in this case, shallower planes are shifting to the left (negative direction of X axis). I did not look into the code but maybe it could be fixed by adding this coordinate to all planes when placing them into the volume:

(max( - shifts_x), max( - shifts_y) )

In this example, this would make plane 1 to be placed on the top-right edge of the image (vs currently at the top-left), and plane 14 would be complete and near the top-left (vs currently partially cropped)

alihaydaroglu commented 1 year ago

Good catch, I am pushing a corrected implementation to the dev branch. I will merge dev in to master in a few days, but you can also pull the dev branch and re-run today.

Here's plane 0 and plane 14 in the new version (these are without much averaging so it's noisy, but you can see they aren't clipping at the edges):

Untitled Untitled

alihaydaroglu commented 1 year ago

relevant commit: https://github.com/alihaydaroglu/s2p-lbm/commit/71b34c45a76286078ba787c36d15f2931fab06dc

alihaydaroglu commented 1 year ago

padding is adjusted correctly in GPU and CPU reg #48