Skip to content

BUG: Array must not contain infs or NaNs #1252

Description

@SSSRgo

Describe the issue:

I use the same dataset but have a problem of "Array must not contain infs or NaNs" in 1.1.0

Reproduce the code example:

ops = default_ops()
    ops.update(
        {
            "nplanes": 1,
            "nchannels": 1,
            "functional_chan": 1,
            "fs": float(settings["frame_rate"] or 10.0),
            "tau": 1,
            # "do_bidiphase": True,
            "do_registration": True,
            "nonrigid": True,
            "roidetect": True,
            "spikedetect": True,
            "delete_bin": False,
            "save_mat": True,
            "batch_size": 500,
            "max_iterations": 100,
            # "threshold_scaling": 0.5,
            # "spatial_scale": 1,
            "extract_patches": True,
            # "smooth_sigma_time": 1.0,
            # "two_step_registration": True
            # "diameter": [10]
        }
    )

Example input dataset used to reproduce the issue:

detect gcamp7f soma

Error message:

D:\free moving 2p\PhD\free moving 2p\data_analysis\run_suite2p_cellvideo_260518.py' 
Running Suite2p
Input:  D:\free moving 2p\PhD\free moving 2p\data_analysis\data\260518-2-2_2026-05-19_19-06-27\CellVideo1\CellVideo
Output: D:\free moving 2p\PhD\free moving 2p\data_analysis\data\260518-2-2_2026-05-19_19-06-27\CellVideo1\suite2p_CellVideo1
Frame rate: 9.21 Hz
C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\detection\stats.py:184: RuntimeWarning: invalid value encountered in divide
  dy, dx = np.meshgrid(np.arange(-d0[0]*3, d0[0]*3 + 1) / d0[0],
C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\detection\stats.py:185: RuntimeWarning: invalid value encountered in divide
  np.arange(-d0[1]*3, d0[1]*3 + 1) / d0[1], indexing="ij")
C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\detection\stats.py:205: RuntimeWarning: divide by zero encountered in divide
  dists = (((ypix - med[0]) / d0[0])**2 + ((xpix - med[1]) / d0[1])**2)**0.5
C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\detection\stats.py:205: RuntimeWarning: invalid value encountered in divide
  dists = (((ypix - med[0]) / d0[0])**2 + ((xpix - med[1]) / d0[1])**2)**0.5
C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\detection\stats.py:67: RuntimeWarning: divide by zero encountered in divide
  y = y / dy
C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\detection\stats.py:68: RuntimeWarning: divide by zero encountered in divide
  x = x / dx
C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\detection\stats.py:79: RuntimeWarning: invalid value encountered in subtract
  yx = (yx - mu[:, np.newaxis]) * lam**.5
Backend qtagg is interactive backend. Turning interactive mode on.
Traceback (most recent call last):
  File "C:\Users\TsingSV\.conda\envs\data_analysis\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\TsingSV\.conda\envs\data_analysis\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\TsingSV\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64\bundled\libs\debugpy\__main__.py", line 71, in <module>
    cli.main()
  File "c:\Users\TsingSV\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64\bundled\libs\debugpy/..\debugpy\server\cli.py", line 542, in main
    run()
  File "c:\Users\TsingSV\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64\bundled\libs\debugpy/..\debugpy\server\cli.py", line 361, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:\Users\TsingSV\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 310, in run_path
    return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
  File "c:\Users\TsingSV\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 127, in _run_module_code
    _run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
  File "c:\Users\TsingSV\.vscode\extensions\ms-python.debugpy-2026.6.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 118, in _run_code
    exec(code, run_globals)
  File "D:\free moving 2p\PhD\free moving 2p\data_analysis\run_suite2p_cellvideo_260518.py", line 28, in <module>
    main()
  File "D:\free moving 2p\PhD\free moving 2p\data_analysis\run_suite2p_cellvideo_260518.py", line 15, in main
    run_suite2p_session(
  File "D:\free moving 2p\PhD\free moving 2p\data_analysis\src\twop_analysis\suite2p_runner.py", line 114, in run_suite2p_session
    return  run_s2p(db,ops )
  File "C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\run_s2p.py", line 459, in run_s2p
    outputs = run_plane(db=db, settings=settings, db_path=db_path)
  File "C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\run_s2p.py", line 303, in run_plane
    outputs = pipeline(db["save_path"], f_reg, f_raw, f_reg_chan2, f_raw_chan2, 
  File "C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\pipeline_s2p.py", line 156, in pipeline
    detect_outputs, stat, redcell = detection.detection_wrapper(f_reg, 
  File "C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\detection\detect.py", line 255, in detection_wrapper
    stat = roi_stats(stat, Ly, Lx, diameter=diameter, 
  File "C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\detection\stats.py", line 211, in roi_stats
    radii = fitMVGaus(ypix, xpix, lam, dy=d0[0], dx=d0[1], thres=2)[2]
  File "C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\suite2p\detection\stats.py", line 83, in fitMVGaus
    radii, evec = np.linalg.eig(cov)
  File "C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\numpy\linalg\_linalg.py", line 1465, in eig
    _assert_finite(a)
  File "C:\Users\TsingSV\.conda\envs\data_analysis\lib\site-packages\numpy\linalg\_linalg.py", line 207, in _assert_finite
    raise LinAlgError("Array must not contain infs or NaNs")
numpy.linalg.LinAlgError: Array must not contain infs or NaNs

Version information:

The newest verision 1.1.0.

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions