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
640 stars 370 forks source link

Fix medw loading as b'NoneType' instead of None #1353

Closed ethanbb closed 6 months ago

ethanbb commented 6 months ago

Description

I encountered a bug when running a CNMF refit after loading the CNMF object from HDF5. This was caused by params.spatial['medw'] being b'NoneType' rather than None.

None parameters are currently converted to the string 'NoneType' during saving, which is read back into Python as b'NoneType', and this should be converted back to None, but due to the way the conditionals are structured, parameters which should be converted to tuples if not None are not converted if they equal b'NoneType'. (They are converted if they are the regular string 'NoneType'.) I fixed it so that both NoneType cases are handled first, and otherwise simplified the conditional structure (but that should be the only change in behavior).

Partially addresses #1264.

Type of change

Please delete options that are not relevant.

Has your PR been tested?

Yes, caimanmanager test and caimanmanager demotest pass.

pgunn commented 6 months ago

Looks good, thanks!