csttool
csttool is a command-line tool for automated assessment of the corticospinal tract (CST) from diffusion-weighted MRI (DWI/DTI) data. It runs a full analysis pipeline — from DICOM import through tractography, CST extraction, and quantitative metrics — and produces BIDS-aligned derivative outputs.
What it does
The pipeline runs in six sequential steps:
| Step | Command | Description |
|---|---|---|
| 1 | check |
Verify Python environment and external dependencies |
| 2 | import |
Convert DICOM to NIfTI, or validate an existing NIfTI dataset |
| 3 | preprocess |
Denoise (patch2self or NLMEANS), skull-strip, optional motion correction and Gibbs unringing |
| 4 | track |
Whole-brain deterministic tractography using a CSA ODF model |
| 5 | extract |
Atlas-based bilateral CST extraction via MNI152 registration and Harvard-Oxford ROI masks |
| 6 | metrics |
Per-side and bilateral metrics (FA, MD, morphology, tract profiles, asymmetry indices) with PDF/HTML reports |
Steps can be run individually or as a single run command. A batch command supports multi-subject processing via a BIDS dataset or JSON manifest.
Inputs
- DICOM directory — study root or series directory (converted with
dcm2niix) - NIfTI dataset —
.nii/.nii.gz+ bval + bvec files (DICOM conversion skipped) - Optional: BIDS JSON sidecar, subject/session labels, field strength, echo time overrides
Outputs
All outputs are written to a BIDS-aligned derivative directory:
- Preprocessed DWI (denoised, brain-masked)
- Scalar maps: FA, MD
- Whole-brain tractogram (
.trk) - Left and right CST tractograms (
.trk) - Per-subject metrics in JSON and TSV
- HTML and PDF clinical reports
- QC visualizations (optional)
Installation
Recommended: conda (Linux, macOS, Windows)
Conda handles both the Python stack and the external dcm2niix binary, plus the native libraries (Cairo, Pango, GDK-PixBuf) that the PDF report backend depends on. This is the only path that gives full functionality on Windows out of the box.
git clone https://github.com/alemnalo/csttool.git
cd csttool
conda env create -f environment.yml
conda activate csttool
csttool fetch-data --accept-fsl-license
Advanced: pip
pip install csttool # core pipeline + HTML reports
pip install 'csttool[reports]' # adds PDF rendering (Linux/macOS)
On Windows, pip install 'csttool[reports]' will install weasyprint but its native dependencies (Cairo, Pango) are not bundled — PDF generation will fail at runtime with a missing-DLL error. Use the conda install path on Windows if you need PDF reports. HTML reports work on all platforms regardless.
You will also need to install dcm2niix separately:
sudo apt install dcm2niix # Debian / Ubuntu (check version >= 1.0.20220720)
brew install dcm2niix # macOS
conda install -c conda-forge dcm2niix # any platform
If dcm2niix is not on PATH, csttool falls back to dicom2nifti. The fallback does not produce BIDS JSON sidecars and is less reliable for non-Siemens data.
Atlas data (required for extraction)
csttool fetch-data --accept-fsl-license
Downloads the FMRIB58_FA template and Harvard-Oxford atlas under the FSL non-commercial license.
Development install
git clone https://github.com/alemnalo/csttool.git
cd csttool
pip install -e '.[reports,test]'
Usage
Full pipeline from DICOM:
csttool run --dicom /path/to/dicom --out /path/to/output --subject-id sub-01 --save-visualizations --generate-pdf
Full pipeline from existing NIfTI:
csttool run --nifti sub-01_dwi.nii.gz --out /path/to/output --subject-id sub-01
Run individual steps:
csttool preprocess --dwi sub-01_dwi.nii.gz --out preproc/
csttool track --nifti preproc/sub-01_dwi_preproc.nii.gz --out tracking/
csttool extract --tractogram tracking/sub-01_tractogram.trk --nifti preproc/sub-01_dwi_preproc.nii.gz --out extract/
csttool metrics --cst-left extract/sub-01_cst-left.trk --cst-right extract/sub-01_cst-right.trk --out metrics/
Batch processing (BIDS dataset):
csttool batch --bids /path/to/bids --out /path/to/derivatives
Batch processing (manifest):
csttool batch --manifest subjects.json --out /path/to/derivatives
Assess DWI data quality before running:
csttool check-dataset --dwi sub-01_dwi.nii.gz --verbose
Testing
pytest tests/
Metadata
Release files for csttool 0.5.0
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 |
|---|---|---|---|---|
| csttool-0.5.0.tar.gz | 4.3 MB | With provenance | Details for csttool-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| csttool-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for csttool-0.5.0-py3-none-any.whl |
Total release size: 7.0 MB
Release files / csttool-0.5.0.tar.gz
| Download URL | csttool-0.5.0.tar.gz |
|---|---|
| Size | 4.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5955d32191d84eab31123a70d55b0e62ca83e0fde01345714113527f5292d0c
|
|
BLAKE2b-256 checksum How to use checksums |
17f0bf84c69b376307be5bb6db8c1a74755d467e2d85ed2234855ed1e07b24b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 21, 2026.
Transparency logRelease files / csttool-0.5.0-py3-none-any.whl
| Download URL | csttool-0.5.0-py3-none-any.whl |
|---|---|
| Size | 2.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f52032e177d2d4ce073a7efb3c6cc0cc178d4656df13ad801ad47a2ec5bfedb
|
|
BLAKE2b-256 checksum How to use checksums |
552db5833676d521ec53f15dcdf645c9a770ec98a9fe2d0c27ce54ab53141cc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 21, 2026.
Transparency logSecurity for csttool 0.5.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for csttool-0.5.0.tar.gz
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 May 21, 2026.
Transparency logA 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.