Skip to main content

dfc-kit

dfc-kit is an open-source Python toolkit for dynamic functional connectivity analysis of XCP-D parcellated derivatives. It provides composable estimators, state models, network summaries, statistical inference, and command-line workflows for reproducible neuroimaging analysis.

BIDS -> fMRIPrep -> XCP-D -> dfc-kit

Why dfc-kit

dfc-kit provides a unified workflow for estimating time-varying functional connectivity, identifying recurring brain states, and testing paired or between-group differences. Sliding-window FC, instantaneous edges generated from ETS or MTD samples, LEiDA, CAP, KMeans, and Gaussian HMM analyses share the same data structures and output conventions, making it easier to compare methods without rebuilding data loading, state summaries, and statistical inference for every analysis.

The toolkit supports both direct in-memory analysis and chunked feature stores for larger datasets, with matching Python and command-line interfaces.

Features

  • Input and topology: XCP-D discovery and validation, multi-atlas ROI loading, acquisition identity, and censor-bounded sequences. Censored time points retain their original frame indices, and temporal operations are evaluated separately within contiguous retained segments.
  • Connectivity: whole-acquisition and weighted sliding-window FC, whole-edge all-pair and order-specific pattern similarity, instantaneous ETS/MTD edges, LEiDA, low-rank covariance geometry, and fixed-length MI/CMI.
  • Connectivity and state analysis: partition-based graph metrics, CAP, KMeans, Gaussian HMMs, state alignment, occupancy/dwell/transition summaries, and selection of the number of states using held-out participants.
  • Inference: paired sign-flips, bootstrap intervals, HC3 models, declared-family FDR, generic paired endpoint inference, independent-group endpoint models, paired NBS, and within-subject motion matching.
  • Large-dataset workflows: chunked, memory-mapped FeatureStores and batch-wise fitting for MiniBatch KMeans and Incremental PCA.
  • Portable results: models and held-out predictions stored as JSON and NumPy arrays with explicit feature, subject, and parameter metadata.

The method inventory maps each method family to its public API and guide. Public data, connectivity, state, reference, and inference objects are covered by the package test suite and documented contracts.

Scope

The supported input boundary is XCP-D output. dfc-kit does not reimplement fMRIPrep-to-XCP-D denoising, filtering, censoring, interpolation, or parcellation. Callers provide ROI definitions, cohort labels, clinical variables, and manuscript-specific analyses around the library's numerical interfaces. The array API is also available for equivalently preprocessed ROI time series that are not stored as XCP-D derivatives.

Installation

python -m pip install dfc-kit

Install only the optional method families required by an analysis:

python -m pip install 'dfc-kit[phase,states,hmm,information,inference]'

Python 3.10 or newer is required. See Getting started for development installation and dependency details.

Quick start

from dfckit.connectivity import SlidingWindowFC
from dfckit.io import load_xcpd_run

loaded = load_xcpd_run(
    "/path/to/xcp_d",
    subject="sub-001",
    session="01",
    task="rest",
    atlases=("Schaefer200",),
    space="MNI152NLin2009cAsym",
    minimum_coverage=0.5,
    tr=0.8,
)

result = SlidingWindowFC(length=60, step=10, taper="hamming").transform(loaded.run)
print(result.features.shape)
print(result.start_frames, result.end_frames, result.segment_ids)

The result contains Fisher-z upper-triangle edges and the original-frame bounds of every valid window. For a complete path from XCP-D discovery through state fitting, see the XCP-D-to-state tutorial.

Command line

The dfc-kit command exposes XCP-D inspection, FeatureStore construction, state fitting, held-out prediction, scoring, alignment, and state-count validation. Start with:

dfc-kit --help
dfc-kit inspect-xcpd --help
dfc-kit build-store --help
dfc-kit fixed-information --help
dfc-kit lowrank-endpoints --help
dfc-kit window-pattern-endpoints --help
dfc-kit static-fc-endpoints --help
dfc-kit describe-states --help
dfc-kit infer-state-metrics --help
dfc-kit summarize-store --help
dfc-kit summarize-information --help
dfc-kit infer-paired-endpoints --help
dfc-kit infer-independent-endpoints --help
dfc-kit infer-paired-nbs --help

See Command-line workflows for complete examples and arguments, including fixed-length MI/CMI artifacts and frozen-window replay.

For two independent endpoint cohorts, infer-independent-endpoints fits the declared group contrast with HC3 standard errors, optional numeric covariates, and family-level Benjamini-Hochberg correction. See Independent group inference.

Documentation

Development

python -m pip install -e '.[all,dev,docs]'
python -m unittest discover
ruff check src tests
mkdocs build --strict

dfc-kit is distributed under the BSD-3-Clause license. See LICENSE and CITATION.cff for licensing and citation information.

Metadata

Release files for dfc-kit 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dfc-kit 1.0.3
File Size Uploaded
dfc_kit-1.0.3.tar.gz 275.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dfc-kit 1.0.3
File Interpreter ABI Platform
dfc_kit-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 462.4 kB

Release files / dfc_kit-1.0.3.tar.gz

Download URL dfc_kit-1.0.3.tar.gz
Size 275.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1ed1ed3379c32227f580accaafeee4325d0b48e2f3e2a6a1756012798dc211a2
BLAKE2b-256 checksum
How to use checksums
9aa82654df755ff85eed015b80ce1abebaee0b4ed083bc7c4dc80d35ea34707b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / dfc_kit-1.0.3-py3-none-any.whl

Download URL dfc_kit-1.0.3-py3-none-any.whl
Size 186.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bfc6e558d95ff55874903bbd8a0da621300d0617ae1eff291866171c122a00b
BLAKE2b-256 checksum
How to use checksums
7fcfd0e8ee650833e8ce3097896fa60ea4172ebdf80c36a7fee9bcd4857e2b23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page