NeuroCAPs: Neuroimaging Co-Activation Patterns#

Latest Version Python Versions DOI GitHub Repository Test Status codecov License Docker JOSS

NeuroCAPs (Neuroimaging Co-Activation Patterns) is a Python package for performing Co-Activation Patterns (CAPs) analyses on resting-state or task-based fMRI data. CAPs identifies recurring brain states by applying k-means clustering on BOLD timeseries data [1].

_images/workflow.png

Citing#

If you would like to cite NeuroCAPs, you can use:

Smith, D., (2025). NeuroCAPs: A Python Package for Performing Co-Activation Patterns Analyses on Resting-State and Task-Based fMRI Data. Journal of Open Source Software, 10(112), 8196, https://doi.org/10.21105/joss.08196

Features#

NeuroCAPs is built around two main classes (TimeseriesExtractor and CAP) and includes several features to perform the complete CAPs workflow from postprocessing to visualizations. Notable features includes:

Component

Key Features

Timeseries Extraction (TimeseriesExtractor)

  • supports Schaefer, AAL, and custom deterministic parcellations

  • performs nuisance regression and motion scrubbing

  • reports quality control based on framewise displacement

Important

Optimized for BIDS-compliant data preprocessed with fMRIPrep. Refer to NeuroCAPs’ BIDS Structure and Entities Documentation for more information.

CAPs analysis (CAP)

  • performs k-means clustering

  • finds the optimal number of clusters (silhouette, elbow, variance ratio, Davies-Bouldin)

  • computes temporal dynamic metrics (temporal fraction, persistence, counts, transition frequency and probabilities) [2] [3]

  • converts CAPs to NIfTI images

  • creates visualizations (heatmaps, outer products, surface plots, correlation matrices, cosine similarity radar plots [4] [5] )

Standalone Functions

  • plots transition matrices

  • merges timeseries data across tasks or sessions [6]

  • generates and fetches custom parcellation approaches

Full details for every function and parameter are available in the API Documentation.

Refer to the demos to the demos or tutorials for an extensive demonstration of the features included in this package.

Dependencies#

NeuroCAPs relies on several packages:

dependencies = [
   "numpy>=1.26.3",
   "pandas>=2.1.0",
   "joblib>=1.3.0",
   "matplotlib>=3.6.0",
   "seaborn>=0.11.0",
   "kneed>=0.8.5",
   "nibabel>=5.0.0",
   "nilearn>=0.10.4",
   "scikit-learn>=1.4.0",
   "scipy>=1.10.0",
   "brainspace>=0.1.16",
   "surfplot>=0.2.0",
   "neuromaps>=0.0.5",
   "pybids>=0.16.5; platform_system != 'Windows'",
   "plotly>=6.5.0",
   "nbformat>=5.10.0",
   "kaleido>=1.2.0",
   "setuptools>=77.0.1, <82.0.0",
   "typing_extensions>=4.10.0",
   "vtk>=9.2.0",
   "tqdm>=4.65.0"
   ]

Acknowledgements#

Some foundational concepts in NeuroCAPs take inspiration from features or design patterns implemented in other neuroimaging Python packages, specifically:

  • mtorabi59’s pydfc, a toolbox that allows comparisons among several popular dynamic functionality methods.

  • 62442katieb’s IDConn, a pipeline for assessing individual differences in resting-state or task-based functional connectivity.

References#