科研 Skill
钙成像数据分析
calcium-imaging-analysis
Processes two-photon or widefield calcium imaging with Suite2p or CaImAn, from motion correction through ROI extraction to dF/F and spike deconvolution. Use for calcium imaging movies.
SKILL.md
Calcium imaging analysis
Calcium imaging movies need to be stabilized, segmented into cells (or other regions of interest), and turned into interpretable fluorescence traces before any downstream analysis (tuning curves, place fields, decoding) is meaningful. The pipeline below follows the two dominant open-source tools, Suite2p and CaImAn, and the checks that catch the most common mistakes.
When to use this skill
Use it when the user:
- has raw two-photon, one-photon miniscope, or widefield calcium movies
(TIFF stacks, ScanImage, Bruker/PrairieView, Thorlabs, Inscopix
.isxd) and needs cells/ROIs and traces out of them, - asks about motion correction, non-rigid registration, or "my movie is jittery / shifted",
- asks how to pick between Suite2p and CaImAn, or how to tune their parameters,
- needs dF/F, neuropil-corrected traces, or deconvolved spike estimates,
- is comparing ROIs or registering cells across sessions or days,
- asks about photobleaching correction, z-drift, or SNR of a calcium indicator (GCaMP6/7/8, jGCaMP8, RCaMP, jRGECO).
1. Inventory the recording
Before processing, record: indicator (GCaMP6f/6s/7f/7s/8f/8m/8s, jRGECO1a, etc.) and its kinetics (fast indicators need higher frame rates to resolve single spikes), imaging modality (two-photon, one-photon miniscope, widefield), frame rate, field of view and pixel size, number of planes (single-plane vs. volumetric/multi-plane), and the microscope's native file format. Fast indicators (GCaMP8f, jGCaMP8f) decay in ~100-200 ms; slow indicators (GCaMP6s) decay over ~1-2 s and blur closely spaced events together — this matters for how much to trust deconvolved spike timing.
2. Pick a toolkit
| Tool | Best for | Install |
|---|---|---|
| Suite2p | Two-photon, fast, good defaults, built-in GUI curation | pip install suite2p |
| CaImAn | One-photon/miniscope (CNMF-E), online/streaming analysis, more tunable | pip install caiman (conda recommended; needs a caimanmanager install step for demos) |
| EXTRACT | Dense/overlapping somas, more robust to neuropil contamination | MATLAB-based; use when Suite2p/CaImAn ROI shapes look implausible |
Both Suite2p and CaImAn implement motion correction, cell/ROI detection, and trace extraction; the choice usually comes down to imaging modality (CaImAn's CNMF-E is the standard choice for one-photon miniscope data with large out-of-focus background) and whether interactive GUI curation (Suite2p) is wanted.
3. Motion correction
- Rigid correction first (whole-frame x/y shift) against a reference image built from a clean, low-motion subset of frames.
- Non-rigid correction (Suite2p's built-in non-rigid registration, or
CaImAn's
MotionCorrectwithpw_rigid=True) when the FOV is large enough that different parts of the tissue move independently (brain warping, especially in awake, behaving animals). - For volumetric/multi-plane data, correct each plane independently, then check for z-drift (focus plane drift) separately — x/y registration cannot fix out-of-plane motion.
- Always inspect the registered movie (or at minimum a mean/max-projection before vs. after, and a line profile over time) before trusting downstream ROI detection. Residual motion after correction propagates directly into spurious "activity".
# Suite2p: minimal end-to-end run
import suite2p
ops = suite2p.default_ops()
ops.update({
"fs": 30.0, # imaging frame rate (Hz)
"nplanes": 1,
"nchannels": 1,
"tau": 1.0, # indicator decay time constant (s); ~1.0 for GCaMP6s, ~0.7 for 6f
"nonrigid": True,
})
db = {"data_path": ["/path/to/tiffs"], "save_path0": "/path/to/output"}
output_ops = suite2p.run_s2p(ops=ops, db=db)
# CaImAn: CNMF-E for one-photon miniscope data
import caiman as cm
from caiman.source_extraction.cnmf import cnmf, params
fnames = ["/path/to/miniscope_movie.tif"]
opts = params.CNMFParams(params_dict={
"fnames": fnames,
"fr": 20, # frame rate
"decay_time": 0.4, # indicator decay (s)
"pw_rigid": True, # non-rigid motion correction
"gSig": (3, 3), # expected (half-)cell radius in pixels
"center_psf": True, # required for CNMF-E (1p data)
"method_init": "corr_pnr",
})
4. ROI / source extraction
- Suite2p's detection (based on sparse PCA / clustering of correlated pixels) and CaImAn's CNMF/CNMF-E (a constrained matrix-factorization model that jointly estimates spatial footprints and temporal traces, explicitly separating cells from background/neuropil) both need the expected cell diameter in pixels as a key parameter — get this from the microscope's pixel size and typical soma diameter (~10-20 µm for cortical neurons) rather than a default.
- Inspect ROI shapes after detection: implausibly large, donut-shaped, or dendrite-shaped "cells" usually indicate the diameter parameter is mis-set or that the movie still has residual motion.
- Manually curate (Suite2p's GUI, or CaImAn's
component_evaluationwith SNR/rvalue/CNN thresholds) rather than trusting automatic classification alone, especially near the edges of the field of view.
5. Neuropil correction and dF/F
Raw somatic fluorescence is contaminated by out-of-focus neuropil signal. Standard correction (Suite2p default, and the classic approach, Chen et al. 2013; Kerlin et al. 2010):
F_corrected(t) = F_soma(t) - r * F_neuropil(t) # r is typically 0.7
dF/F(t) = (F_corrected(t) - F0) / F0
F0 is a slow baseline, commonly the 8th-percentile of F_corrected in a
sliding window (e.g. 30-60 s) to track slow drift (bleaching, focus) while
not being pulled up by transients. Report the neuropil coefficient r and
the baseline window used — both materially change dF/F magnitude and are
rarely reported but change results.
6. Deconvolution to spike estimates
Both toolkits ship a deconvolution step (Suite2p: OASIS; CaImAn: OASIS or constrained-foopsi) that estimates a denoised calcium trace and a spike-rate proxy from dF/F, given the indicator's decay time constant.
- Deconvolved "spikes" are relative spike-rate estimates, not validated spike counts, unless calibrated against simultaneous electrophysiology for that exact indicator/cell-type/frame-rate combination (e.g. the ground-truth datasets from the Allen Institute or Svoboda lab spikefinder benchmarks).
- Report the indicator decay constant (
tau) used, since it strongly affects deconvolution output and is often left at a tool's default rather than set from the actual indicator in use. - For slow indicators (GCaMP6s) at typical two-photon frame rates (~5-30 Hz), do not interpret deconvolved output as single-spike-resolved; treat it as a smoothed estimate of firing rate.
7. Cross-session / cross-day registration
When tracking the same cells across sessions or days (chronic imaging
through a cranial window), register mean/max-projection images across
sessions (e.g. with suite2p's cross-session matching, or CaImAn's
register_multisession) before assuming an ROI index means the same cell
on different days. FOV rotation, z-drift, and tissue growth/scarring over
weeks all degrade naive ROI-index matching.
8. Quality checks before trusting the output
- SNR per ROI (peak dF/F vs. baseline noise) — drop or flag low-SNR ROIs rather than including them unweighted in population analyses.
- Fraction of frames flagged as high-motion (from the registration shift trace) — exclude or flag epochs with motion beyond a few pixels.
- Photobleaching: check whether the baseline
F0trends downward over the session; correct or regress it out before comparing early vs. late trials. - Visual spot-check: overlay a sample of accepted ROI contours on the mean/max-projection image. Misshapen or background-only "cells" indicate detection parameters need retuning.
Output
A short processing report: indicator and frame rate, motion-correction method and residual-motion check, detection tool and cell-diameter parameter, number of ROIs before/after curation with the curation criteria, neuropil coefficient and dF/F baseline window, deconvolution tau, and per-ROI SNR distribution.
Prerequisites
- Python 3.9+ with
suite2pand/orcaimaninstalled (CaImAn is best installed via conda due to compiled dependencies); a GPU is not required but speeds up Suite2p registration on large movies. - Enough disk/RAM to hold at least one copy of the raw movie plus a registered copy; multi-plane or long sessions can be tens of GB.
- Known imaging frame rate, pixel size and indicator identity — without these, default parameters (cell diameter, decay tau) are likely wrong.
Limitations
- This skill covers single-photon and two-photon somatic calcium imaging
analysis; it does not cover voltage imaging, fiber photometry (a
single-ROI, non-cellular-resolution technique with its own skill needs),
or electrophysiology spike sorting (see
neuro-spike-sorting-qcandneuropixels-analysisfor that). - Deconvolved spike estimates are not a substitute for simultaneous electrophysiological validation when precise spike timing or counts are required.
- Cross-session cell registration is never perfect; always report the fraction of cells successfully matched and treat unmatched ROIs as missing data, not as absent cells.
示例提示词
帮我用Suite2p处理这段双光子钙成像视频,提取细胞ROI和dF/F曲线。
所属插件
安装该插件会一并获得同领域的 45 个 Skill / MCP。
同插件的其他科研 Skill
- Allen脑区本体查询Looks up Allen Institute brain region names, acronyms and atlas hierarchy, and picks a BrainGlobe reference atlas. Use when matching region labels across datasets or papers.
- 动物行为姿态追踪Tracks animal pose and behavior from video with DeepLabCut or SLEAP, and extracts kinematic and behavioral event features. Use for markerless tracking or scoring behavior.
- BIDS神经影像数据管理Converts raw EEG or fMRI data to BIDS, validates with bids-validator, and queries or manages datasets with pybids and datalad. Use when organizing or sharing neuroimaging data.
- Brian2脉冲神经网络仿真Simulates LIF, AdEx and Hodgkin-Huxley spiking neuron networks in Brian2, including STDP plasticity and recurrent dynamics. Use when building a spiking network model.
- 功能连接组图论分析Computes functional connectivity matrices and graph-theory metrics such as modularity and path length from ROI time series. Use when analyzing brain network topology.
- MNE脑电脑磁分析Runs an MNE-Python EEG or MEG pipeline covering preprocessing, ICA cleanup, ERP and time-frequency analysis, and source localization. Use to analyze raw EEG/MEG recordings end to end.
- 神经解码无泄漏评估Guides leakage-free cross-validation of neural decoders, including subject grouping, nested CV, chance levels and confound checks. Use when training or reporting a BCI classifier.
- 电极通道映射校验Checks that EEG, ECoG or probe channel labels and positions match physiology using correlation-distance consistency. Use when montage labels may be swapped or bridged.
- 聚类置换统计检验Explains how to set up and correctly interpret cluster-based permutation tests and TFCE for ERP or time-frequency data. Use to avoid onset or localization overclaims.
- 神经连接性分析核查Guides choice of leakage-robust connectivity measures such as wPLI, imaginary coherency and AEC, with confound controls. Use when reviewing or planning a connectivity analysis.
- 神经数据集陷阱审查Checklist for auditing neural datasets before training: rate and channel consistency, duplicate subjects, label mapping. Use before modeling on a public or lab dataset.
- 神经数据档案库导航Lists neural data archives such as OpenNeuro, DANDI, PhysioNet and MOABB by paradigm, with access tiers and download guidance. Use when finding a dataset for a research question.
- DBS植入物传感数据分析Loads, time-aligns and analyzes sensing data from DBS and bidirectional implants such as Percept and Summit RC+S. Use with implant LFP exports, packet loss or aDBS biomarkers.
- 神经解码器嵌入式移植Ports a neural signal-processing or BCI decoder from Python or MATLAB to fixed-point embedded C on a microcontroller. Use when moving a decoder onto implant or headstage firmware.
- 神经设备法规合规映射Maps a neurotech device to the regulatory standards and testing it needs and builds a requirements-to-risk traceability matrix. Use when planning verification or a design review.
- EEG预处理流程审查Designs or audits an EEG or MEG preprocessing pipeline in MNE-Python, EEGLAB, FieldTrip or Brainstorm. Use when choosing or reviewing filter, ICA or epoching settings.
- 神经电极电化学表征Characterizes neural electrodes electrochemically via impedance spectroscopy, cyclic voltammetry and charge-injection limits. Use when comparing electrode coatings or charge capacity.
- 神经记录文件格式转换Opens, inspects and converts neural recording files from EEG, MEG, intracranial and fNIRS acquisition systems. Use when a reader errors or units, rates or events look wrong.
- 神经信号基础模型评估Fairly evaluates pretrained EEG or iEEG foundation models against classical baselines with matched data and splits. Use when fine-tuning or linear-probing a pretrained model.
- 神经记录前端电路设计Designs or reviews analog front ends for neural recording headstages, covering noise budget, CMRR and ADC resolution. Use when choosing an amplifier or debugging a noisy front end.
- 脑机解码器长期稳定性Evaluates intracortical BCI decoders across days using zero-shot and few-shot regimes to quantify drift and recalibration cost. Use to assess decoder stability over sessions.
- 植入设备功耗热预算Budgets power, data rate and tissue heating for implanted or wireless neural interfaces against thermal screening limits. Use when sizing a high-channel-count implant design.
- NeuroKit2生理信号处理Processes physiological biosignals such as ECG, EEG, EDA, RSP, EMG and EOG with NeuroKit2, including HRV and complexity metrics. Use for psychophysiology or multi-modal signal analysis.
- NeuroMorpho神经元形态检索Finds and compares digital neuron reconstructions on NeuroMorpho.Org by region, cell type or species and reads their morphometry. Use when real neuron morphologies are needed.
常见问题
钙成像数据分析能做什么?
Processes two-photon or widefield calcium imaging with Suite2p or CaImAn, from motion correction through ROI extraction to dF/F and spike deconvolution. Use for calcium imaging movies。
如何安装钙成像数据分析?
在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「钙成像数据分析」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。
钙成像数据分析需要哪些权限?
该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。
钙成像数据分析经过官方审核吗?
是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。