Skip to content

[Legacy v1.9.16] evaluate_components crashes with TypeError when using seeded initialization (Ain) and only_init=True #1569

@LinxiuZeng

Description

@LinxiuZeng

I am using a legacy local version of CaImAn (v1.9.16) for longitudinal consistency in an endoscopic (CNMF-E) processing pipeline. I am implementing an iterative refinement strategy where spatial and temporal estimates from a first pass are used to seed a second pass.

When providing Ain, Cin, b_in, and f_in to the CNMF object and setting only_init=True (following the CNMF-E demo logic), the fit() function completes but leaves the estimates.YrA attribute as None.

When calling evaluate_components() immediately after, the process crashes because the evaluation logic attempts to sum the traces and residuals (C + YrA).

Minimal Reproducible Example (v1.9.16)

# Seeded Initialization for CNMF-E
# Ain, Cin, b_in, and f_in are all from the last cnmfe pass
cnm = cnmf.CNMF(n_processes=n_processes, 
                dview=dview, 
                Ain=iterativeA, 
                Cin=iterativeC, 
                b_in=iterativeb, 
                f_in=iterativef, 
                params=opts)

# opts has 'only_init': True and 'method_init': 'corr_pnr' (or 'seeded')
cnm.fit(images) 

# Result: cnm.estimates.YrA is None
# This call fails:
cnm.estimates.evaluate_components(images, cnm.params, dview=dview)

Traceback

File "caiman/components_evaluation.py", line 608, in estimate_components_quality_auto
    traces = C + YrA
TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'

Questions

  1. In v1.9.16, is it expected that only_init=True skips the residual (YrA) calculation even when Ain is provided?
  2. To maintain the CNMF-E model while achieving iterative refinement, is the recommended workaround to manually call compute_residuals() before evaluation, or should only_init be set to False for the seeded run?
  3. In the official demo_pipeline_cnmfE.ipynb, only_init is set to True (Cell 11); I am concerned that changing this to False to resolve the YrA/evaluation crash might bypass the specialized CNMF-E local background model in favor of standard CNMF refinement.
  4. Is there a specific parameter configuration in v1.9.16 that ensures the background components are properly updated during a seeded refinement pass without reverting to the CNMF model?

Environment
CaImAn version: 1.9.16
Installation: Local source files (.../Downloads..../CaImAn-main/...)
Data Type: 1-photon/CNMF-E

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