A package for calcium image processing
Project description
NeuroPixelAI
NeuroPixelAI is an open-source, GPU-accelerated pipeline that converts raw mesoscale imaging data into spike trains via automated motion registration, deep-learning denoising, region-adaptive segmentation, baseline-corrected trace extraction, and spike inference.
This code was written by Jiahao Hu from Li lab at Fudan University.All related implementations are referenced in the paper.
The reference paper is here.
CITATION
If you use this package in your research, please cite the paper:
Jiahao Hu, Yanfeng Zhu, Shoupei Liu, Chengyu Li, Min Zhang, Xinyang Gu, Jingchuan Wu, Fang Xu, Ying Mao, Bo Li (2025) Cortex-Wide, Cellular-Resolution Volumetric Imaging with a Modular Two-Photon Imaging Platform BioRxiv 662899
Local Installation
- Install an Anaconda distribution of Python -- Choose Python 3.8 and your operating system. Note you might need to use an anaconda prompt if you did not add anaconda to the path.
- Open an anaconda prompt / command prompt with
condafor python 3 in the path - Create a new environment with
conda create --name neuroai python=3.8. - To activate this new environment, run
conda activate neuronai - Install the NeuroPixelAI with
python -m pip install neuroai. - Next, install the appropriate version of PyTorch and CUDA support based on your GPU configuration. For example, to install PyTorch 2.7.1 with CUDA 11.8, run the following command:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118. - Now run
python -m NeuroPixelAIand you're all set.
Notably, to avoid potential errors caused by hardware incompatibility, it is strongly recommended to run NeuroPixelAI on Windows systems with NVIDIA GPUs.
Examples
An example dataset is provided here. It's a single-plane, single-channel recording.
Getting started
After completing the installation steps, follow these instructions to launch NeuroPixelAI:
- Activate the environment: Open Anaconda Prompt and enter:
activate neuroai - Launch NeuroPixelAI: Run:
python -m NeuroPixelAI
A standard calcium imaging data processing workflow consists of five stages: motion correction, image denoising, cell segmentation, signal extraction, and spike inference. For a basic usage example, refer to Supplementary Viedo 3.
Tab 1: Data Loading, Motion Correction & Denoising
- Load Data: Click
Load Imagein the bottom-left corner to select your data file. The raw image will appear in the left image panel. - Run Processing: Adjust parameters in the left-side
Parameterpanel, then clickRun Enhancement. This performs motion correction and denoising. The processed image will display in the right image panel.
Tab 2: Segmentation, Extraction & Spike Analysis
- Run Segmentation: After adjusting parameters, click
Run segmentation. - Extract Signals: Click
Signal extraction. - Infer Spikes: Click
Spike inference. - Discretize Spikes: Click
Spike discrete.
Additional Tab 2 Controls
- Manual ROI Selection: Right-click within the top-left image panel to manually select Regions of Interest (ROIs).
- Adjust ROIs: Use the
W,A,S,Dkeys to move individual or all ROIs. PressEto delete a single ROI.- Note: If interactions become unresponsive, simply click any checkbox within Tab 2 twice to restore functionality.
- Select ROIs to View: Enter specific ROI identifiers (e.g.,
'a,b,e:h') in theROI to Showfield to view corresponding signals.
All processed data can be exported to .mat files and previously saved .mat files can be reloaded into NeuroPixelAI using the Load processed result option.You can also modify the exported .mat files using external tools and then re-import them into NeuroPixelAI for further analysis or visualization.
Parameter Specifications
This section details the key parameters for each processing stage. Parameters marked with 🔴 are commonly adjusted for optimal results.
Motion Correction Parameters
Smooth_sigma_time(Default:2)- Gaussian temporal standard deviation. Smoothes the data over time before calculating phase correlation.
- Recommendation: Use
1or2for low signal-to-noise ratio (SNR) data.
- 🔴
Nimg_init(Default:500)- Number of frames used to compute the initial reference image. Registration works by aligning each frame to this reference.
Maxregshift(Default:0.1)- Maximum relative shift allowed (as a fraction of the image dimension).
- Example: With a default of
0.1and data size512x512, the maximum shift per frame is51.2pixels.
Smooth_sigma(Default:2)- Gaussian spatial standard deviation. Smoothes the phase correlation map between the reference and each frame.
- ☑️
Nonrigid(Checkbox)- Enable non-rigid registration to correct for small sample deformations during imaging.
- ☑️
Bidiphase(Checkbox)- Correct for row misalignment artifacts (scan phase offset between odd and even lines).
Denoising Parameters
Denoise model(Default:deepcad_model)- Specifies the denoising model used by DeepCAD-RT.
Cell Segmentation Parameters
Flow_threshold(Default:0.4)- Maximum allowed flow error per potential object during segmentation.
- Effect: Increasing this value → More ROIs detected. Decreasing this value → Fewer ROIs detected.
- 🔴
Cellprob_threshold(Default:0)- Threshold (range:
-6to6) for the probability that an object is a valid cell. - Adjustment:
- Decrease if too few ROIs are found.
- Increase if too many ROIs are found, especially in dark areas.
- Threshold (range:
- 🔴
Diameter(Default:21.5)- Estimated diameter of objects (e.g., cell bodies) in pixels.
Segmentation model(Default:cyto)- Specifies the Cellpose 2.0 model used (
cytois the default model for neuronal cell bodies).
- Specifies the Cellpose 2.0 model used (
- ☑️
Regional Seg(Checkbox)- Enable regional segmentation mode. Recommended for processing large field-of-view (FOV) data (e.g.,
2048x2048or4096x4096pixels).
- Enable regional segmentation mode. Recommended for processing large field-of-view (FOV) data (e.g.,
Spike Inference Parameters
- 🔴
Spike model(Default:3.51Hz_420ms)- Specifies the model used by Cascade for spike inference.
- Note: Models near
FrameRate (Hz) x SpikeDecayTime (ms) ≈ 1500(e.g.,3.51 x 420 ≈ 1500) often perform best.
Additional Options
- ☑️
Baseline correction(Checkbox)- Enable baseline correction during signal extraction. Recommended for long recordings.
- ☑️
Mask fixed(Checkbox)- Use a fixed segmentation mask when processing multiple files in a batch (
Run batchesmode).
- Use a fixed segmentation mask when processing multiple files in a batch (
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neuroai-0.4.8.tar.gz.
File metadata
- Download URL: neuroai-0.4.8.tar.gz
- Upload date:
- Size: 66.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3290f6a473c6b5ef2155dc72665ba2d8d52fcc825a99c4b8005f2ea61fe22812
|
|
| MD5 |
0febd305588b3a606f04e3fc4d844f51
|
|
| BLAKE2b-256 |
2f050a2c3a6e379768cef99da763726d433e2dc8c13de6f791297cf24b324ed6
|
File details
Details for the file neuroai-0.4.8-py3-none-any.whl.
File metadata
- Download URL: neuroai-0.4.8-py3-none-any.whl
- Upload date:
- Size: 66.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7ddabe0f4bd662d543b6d1d4f3b8779d0d432f11b45681e73396f11c5212ee7
|
|
| MD5 |
c7e540bec9e0a399b52d6719c57aa154
|
|
| BLAKE2b-256 |
73ce38557871d7a67374e038f147d31a1684fd3210b897c7940b62f0565111f0
|