Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
carsen-stringer committed Aug 16, 2022
2 parents f025016 + 756c387 commit 40b534d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The software has been heavily tested on Windows 10 and Ubuntu 18.04, and less we
2. Run `conda env create --name suite2p`
3. To activate this new environment, run `conda activate suite2p` (you will have to activate every time you want to run suite2p)
4. Install the local version of suite2p into this environment in develop mode with the command `pip install -e .`
5. Run tests: `python setup.py test` or `pytest tests\`, this will automatically download the test data into your `suite2p` folder in `data/test_data` (this download is 1.6GB and can be downloaded also from this [link](https://www.suite2p.org/static/test_data/test_data.zip)).
5. Run tests: `python setup.py test` or `pytest tests\`, this will automatically download the test data into your `suite2p` folder. The test data is split into two parts: test inputs and expected test outputs which will be downloaded in `data/test_inputs` and `data/test_outputs` respectively. The .zip files for these two parts can be downloaded from these links: [test_inputs](https://www.suite2p.org/static/test_data/test_inputs.zip) and [test_outputs](https://www.suite2p.org/static/test_data/test_outputs.zip).

## Examples

Expand Down
2 changes: 2 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from tqdm import tqdm
from pathlib import Path
from urllib.request import urlopen
from tenacity import retry

@pytest.fixture()
def data_dir():
Expand Down Expand Up @@ -55,6 +56,7 @@ def extract_zip(cached_file, url, data_path):
with zipfile.ZipFile(cached_file,"r") as zip_ref:
zip_ref.extractall(data_path)

@retry
def download_url_to_file(url, dst, progress=True):
r"""Download object at the given URL to a local path.
Thanks to torch, slightly modified
Expand Down
62 changes: 23 additions & 39 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -1,54 +1,36 @@
Installation
----------------

Install an `Anaconda`_ distribution of Python -- Choose **Python 3.x**
and your operating system. Note you might need to use an anaconda prompt
if you did not add anaconda to the path.

1. Download the suite2p repository from GitHub using Git: ``git clone https://github.com/MouseLand/suite2p``
2. Open an anaconda prompt / command prompt with ``conda`` for **python
3** in the path
3. Change the current directory to the suite2p folder: ``cd suite2p``
4. Run ``conda env create -f environment.yml``
5. To activate this new environment, run ``conda activate suite2p``. Afterwards, You should see ``(suite2p)`` on the left side of the terminal line.
6. Install suite2p into this environment: ``pip install suite2p``
7. Now run ``suite2p`` and you're all set.

If you have an older ``suite2p`` environment you can remove it with
``conda env remove -n suite2p`` before creating a new one.

Note you will always have to run **conda activate suite2p** before you
run suite2p. Conda ensures mkl_fft and numba run correctly and quickly
on your machine. If you want to run jupyter notebooks in this
environment, then also ``conda install jupyter``.

To upgrade suite2p (package `here`_), run the following in the
environment:

::

pip install suite2p --upgrade
Please refer to the suite2p `README`_ for the latest up-to-date installation instructions.

**Common issues**

If when running ``suite2p``, you receive the error:
``No module named PyQt5.sip``, then try uninstalling and reinstalling
pyqt5
- If when running ``suite2p``, you receive the error:
``No module named PyQt5.sip``, then try uninstalling and reinstalling pyqt5

::

pip uninstall pyqt5 pyqt5-tools
pip install suite2p

::
- If when running ``suite2p``, you receive an error associated
with **matplotlib**, try upgrading it:

pip uninstall pyqt5 pyqt5-tools
pip install suite2p
::

If when running ``suite2p``, you receive an error associated
with **matplotlib**, try upgrading it:
pip install matplotlib --upgrade

::
- If you are on Yosemite Mac OS, PyQt doesn't work, and you won't be able to install suite2p. More recent versions of Mac OS are fine.

pip install matplotlib --upgrade
- If you are using Ubuntu 22.04 and run into the following issue:

If you are on Yosemite Mac OS, PyQt doesn't work, and you won't be able
to install suite2p. More recent versions of Mac OS are fine.
::
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application
may fix this problem.
Follow this `link`_ to install Qt5 and the issue above should be fixed.

The software has been heavily tested on Windows 10 and Ubuntu 18.04, and
less well tested on Mac OS. Please post an issue if you have
Expand Down Expand Up @@ -84,3 +66,5 @@ Dependencies
.. _matplotlib: https://matplotlib.org/
.. _Anaconda: https://www.anaconda.com/download/
.. _here: https://pypi.org/project/suite2p/
.. _link: https://askubuntu.com/questions/1406379/qt5-install-problem-ubuntustudio-22-04/1406503#1406503
.. _README: https://github.com/MouseLand/suite2p#readme
2 changes: 1 addition & 1 deletion docs/registration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Registering the frames to the reference image

Once the reference image is obtained, we align each frame to the
reference image. The frames are registered in batches of size
``ops['batch_size']`` (default is 200 frames per batch).
``ops['batch_size']`` (default is 500 frames per batch).

We first perform rigid registration (assuming that the whole image
shifts by some (dy,dx)), and then optionally after that we perform
Expand Down
2 changes: 1 addition & 1 deletion docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Registration
- **nimg_init**: (*int, default: 200*) how many frames to use to
compute reference image for registration

- **batch_size**: (*int, default: 200*) how many frames to register
- **batch_size**: (*int, default: 500*) how many frames to register
simultaneously in each batch. This depends on memory constraints - it
will be faster to run if the batch is larger, but it will require
more RAM.
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
]
test_deps = [
'pytest',
'tenacity',
'tqdm',
'pytest-qt==3.3.0',
]
Expand Down
4 changes: 2 additions & 2 deletions suite2p/detection/chan2detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def cellpose_overlap(stats, mimg2):
from . import anatomical
masks = anatomical.roi_detect(mimg2)[0]
Ly, Lx = masks.shape
redstats = np.zeros(len(stats), np.float32)
redstats = np.zeros((len(stats),2), np.float32) #changed the size of preallocated space
for i in range(len(stats)):
smask = np.zeros((Ly, Lx), np.uint16)
ypix0, xpix0= stats[i]['ypix'], stats[i]['xpix']
smask[ypix0, xpix0] = 1
ious = utils.mask_ious(masks, smask)[0]
iou = ious.max()
redstats[i] = np.array([iou>0.5, iou])
redstats[i,] = np.array([iou>0.5, iou]) #this had the wrong dimension
return redstats

def detect(ops, stats):
Expand Down

0 comments on commit 40b534d

Please sign in to comment.