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

CNMF_Fit Error: Index Out of Bound #1169

Open anlo5007 opened 1 year ago

anlo5007 commented 1 year ago

CNMF_Fit Index Out of Bound

Your setup:

  1. Google Colab
    1. 2CPU 12.7GB RAM
    2. Python Version 3.10.12:
    3. Caiman version 1.9.15:
    4. Which demo exhibits the problem (if applicable): N/A
    5. How you installed Caiman (pure conda, conda + compile, colab, ..): Colab
    6. Details: I first Initialized the model with cnmf_model = cnmf.CNMF(n_processes, params=parameters, dview=multiprocessing_pool) then I have run the model with cnmf_fit = cnmf_model.fit(images) Then without reinitializing the cnmf object I updated the parameters of the model with: cnmf_model.params.change_params(params_dict=cnmf_new_params) Then I have run the cnmf_model.fit again and it threw the Index out of bound error:

` IndexError Traceback (most recent call last)

in [/content/CaImAn/caiman/source_extraction/cnmf/cnmf.py](https://localhost:8080/#) in fit(self, images, indices) 641 else: 642 while len(self.estimates.merged_ROIs) > 0: --> 643 self.merge_comps(Yr, mx=np.Inf) 644 645 logging.info("update temporal") 1 frames [/content/CaImAn/caiman/source_extraction/cnmf/merging.py](https://localhost:8080/#) in merge_components(Y, A, b, C, R, f, S, sn_pix, temporal_params, spatial_params, dview, thr, fast_merge, mx, bl, c1, sn, g, merge_parallel, max_merge_area) 273 # we continue for the variables 274 if S is not None: --> 275 S = np.vstack((S[good_neurons, :], S_merged)) 276 if R is not None: 277 R = np.vstack((R[good_neurons, :], R_merged)) IndexError: index 215 is out of bounds for axis 0 with size 4` After re-initializing the cnmf object cnmf_model.fit worked.
EricThomson commented 1 year ago

Thanks for bringing this to our attention! I have replicated this outside of colab as well, and it is something we should fix. Will think about best approach for this after Lindoscope.