suite2p icon indicating copy to clipboard operation
suite2p copied to clipboard

Re-run registration on binary data

Open sdaste opened this issue 2 years ago • 5 comments

Hi, I would like to re-run Suite2P, especially the registration on data already binarized (data_raw.bin) in order to test other parameters. However Suite2P either note that the registered data.bin already exists and skips it, or does not run in the file is removed from the folder. What's the best way to work around it (and therefore, avoiding re-binarizing the data)? I'm using the GUI.

Thanks for your help!

sdaste avatar Sep 05 '22 19:09 sdaste

I tried to remove some output informations related to registration in the ops file, but Suite2P would still skips it.

sdaste avatar Sep 05 '22 19:09 sdaste

As I recall, if you keep the (non-registered) binary files but delete the registered binary files, and keep everything else the same, suite2p will re-run the registration only, without again converting from your native / TIFF files to binary. I believe you need to also keep the stats.py file from the previous run. That said, I haven't tested this myself with the latest version.

generalciao avatar Sep 05 '22 20:09 generalciao

This is the error message I get when I try what you mentionned @generalciao:

{'data_path': ['/Volumes/2022_BigSme/RAW_DATA_BigSmells/Day_4/Mouse#2033/TSeries-08242022-1221-001'], 'subfolders': [], 'save_path0': '/Volumes/2023_BigSme/Big_Smell_Exp/Suite2P/Day_4/Mouse#2033', 'fast_disk': '/Volumes/2023_BigSme/Big_Smell_Exp/Suite2P/Day_4/Mouse#2033', 'input_format': 'bruker'}
FOUND BINARIES AND OPS IN ['/Volumes/2023_BigSme/Big_Smell_Exp/Suite2P/Day_4/Mouse#2033/suite2p/plane0/ops.npy', '/Volumes/2023_BigSme/Big_Smell_Exp/Suite2P/Day_4/Mouse#2033/suite2p/plane1/ops.npy', '/Volumes/2023_BigSme/Big_Smell_Exp/Suite2P/Day_4/Mouse#2033/suite2p/plane2/ops.npy']
 PLANE 0 <<<<<<<<<<<<<<<<<<<<<<
NOTE: not running registration, plane already registered
binary path: /Volumes/2023_BigSme/Big_Smell_Exp/Suite2P/Day_4/Mouse#2033/suite2p/plane0/data.bin
NOTE: applying default /Users/sdaste/.suite2p/classifiers/classifier_user.npy
----------- ROI DETECTION
Binning movie in chunks of length 03
Binned movie of size [0,354,410] created in 0.00 sec.
>>>ERROR<<<
Traceback (most recent call last):
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/runpy.py", line 194, in _run_module_as_main
>>>ERROR<<<
    return _run_code(code, main_globals, None,
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/suite2p/__main__.py", line 78, in <module>
>>>ERROR<<<
    main()
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/suite2p/__main__.py", line 71, in main
    run_s2p(ops, db)
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/suite2p/run_s2p.py", line 429, in run_s2p
    op = run_plane(op, ops_path=ops_path)
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/suite2p/run_s2p.py", line 292, in run_plane
>>>ERROR<<<
    ops = pipeline(f_reg, f_raw, f_reg_chan2, f_raw_chan2, run_registration, ops, stat=stat)
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/suite2p/run_s2p.py", line 129, in pipeline
    ops, stat = detection.detection_wrapper(f_reg,
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/suite2p/detection/detect.py", line 126, in detection_wrapper
    mov = pca_denoise(mov, block_size=[ops['block_size'][0]//2, ops['block_size'][1]//2],
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/suite2p/detection/denoise.py", line 25, in pca_denoise
>>>ERROR<<<
    model = PCA(n_components=n_comps, random_state=0).fit(block)
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/sklearn/decomposition/_pca.py", line 408, in fit
>>>ERROR<<<
    self._fit(X)
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/sklearn/decomposition/_pca.py", line 456, in _fit
>>>ERROR<<<
    X = self._validate_data(
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/sklearn/base.py", line 577, in _validate_data
>>>ERROR<<<
    X = check_array(X, input_name="X", **check_params)
  File "/Users/sdaste/anaconda3/envs/suite2p/lib/python3.8/site-packages/sklearn/utils/validation.py", line 909, in check_array
>>>ERROR<<<
    raise ValueError(
ValueError: Found array with 0 sample(s) (shape=(0, 16384)) while a minimum of 1 is required by PCA.
Interrupted by error (not finished)

sdaste avatar Sep 05 '22 20:09 sdaste

Hmm, either my recollection (about that approach working for me in the past) is wrong, or something is different about your setup, or there's a newly introduced bug? If you want to change registration params, in theory doing so (changing registration-related parameters in the ops) should trigger a new registration, even if you don't delete the data.bin file. That worked for me in the past.

I'm sorry to say that I'm not familiar enough with the code to debug your specific errors. Hopefully one of the developers will take a look.

generalciao avatar Sep 05 '22 21:09 generalciao

Hi @sdaste, have you tried setting do_registration in the ops file you're using to 2? This should force registration to happen again using the binary file already available.

chriski777 avatar Sep 09 '22 19:09 chriski777

@sdaste, are you still facing this issue? I'll close this issue for now. Feel free to reopen this issue if you are.

chriski777 avatar Oct 16 '22 02:10 chriski777