Skip to main content

CarDpy

Cardiac Diffusion in Python: a Python toolbox for processing cardiac diffusion tensor imaging (cDTI) data. It runs the full pipeline, from DICOM or NIfTI input to diffusion tensor and cardiac metrics (MD, FA, helix angle, E2A).

Pipeline overview

https://github.com/user-attachments/assets/94ed65fc-ec80-4635-a24a-68b779b8f039

Command-line demo

https://github.com/user-attachments/assets/d49ed1cd-8b80-441a-ae34-f27c8d6ec2c4

Updates in CarDpy 2.0

  • Three shot rejection modes: Algorithmic (SSIM/NRMSE clustering, default), Manual (click-to-reject review window), and CNN-Reject (a bundled deep learning classifier).
  • Automated segmentation with nnUNet-Segment: LV contours and RV insertion points without manual drawing, with an optional review step.
  • Bootstrapped uncertainty: 95% intervals for MD and FA, and cone half-angles for E1/E2/E3.
  • Redesigned GUIs: box cropping, spline contouring with zoom, and a manual shot rejection review window.

Install

conda create -n cardpy python=3.14 -y
conda activate cardpy
pip install "cardpy-cmr[macos]"    # drop [macos] on Linux/Windows

The PyPI name is cardpy-cmr; the import name is cardpy.

  • Install size: CarDpy 2.0 depends on torch, nnunetv2, ultralytics and huggingface_hub, so you can expect a 1–2 GB install.
  • nnUNet-Segment weights (~4 GB) download on first use from the gated Hugging Face repo sash99666/cdti-lv-baseline. Request access on that page, then run hf auth login once. Manual segmentation does need either of these steps.

Quick start

import copy
from cardpy.pipeline import process
from cardpy.config import DEFAULT_CONFIG

config = copy.deepcopy(DEFAULT_CONFIG)
config["dicom_subpath"] = "02_cDTI/SAX/your_series_folder_name"
config["slice_index"]   = None              # all slices, or e.g. [3, 4]

config["rejection"]["mode"]    = "algorithm"  # "algorithm" / "manual" / "ml" (CNN-Reject)
config["segmentation"]["mode"] = "manual"     # "manual" / "auto" (nnUNet-Segment)
config["uncertainty"]["enabled"] = False      # True adds bootstrapped uncertainty

results = process("/full/path/to/your/study_folder", config)

The GUIs open during the run when needed. When they're done, results holds the DTI metrics, eigenvectors, cardiac metrics and mask, and every stage is written to CarDpy_Output/ inside your study folder.

Step-by-step notebooks are in the repository: 01_Data_Processing, 02_Post-Processing, 03_Uncertainty and 04_Manual_Shot_Rejection. A sample dataset, Healthy_Volunteer_007.zip, is included.

Full guide (every config option, outputs, GUIs, troubleshooting): HOW_TO_USE.md

Associated publication

Cork, T.E., Hannum, A.J., Loecher, M., Perotti, L.E., Ennis, D.B. (2025). Evaluating the Effect of Post-processing Steps When Analyzing Cardiac Diffusion Tensor Data. In: Functional Imaging and Modeling of the Heart (FIMH 2025). Lecture Notes in Computer Science, vol. 15673. Springer, Cham. https://doi.org/10.1007/978-3-031-94562-5_13

Credits and license

CarDpy was originally written by Tyler Cork (CMR Group, Stanford Radiological Sciences Laboratory). nnUNet-Segment was developed by Sascha Stocker; its code is included in cardpy/Data_Processing/nnunet_cdti/ under the Apache 2.0 license. CarDpy is released under the GNU GPL v3.

Metadata

Release files for cardpy-cmr 0.2.1

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

Source distribution (sdist)

Source distribution for cardpy-cmr 0.2.1
File Size Uploaded Provenance Actions
cardpy_cmr-0.2.1.tar.gz 1.3 MB With provenance Details for cardpy_cmr-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cardpy-cmr 0.2.1
File Interpreter ABI Platform Actions
cardpy_cmr-0.2.1-py3-none-any.whl Python 3 none any Details for cardpy_cmr-0.2.1-py3-none-any.whl

Total release size: 2.6 MB

Release files / cardpy_cmr-0.2.1.tar.gz

Download URL cardpy_cmr-0.2.1.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
119e405626d6da0fe9a846afd4fdecbf6e1f4fffaac4ffc01e11202e1d584db5
BLAKE2b-256 checksum
How to use checksums
6d7e3978d59c041128b22fed817f8831a850f8226824ef2e8b6138126ea8901e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Release files / cardpy_cmr-0.2.1-py3-none-any.whl

Download URL cardpy_cmr-0.2.1-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c83127489494616dbfc3124cf13f8229967d7801ba92242b8fcbe83e25d21cf5
BLAKE2b-256 checksum
How to use checksums
876e74d625882fd26934831c0edb97d35f1c3edad9549ba4a1c52aa2a55fe51c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 13, 2026.

Transparency log

Security for cardpy-cmr 0.2.1

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.

Select from 2 files

Attestation for cardpy_cmr-0.2.1.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 Nov 13, 2026.

Transparency log

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.

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