Skip to content

Commit ea3ee2d

Browse files
Merge branch 'main' into patch-6
2 parents b6d278f + a652874 commit ea3ee2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1109
-526
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: tests
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
tags:
11+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
12+
pull_request:
13+
branches:
14+
- main
15+
workflow_dispatch:
16+
17+
jobs:
18+
test:
19+
name: ${{ matrix.platform }} py${{ matrix.python-version }}
20+
runs-on: ${{ matrix.platform }}
21+
strategy:
22+
matrix:
23+
platform: [ubuntu-latest, windows-latest, macos-latest]
24+
python-version: [3.8]
25+
26+
steps:
27+
- uses: actions/checkout@v2
28+
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
34+
# these libraries, along with pytest-xvfb (added in the `deps` in tox.ini),
35+
# enable testing on Qt on linux
36+
- name: Install Linux libraries
37+
if: runner.os == 'Linux'
38+
run: |
39+
sudo apt-get install -y libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 \
40+
libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \
41+
libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 pkg-config libhdf5-103 libhdf5-dev
42+
# strategy borrowed from vispy for installing opengl libs on windows
43+
- name: Install Windows OpenGL
44+
if: runner.os == 'Windows'
45+
run: |
46+
git clone --depth 1 git://github.com/pyvista/gl-ci-helpers.git
47+
powershell gl-ci-helpers/appveyor/install_opengl.ps1
48+
# note: if you need dependencies from conda, considering using
49+
# setup-miniconda: https://github.com/conda-incubator/setup-miniconda
50+
# and
51+
# tox-conda: https://github.com/tox-dev/tox-conda
52+
- name: Install dependencies
53+
run: |
54+
python -m pip install --upgrade pip
55+
pip install wheel setuptools tox tox-gh-actions
56+
pip install dvc==1.11.0 pydrive2
57+
- name: Get test data
58+
run: |
59+
dvc pull -r gdrive-travis
60+
# this runs the platform-specific tests declared in tox.ini
61+
- name: Test with tox
62+
run: tox
63+
env:
64+
PLATFORM: ${{ matrix.platform }}
65+
66+
- name: Coverage
67+
uses: codecov/codecov-action@v1

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Note: Marius and Carsen are currently at The Neuromatch Academy, and we won't do anything Suite2p-related until after the deep learning course!
2+
13
# suite2p <img src="suite2p/logo/logo_unshaded.png" width="250" title="sweet two pea" alt="sweet two pea" align="right" vspace = "50">
24

35
[![Documentation Status](https://readthedocs.org/projects/suite2p/badge/?version=dev)](https://suite2p.readthedocs.io/en/dev/?badge=dev)

benchmarks/registration_metrics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def registration_metrics(data_path, tiff_list, ops, nPC=10):
2525
ops['tiff_list'] = tiff_list
2626

2727
result_ops = suite2p.run_s2p(ops)
28+
if not isinstance(result_ops, list) or not isinstance(result_ops, np.ndarray):
29+
result_ops = [result_ops]
2830
metric_results = []
2931
for nplane, result_op in enumerate(result_ops):
3032
offsets = result_op['regDX']

docs/settings.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Registration
104104
of the gaussian used to smooth the data before phase correlation is computed.
105105
Might need this to be set to 1 or 2 for low SNR data.
106106

107-
- **keep_movie_raw**: (*bool, default: True*) whether or not to keep
107+
- **keep_movie_raw**: (*bool, default: False*) whether or not to keep
108108
the binary file of the non-registered frames. You can view the
109109
registered and non-registered binaries together in the GUI in the
110110
"View registered binaries" view if you set this to *True*.

environment.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
name: suite2p
22
channels:
33
- conda-forge
4+
- pytorch
45
dependencies:
5-
- python>=3.7.6,<3.8
6+
- python>=3.8,<3.9
67
- pip
7-
- mkl_fft=1.0.10
8-
- mkl=2019.3
8+
- mkl
99
- tbb
10-
- numpy<1.19.0
11-
- numba<0.50.0
10+
- numpy
11+
- numba
1212
- matplotlib
1313
- scipy
1414
- scikit-learn
15-
- pyqt
15+
- pytorch>=1.7.1
16+
- h5py=2.10.0
1617
- pip:
17-
- h5py==2.10.0
18+
- pyqt5
19+
- pyqt5.sip
1820
- natsort
1921
- rastermap>0.1.0
2022
- tifffile
2123
- scanimage-tiff-reader>=1.4.1
2224
- pyqtgraph
2325
- importlib-metadata
2426
- paramiko
25-
- pynwb<1.4.0
27+
- pynwb
2628
- sbxreader
2729
- suite2p

setup.py

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,50 @@
11
import setuptools
22

3+
install_deps = ['importlib-metadata',
4+
'natsort',
5+
'rastermap>0.1.0',
6+
'tifffile',
7+
'scanimage-tiff-reader>=1.4.1',
8+
'torch>=1.7.1',
9+
'paramiko',
10+
'numpy>=1.16',
11+
'numba>=0.43.1',
12+
'matplotlib',
13+
'scipy',
14+
'h5py',
15+
'sbxreader',
16+
'scikit-learn',]
17+
18+
gui_deps = [
19+
"pyqt5",
20+
"pyqt5-tools",
21+
"pyqt5.sip",
22+
'pyqtgraph',
23+
'rastermap>0.1.0',
24+
]
25+
data_deps = [
26+
"dvc==1.11.0",
27+
"pydrive2",
28+
]
29+
nwb_deps = [
30+
"pynwb",
31+
]
32+
test_deps = [
33+
'pytest',
34+
'pytest-qt==3.3.0',
35+
]
36+
37+
all_deps = gui_deps + data_deps + nwb_deps
38+
39+
try:
40+
import torch
41+
a = torch.ones(2, 3)
42+
version = int(torch.__version__[2])
43+
if version >= 6:
44+
install_deps.remove('torch')
45+
except:
46+
pass
47+
348
with open("README.md", "r") as fh:
449
long_description = fh.read()
550

@@ -17,24 +62,8 @@
1762
'setuptools_scm',
1863
],
1964
use_scm_version=True,
20-
install_requires=['importlib-metadata',
21-
'natsort',
22-
'rastermap>0.1.0',
23-
'tifffile',
24-
'scanimage-tiff-reader>=1.4.1',
25-
'pyqtgraph',
26-
'paramiko',
27-
'numpy>=1.16',
28-
'numba>=0.43.1',
29-
'matplotlib',
30-
'scipy',
31-
'h5py',
32-
'sbxreader',
33-
'scikit-learn',], # see environment.yml for this info.
34-
tests_require=[
35-
'pytest',
36-
'pytest-qt',
37-
],
65+
install_requires=install_deps,
66+
tests_require=test_deps,
3867
extras_require={
3968
"docs": [
4069
'sphinx>=3.0',
@@ -43,24 +72,10 @@
4372
'sphinx-prompt',
4473
'sphinx-autodoc-typehints',
4574
],
46-
# Note: Available in pypi, but cleaner to install as pyqt from conda.
47-
"gui": [
48-
"pyqt5",
49-
"pyqt5-tools",
50-
"pyqt5.sip",
51-
],
52-
# Note: Not currently available in pip: use conda to install.
53-
"mkl": [
54-
"mkl_fft>=1.0.10",
55-
"mkl>=2019.3",
56-
],
57-
"data": [
58-
"dvc>=1.1",
59-
"pydrive2",
60-
],
61-
"nwb": [
62-
"pynwb<1.4.0",
63-
]
75+
"gui": gui_deps,
76+
"data": data_deps,
77+
"nwb": nwb_deps,
78+
"all": all_deps
6479
},
6580
include_package_data=True,
6681
classifiers=[

suite2p/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .run_s2p import run_s2p, default_ops
2-
from .gui import run as run_gui
32
from .detection import ROI
3+
from .version import version
44

55

66
name = "suite2p"

suite2p/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def add_args(parser: argparse.ArgumentParser):
99
parser.add_argument('--single_plane', action='store_true', help='run single plane ops')
1010
parser.add_argument('--ops', default=[], type=str, help='options')
1111
parser.add_argument('--db', default=[], type=str, help='options')
12-
#parser.add_argument('--version', action='store_true', help='print version number.')
12+
parser.add_argument('--version', action='store_true', help='print version number.')
1313
ops0 = default_ops()
1414
for k in ops0.keys():
1515
v = dict(default=ops0[k], help='{0} : {1}'.format(k, ops0[k]))
@@ -59,7 +59,7 @@ def parse_args(parser: argparse.ArgumentParser):
5959

6060
def main():
6161
args, ops = parse_args(add_args(argparse.ArgumentParser(description='Suite2p parameters')))
62-
if 0:#args.version:
62+
if args.version:
6363
print("suite2p v{}".format(version))
6464
elif args.single_plane and args.ops:
6565
from suite2p.run_s2p import run_plane

suite2p/detection/detect.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def detect(ops, classfile=None):
4747

4848
if ops.get('anatomical_only', 0) > 0 and CELLPOSE_INSTALLED:
4949
print('>>>> CELLPOSE finding masks in ' + ['max_proj / mean_img', 'mean_img', 'enhanced_mean_img'][int(ops['anatomical_only'])-1])
50-
stats = anatomical.select_rois(
50+
stat = anatomical.select_rois(
5151
ops=ops,
5252
mov=mov,
5353
dy=dy,
@@ -57,7 +57,7 @@ def detect(ops, classfile=None):
5757
diameter=ops['diameter'])
5858

5959
else:
60-
stats = select_rois(
60+
stat = select_rois(
6161
ops=ops,
6262
mov=mov,
6363
dy=dy,
@@ -74,10 +74,10 @@ def detect(ops, classfile=None):
7474
if 'meanImg_chan2' in ops:
7575
if 'chan2_thres' not in ops:
7676
ops['chan2_thres'] = 0.65
77-
ops, redcell = chan2detect.detect(ops, stats)
77+
ops, redcell = chan2detect.detect(ops, stat)
7878
np.save(Path(ops['save_path']).joinpath('redcell.npy'), redcell)
7979

80-
return ops, stats
80+
return ops, stat
8181

8282
def select_rois(ops: Dict[str, Any], mov: np.ndarray, dy: int, dx: int, Ly: int, Lx: int,
8383
max_overlap: float = True, sparse_mode: bool = True, do_crop: bool=True,
@@ -86,7 +86,7 @@ def select_rois(ops: Dict[str, Any], mov: np.ndarray, dy: int, dx: int, Ly: int,
8686
t0 = time.time()
8787
if sparse_mode:
8888
ops.update({'Lyc': mov.shape[1], 'Lxc': mov.shape[2]})
89-
new_ops, stats = sparsedetect.sparsery(
89+
new_ops, stat = sparsedetect.sparsery(
9090
mov=mov,
9191
high_pass=ops['high_pass'],
9292
neuropil_high_pass=ops['spatial_hp_detect'],
@@ -100,29 +100,32 @@ def select_rois(ops: Dict[str, Any], mov: np.ndarray, dy: int, dx: int, Ly: int,
100100
)
101101
ops.update(new_ops)
102102
else:
103-
ops, stats = sourcery.sourcery(mov=mov, ops=ops)
103+
ops, stat = sourcery.sourcery(mov=mov, ops=ops)
104104

105-
print('Detected %d ROIs, %0.2f sec' % (len(stats), time.time() - t0))
106-
stats = np.array(stats)
105+
print('Detected %d ROIs, %0.2f sec' % (len(stat), time.time() - t0))
106+
stat = np.array(stat)
107+
108+
if len(stat)==0:
109+
raise ValueError("no ROIs were found -- check registered binary and maybe change spatial scale")
107110

108111
if ops['preclassify'] > 0:
109112
if classfile is None:
110113
print(f'NOTE: Applying user classifier at {str(user_classfile)}')
111114
classfile = user_classfile
112115

113-
stats = roi_stats(stats, dy, dx, Ly, Lx, do_crop=do_crop)
114-
if len(stats) == 0:
116+
stat = roi_stats(stat, dy, dx, Ly, Lx, do_crop=do_crop)
117+
if len(stat) == 0:
115118
iscell = np.zeros((0, 2))
116119
else:
117-
iscell = classify(stat=stats, classfile=classfile)
120+
iscell = classify(stat=stat, classfile=classfile)
118121
np.save(Path(ops['save_path']).joinpath('iscell.npy'), iscell)
119122
ic = (iscell[:,0]>ops['preclassify']).flatten().astype(np.bool)
120-
stats = stats[ic]
123+
stat = stat[ic]
121124
print('Preclassify threshold %0.2f, %d ROIs removed' % (ops['preclassify'], (~ic).sum()))
122-
123-
# add ROI stats to stats
124-
stats = roi_stats(stats, dy, dx, Ly, Lx, max_overlap=max_overlap, do_crop=do_crop)
125+
126+
# add ROI stat to stat
127+
stat = roi_stats(stat, dy, dx, Ly, Lx, max_overlap=max_overlap, do_crop=do_crop)
125128

126-
print('After removing overlaps, %d ROIs remain' % (len(stats)))
127-
return stats
129+
print('After removing overlaps, %d ROIs remain' % (len(stat)))
130+
return stat
128131

suite2p/detection/sparsedetect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ def extendROI(ypix, xpix, Ly, Lx,niter=1):
157157
ypix,xpix = yu[:, ix]
158158
return ypix,xpix
159159

160-
def two_comps(mpix0, lam, Th2):
160+
161+
def two_comps(mpix0, lam, Th2):
161162
""" check if splitting ROI increases variance explained
162163
163164
Parameters

0 commit comments

Comments
 (0)