slicerheart_4dflow
Filters for 4D flow MRI processing by the SlicerHeart project:
- background phase (eddy current) correction:
ols,msac,wrls,war+msac - velocity anti-aliasing (phase unwrapping): temporal, Laplacian 3D/4D, Laplacian then temporal
- noise masking and PC-MRA
- divergence-free filtering and denoising:
fdm,relaxed,leray,dfw - plane flow quantification and mass-conservation QA
- pathlines (numpy RK4 or VTK particle tracer) and centerline-based plane placement
Only numpy and scipy are required; VTK is needed for pathline export and the VTK particle tracer. Methods, defaults and literature references are described in docs/FLOWFILTERS_README.md, docs/BACKGROUND.md and docs/METHODS_DRAFT.md.
Installation
pip install slicerheart_4dflow
In 3D Slicer: slicer.util.pip_install("slicerheart_4dflow").
Usage
import slicerheart_4dflow as f4d
# encoded velocity components, each aliased at its venc
corrected, info = f4d.correct_background_phase(velocity_t, magnitude_t, method="war+msac")
unwrapped = f4d.unwrap_velocity(corrected, venc, voxel_to_world, method="laplacian_then_temporal")
# world velocity components
velocity_world_t = unwrapped @ encoding_to_world.T
filtered, infos = f4d.divergence_free_sequence(velocity_world_t, lumen_mask, voxel_to_world, method="fdm")
flow = f4d.plane_flow(filtered, voxel_to_world, centre=(10.0, -32.0, 54.0), normal=(0.0, 0.3, 1.0),
radius=15.0, lumen_mask=lumen_mask)["flow"]
Conventions (see geometry.py):
- Image arrays are indexed
[k, j, i](i varies fastest), as returned by ITKGetArrayFromImageorslicer.util.arrayFromVolume: velocity(nt, nk, nj, ni, 3), magnitude(nt, nk, nj, ni), lumen mask(nk, nj, ni)bool. voxel_to_worldis a 4x4 homogeneous matrix that maps voxel coordinates(i, j, k, 1)to world coordinates(x, y, z, 1)in mm. Any affine mapping is supported: anisotropic, oblique, flipped or even sheared voxel axes.f4d.voxel_to_world_matrix(spacing, origin, directions)builds one.- The world coordinate system can be any (e.g. LPS or RAS); the package makes no assumption about it, the inputs only need to be consistent.
- Velocity vectors have world components
(vx, vy, vz)in the coordinate system ofvoxel_to_world. Unwrapping is the exception: it must be applied to the components as encoded, because each encoding direction aliases at its own venc. - Points (plane centres, seeds, centerlines, pathline points) are world
(x, y, z)mm; plane normals are world vectors.
Development
pip install -e ".[test]"
python -m pytest
Tests that use the aortic CFD example of 4DFlowNet
download it into tests/data on first use (see tests/README.md).
Releasing
Versions are derived from git tags. Publishing a GitHub release with a tag such as v0.1.0
runs the tests, builds the sdist and wheel, and uploads them to PyPI
(.github/workflows/publish.yml).
This requires a PyPI trusted publisher set up for
project slicerheart_4dflow, repository JolleyLab/slicerheart_4dflow, workflow publish.yml,
environment pypi.
License
MIT
Metadata
Release files for slicerheart-4dflow 0.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 | |
|---|---|---|---|---|
| slicerheart_4dflow-0.1.0.tar.gz | 57.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| slicerheart_4dflow-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 90.7 kB
Release files / slicerheart_4dflow-0.1.0.tar.gz
| Download URL | slicerheart_4dflow-0.1.0.tar.gz |
|---|---|
| Size | 57.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04f464d1f47bb9bbd1ff9cf3a88efdf7eae477849043fff32770158bbf9bd440
|
|
BLAKE2b-256 checksum How to use checksums |
f91230acd699323abbc782ff04013d1203978447d8ba2c878806663112af0080
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 19, 2026.
Transparency logRelease files / slicerheart_4dflow-0.1.0-py3-none-any.whl
| Download URL | slicerheart_4dflow-0.1.0-py3-none-any.whl |
|---|---|
| Size | 32.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0fb29f873b04a140bea206af1ffc05256cae297b5d1a06a5965a1eb4b4d2ae6
|
|
BLAKE2b-256 checksum How to use checksums |
93ea0eb491209e961d17834d6eccfffa921e730498355f6a9ec5342e44c54dda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 19, 2026.
Transparency logSecurity for slicerheart-4dflow 0.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for slicerheart_4dflow-0.1.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 Oct 19, 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.