parcellate
Extract regional statistics from scalar neuroimaging maps using atlas-based parcellation.
What It Does
parcellate is a Python library that extracts regional statistics from volumetric brain images using atlas-based parcellation. Given a scalar map (e.g., gray matter density, fractional anisotropy) and a labeled atlas, it computes summary statistics for each brain region and returns a tidy pandas.DataFrame.
Key Features:
- 45 built-in statistics in three tiers (core / extended / diagnostic), including robust estimates, higher-order moments, and normality tests
- Flexible atlases: discrete 3D integer-label atlases and 4D probabilistic atlases (e.g., XTRACT tracts)
- Built-in masks: MNI152 grey-matter, white-matter, and brain masks via nilearn
- Custom statistics: supply any callable as a statistic
- Scikit-learn–style API:
fit/transformpattern with smart resampling caching
Installation
pip install parcellate
Or from a local checkout:
git clone https://github.com/GalKepler/parcellate.git
cd parcellate
pip install -e .
Quick Start
from parcellate import VolumetricParcellator
parcellator = VolumetricParcellator(
atlas_img="atlas.nii.gz",
lut="atlas_lut.tsv", # TSV with "index" and "label" columns
mask="gm", # built-in MNI152 grey-matter mask
stat_tier="extended", # 21 statistics (default: all 45)
)
parcellator.fit("subject_map.nii.gz")
stats = parcellator.transform("subject_map.nii.gz")
print(stats.head())
Statistics Tiers
Select a tier with stat_tier to control the number of computed statistics:
| Tier | Count | Use case |
|---|---|---|
core |
6 | Fast exploration, large cohorts |
extended |
21 | Production pipelines |
diagnostic (default) |
45 | QC, distribution inspection |
Core: mean, std, median, volume_mm3, voxel_count, sum
Extended adds: robust means (MAD, z-score, IQR filtered), dispersion (cv, robust_cv), shape (skewness, excess_kurtosis), percentiles (5th, 25th, 75th, 95th)
Diagnostic adds: normality tests (Shapiro-Wilk, D'Agostino K²), outlier proportions, tail mass, entropy, boolean QC flags
See the full Metrics reference for descriptions of all 45 statistics.
Custom Statistics
import numpy as np
from parcellate import VolumetricParcellator
parcellator = VolumetricParcellator(
atlas_img="atlas.nii.gz",
stat_functions={
"iqr": lambda x: float(np.nanpercentile(x, 75) - np.nanpercentile(x, 25)),
"q90": lambda x: float(np.nanpercentile(x, 90)),
},
)
Output
transform() returns a pandas.DataFrame with one row per atlas region:
| Column | Description |
|---|---|
index |
Integer region index from the atlas |
label |
Region name from the lookup table |
mean, std, … |
Computed statistics (depends on stat_tier) |
Development
make install # create venv + install pre-commit hooks
make test # run tests with coverage
make check # lock file, pre-commit, deptry
Documentation
Full documentation: https://GalKepler.github.io/parcellate/
License
MIT License — see the LICENSE file for details.
Citation
@software{parcellate,
author = {Kepler, Gal},
title = {parcellate: Atlas-based parcellation of neuroimaging data},
url = {https://github.com/GalKepler/parcellate},
year = {2024}
}
Acknowledgments
Repository initiated with fpgmaas/cookiecutter-uv.
Metadata
Release files for parcellate 0.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| parcellate-0.4.2.tar.gz | 1.3 MB | Without provenance | Details for parcellate-0.4.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| parcellate-0.4.2-py3-none-any.whl | Python 3 | none | any | Details for parcellate-0.4.2-py3-none-any.whl |
Total release size: 1.3 MB
Release files / parcellate-0.4.2.tar.gz
| Download URL | parcellate-0.4.2.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07b68063073b65430a64f81d9732aca12b97348a37bd29b04ffae3e166ccfd5d
|
|
BLAKE2b-256 checksum How to use checksums |
fd1d341d41670083b76364ad47dac35d2c665d5246c47d37d442e3b995602d93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / parcellate-0.4.2-py3-none-any.whl
| Download URL | parcellate-0.4.2-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a396b968d504580a095fab4a7fce1690c8ba51dd7222ff9132e3b05ff45e0a3
|
|
BLAKE2b-256 checksum How to use checksums |
31c2380e5e650f4a6570415b43b95097faa521ca0f748094df70263b43769802
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for parcellate 0.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.