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

Handle warnings about upcoming deprecations #1303

Open EricThomson opened 8 months ago

EricThomson commented 8 months ago

Turned off warnings and checked for upcoming deprecations. Most of these are repeated many times in the different notebooks, just noting the warnings not where they are occurring in the code base:

A couple to not handle now, or not our problem:

EricThomson commented 8 months ago

Couple of things: most of these are very simple. randrange() deprecation is out of our control I just dumped stuff in here without thinking too much that's a Python standard library thing with v 3.10. The only one that will take some thinking/time is the np.matrix() one, and that is still not deprecated (it's not even very concrete it's just pending). Maybe better to handle that with the push to Numpy 2+ definitely don't want to rush it, it is used in about 20 places in the code base, in important places. The others were all simple syntax changes. Testing them now.

ethanbb commented 2 months ago

caiman\source_extraction\cnmf\spatial.py:844: DeprecationWarning: Please use grey_dilation from the scipy.ndimage namespace, the scipy.ndimage.morphology namespace is deprecated. from scipy.ndimage.morphology import grey_dilation. (evaluate_components)

I'm getting the same warning (repeated many many times) from line 955 of spatial.py (construct_dilate_parallel):

from scipy.ndimage.morphology import generate_binary_structure, iterate_structure, grey_dilation

Since these are now imported at the top level, this line can just be removed, right?

pgunn commented 2 months ago

@ethanbb Ah, yes. Good spot. I've been trying to remove non-toplevel imports when I find them.

You want to do it or shall I?

ethanbb commented 2 months ago

I can do it no problem! I'll do a quick search for any other similar cases first.

ethanbb commented 2 months ago

So actually there is this comment in the same file:

https://github.com/flatironinstitute/CaImAn/blob/bb55800806f0898592d79dcc705a0b53ccd01ec3/caiman/source_extraction/cnmf/spatial.py#L355-L359

which seems to imply that the local imports are needed for ipyparallel or multiprocessing workers. But I don't think that's true; anything defined at the module level, including imports, should be accessible to the workers regardless of how they are launched, right?