Metadata-Version: 2.4
Name: masknmf
Version: 0.1.0
Summary: masknmf pipeline for motion correction, denoising, compression, and demixing of functional neuroimaging data
Keywords: neuroimaging,motion correction,demixing,calcium imaging
Author: Amol Pasarkar
Requires-Python: >=3.11, <3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>2
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: h5py
Requires-Dist: scikit-image
Requires-Dist: opencv-contrib-python-headless
Requires-Dist: cvxpy>=1.6.5
Requires-Dist: networkx
Requires-Dist: tqdm
Requires-Dist: plotly
Requires-Dist: matplotlib
Requires-Dist: jupyterlab
Requires-Dist: pytorch-lightning>=2.5.2
Requires-Dist: tensorboard>=2.20.0
Requires-Dist: fastplotlib[imgui, notebook]>=0.7.0
Requires-Dist: imgui-bundle==1.92.801
Requires-Dist: imgui_data_loader>=0.2.0
Requires-Dist: simplejpeg
Requires-Dist: glfw
Requires-Dist: psutil
Requires-Dist: pyperclip
Requires-Dist: oasis-deconv
Requires-Dist: roicat[latest] >= 1.7.10
Requires-Dist: scipy-stubs~=1.15.3
Requires-Dist: pytest>=8.4.0 ; extra == "dev"
Requires-Dist: ruff>=0.11.13 ; extra == "dev"
Requires-Dist: nbmake ; extra == "dev"
Requires-Dist: masknmf[docs] ; extra == "dev"
Requires-Dist: sphinx ; extra == "docs"
Requires-Dist: sphinx-gallery ; extra == "docs"
Requires-Dist: pydata-sphinx-theme ; extra == "docs"
Requires-Dist: sphinx-copybutton ; extra == "docs"
Requires-Dist: sphinx-design ; extra == "docs"
Requires-Dist: pandoc ; extra == "docs"
Requires-Dist: imageio[ffmpeg] ; extra == "docs"
Project-URL: Homepage, https://github.com/apasarkar/masknmf-toolbox
Project-URL: Issues, https://github.com/apasarkar/masknmf-toolbox/issues
Project-URL: Repository, https://github.com/apasarkar/masknmf-toolbox
Provides-Extra: dev
Provides-Extra: docs

# masknmf-toolbox

[**Installation**](https://github.com/apasarkar/masknmf-toolbox#Installation) |
[**API**](https://github.com/apasarkar/masknmf-toolbox#API) |
[**Data Formats**](https://github.com/apasarkar/masknmf-toolbox#examples) |
[**Paper**](https://github.com/apasarkar/masknmf-toolbox#Paper) |

PyTorch implementation of the masknmf framework for {calcium, voltage, glutamate} imaging analysis. Supports GPU-accelerated:
- Motion Correction
- Compression and Denoising
- Signal Demixing
- High-performance visualization

## Installation
 
Tests are run against Python 3.12 and 3.13, on Linux and Windows using `pip` and `miniforge3`.

### Download the repository

Until the package is published to PyPI, you have a few options to download the software:
1. `git clone` (recommended)
2. Download directly from [GitHub (code -> Download ZIP)](https://github.com/apasarkar/masknmf-toolbox)
3. Install directly from a branch (see [Skip the cloning step](https://github.com/apasarkar/masknmf-toolbox#skip-the-cloning-step))

```bash
git clone https://github.com/apasarkar/masknmf-toolbox.git
cd masknmf-toolbox
```

### pip

Virtual environments are outside the scope of this README, but in general we recommend:
- [UV](https://docs.astral.sh/uv/) (strongly recommended, prepend `uv` to all `pip` commands)
```bash
uv pip install .
```
- [venv](https://docs.python.org/3/library/venv.html#creating-virtual-environments)
```bash
pip install .
```

### miniforge3

The only tested and supported flavor of `anaconda` is [miniforge3](https://github.com/conda-forge/miniforge?tab=readme-ov-file#requirements-and-installers):

```bash
conda create -n masknmf -c conda-forge python=3.12
pip install .
```

### Skip the cloning step

If your environment is already set up, you can skip the cloning step and install directly from a branch of the repository:

```bash
# with standard venvs 
$ pip install git+https://github.com/apasarkar/masknmf-toolbox.git@main
# or with UV
$ uv pip install git+https://github.com/apasarkar/masknmf-toolbox.git@main

Installed 1 package in 0.63ms
 - masknmf-toolbox==0.1.0 
 + masknmf-toolbox==0.1.0 
```

## GPU Dependencies

The default installation of PyTorch will not have cuda enabled.
To get the cuda-enabled PyTorch installation

Find which Cuda version you're using (e.g. cuda_12.6)

```bash
nvcc --version
% or
nvidia-smi
```

Windows should have `nvcc` available in the command prompt if you have installed the CUDA toolkit.

If not, you can find it in the CUDA installation directory:

- Windows:`C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\bin`
- Linux/Unix: `/usr/local/cuda/bin/nvcc`

```bash
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Sep_12_02:55:00_Pacific_Daylight_Time_2024
Cuda compilation tools, release 12.6, V12.6.77
Build cuda_12.6.r12.6/compiler.34841621_0
```

Install the version of PyTorch that matches your cuda and operating system [on the PyTorch Getting Started](https://pytorch.org/get-started/locally/).

## API
See the notebooks folder for demos on how to use the motion correction, compression, and demixing APIs.

## Data Formats
Support currently provided for 
- multipage .tiff files 
- hdf5 files. 

Support for other formats can be easily added by defining a data loader class that implements LazyDataLoader. 

## Paper

If you use this method, please cite the accompanying [paper](https://www.biorxiv.org/content/10.1101/2023.09.14.557777v1)

> _maskNMF: A denoise-sparsen-detect approach for extracting neural signals from dense imaging data_. (2023). A. Pasarkar\*, I. Kinsella, P. Zhou, M. Wu, D. Pan, J.L. Fan, Z. Wang, L. Abdeladim, D.S. Peterka, H. Adesnik, N. Ji, L. Paninski.

