kushalkolar / MESmerize

Platform for Calcium Imaging analysis. DEPRECATED.
GNU General Public License v3.0
59 stars 14 forks source link

not able to get mesmerize to work with caiman? #25

Closed cudmore closed 3 years ago

cudmore commented 3 years ago

Hi all, first off thanks for making mesmerize. Looks very promising.

I have installed mesmerize without a hitch but what I really want is to integrate caimen into mesmerize and I am stuck.

After install, the mesmerize gui seems to run fine, except when I run with 'mesmerize' I get a popup telling me ...

Caiman not found ... The caiman package could not be found in your python environment. Caiman features will not work.

Operating System

Ubuntu 20.0.4

Details about your Mesmerize install

pip 20.2.3 from /home/cudmore/Sites/MESmerize/mesmerize-env/lib/python3.6/site-packages/pip (python 3.6)

No, I was not able to install mesmerize from a cloned source? I installed from PyPi with

pip install mesmerize

I would prefer to install mesmerize from a cloned source, any suggestions?

In the cloned mesmerize source folder the following failed:

pip install -e .

with

    ERROR: Command errored out with exit status 1:
     command: /home/cudmore/Sites/MESmerize/mesmerize-env/bin/python3.6 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/cudmore/Sites/MESmerize/setup.py'"'"'; __file__='"'"'/home/cudmore/Sites/MESmerize/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ck5wbdq8
         cwd: /home/cudmore/Sites/MESmerize/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/cudmore/Sites/MESmerize/setup.py", line 71, in <module>
        with open(Path(__file__).joinpath('mesmerize').joinpath('VERSION'), 'r') as vf:
    NotADirectoryError: [Errno 20] Not a directory: '/home/cudmore/Sites/MESmerize/setup.py/mesmerize/VERSION'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I am using Python3.6 venv following your install instructions

Describe the issue, please be as explicit and detailed as possible.

When I follow your install instructions, all goes well except (for my) attempting to use caiman with mesmerize. When I run mesmerize I am warned 'Caiman not found ... The caiman package could not be found in your python environment. Caiman features will not work.'

Steps that can be followed to reproduce the problem. What exactly were you were doing that lead to the issue.

I followed your Ubuntu/Linux install instructions here and all went well.

Once I am in my Python3.6 mesmerize venv (named mesmerize-env), I install caiman from source with

# activate my mesmerize python 3.6 environment
source mesmerize-env/bin/activate
# install caiman (from source, CaimAn is in a different folder)
pip install ../CaImAn/.

Now, still, in my mesmerize-env python 3.6 environment

pip freeze | grep caiman

gives me

caiman==1.8.5

But when I run 'mesmerize' I get the error

Caiman not found ... The caiman package could not be found in your python environment. Caiman features will not work.

Your recipe/pattern for installing caiman is unfamiliar to me?

git clone https://github.com/flatironinstitute/CaImAn
cd CaImAn/
source activate caiman # !!! Is this assuming a conda install of caiman ???
pip install .

I am confused by 'source activate caiman'. Is this assuming caiman has been previously installed with conda? That is actually the case for me, I have a conda environment named 'caimen'.

Am I supposed to activate the conda caiman environment and then install caiman? Wouldn't this deactivate my python 3.6 ven v named 'mesmerized-env'?

Anything else which you think is relevant

Thanks for making mesmerize and I look forward to using it ...

kushalkolar commented 3 years ago

Hi,

Thanks for all the details!

If you open ipython in the mesmerize environment are you able to import caiman

Have you ran caimanmanager in the environment to set it up?

You can also try adding the full path to the CaImAn dir to your PYTHONPATH env variable if you did an inplace installation for it ( pip install -e )

The master branch for mesmerize isn't always reliable so I'd recommend switching to a release branch to run it from source.

Sorry for the confusion in the docs, you're right, I'll change that bit. Anaconda isn't necessary nor recommend for installation in Linux.

cudmore commented 3 years ago

Thanks for the speedy response and detailed troubleshooting. I was able to get it running with caiman.

No, I was not able to import caiman in the mesmerize environments ipython. Was failing on tensorflow. After pip install tensorflow I was able to import caiman in ipython and then when I ran memerize, it loaded caimen properly.

I downloaded the v0.4 branch and pip install -e . still failed. I modified the setup.py as follows and install went off without a hitch ...

import os
versionFilePath, myFileName = os.path.split(__file__)
versionFilePath = os.path.join(versionFilePath, 'mesmerize', 'VERSION')
print('versionFilePath:', versionFilePath)

#with open(Path(__file__).joinpath('mesmerize').joinfile('VERSION'), 'r') as vf:
with open(versionFilePath, 'r') as vf:
    vesion_str = vf.read().split('\n')[0]

Thanks for your help. I will also check out the mesmerize gitter ...

kushalkolar commented 3 years ago

Glad to hear that you got it working!

Thanks for the fix. By the way v0.4 is currently in development. I'd recommend using a tagged release.

Let me know if you have further questions or issues.