flatironinstitute / CaImAn

Computational toolbox for large scale Calcium Imaging Analysis, including movie handling, motion correction, source extraction, spike deconvolution and result visualization.
https://caiman.readthedocs.io
GNU General Public License v2.0
639 stars 370 forks source link

Fix unbound local error in online_cnmf when use_corr_img is true but is1p is false #1384

Closed ethanbb closed 3 months ago

ethanbb commented 3 months ago

Description

Currently, in the method OnACID._prepare_object , d1 and d2 are only set when self.is1p is true, but are only used if the parameter online['use_corr_img'] is true. I was trying to run it withuse_corr_imgbut without setting the other parameters in a way that causesis1p` to be true, so I got an unbound local error.

Since these variables are only used in one place in this function, I just moved the line that defines them to be right before they are used. I'm not 100% sure the functionality is correct, but the line just reads from estimates.dims, which seems pretty straightforward.

Type of change

Please delete options that are not relevant.

Has your PR been tested?

Did not run the tests myself (relying on CI) but I did check that making this change prevented the error I was getting when trying to call fit_online with these parameters.