VeinSeg
Physics-informed deep learning for cerebral vein segmentation from QSM.
Overview
VeinSeg segments cerebral veins from Quantitative Susceptibility Mapping (QSM). 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
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 with -r r2star |
-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 |
|---|---|---|
--local-field PATH |
— | Measured background-removed local field (skips dipole computation) |
--local-field-units |
auto |
hz | ppm | auto |
--b0 X Y Z |
0 0 1 |
B0 direction in world/scanner axes |
--frangi-erode-mm |
5 |
Zero the Frangi prior within this distance (mm) of the brain edge |
--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 |
--device |
auto |
auto | cpu | cuda |
--out-field PATH |
— | Save local field channel used (ppm) |
--out-frangi PATH |
— | Save Frangi vesselness channel |
Examples
# Dipole field computed automatically from QSM
veinseg -i qsm.nii.gz -r tgv -f 7t -o mask.nii.gz -p prob.nii.gz
# With measured local field (Romeo output in Hz — auto-detected)
veinseg -i qsm.nii.gz -r medi -f 7t -o mask.nii.gz -p prob.nii.gz \
--local-field bgrm_field.nii.gz
# Inspect intermediate channels
veinseg -i qsm.nii.gz -r tgv -f 7t -o mask.nii.gz -p prob.nii.gz \
--out-field dipole_field.nii.gz --out-frangi frangi.nii.gz
License
Apache 2.0
Metadata
Release files for veinseg-qsm 1.1.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 |
|---|---|---|---|---|
| veinseg_qsm-1.1.0.tar.gz | 22.8 kB | Without provenance | Details for veinseg_qsm-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| veinseg_qsm-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for veinseg_qsm-1.1.0-py3-none-any.whl |
Total release size: 45.8 kB
Release files / veinseg_qsm-1.1.0.tar.gz
| Download URL | veinseg_qsm-1.1.0.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
987bec52c6223070a59cf7f90ca57844a62a171d9f03c98248c17a7b18e13f6b
|
|
BLAKE2b-256 checksum How to use checksums |
16043632e4702534ff58a1073436582a379e22043148593284bea8970b53c003
|
| 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.0-py3-none-any.whl
| Download URL | veinseg_qsm-1.1.0-py3-none-any.whl |
|---|---|
| Size | 23.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1ea8561cb43624a594decd5008a6625649abbfde1396f9d2fec0f531971c318
|
|
BLAKE2b-256 checksum How to use checksums |
b7f3f49379c206db34e8dea1578f838f38eaa0111254c3ddb5f5ae0c511a0992
|
| 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.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.
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.