Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with installation of suite2p #1128

Open
GiangTranHU opened this issue Jun 17, 2024 · 8 comments
Open

Issues with installation of suite2p #1128

GiangTranHU opened this issue Jun 17, 2024 · 8 comments

Comments

@GiangTranHU
Copy link

Describe the issue:

Dear Marius and suite2p administrative team,
I am Giang Tran, from Japan.
I am using your program suite2p for my research.
Unfortunately, when I tried to install it, I got the following errors, I hope you can give me advice to resolve the problem.
When I installed it from anaconda, I got the following error after typing "python -m suite2p"

Traceback (most recent call last):
File "", line 189, in run_module_as_main
File "", line 148, in get_module_details
File "", line 112, in get_module_details
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\site-packages\suite2p_init
.py", line 6, in
from .run_s2p import run_s2p, run_plane, pipeline
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\site-packages\suite2p\run_s2p.py", line 15, in
from . import extraction, io, registration, detection, classification, default_ops
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\site-packages\suite2p\extraction_init
.py", line 5, in
from .extract import create_masks_and_extract, enhanced_mean_image, extract_traces_from_masks, extraction_wrapper
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\site-packages\suite2p\extraction\extract.py", line 11, in
from .masks import create_masks
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\site-packages\suite2p\extraction\masks.py", line 9, in
from ..detection.sparsedetect import extendROI
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\site-packages\suite2p\detection_init.py", line 4, in
from .detect import detect, detection_wrapper, bin_movie
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\site-packages\suite2p\detection\detect.py", line 9, in
from . import sourcery, sparsedetect, chan2detect, utils
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\site-packages\suite2p\detection\sourcery.py", line 12, in
from .stats import fitMVGaus
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\site-packages\suite2p\detection\stats.py", line 52, in
@DataClass(frozen=True)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\dataclasses.py", line 1220, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\dataclasses.py", line 958, in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\gtran\anaconda3\envs\suite2p\Lib\dataclasses.py", line 815, in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'numpy.ndarray'> for field rsort is not allowed: use default_factory.

I am using python 3.11.7.

I also tried to install using the instruction
"
Clone the repository with git and cd suite2p
Run pip install -e . in that folder
"
Then, I tried the jupyter notebook "run_suite2p_colab_2023" at the cell
"
ops = suite2p.default_ops()
ops['batch_size'] = 200 # we will decrease the batch_size in case low RAM on computer
ops['threshold_scaling'] = 2.0 # we are increasing the threshold for finding ROIs to limit the number of non-cell ROIs found (sometimes useful in gcamp injections)
ops['fs'] = 13 # sampling rate of recording, determines binning for cell detection
ops['tau'] = 1.25 # timescale of gcamp to use for deconvolution
print(ops)
"
I also got an error
"

TypeError Traceback (most recent call last)
Cell In[19], line 3
1 #print(suite2p.version)
2 #from suite2p import default_ops
----> 3 ops = suite2p.default_ops()
4 ops['batch_size'] = 200 # we will decrease the batch_size in case low RAM on computer
5 ops['threshold_scaling'] = 2.0 # we are increasing the threshold for finding ROIs to limit the number of non-cell ROIs found (sometimes useful in gcamp injections)

TypeError: 'module' object is not callable
"

Would you please give me advice on how to solve the problems?
Thank you very much and I am looking forward to hearing from you!
Best,
Giang Tran

Provide environment info:

active environment : suite2p
active env location : C:\Users\gtran\anaconda3\envs\suite2p
shell level : 2
user config file : C:\Users\gtran.condarc
populated config files : C:\Users\gtran.condarc
conda version : 24.4.0
conda-build version : 24.1.2
python version : 3.11.7.final.0
solver : libmamba (default)
virtual packages : __archspec=1=x86_64_v4
__conda=24.4.0=0
__cuda=12.3=0
_win=0=0
base environment : C:\Users\gtran\anaconda3 (writable)
conda av data dir : C:\Users\gtran\anaconda3\etc\conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Users\gtran\anaconda3\pkgs
C:\Users\gtran.conda\pkgs
C:\Users\gtran\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\gtran\anaconda3\envs
C:\Users\gtran.conda\envs
C:\Users\gtran\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/24.4.0 requests/2.31.0 CPython/3.11.7 Windows/10 Windows/10.0.22631 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.6 aau/0.4.3 c/kG-aFcIWoPdrzB3QmON-aQ s/9Mi
-x20V1u2hkqmK45u8w e/kPgv2tDRiRGO7hI7D-X34w
administrator : False
netrc file : None
offline mode : False

@StephenThornquist
Copy link

This is explored in issue #1047 -- suite2p is not compatible with Python >=3.11 as far as I can tell due to a single line that is not compatible with the builtin dataclasses, and can't even be imported to test whether anything is broken until they fix this bug (which appears not to be a priority?). I've been using it (in a fairly limited way) in Python 3.10 but I'll echo that it would be nice to see this fixed.

@GiangTranHU
Copy link
Author

Thank you very much for your help!
Since I am new to suite2p, may I have a few questions?
Can suite2p be used for 3D images? Would you please give me some tips to apply suite2p to 3D images?
Thank you very much!

@StephenThornquist
Copy link

I haven't actually tried to use it for analyses; personally I only use it for image registration because I work in Drosophila and our signal extraction and ROI identification needs are pretty different from rodent. Since the default_ops contains an entry for n_planes and a recent commit has the message "fixing bug with multi-plane nonrigid ops", my guess is there are some features intended for 3d imaging, though quickly scanning some of the files I don't see it come up in that many places. It might be useful if you were more specific about what you're trying to do, and maybe someone else can help answer?

@GiangTranHU
Copy link
Author

Hi Stephen,
Thank you very much for your comments!
In fact, I want to detect cells in 3D images of mouse brain. I am considering applying suite2p, but as I was known it is only for 2D.
It should be more convenient if it can be extended to 3D.
I am also looking for some other softwares which can be used for 3D, but currently I could not find one.

@rcpeene
Copy link

rcpeene commented Jul 9, 2024

Also experiencing this problem; Trying to run Suite2p with files from DANDI and Dandihub has updated their Python version, which I don't have control over.

@StephenThornquist
Copy link

StephenThornquist commented Jul 10, 2024

I think you can do one of two things:

  1. you can edit the suite2p source code yourself to get it up to speed (as far as I can, it's really only a simple change that should not affect anything: change line 59 of suite2p/detection/stats.py to rsort : np.ndarray = field(default_factory=lambda: np.sort(distance_kernel(radius=30).flatten()), repr=False)) or

  2. you can use one of the various forks that are compatible with more recent versions. For example, I use my own branch of suite2p where I updated the continuous integration tests to ensure compatibility with newer versions of Python up to 3.12 and across OSes. But be wary of any foreign code on Github -- even if the CI tests run you don't know that something we didn't test isn't broken! https://github.com/StephenThornquist/suite2p/tree/ci_macos_fix_and_py311

If suite2p is installed as a dependency in one of your other libraries (or you make it a dependency in one of your own tools), and you're willing to be extra brave, you can also ensure those users install a Py >=311 -compliant branch by modifying the dependencies of your pyproject.toml, e.g. dependencies = [... , "suite2p @ git+https://github.com/StephenThornquist/suite2p.git"]

@rcpeene
Copy link

rcpeene commented Jul 10, 2024

Yeah, my platform, the OpenScope Databook is intended to be launchable by many people and we'd like to keep the environment tinkering processing simple.

Are there plans to keep Suite2p up to date with newer version of Python? If not, I'll probably try to option 3.

@carsen-stringer
Copy link
Member

sorry for the trouble here, we plan to update suite2p to support python 3.11 and 3.12 in ~2 months. in the meantime thanks @StephenThornquist your fork seems very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants