Skip to main content

Simple, modular CST assessment tool (DW-MRI).

Project description

csttool

License: MIT Python 3.10+ Documentation

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/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csttool-0.5.0.tar.gz (4.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

csttool-0.5.0-py3-none-any.whl (2.7 MB view details)

Uploaded Python 3

File details

Details for the file csttool-0.5.0.tar.gz.

File metadata

  • Download URL: csttool-0.5.0.tar.gz
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for csttool-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d5955d32191d84eab31123a70d55b0e62ca83e0fde01345714113527f5292d0c
MD5 1e1cd6605136d909be99c97f631bd1cc
BLAKE2b-256 17f0bf84c69b376307be5bb6db8c1a74755d467e2d85ed2234855ed1e07b24b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for csttool-0.5.0.tar.gz:

Publisher: ci.yml on alemnalo/csttool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file csttool-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: csttool-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for csttool-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f52032e177d2d4ce073a7efb3c6cc0cc178d4656df13ad801ad47a2ec5bfedb
MD5 9488613132e6bba5bb8a148452ce84a9
BLAKE2b-256 552db5833676d521ec53f15dcdf645c9a770ec98a9fe2d0c27ce54ab53141cc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for csttool-0.5.0-py3-none-any.whl:

Publisher: ci.yml on alemnalo/csttool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page