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

Cannot import name 'oasis' #435

Closed omidm7 closed 5 years ago

omidm7 commented 5 years ago

Operating system: macOS, Python version (3.6), and working environment (Spyder)

Hello, after upgrading Caiman and running caimanmanager.py install in the terminal, I see a file directory 'Caiman' with the file caimanmanager.py in it and another directory called "Caiman data" as described in the installation instructions. However, I get the following error upon trying to import caiman:

ImportError: cannot import name 'oasis'


In a previous topic I saw the suggestion to remove caimanmanager.py from the Caiman folder and try running it there. I tried this and still receive the error.

Thanks for your help!

epnev commented 5 years ago

@omidm7 Did you run the pip install command during the installation?

omidm7 commented 5 years ago

@epnev Yes!

pgunn commented 5 years ago

Hi, So what are you running right now that's doing the caiman import, and where are you running it from?

omidm7 commented 5 years ago

Hey. I'm running demo_pipeline_cnmfE.py on Spyder (Python 3.6).

pgunn commented 5 years ago

Sounds good; what's the path to that script when you're running it, and from what directory are you launching Spyder?

omidm7 commented 5 years ago

The script is in the path: /Users/omid/CaImAn/demos/general. And I am launching Spyder from the anaconda caiman environment I created. I got the whole thing to work on my laptop, but can't get it to run on the desktop. Both are iOS, python 3.6.

j-friedrich commented 5 years ago

Maybe oasis didn't properly compile. Can you check whether there is a file oasis.cpython-36m-darwin.so (or a similarly named *.so file) in directory caiman/source_extraction/cnmf/?

omidm7 commented 5 years ago

Hi, I don't see any .so files in that directory. image

pgunn commented 5 years ago

Hi, So after you install caiman with pip, you will want to use the caimanmanager.py script to make a working directory, and then use that working directory rather than working in the sources.

j-friedrich commented 5 years ago

You can create the oasis.so file by running python setup.py build_ext -i within the CaImAn directory.

omidm7 commented 5 years ago

@pgunn , even when I run the caimanmanager.py script by itself, I get the oasis error. image

pgunn commented 5 years ago

Copy that script out of the caiman directory and then launch/run it from there. It can't run correctly out of the source dir.

omidm7 commented 5 years ago

@j-friedrich , that line gives me the following error: image

j-friedrich commented 5 years ago

you have to change to the CaImAn directory, there is the setup.py

omidm7 commented 5 years ago

@pgunn , No matter where I copy and paste that caimanmanager.py file, and whichever directory I use to open it, I still get the oasis error.

omidm7 commented 5 years ago

@j-friedrich , That seems to have fixed it.

Thank you both very much for your time, it is much appreciated! Omid

SensibleLife333 commented 2 years ago

Hi everyone, I'm getting the same cannot import oasis error. Even though I have imported it. from . import oasis ImportError: cannot import name 'oasis' from partially initialized module 'caiman.source_extraction.cnmf' (most likely due to a circular import) (C:\Users\Shreyasta\PycharmProjects\CaImAn\caiman\source_extraction\cnmf__init__.py)

What should I do?

pgunn commented 2 years ago

@SensibleLife333 Hello, how did you install caiman?

(note that we can have this conversation much faster if you can pop on Gitter: https://gitter.im/agiovann/Constrained_NMF )

SensibleLife333 commented 2 years ago

Hi Pat,

I installed CaImAn from https://linuxtut.com/en/be62cbf84161279e33af/

Regards, Shreyasta Samal

On Fri, Dec 31, 2021 at 10:16 PM Pat Gunn @.***> wrote:

@SensibleLife333 https://github.com/SensibleLife333 Hello, how did you install caiman?

(note that we can have this conversation much faster if you can pop on Gitter: https://gitter.im/agiovann/Constrained_NMF )

— Reply to this email directly, view it on GitHub https://github.com/flatironinstitute/CaImAn/issues/435#issuecomment-1003452472, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXCM4WU45NTTKTUIVR6NCIDUTYMRJANCNFSM4GR5I3SA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

raymondwjang commented 1 month ago

Hi, I'm having the same issue as @SensibleLife333 , but cannot find the relevant thread on the gitter link. Could somebody help me out?

System: Apple M1, OS X Sequoia, Python 3.11

Error Reproduction:

git clone https://github.com/flatironinstitute/CaImAn.git
conda install -n base -c conda-forge mamba -y  # install mamba in base environment
mamba create -n caiman -c conda-forge caiman -y # install caiman
conda activate caiman  # activate virtual environment
caimanmanager install

Run the first cell in demo_online_cnmfE.ipynb

Error Trace:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 9
      6 import numpy as np
      7 from time import time
----> 9 import caiman as cm
     10 from caiman.source_extraction import cnmf as cnmf
     11 from caiman.motion_correction import MotionCorrect

File ~/CaImAn/caiman/__init__.py:4
      1 #!/usr/bin/env python
      3 import pkg_resources
----> 4 from caiman.base.movies import movie, load, load_movie_chain, _load_behavior, play_movie
      5 from caiman.base.timeseries import concatenate
      6 from caiman.cluster import start_server, stop_server

File ~/CaImAn/caiman/base/movies.py:36
     34 import caiman.base.traces
     35 import caiman.mmapping
---> 36 import caiman.summary_images
     37 import caiman.utils.sbx_utils
     38 import caiman.utils.visualization

File ~/CaImAn/caiman/summary_images.py:18
     16 import caiman
     17 import caiman.base.movies
---> 18 from caiman.source_extraction.cnmf.pre_processing import get_noise_fft
     20 def max_correlation_image(Y, bin_size: int = 1000, eight_neighbours: bool = True, swap_dim: bool = True) -> np.ndarray:
     21     """Computes the max-correlation image for the input dataset Y with bin_size
     22 
     23     Args:
   (...)
     40             max correlation image
     41     """

File ~/CaImAn/caiman/source_extraction/cnmf/__init__.py:12
     10 from . import spatial
     11 from . import temporal
---> 12 from . import oasis
     13 from . import params
     14 from . import online_cnmf

ImportError: cannot import name 'oasis' from partially initialized module 'caiman.source_extraction.cnmf' (most likely due to a circular import) (~/CaImAn/caiman/source_extraction/cnmf/__init__.py)

Attempted Solutions:

  1. Following @pgunn 's suggestion from 2019 to check for oasis.so.
  2. Was not present so I ran python setup.py build_ext -i from project root directory, but was returned with
    Traceback (most recent call last):
    File "~/CaImAn/setup.py", line 7, in <module>
    from Cython.Build import cythonize
    ModuleNotFoundError: No module named 'Cython'
  3. Tried searching for which Cython version to install into caiman Conda env., but could not find it.
pgunn commented 1 month ago

Hello, The instructions you're following mix two different install methods; it's important you just pick one and stick with it.

I suggest removing your checkout of caiman (do not check it out) and just use the rest of the instructions you have. See if it changes the results. If you still encounter issues, please open a new issue so we don't notify everyone else on this issue.

Cheers, Pat