CAT-NAP (calcium imaging)¶
CAT-NAP is the calcium-imaging analysis pathway — the Python equivalent of
MATLAB’s suite2pToAdjm / denoiseSuite2pData workflow. It’s triggered from
the CAT-NAP (2P) tab by pointing at a folder that contains
suite2p output, rather than raw MEA
.mat recordings.
Expected folder structure¶
CAT-NAP scans your raw data folder for recordings whose directory contains a
suite2p/plane0/ subfolder with at least a stat.npy file:
raw_data/
├── recording_A/
│ └── suite2p/
│ └── plane0/
│ ├── F.npy
│ ├── spks.npy
│ ├── iscell.npy
│ ├── stat.npy
│ └── ops.npy
└── recording_B/
└── suite2p/
└── plane0/
└── ...
Using the CAT-NAP tab¶
Enter (or browse to) your raw data folder in Suite2p recordings.
Click Scan for suite2p folders. Discovered recordings appear in the list; a ✓ prefix means denoising outputs already exist for that recording.
Click a recording to load it — the info panel shows cell count, sampling rate, and duration.
(Optional) Adjust denoising settings and click Run denoising on selected recording to generate
Fdenoised.npyand peak-detection outputs.Use the Trace preview panel to inspect individual cell traces, switching between the activity types below.
Activity types¶
Type |
Description |
|---|---|
|
Detected calcium transient onset frames (from the denoising pipeline). |
|
Baseline-corrected, OASIS-deconvolved fluorescence. |
|
Raw fluorescence as output by suite2p. |
|
Inferred spike probabilities from suite2p. |
Denoising pipeline¶
Runs on raw fluorescence (F.npy) and writes outputs alongside the suite2p
files:
Polynomial baseline (
pybaselines.imodpoly) — estimate and remove slow drift.OASIS deconvolution — separate the calcium signal from noise (requires the optional install below; falls back to Savitzky-Golay smoothing otherwise, with a warning shown in the tab).
Peak detection (
scipy.signal.find_peaks) — find calcium transient events.Outputs saved:
Fdenoised.npy,timePoints.npy,peakStartFrames.npy,peakEndFrames.npy,peakHeights.npy,eventAreas.npy.
Installing OASIS
OASIS deconvolution isn’t on PyPI, so it isn’t installed by default:
uv run pip install git+https://github.com/j-friedrich/OASIS.git
Using CAT-NAP from Python¶
The scanner, loader, and denoising pipeline are all usable without the GUI:
from meanap.catnap.scanner import find_suite2p_recordings
from meanap.catnap.loader import load_suite2p
from meanap.catnap.denoising import process_suite2p_folder
# Discover all suite2p recordings under a folder
recordings = find_suite2p_recordings("/path/to/raw_data")
for rec in recordings:
print(rec.name, rec.suite2p_dir, rec.has_denoised)
# Load one recording
data = load_suite2p(recordings[0].suite2p_dir)
print(data.n_cells, data.fs, data.duration_s)
print(data.F_cells.shape) # (n_cells, n_frames)
print(data.xy_cells.shape) # (n_cells, 2)
# Run denoising (writes output .npy files next to the inputs)
process_suite2p_folder(
recordings[0].suite2p_dir,
overwrite=False,
denoising_threshold=1.3,
time_before_peak_s=1.0,
time_after_peak_s=2.05,
)
# Reload to get denoised data
data = load_suite2p(recordings[0].suite2p_dir)
print(data.F_denoised_cells.shape) # (n_cells, n_frames)
print(data.peak_start_frames.shape) # (n_rois, max_peaks), NaN-padded
See the API reference for the full meanap.catnap surface.