Skip to main content

VeinSeg

Physics-informed deep learning for cerebral vein segmentation from QSM or R2*.

Hugging Face | GitHub


Overview

VeinSeg segments cerebral veins from Quantitative Susceptibility Mapping (QSM) or R2* maps, using only the image as input. It supports multi-site, multi-field-strength data (3T and 7T) across five QSM reconstruction methods (TGV, MEDI, L1, STAR, iLSQR) and R2* maps using a physics-informed training objective.


Installation

Install PyTorch first (pytorch.org), then:

pip install veinseg-qsm

Download the model weights (~290 MB, once only):

veinseg-install /path/to/models/dir

On shared HPC clusters, set:

export VEINSEG_CHECKPOINT=/shared/models/veinseg/checkpoint.pth

Usage

veinseg -i qsm.nii.gz -r tgv -f 7t -o mask.nii.gz -p prob.nii.gz

Required arguments

Flag Description
-i QSM susceptibility map (.nii / .nii.gz, ppm), or R2* map (1/s) with -r r2star — the only input needed
-r Reconstruction method: tgv | medi | l1 | star | ilsqr | r2star
-f MRI field strength: 7t | 3t
-o Output binary vein mask
-p Output vein probability map

Optional arguments

Flag Default Description
--threshold 0.5 Probability threshold for binary mask
--step-size 0.5 Sliding window overlap as fraction of patch
--no-tta off Disable test-time augmentation (mirroring)
--device auto auto | cpu | cuda

Examples

# QSM
veinseg -i qsm.nii.gz -r medi -f 3t -o mask.nii.gz -p prob.nii.gz

# R2*
veinseg -i r2star.nii.gz -r r2star -f 3t -o mask.nii.gz -p prob.nii.gz

# CPU inference, no test-time augmentation (faster)
veinseg -i qsm.nii.gz -r tgv -f 7t -o mask.nii.gz -p prob.nii.gz \
        --device cpu --no-tta

License

Apache 2.0

Metadata

Release files for veinseg-qsm 1.1.2

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

Source distribution (sdist)

Source distribution for veinseg-qsm 1.1.2
File Size Uploaded Provenance Actions
veinseg_qsm-1.1.2.tar.gz 16.1 kB Without provenance Details for veinseg_qsm-1.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for veinseg-qsm 1.1.2
File Interpreter ABI Platform Actions
veinseg_qsm-1.1.2-py3-none-any.whl Python 3 none any Details for veinseg_qsm-1.1.2-py3-none-any.whl

Total release size: 31.6 kB

Release files / veinseg_qsm-1.1.2.tar.gz

Download URL veinseg_qsm-1.1.2.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f6c00ca4cff83f6405ca94d7c35822c79890e57e4a1569d81933177e67bd75e5
BLAKE2b-256 checksum
How to use checksums
fe7599608b0a460c4885efea8def223daf6107fcb69cefb3a7a17944b918c380
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Release files / veinseg_qsm-1.1.2-py3-none-any.whl

Download URL veinseg_qsm-1.1.2-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0795a3fbf5add6e6879ce328faa20ead83a360dce7b381288b54c2c26580b99c
BLAKE2b-256 checksum
How to use checksums
84db644abc2cfe5529c1a30ec5885e890a166a288c6e14bb5863e6a6d2e0818b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Security for veinseg-qsm 1.1.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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