MouseLand / suite2p

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

BUG: Partial analysis on subset of data does not work #1113

Open knowblesse opened 6 months ago

knowblesse commented 6 months ago

Describe the issue:

Behavior

In the latest document, frames_include option is implemented for the following reason.

frames_include: (int, default: -1) if greater than zero, only frames_include frames are processed. useful for testing parameters on a subset of data.

However this option does not work and also is not implemented in the GUI.

The source of the error : suite2p/registration/register.py#L493


Cause

The line compares xoff and yoff (probably movement correction values for each frame) with frames_include.

Those two variables have the matching size of frames_include, but the n_frames parameter is loaded from suite2p/run_s2p.py#L500, and has the total number of frame number instead.

Reproduce the code example:

from suite2p import default_ops
from suite2p.run_s2p import run_s2

base_ops = default_ops()
# with other necessary options..
base_ops.update({'frames_include': 100})

run_s2p(base_ops)

Error message:

Traceback (most recent call last):
  File "/home/jihoon_jeong/miniforge3/envs/2p_prep/lib/python3.9/site-packages/suite2p/run_s2p.py", line 336, in run_plane
    ops = pipeline(f_reg, f_raw, f_reg_chan2, f_raw_chan2, run_registration, ops,
  File "/home/jihoon_jeong/miniforge3/envs/2p_prep/lib/python3.9/site-packages/suite2p/run_s2p.py", line 108, in pipeline
    registration_outputs = registration.registration_wrapper(
  File "/home/jihoon_jeong/miniforge3/envs/2p_prep/lib/python3.9/site-packages/suite2p/registration/register.py", line 652, in registration_wrapper
    mean_img_alt = shift_frames_and_write(f_alt_in, f_alt_out, yoff, xoff, yoff1,
  File "/home/jihoon_jeong/miniforge3/envs/2p_prep/lib/python3.9/site-packages/suite2p/registration/register.py", line 492, in shift_frames_and_write
    raise ValueError(
ValueError: rigid registration offsets are not the same size as input frames

Version information:

0.14.0

Context for the issue:

No response