Processing pipelines to extract brain microstructure from diffusion MRI
Project description
kwneuro
A Python-native toolkit for diffusion MRI analysis -- pip install and go from
raw dMRI data to microstructure maps, fiber orientations, and tract
segmentations without wrestling with multi-tool installations.
Early phase, under active development. The API may change between releases.
Why kwneuro?
Diffusion MRI analysis typically requires stitching together several packages (FSL, MRtrix3, DIPY, AMICO, ANTs, ...), each with its own installation story, file conventions, and coordinate quirks. kwneuro wraps the best of these tools behind a single, pip-installable Python interface so you can:
- Get started fast -- no system-level dependencies to configure.
- Swap models easily -- go from DTI to NODDI to CSD without rewriting your script.
- Work lazily or eagerly -- data stays on disk until you call
.load(), so you control memory usage.
kwneuro is not (yet) a replacement for the full power of FSL or MRtrix3. It is a lightweight layer for researchers who want standard dMRI analyses with minimal friction.
Installation
pip install kwneuro
Requires Python 3.10+.
Quick start
from kwneuro.dwi import Dwi
from kwneuro.io import FslBvalResource, FslBvecResource, NiftiVolumeResource
# Load DWI data into memory
dwi = Dwi(
NiftiVolumeResource("sub-01_dwi.nii.gz"),
FslBvalResource("sub-01_dwi.bval"),
FslBvecResource("sub-01_dwi.bvec"),
).load()
# Denoise and extract a brain mask
dwi = dwi.denoise()
mask = dwi.extract_brain()
# Fit DTI and get FA / MD maps
dti = dwi.estimate_dti(mask=mask)
fa, md = dti.get_fa_md()
# Fit NODDI (needs multi-shell data)
noddi = dwi.estimate_noddi(mask=mask)
# Save everything to disk
dti.save("output/dti.nii.gz")
NiftiVolumeResource.save(fa, "output/fa.nii.gz")
noddi.save("output/noddi.nii.gz")
What's included
| Capability | What it does | Powered by |
|---|---|---|
| Denoising | Patch2Self self-supervised denoising | DIPY |
| Brain extraction | Deep-learning brain masking from mean b=0 | HD-BET |
| DTI | Tensor fitting, FA, MD, eigenvalue decomposition | DIPY |
| NODDI | Neurite density, orientation dispersion, free water fraction | AMICO |
| CSD | Fiber orientation distributions and peak extraction | DIPY |
| Tract segmentation | 72 white-matter bundles from CSD peaks | TractSeg |
| Registration | Pairwise registration (rigid, affine, SyN) | ANTs |
| Template building | Iterative unbiased population templates (single- or multi-metric) | ANTs |
Example notebooks
The notebooks/ directory contains Jupytext notebooks you can run
end-to-end:
- example-pipeline.py -- Single-subject walkthrough: loading, denoising, brain extraction, DTI, NODDI, CSD, and TractSeg.
- example-group-template.py -- Multi-subject FA/MD template construction using iterative registration.
Contributing
Contributions are welcome! To set up a dev environment:
pip install -e ".[dev]"
pre-commit install
Run the tests and linter:
pytest
ruff check .
See the GitHub Discussions for questions and ideas, or open an issue for bugs and feature requests.
Acknowledgements
This work is supported by the National Institutes of Health under Award Number 1R21MH132982. The content is solely the responsibility of the authors and does not necessarily represent the official views of the National Institutes of Health.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kwneuro-0.3.0.tar.gz.
File metadata
- Download URL: kwneuro-0.3.0.tar.gz
- Upload date:
- Size: 60.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d0612edf4ae89d73e6ee354136ae18415ac7792406bc306719ad713797af83f
|
|
| MD5 |
49dbfd3807f3c1de62b29fbb1da8a7fe
|
|
| BLAKE2b-256 |
f74d6bce732190d11577ae2d8a2d50148664f9b60fedbe919d8c34da783d795a
|
Provenance
The following attestation bundles were made for kwneuro-0.3.0.tar.gz:
Publisher:
cd.yml on KitwareMedical/kwneuro
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kwneuro-0.3.0.tar.gz -
Subject digest:
1d0612edf4ae89d73e6ee354136ae18415ac7792406bc306719ad713797af83f - Sigstore transparency entry: 991666796
- Sigstore integration time:
-
Permalink:
KitwareMedical/kwneuro@dd3f9824420472090f032ddb94d0027554ae3011 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/KitwareMedical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@dd3f9824420472090f032ddb94d0027554ae3011 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kwneuro-0.3.0-py3-none-any.whl.
File metadata
- Download URL: kwneuro-0.3.0-py3-none-any.whl
- Upload date:
- Size: 36.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffee1b6ef120d1ca3e474ebcd8d08da320658b1271fe8147c20dcc409f8ae979
|
|
| MD5 |
3c89d2ed6556a17d9ad3c0f4b16ab17c
|
|
| BLAKE2b-256 |
05fd249e4be0c04f1cbcdfbae2c99d6f3d38399c054df912cd6805f38ab34c45
|
Provenance
The following attestation bundles were made for kwneuro-0.3.0-py3-none-any.whl:
Publisher:
cd.yml on KitwareMedical/kwneuro
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kwneuro-0.3.0-py3-none-any.whl -
Subject digest:
ffee1b6ef120d1ca3e474ebcd8d08da320658b1271fe8147c20dcc409f8ae979 - Sigstore transparency entry: 991666804
- Sigstore integration time:
-
Permalink:
KitwareMedical/kwneuro@dd3f9824420472090f032ddb94d0027554ae3011 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/KitwareMedical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@dd3f9824420472090f032ddb94d0027554ae3011 -
Trigger Event:
release
-
Statement type: