optimouse 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {optimouse-0.1.0 → optimouse-0.1.2}/PKG-INFO +59 -31
- {optimouse-0.1.0 → optimouse-0.1.2}/README.md +51 -29
- {optimouse-0.1.0 → optimouse-0.1.2}/optimouse.egg-info/PKG-INFO +59 -31
- {optimouse-0.1.0 → optimouse-0.1.2}/optimouse.egg-info/requires.txt +8 -1
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/configs/config_C57_O1M2_10022023_run1run2.json +1 -1
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/utils/pipeline_utils.py +23 -10
- {optimouse-0.1.0 → optimouse-0.1.2}/pyproject.toml +13 -2
- {optimouse-0.1.0 → optimouse-0.1.2}/LICENSE.md +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/modules/__init__.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/modules/bruker_concat_tif.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/modules/compute_zcorr.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/modules/extraction.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/modules/motion_correction.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/modules/utils/plot_zones.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/modules/utils/save_z_motion_args.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/optimouse.egg-info/SOURCES.txt +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/optimouse.egg-info/dependency_links.txt +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/optimouse.egg-info/top_level.txt +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/__init__.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/configs/config_C57_O1M2_10022023_run1run2run3run4.json +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/configs/config_template_cnmf.json +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/configs/config_template_suite2p.json +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/configs/config_test.json +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/pipeline_cnmf.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/pipeline_mcorr.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/roi_zcorr.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/utils/__init__.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/pipeline/utils/config_loader.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/setup.cfg +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/tests/test_make_composite_f_anat.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/tests/test_module.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/tests/test_motion_correction.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/tests/test_patch_plots_efficient.py +0 -0
- {optimouse-0.1.0 → optimouse-0.1.2}/tests/test_subtract_z_motion_patches.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: optimouse
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: 2-photon calcium imaging data processing pipeline with CaImAn / Suite2P
|
|
5
5
|
Author-email: Vincent Prevosto <prevosto@mit.edu>, Manuel Levy <levym@mit.edu>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,7 +20,6 @@ Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
|
20
20
|
Requires-Python: >=3.10
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE.md
|
|
23
|
-
Requires-Dist: caiman<=1.13.0,>=1.12.2
|
|
24
23
|
Requires-Dist: mesmerize-core>=0.5.0
|
|
25
24
|
Requires-Dist: numpy>=1.26.4
|
|
26
25
|
Requires-Dist: scipy>=1.15.3
|
|
@@ -37,38 +36,69 @@ Requires-Dist: ruff>=0.0.200; extra == "dev"
|
|
|
37
36
|
Provides-Extra: viz
|
|
38
37
|
Requires-Dist: fastplotlib>=0.1.0a16; extra == "viz"
|
|
39
38
|
Requires-Dist: plotly>=6.5.2; extra == "viz"
|
|
39
|
+
Provides-Extra: all
|
|
40
|
+
Requires-Dist: pytest>=7.0.0; extra == "all"
|
|
41
|
+
Requires-Dist: pytest-cov>=3.0.0; extra == "all"
|
|
42
|
+
Requires-Dist: black>=22.0.0; extra == "all"
|
|
43
|
+
Requires-Dist: ruff>=0.0.200; extra == "all"
|
|
44
|
+
Requires-Dist: fastplotlib>=0.1.0a16; extra == "all"
|
|
45
|
+
Requires-Dist: plotly>=6.5.2; extra == "all"
|
|
40
46
|
Dynamic: license-file
|
|
41
47
|
|
|
42
48
|
# 2P-proc (optimouse)
|
|
43
49
|
|
|
44
50
|
[](https://www.python.org/)
|
|
45
51
|
[](https://github.com/flatironinstitute/CaImAn)
|
|
52
|
+
[](https://pypi.org/project/optimouse/)
|
|
53
|
+
[](https://doi.org/10.5281/zenodo.18371949)
|
|
54
|
+
<!-- [](https://github.com/vncntprvst/2P-proc/actions) -->
|
|
46
55
|

|
|
47
56
|
|
|
48
|
-
**2P-proc (optimouse)** is a 2-photon calcium imaging data processing pipeline built on [CaImAn](https://github.com/flatironinstitute/CaImAn/)
|
|
57
|
+
**2P-proc (optimouse)** is a 2-photon calcium imaging data processing pipeline built on [CaImAn](https://github.com/flatironinstitute/CaImAn/), [Mesmerize](https://github.com/nel-lab/mesmerize-core/) and [Suite2p](https://github.com/MouseLand/suite2p).
|
|
49
58
|
|
|
50
59
|
This package provides:
|
|
51
|
-
- **Motion correction**: Rigid and non-rigid motion correction with optional z-drift correction
|
|
52
|
-
- **ROI extraction**: CNMF-based
|
|
60
|
+
- **Motion correction**: Rigid and non-rigid motion correction with optional z-drift correction (rigid/non-rigid)
|
|
61
|
+
- **ROI extraction**: CNMF-based or Suite2p-based cell detection and segmentation
|
|
53
62
|
- **Spike deconvolution**: Temporal activity inference from calcium signals
|
|
54
|
-
- **Parameter optimization**: Notebooks for systematic parameter exploration
|
|
63
|
+
- **Parameter optimization**: Notebooks for systematic parameter exploration (CaImAn NoRMCorre and CNMF)
|
|
55
64
|
- **Multi-session registration**: Cross-session ROI alignment using CaImAn's registration algorithm
|
|
56
65
|
|
|
66
|
+
## No-installation Quick Start
|
|
67
|
+
Try the pipeline without installation, using containers:
|
|
68
|
+
* Create your config JSON as described in the [Quick Start](#quick-start) section
|
|
69
|
+
* Edit scripts/2P_proc.sh to set paths and options:
|
|
70
|
+
```bash
|
|
71
|
+
# Copy and customize the batch script
|
|
72
|
+
cp scripts/2P_proc_template.sh scripts/2P_proc.sh
|
|
73
|
+
```
|
|
74
|
+
* Run the pipeline
|
|
75
|
+
```bash
|
|
76
|
+
# On a local machine
|
|
77
|
+
bash scripts/2P_proc.sh configs/my_config.json
|
|
78
|
+
# On a cluster with SLURM
|
|
79
|
+
sbatch scripts/2P_proc.sh configs/my_config.json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The Docker containers are available on [Docker Hub](https://hub.docker.com/r/wanglabneuro/2p_proc). If using Docker, they will be pulled automatically when running the batch script.
|
|
83
|
+
Singularity images can be built from the Docker containers using the provided scripts in `containers/2P_proc/`.
|
|
84
|
+
|
|
57
85
|
## Installation
|
|
58
86
|
|
|
59
|
-
|
|
87
|
+
If you prefer to install the pipeline locally, follow the instructions below.
|
|
88
|
+
|
|
89
|
+
### Standard Installation
|
|
60
90
|
|
|
61
91
|
```bash
|
|
62
92
|
# Create and activate conda environment
|
|
63
93
|
conda create -n toupie python=3.10 -c conda-forge # Name the env any name you prefer
|
|
64
94
|
conda activate toupie
|
|
65
|
-
# Install optimouse
|
|
66
|
-
pip install
|
|
95
|
+
# Install optimouse from PyPI
|
|
96
|
+
pip install optimouse
|
|
67
97
|
# Install CaImAn manager
|
|
68
98
|
caimanmanager install
|
|
69
99
|
```
|
|
70
100
|
|
|
71
|
-
###
|
|
101
|
+
### For Developers
|
|
72
102
|
|
|
73
103
|
```bash
|
|
74
104
|
# Clone repository
|
|
@@ -88,12 +118,6 @@ caimanmanager install
|
|
|
88
118
|
|
|
89
119
|
### Additional dependencies
|
|
90
120
|
|
|
91
|
-
For z-correction:
|
|
92
|
-
```bash
|
|
93
|
-
conda install -c conda-forge mkl mkl_fft
|
|
94
|
-
pip install suite2p
|
|
95
|
-
```
|
|
96
|
-
|
|
97
121
|
For visualization:
|
|
98
122
|
```bash
|
|
99
123
|
pip install "fastplotlib[notebook]"
|
|
@@ -218,14 +242,17 @@ Create a configuration JSON based on `pipeline/configs/config_template_cnmf.json
|
|
|
218
242
|
**On a local machine:**
|
|
219
243
|
|
|
220
244
|
```bash
|
|
221
|
-
|
|
222
|
-
python pipeline
|
|
245
|
+
conda activate toupie # Activate your conda environment
|
|
246
|
+
python -m pipeline.pipeline_mcorr configs/my_config.json
|
|
247
|
+
python -m pipeline.pipeline_cnmf configs/my_config.json
|
|
223
248
|
```
|
|
224
249
|
|
|
225
250
|
**On a cluster with SLURM:**
|
|
226
251
|
|
|
252
|
+
Copy and customize `scripts/2P_proc_template.sh` to `scripts/2P_proc.sh`, then submit:
|
|
253
|
+
|
|
227
254
|
```bash
|
|
228
|
-
sbatch scripts/
|
|
255
|
+
sbatch scripts/2P_proc.sh configs/my_config.json
|
|
229
256
|
```
|
|
230
257
|
|
|
231
258
|
### 3. Multi-session registration
|
|
@@ -238,13 +265,13 @@ python Caiman/multisession_registration.py --json configs/my_config.json
|
|
|
238
265
|
|
|
239
266
|
### Motion Correction
|
|
240
267
|
- Rigid and non-rigid motion correction using NoRMCorre algorithm
|
|
241
|
-
- Optional z-drift correction using anatomical z-stack
|
|
268
|
+
- Optional rigid or non-rigid z-drift correction using anatomical z-stack
|
|
242
269
|
- Export to multiple formats (TIFF, memmap, HDF5)
|
|
243
270
|
|
|
244
271
|
### ROI Extraction
|
|
245
|
-
- CNMF (CaImAn): Constrained non-negative matrix factorization with automatic component quality assessment
|
|
246
|
-
- Suite2p: Fast, correlation-based clustering and SVD-accelerated cell detection and extraction
|
|
247
|
-
|
|
272
|
+
- [Option 1] CNMF (CaImAn): Constrained non-negative matrix factorization with automatic component quality assessment
|
|
273
|
+
- [Option 2] Suite2p: Fast, correlation-based clustering and SVD-accelerated cell detection and extraction
|
|
274
|
+
Both methods provide denoised fluorescence traces and deconvolved spikes
|
|
248
275
|
|
|
249
276
|
### ROI Z-Correction
|
|
250
277
|
- Regress and subtract axial drift from ROI traces
|
|
@@ -255,10 +282,10 @@ python Caiman/multisession_registration.py --json configs/my_config.json
|
|
|
255
282
|
Jupyter notebooks in `Mesmerize/` for systematic parameter exploration:
|
|
256
283
|
- `optimize_mcorr_bruker.ipynb`: Motion correction parameters
|
|
257
284
|
- `optimize_cnmf_bruker.ipynb`: CNMF extraction parameters
|
|
258
|
-
- `pipeline_notebook_template.ipynb`: Complete pipeline template
|
|
285
|
+
- `pipeline_notebook_template.ipynb`: Complete pipeline template (**Needs to be updated**)
|
|
259
286
|
|
|
260
287
|
## Testing
|
|
261
|
-
|
|
288
|
+
**Note: the tests are outdated and may not reflect the current state of the pipeline.**
|
|
262
289
|
```bash
|
|
263
290
|
# Download test data (~1.2GB)
|
|
264
291
|
./scripts/download_test_data.sh
|
|
@@ -280,17 +307,17 @@ Docker/Singularity containers are available for cluster computing:
|
|
|
280
307
|
Build and use containers:
|
|
281
308
|
```bash
|
|
282
309
|
# Build container
|
|
283
|
-
cd containers/
|
|
284
|
-
|
|
310
|
+
cd containers/2P_proc
|
|
311
|
+
./build.sh # For Docker only
|
|
312
|
+
./build_docker_singularity.sh # For Singularity too
|
|
285
313
|
|
|
286
314
|
# Run with Singularity
|
|
287
|
-
singularity exec containers/
|
|
315
|
+
singularity exec containers/2p_proc_latest.sif python -m pipeline.pipeline_mcorr configs/my_config.json
|
|
288
316
|
```
|
|
289
317
|
|
|
290
318
|
## Documentation
|
|
291
319
|
|
|
292
|
-
- **Configuration**: See `pipeline/configs/config_template_cnmf.json` for
|
|
293
|
-
- **API Reference**: Coming soon
|
|
320
|
+
- **Configuration**: See `pipeline/configs/config_template_cnmf.json` and `pipeline/configs/config_template_suite2p.json` for available parameters
|
|
294
321
|
- **Tutorials**: Jupyter notebooks in `Mesmerize/` and `Caiman/`
|
|
295
322
|
|
|
296
323
|
## Post-Processing and Analysis
|
|
@@ -308,9 +335,10 @@ Contributions are welcome! Please:
|
|
|
308
335
|
|
|
309
336
|
## Citation
|
|
310
337
|
|
|
311
|
-
|
|
338
|
+
This pipeline builds upon the following tools:
|
|
312
339
|
- CaImAn: Giovannucci et al. (2019) eLife
|
|
313
340
|
- Mesmerize: Kolar et al. (2019) Nature Communications
|
|
341
|
+
- Suite2p: Pachitariu et al. (2017) bioRxiv
|
|
314
342
|
|
|
315
343
|
## License
|
|
316
344
|
|
|
@@ -2,32 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.python.org/)
|
|
4
4
|
[](https://github.com/flatironinstitute/CaImAn)
|
|
5
|
+
[](https://pypi.org/project/optimouse/)
|
|
6
|
+
[](https://doi.org/10.5281/zenodo.18371949)
|
|
7
|
+
<!-- [](https://github.com/vncntprvst/2P-proc/actions) -->
|
|
5
8
|

|
|
6
9
|
|
|
7
|
-
**2P-proc (optimouse)** is a 2-photon calcium imaging data processing pipeline built on [CaImAn](https://github.com/flatironinstitute/CaImAn/)
|
|
10
|
+
**2P-proc (optimouse)** is a 2-photon calcium imaging data processing pipeline built on [CaImAn](https://github.com/flatironinstitute/CaImAn/), [Mesmerize](https://github.com/nel-lab/mesmerize-core/) and [Suite2p](https://github.com/MouseLand/suite2p).
|
|
8
11
|
|
|
9
12
|
This package provides:
|
|
10
|
-
- **Motion correction**: Rigid and non-rigid motion correction with optional z-drift correction
|
|
11
|
-
- **ROI extraction**: CNMF-based
|
|
13
|
+
- **Motion correction**: Rigid and non-rigid motion correction with optional z-drift correction (rigid/non-rigid)
|
|
14
|
+
- **ROI extraction**: CNMF-based or Suite2p-based cell detection and segmentation
|
|
12
15
|
- **Spike deconvolution**: Temporal activity inference from calcium signals
|
|
13
|
-
- **Parameter optimization**: Notebooks for systematic parameter exploration
|
|
16
|
+
- **Parameter optimization**: Notebooks for systematic parameter exploration (CaImAn NoRMCorre and CNMF)
|
|
14
17
|
- **Multi-session registration**: Cross-session ROI alignment using CaImAn's registration algorithm
|
|
15
18
|
|
|
19
|
+
## No-installation Quick Start
|
|
20
|
+
Try the pipeline without installation, using containers:
|
|
21
|
+
* Create your config JSON as described in the [Quick Start](#quick-start) section
|
|
22
|
+
* Edit scripts/2P_proc.sh to set paths and options:
|
|
23
|
+
```bash
|
|
24
|
+
# Copy and customize the batch script
|
|
25
|
+
cp scripts/2P_proc_template.sh scripts/2P_proc.sh
|
|
26
|
+
```
|
|
27
|
+
* Run the pipeline
|
|
28
|
+
```bash
|
|
29
|
+
# On a local machine
|
|
30
|
+
bash scripts/2P_proc.sh configs/my_config.json
|
|
31
|
+
# On a cluster with SLURM
|
|
32
|
+
sbatch scripts/2P_proc.sh configs/my_config.json
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The Docker containers are available on [Docker Hub](https://hub.docker.com/r/wanglabneuro/2p_proc). If using Docker, they will be pulled automatically when running the batch script.
|
|
36
|
+
Singularity images can be built from the Docker containers using the provided scripts in `containers/2P_proc/`.
|
|
37
|
+
|
|
16
38
|
## Installation
|
|
17
39
|
|
|
18
|
-
|
|
40
|
+
If you prefer to install the pipeline locally, follow the instructions below.
|
|
41
|
+
|
|
42
|
+
### Standard Installation
|
|
19
43
|
|
|
20
44
|
```bash
|
|
21
45
|
# Create and activate conda environment
|
|
22
46
|
conda create -n toupie python=3.10 -c conda-forge # Name the env any name you prefer
|
|
23
47
|
conda activate toupie
|
|
24
|
-
# Install optimouse
|
|
25
|
-
pip install
|
|
48
|
+
# Install optimouse from PyPI
|
|
49
|
+
pip install optimouse
|
|
26
50
|
# Install CaImAn manager
|
|
27
51
|
caimanmanager install
|
|
28
52
|
```
|
|
29
53
|
|
|
30
|
-
###
|
|
54
|
+
### For Developers
|
|
31
55
|
|
|
32
56
|
```bash
|
|
33
57
|
# Clone repository
|
|
@@ -47,12 +71,6 @@ caimanmanager install
|
|
|
47
71
|
|
|
48
72
|
### Additional dependencies
|
|
49
73
|
|
|
50
|
-
For z-correction:
|
|
51
|
-
```bash
|
|
52
|
-
conda install -c conda-forge mkl mkl_fft
|
|
53
|
-
pip install suite2p
|
|
54
|
-
```
|
|
55
|
-
|
|
56
74
|
For visualization:
|
|
57
75
|
```bash
|
|
58
76
|
pip install "fastplotlib[notebook]"
|
|
@@ -177,14 +195,17 @@ Create a configuration JSON based on `pipeline/configs/config_template_cnmf.json
|
|
|
177
195
|
**On a local machine:**
|
|
178
196
|
|
|
179
197
|
```bash
|
|
180
|
-
|
|
181
|
-
python pipeline
|
|
198
|
+
conda activate toupie # Activate your conda environment
|
|
199
|
+
python -m pipeline.pipeline_mcorr configs/my_config.json
|
|
200
|
+
python -m pipeline.pipeline_cnmf configs/my_config.json
|
|
182
201
|
```
|
|
183
202
|
|
|
184
203
|
**On a cluster with SLURM:**
|
|
185
204
|
|
|
205
|
+
Copy and customize `scripts/2P_proc_template.sh` to `scripts/2P_proc.sh`, then submit:
|
|
206
|
+
|
|
186
207
|
```bash
|
|
187
|
-
sbatch scripts/
|
|
208
|
+
sbatch scripts/2P_proc.sh configs/my_config.json
|
|
188
209
|
```
|
|
189
210
|
|
|
190
211
|
### 3. Multi-session registration
|
|
@@ -197,13 +218,13 @@ python Caiman/multisession_registration.py --json configs/my_config.json
|
|
|
197
218
|
|
|
198
219
|
### Motion Correction
|
|
199
220
|
- Rigid and non-rigid motion correction using NoRMCorre algorithm
|
|
200
|
-
- Optional z-drift correction using anatomical z-stack
|
|
221
|
+
- Optional rigid or non-rigid z-drift correction using anatomical z-stack
|
|
201
222
|
- Export to multiple formats (TIFF, memmap, HDF5)
|
|
202
223
|
|
|
203
224
|
### ROI Extraction
|
|
204
|
-
- CNMF (CaImAn): Constrained non-negative matrix factorization with automatic component quality assessment
|
|
205
|
-
- Suite2p: Fast, correlation-based clustering and SVD-accelerated cell detection and extraction
|
|
206
|
-
|
|
225
|
+
- [Option 1] CNMF (CaImAn): Constrained non-negative matrix factorization with automatic component quality assessment
|
|
226
|
+
- [Option 2] Suite2p: Fast, correlation-based clustering and SVD-accelerated cell detection and extraction
|
|
227
|
+
Both methods provide denoised fluorescence traces and deconvolved spikes
|
|
207
228
|
|
|
208
229
|
### ROI Z-Correction
|
|
209
230
|
- Regress and subtract axial drift from ROI traces
|
|
@@ -214,10 +235,10 @@ python Caiman/multisession_registration.py --json configs/my_config.json
|
|
|
214
235
|
Jupyter notebooks in `Mesmerize/` for systematic parameter exploration:
|
|
215
236
|
- `optimize_mcorr_bruker.ipynb`: Motion correction parameters
|
|
216
237
|
- `optimize_cnmf_bruker.ipynb`: CNMF extraction parameters
|
|
217
|
-
- `pipeline_notebook_template.ipynb`: Complete pipeline template
|
|
238
|
+
- `pipeline_notebook_template.ipynb`: Complete pipeline template (**Needs to be updated**)
|
|
218
239
|
|
|
219
240
|
## Testing
|
|
220
|
-
|
|
241
|
+
**Note: the tests are outdated and may not reflect the current state of the pipeline.**
|
|
221
242
|
```bash
|
|
222
243
|
# Download test data (~1.2GB)
|
|
223
244
|
./scripts/download_test_data.sh
|
|
@@ -239,17 +260,17 @@ Docker/Singularity containers are available for cluster computing:
|
|
|
239
260
|
Build and use containers:
|
|
240
261
|
```bash
|
|
241
262
|
# Build container
|
|
242
|
-
cd containers/
|
|
243
|
-
|
|
263
|
+
cd containers/2P_proc
|
|
264
|
+
./build.sh # For Docker only
|
|
265
|
+
./build_docker_singularity.sh # For Singularity too
|
|
244
266
|
|
|
245
267
|
# Run with Singularity
|
|
246
|
-
singularity exec containers/
|
|
268
|
+
singularity exec containers/2p_proc_latest.sif python -m pipeline.pipeline_mcorr configs/my_config.json
|
|
247
269
|
```
|
|
248
270
|
|
|
249
271
|
## Documentation
|
|
250
272
|
|
|
251
|
-
- **Configuration**: See `pipeline/configs/config_template_cnmf.json` for
|
|
252
|
-
- **API Reference**: Coming soon
|
|
273
|
+
- **Configuration**: See `pipeline/configs/config_template_cnmf.json` and `pipeline/configs/config_template_suite2p.json` for available parameters
|
|
253
274
|
- **Tutorials**: Jupyter notebooks in `Mesmerize/` and `Caiman/`
|
|
254
275
|
|
|
255
276
|
## Post-Processing and Analysis
|
|
@@ -267,9 +288,10 @@ Contributions are welcome! Please:
|
|
|
267
288
|
|
|
268
289
|
## Citation
|
|
269
290
|
|
|
270
|
-
|
|
291
|
+
This pipeline builds upon the following tools:
|
|
271
292
|
- CaImAn: Giovannucci et al. (2019) eLife
|
|
272
293
|
- Mesmerize: Kolar et al. (2019) Nature Communications
|
|
294
|
+
- Suite2p: Pachitariu et al. (2017) bioRxiv
|
|
273
295
|
|
|
274
296
|
## License
|
|
275
297
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: optimouse
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: 2-photon calcium imaging data processing pipeline with CaImAn / Suite2P
|
|
5
5
|
Author-email: Vincent Prevosto <prevosto@mit.edu>, Manuel Levy <levym@mit.edu>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,7 +20,6 @@ Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
|
20
20
|
Requires-Python: >=3.10
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE.md
|
|
23
|
-
Requires-Dist: caiman<=1.13.0,>=1.12.2
|
|
24
23
|
Requires-Dist: mesmerize-core>=0.5.0
|
|
25
24
|
Requires-Dist: numpy>=1.26.4
|
|
26
25
|
Requires-Dist: scipy>=1.15.3
|
|
@@ -37,38 +36,69 @@ Requires-Dist: ruff>=0.0.200; extra == "dev"
|
|
|
37
36
|
Provides-Extra: viz
|
|
38
37
|
Requires-Dist: fastplotlib>=0.1.0a16; extra == "viz"
|
|
39
38
|
Requires-Dist: plotly>=6.5.2; extra == "viz"
|
|
39
|
+
Provides-Extra: all
|
|
40
|
+
Requires-Dist: pytest>=7.0.0; extra == "all"
|
|
41
|
+
Requires-Dist: pytest-cov>=3.0.0; extra == "all"
|
|
42
|
+
Requires-Dist: black>=22.0.0; extra == "all"
|
|
43
|
+
Requires-Dist: ruff>=0.0.200; extra == "all"
|
|
44
|
+
Requires-Dist: fastplotlib>=0.1.0a16; extra == "all"
|
|
45
|
+
Requires-Dist: plotly>=6.5.2; extra == "all"
|
|
40
46
|
Dynamic: license-file
|
|
41
47
|
|
|
42
48
|
# 2P-proc (optimouse)
|
|
43
49
|
|
|
44
50
|
[](https://www.python.org/)
|
|
45
51
|
[](https://github.com/flatironinstitute/CaImAn)
|
|
52
|
+
[](https://pypi.org/project/optimouse/)
|
|
53
|
+
[](https://doi.org/10.5281/zenodo.18371949)
|
|
54
|
+
<!-- [](https://github.com/vncntprvst/2P-proc/actions) -->
|
|
46
55
|

|
|
47
56
|
|
|
48
|
-
**2P-proc (optimouse)** is a 2-photon calcium imaging data processing pipeline built on [CaImAn](https://github.com/flatironinstitute/CaImAn/)
|
|
57
|
+
**2P-proc (optimouse)** is a 2-photon calcium imaging data processing pipeline built on [CaImAn](https://github.com/flatironinstitute/CaImAn/), [Mesmerize](https://github.com/nel-lab/mesmerize-core/) and [Suite2p](https://github.com/MouseLand/suite2p).
|
|
49
58
|
|
|
50
59
|
This package provides:
|
|
51
|
-
- **Motion correction**: Rigid and non-rigid motion correction with optional z-drift correction
|
|
52
|
-
- **ROI extraction**: CNMF-based
|
|
60
|
+
- **Motion correction**: Rigid and non-rigid motion correction with optional z-drift correction (rigid/non-rigid)
|
|
61
|
+
- **ROI extraction**: CNMF-based or Suite2p-based cell detection and segmentation
|
|
53
62
|
- **Spike deconvolution**: Temporal activity inference from calcium signals
|
|
54
|
-
- **Parameter optimization**: Notebooks for systematic parameter exploration
|
|
63
|
+
- **Parameter optimization**: Notebooks for systematic parameter exploration (CaImAn NoRMCorre and CNMF)
|
|
55
64
|
- **Multi-session registration**: Cross-session ROI alignment using CaImAn's registration algorithm
|
|
56
65
|
|
|
66
|
+
## No-installation Quick Start
|
|
67
|
+
Try the pipeline without installation, using containers:
|
|
68
|
+
* Create your config JSON as described in the [Quick Start](#quick-start) section
|
|
69
|
+
* Edit scripts/2P_proc.sh to set paths and options:
|
|
70
|
+
```bash
|
|
71
|
+
# Copy and customize the batch script
|
|
72
|
+
cp scripts/2P_proc_template.sh scripts/2P_proc.sh
|
|
73
|
+
```
|
|
74
|
+
* Run the pipeline
|
|
75
|
+
```bash
|
|
76
|
+
# On a local machine
|
|
77
|
+
bash scripts/2P_proc.sh configs/my_config.json
|
|
78
|
+
# On a cluster with SLURM
|
|
79
|
+
sbatch scripts/2P_proc.sh configs/my_config.json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The Docker containers are available on [Docker Hub](https://hub.docker.com/r/wanglabneuro/2p_proc). If using Docker, they will be pulled automatically when running the batch script.
|
|
83
|
+
Singularity images can be built from the Docker containers using the provided scripts in `containers/2P_proc/`.
|
|
84
|
+
|
|
57
85
|
## Installation
|
|
58
86
|
|
|
59
|
-
|
|
87
|
+
If you prefer to install the pipeline locally, follow the instructions below.
|
|
88
|
+
|
|
89
|
+
### Standard Installation
|
|
60
90
|
|
|
61
91
|
```bash
|
|
62
92
|
# Create and activate conda environment
|
|
63
93
|
conda create -n toupie python=3.10 -c conda-forge # Name the env any name you prefer
|
|
64
94
|
conda activate toupie
|
|
65
|
-
# Install optimouse
|
|
66
|
-
pip install
|
|
95
|
+
# Install optimouse from PyPI
|
|
96
|
+
pip install optimouse
|
|
67
97
|
# Install CaImAn manager
|
|
68
98
|
caimanmanager install
|
|
69
99
|
```
|
|
70
100
|
|
|
71
|
-
###
|
|
101
|
+
### For Developers
|
|
72
102
|
|
|
73
103
|
```bash
|
|
74
104
|
# Clone repository
|
|
@@ -88,12 +118,6 @@ caimanmanager install
|
|
|
88
118
|
|
|
89
119
|
### Additional dependencies
|
|
90
120
|
|
|
91
|
-
For z-correction:
|
|
92
|
-
```bash
|
|
93
|
-
conda install -c conda-forge mkl mkl_fft
|
|
94
|
-
pip install suite2p
|
|
95
|
-
```
|
|
96
|
-
|
|
97
121
|
For visualization:
|
|
98
122
|
```bash
|
|
99
123
|
pip install "fastplotlib[notebook]"
|
|
@@ -218,14 +242,17 @@ Create a configuration JSON based on `pipeline/configs/config_template_cnmf.json
|
|
|
218
242
|
**On a local machine:**
|
|
219
243
|
|
|
220
244
|
```bash
|
|
221
|
-
|
|
222
|
-
python pipeline
|
|
245
|
+
conda activate toupie # Activate your conda environment
|
|
246
|
+
python -m pipeline.pipeline_mcorr configs/my_config.json
|
|
247
|
+
python -m pipeline.pipeline_cnmf configs/my_config.json
|
|
223
248
|
```
|
|
224
249
|
|
|
225
250
|
**On a cluster with SLURM:**
|
|
226
251
|
|
|
252
|
+
Copy and customize `scripts/2P_proc_template.sh` to `scripts/2P_proc.sh`, then submit:
|
|
253
|
+
|
|
227
254
|
```bash
|
|
228
|
-
sbatch scripts/
|
|
255
|
+
sbatch scripts/2P_proc.sh configs/my_config.json
|
|
229
256
|
```
|
|
230
257
|
|
|
231
258
|
### 3. Multi-session registration
|
|
@@ -238,13 +265,13 @@ python Caiman/multisession_registration.py --json configs/my_config.json
|
|
|
238
265
|
|
|
239
266
|
### Motion Correction
|
|
240
267
|
- Rigid and non-rigid motion correction using NoRMCorre algorithm
|
|
241
|
-
- Optional z-drift correction using anatomical z-stack
|
|
268
|
+
- Optional rigid or non-rigid z-drift correction using anatomical z-stack
|
|
242
269
|
- Export to multiple formats (TIFF, memmap, HDF5)
|
|
243
270
|
|
|
244
271
|
### ROI Extraction
|
|
245
|
-
- CNMF (CaImAn): Constrained non-negative matrix factorization with automatic component quality assessment
|
|
246
|
-
- Suite2p: Fast, correlation-based clustering and SVD-accelerated cell detection and extraction
|
|
247
|
-
|
|
272
|
+
- [Option 1] CNMF (CaImAn): Constrained non-negative matrix factorization with automatic component quality assessment
|
|
273
|
+
- [Option 2] Suite2p: Fast, correlation-based clustering and SVD-accelerated cell detection and extraction
|
|
274
|
+
Both methods provide denoised fluorescence traces and deconvolved spikes
|
|
248
275
|
|
|
249
276
|
### ROI Z-Correction
|
|
250
277
|
- Regress and subtract axial drift from ROI traces
|
|
@@ -255,10 +282,10 @@ python Caiman/multisession_registration.py --json configs/my_config.json
|
|
|
255
282
|
Jupyter notebooks in `Mesmerize/` for systematic parameter exploration:
|
|
256
283
|
- `optimize_mcorr_bruker.ipynb`: Motion correction parameters
|
|
257
284
|
- `optimize_cnmf_bruker.ipynb`: CNMF extraction parameters
|
|
258
|
-
- `pipeline_notebook_template.ipynb`: Complete pipeline template
|
|
285
|
+
- `pipeline_notebook_template.ipynb`: Complete pipeline template (**Needs to be updated**)
|
|
259
286
|
|
|
260
287
|
## Testing
|
|
261
|
-
|
|
288
|
+
**Note: the tests are outdated and may not reflect the current state of the pipeline.**
|
|
262
289
|
```bash
|
|
263
290
|
# Download test data (~1.2GB)
|
|
264
291
|
./scripts/download_test_data.sh
|
|
@@ -280,17 +307,17 @@ Docker/Singularity containers are available for cluster computing:
|
|
|
280
307
|
Build and use containers:
|
|
281
308
|
```bash
|
|
282
309
|
# Build container
|
|
283
|
-
cd containers/
|
|
284
|
-
|
|
310
|
+
cd containers/2P_proc
|
|
311
|
+
./build.sh # For Docker only
|
|
312
|
+
./build_docker_singularity.sh # For Singularity too
|
|
285
313
|
|
|
286
314
|
# Run with Singularity
|
|
287
|
-
singularity exec containers/
|
|
315
|
+
singularity exec containers/2p_proc_latest.sif python -m pipeline.pipeline_mcorr configs/my_config.json
|
|
288
316
|
```
|
|
289
317
|
|
|
290
318
|
## Documentation
|
|
291
319
|
|
|
292
|
-
- **Configuration**: See `pipeline/configs/config_template_cnmf.json` for
|
|
293
|
-
- **API Reference**: Coming soon
|
|
320
|
+
- **Configuration**: See `pipeline/configs/config_template_cnmf.json` and `pipeline/configs/config_template_suite2p.json` for available parameters
|
|
294
321
|
- **Tutorials**: Jupyter notebooks in `Mesmerize/` and `Caiman/`
|
|
295
322
|
|
|
296
323
|
## Post-Processing and Analysis
|
|
@@ -308,9 +335,10 @@ Contributions are welcome! Please:
|
|
|
308
335
|
|
|
309
336
|
## Citation
|
|
310
337
|
|
|
311
|
-
|
|
338
|
+
This pipeline builds upon the following tools:
|
|
312
339
|
- CaImAn: Giovannucci et al. (2019) eLife
|
|
313
340
|
- Mesmerize: Kolar et al. (2019) Nature Communications
|
|
341
|
+
- Suite2p: Pachitariu et al. (2017) bioRxiv
|
|
314
342
|
|
|
315
343
|
## License
|
|
316
344
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
caiman<=1.13.0,>=1.12.2
|
|
2
1
|
mesmerize-core>=0.5.0
|
|
3
2
|
numpy>=1.26.4
|
|
4
3
|
scipy>=1.15.3
|
|
@@ -8,6 +7,14 @@ h5py>=3.14.0
|
|
|
8
7
|
opencv-python>=4.11.0.86
|
|
9
8
|
pylibtiff>=0.7.0
|
|
10
9
|
|
|
10
|
+
[all]
|
|
11
|
+
pytest>=7.0.0
|
|
12
|
+
pytest-cov>=3.0.0
|
|
13
|
+
black>=22.0.0
|
|
14
|
+
ruff>=0.0.200
|
|
15
|
+
fastplotlib>=0.1.0a16
|
|
16
|
+
plotly>=6.5.2
|
|
17
|
+
|
|
11
18
|
[dev]
|
|
12
19
|
pytest>=7.0.0
|
|
13
20
|
pytest-cov>=3.0.0
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"/home/wanglab/data/2P/C57_O1M2/10022023/TSeries-10022023-1300-002"
|
|
33
33
|
],
|
|
34
34
|
"export_paths": [
|
|
35
|
-
"/home/wanglab/data/2P/Analysis_2P/C57_O1M2/10022023/run1run2/
|
|
35
|
+
"/home/wanglab/data/2P/Analysis_2P/C57_O1M2/10022023/run1run2/test_optimouse"
|
|
36
36
|
],
|
|
37
37
|
"zstack_paths": [
|
|
38
38
|
"/home/wanglab/data/2P/C57_O1M2/10022023/ZSeries-10022023-1300-004"
|
|
@@ -187,22 +187,32 @@ def cleanup_files(batch_path, export_path, preserve_batch=False):
|
|
|
187
187
|
if batch_runfile.exists():
|
|
188
188
|
batch_runfile.unlink()
|
|
189
189
|
batch_dir = Path(export_path) / batch_id
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
190
|
+
if batch_dir.exists():
|
|
191
|
+
for attempt in range(3):
|
|
192
|
+
time.sleep(1 + attempt)
|
|
193
|
+
try:
|
|
194
|
+
shutil.rmtree(batch_dir)
|
|
195
|
+
break
|
|
196
|
+
except Exception as e:
|
|
197
|
+
if attempt == 2:
|
|
198
|
+
log_and_print(f"Could not delete {batch_dir}: {e}")
|
|
199
199
|
for pickle_file in Path(export_path).glob("batch_*.pickle"):
|
|
200
200
|
pickle_file.unlink()
|
|
201
201
|
|
|
202
|
+
# Remove mcorr mmap file if preserve_batch is False
|
|
203
|
+
# (i.e., when output format is not "memmap")
|
|
204
|
+
for mmap_file in Path(export_path).glob('mcorr_*.mmap'):
|
|
205
|
+
try:
|
|
206
|
+
mmap_file.unlink()
|
|
207
|
+
log_and_print(f"Removed intermediate mmap file: {mmap_file}")
|
|
208
|
+
except Exception as e:
|
|
209
|
+
log_and_print(f"Could not remove {mmap_file}: {e}", level="warning")
|
|
210
|
+
|
|
202
211
|
# Remove concatenated tiff if present
|
|
203
212
|
cat_tiff_path = Path(export_path) / 'cat_tiff_bt.tiff'
|
|
204
213
|
if cat_tiff_path.exists():
|
|
205
214
|
cat_tiff_path.unlink()
|
|
215
|
+
|
|
206
216
|
# NOTE: Do not remove the final motion-corrected movie here.
|
|
207
217
|
# Downstream steps (ops creation and extraction) may rely on
|
|
208
218
|
# `mcorr_movie.*` being present in the export directory.
|
|
@@ -233,7 +243,10 @@ def cleanup_files(batch_path, export_path, preserve_batch=False):
|
|
|
233
243
|
sc.unlink()
|
|
234
244
|
except Exception:
|
|
235
245
|
pass
|
|
236
|
-
|
|
246
|
+
if not preserve_batch:
|
|
247
|
+
log_and_print("Batch files deleted.\n")
|
|
248
|
+
else:
|
|
249
|
+
log_and_print("Batch files preserved.\n")
|
|
237
250
|
|
|
238
251
|
|
|
239
252
|
def find_latest_batch(export_path):
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "optimouse"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "2-photon calcium imaging data processing pipeline with CaImAn / Suite2P"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -27,7 +27,6 @@ classifiers = [
|
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
dependencies = [
|
|
30
|
-
"caiman>=1.12.2,<=1.13.0",
|
|
31
30
|
"mesmerize-core>=0.5.0",
|
|
32
31
|
"numpy>=1.26.4",
|
|
33
32
|
"scipy>=1.15.3",
|
|
@@ -49,6 +48,18 @@ viz = [
|
|
|
49
48
|
"fastplotlib>=0.1.0a16",
|
|
50
49
|
"plotly>=6.5.2",
|
|
51
50
|
]
|
|
51
|
+
all = [
|
|
52
|
+
"pytest>=7.0.0",
|
|
53
|
+
"pytest-cov>=3.0.0",
|
|
54
|
+
"black>=22.0.0",
|
|
55
|
+
"ruff>=0.0.200",
|
|
56
|
+
"fastplotlib>=0.1.0a16",
|
|
57
|
+
"plotly>=6.5.2",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
# Note: CaImAn (>=1.12.2,<1.13.0) must be installed separately from GitHub:
|
|
61
|
+
# uv pip install "git+https://github.com/flatironinstitute/CaImAn.git@v1.12.2"
|
|
62
|
+
# caimanmanager install
|
|
52
63
|
|
|
53
64
|
[project.urls]
|
|
54
65
|
Homepage = "https://github.com/vncntprvst/2P-proc"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{optimouse-0.1.0 → optimouse-0.1.2}/pipeline/configs/config_C57_O1M2_10022023_run1run2run3run4.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|