MouseLand / suite2p

cell detection in calcium imaging recordings
http://www.suite2p.org
GNU General Public License v3.0
344 stars 240 forks source link

BUG: <Error in create_neuropil_basis> #979

Closed Gery111 closed 1 year ago

Gery111 commented 1 year ago

Describe the issue:

Hi,

When I run suite2p in ROI detection, it shows that in create_neuropil_basis , it has an infinity number so it can not convert to an integer ntilesY = 1 + 2 * int(np.ceil(tile_factor * Ly / (ratio_neuropil * diameter[0] / 2)) / 2)

I guess the ratio_neuropil or diameter is zero so it's to be infinity. In GUI, I set diameter as 0, I do not know if that diameter value had been estimated correctly in Cellpose.

Thanks

Reproduce the code example:

array({'suite2p_version': '0.13.0', 'look_one_level_down': 0.0, 'fast_disk': 'E:/WTC2307/230509_s1', 'delete_bin': False, 'mesoscan': False, 'bruker': False, 'bruker_bidirectional': False, 'h5py': [], 'h5py_key': 'data', 'nwb_file': '', 'nwb_driver': '', 'nwb_series': '', 'save_path0': 'E:/WTC2307/230509_s1', 'save_folder': 'suite2p', 'subfolders': [], 'move_bin': False, 'nplanes': 1, 'nchannels': 1, 'functional_chan': 1, 'tau': 0.17, 'fs': 58.23, 'force_sktiff': False, 'frames_include': -1, 'multiplane_parallel': 0.0, 'ignore_flyback': [], 'preclassify': 0.0, 'save_mat': False, 'save_NWB': 0.0, 'combined': 1.0, 'aspect': 1.0, 'do_bidiphase': False, 'bidiphase': 0.0, 'bidi_corrected': False, 'do_registration': 1, 'two_step_registration': 1.0, 'keep_movie_raw': True, 'nimg_init': 3000, 'batch_size': 3000, 'maxregshift': 0.1, 'align_by_chan': 1, 'reg_tif': False, 'reg_tif_chan2': False, 'subpixel': 10, 'smooth_sigma_time': 0.0, 'smooth_sigma': 1.15, 'th_badframes': 1.0, 'norm_frames': True, 'force_refImg': False, 'pad_fft': False, 'nonrigid': True, 'block_size': [128, 128], 'snr_thresh': 1.2, 'maxregshiftNR': 5.0, '1Preg': False, 'spatial_hp_reg': 42.0, 'pre_smooth': 0.0, 'spatial_taper': 40.0, 'roidetect': False, 'spikedetect': True, 'sparse_mode': False, 'spatial_scale': 0, 'connected': True, 'nbinned': 5000, 'max_iterations': 30, 'threshold_scaling': 1.0, 'max_overlap': 0.75, 'high_pass': 100.0, 'spatial_hp_detect': 25.0, 'denoise': 0.0, 'anatomical_only': 0, 'diameter': 0, 'cellprob_threshold': 0.0, 'flow_threshold': 1.5, 'spatial_hp_cp': 0.0, 'pretrained_model': 'cyto', 'soma_crop': 0.0, 'neuropil_extract': True, 'inner_neuropil_radius': 2, 'min_neuropil_pixels': 350, 'lam_percentile': 50.0, 'allow_overlap': False, 'use_builtin_classifier': False, 'classifier_path': '', 'chan2_thres': 0.65, 'baseline': 'maximin', 'win_baseline': 60.0, 'sig_baseline': 10.0, 'prctile_baseline': 8.0, 'neucoeff': 0.7

Error message:

----------- ROI DETECTION
Binning movie in chunks of length 930
Binned movie of size [5003,228,236] created in 10465.19 sec.
>>>ERROR<<<
Traceback (most recent call last):
  File "C:\Users\34767\.conda\envs\suite2p\lib\runpy.py", line 194, in _run_module_as_main
>>>ERROR<<<
    return _run_code(code, main_globals, None,
  File "C:\Users\34767\.conda\envs\suite2p\lib\runpy.py", line 87, in _run_code
>>>ERROR<<<
    exec(code, run_globals)
  File "C:\Users\34767\.conda\envs\suite2p\lib\site-packages\suite2p\__main__.py", line 81, in <module>
>>>ERROR<<<
    main()
  File "C:\Users\34767\.conda\envs\suite2p\lib\site-packages\suite2p\__main__.py", line 74, in main
>>>ERROR<<<
    run_s2p(ops, db)
  File "C:\Users\34767\.conda\envs\suite2p\lib\site-packages\suite2p\run_s2p.py", line 518, in run_s2p
>>>ERROR<<<
    op = run_plane(op, ops_path=ops_path)
  File "C:\Users\34767\.conda\envs\suite2p\lib\site-packages\suite2p\run_s2p.py", line 333, in run_plane
>>>ERROR<<<
    ops = pipeline(f_reg, f_raw, f_reg_chan2, f_raw_chan2, run_registration, ops,
  File "C:\Users\34767\.conda\envs\suite2p\lib\site-packages\suite2p\run_s2p.py", line 162, in pipeline
    ops, stat = detection.detection_wrapper(f_reg, ops=ops, classfile=classfile)
  File "C:\Users\34767\.conda\envs\suite2p\lib\site-packages\suite2p\detection\detect.py", line 169, in detection_wrapper
>>>ERROR<<<
    stat = select_rois(
  File "C:\Users\34767\.conda\envs\suite2p\lib\site-packages\suite2p\detection\detect.py", line 237, in select_rois
>>>ERROR<<<
    ops, stat = sourcery.sourcery(mov=mov, ops=ops)
  File "C:\Users\34767\.conda\envs\suite2p\lib\site-packages\suite2p\detection\sourcery.py", line 402, in sourcery
>>>ERROR<<<
    S, StU, StS = getStU(ops, U)
  File "C:\Users\34767\.conda\envs\suite2p\lib\site-packages\suite2p\detection\sourcery.py", line 64, in getStU
    S = create_neuropil_basis(ops, Lyc, Lxc)
  File "C:\Users\34767\.conda\envs\suite2p\lib\site-packages\suite2p\detection\sourcery.py", line 125, in create_neuropil_basis
    ntilesY = 1 + 2 * int(
OverflowError: cannot convert float infinity to integer

Version information:

suite2p v0.13.0

Context for the issue:

No response

Gery111 commented 1 year ago

by the way, I have the multiday recordings, the dataset is quite large. when I test a small data part, It works fine

Gery111 commented 1 year ago

update:

I set sparse_mode as 1, then it works

noahpettit commented 1 year ago

Hey @Gery111, did you ever get it to work with sparse_mode set to 0? I am encountering the same error. I haven't looked into exactly what sparse_mode is doing, but my activity sources are certainly not sparse in space or in time, so I'd like to try the detection without it.