MedVol
A lightweight Python wrapper that unifies SimpleITK, nibabel, and pynrrd under a single, simple API for reading and writing 2‑D, 3‑D, and 4‑D medical images in NIfTI (.nii/.nii.gz) and NRRD (.nrrd) formats.
✨ Features
- Unified API – one
MedVolclass works with all three back‑ends. - Automatic backend selection based on file extension:
.nii/.nii.gz→nibabel.nrrd→pynrrd
- Explicit backend override via the
backend=argument. - Canonical
RAS+orientation by default (no interpolation). - Optional de‑obliquing via
get_geometry(deoblique=True). - Geometry is stored in a single source of truth – the affine matrix.
- Convenient derived properties:
spacing,origin,direction,rotation,shear,coordinate_system. - Direct access to the raw backend header through
header.
📦 Installation
pip install medvol
🚀 Quick start
from medvol import MedVol
# Load the bundled 3‑D example image (NIfTI).
img = MedVol("examples/data/3d_img.nii.gz")
print("Backend:", img.backend)
print("Shape:", img.array.shape)
print("Coordinate system:", img.coordinate_system)
print("Spacing:", img.spacing)
print("Origin:", img.origin)
print("Direction:\n", img.direction)
print("Affine:\n", img.affine)
print("Rotation:\n", img.rotation)
print("Header type:", type(img.header).__name__)
# Access the centre voxel value.
center = tuple(s // 2 for s in img.array.shape)
print("Center voxel:", img.array[center])
To inspect the native geometry without canonicalisation:
native = MedVol(
"examples/data/3d_img.nii.gz",
backend="simpleitk",
canonicalize=False,
)
print("Native coordinate system:", native.coordinate_system)
See the runnable demo at examples/example_showcase_3d_nifti.py.
Contributing
Contributions are welcome! Please open a pull request with clear changes and add tests when appropriate.
Acknowledgments
This repository is developed and maintained by the Applied Computer Vision Lab (ACVL) of Helmholtz Imaging and the Division of Medical Image Computing at DKFZ.
Metadata
Release files for MedVol 0.0.22
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| medvol-0.0.22.tar.gz | 21.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| medvol-0.0.22-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.0 kB
Release files / medvol-0.0.22.tar.gz
| Download URL | medvol-0.0.22.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04c7a808d21f9538bd27707d483315996d1aa7604fc46c751c45638812723c1e
|
|
BLAKE2b-256 checksum How to use checksums |
7f7d47b1625efb91fa178a394e6d6c4b9c7c3a01cccd99a59d8e523d02cfe896
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / medvol-0.0.22-py3-none-any.whl
| Download URL | medvol-0.0.22-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03d9670b6cffa75ccbc6307aaf1a8397ad8363626a4cae95c2bd3e1732a0a564
|
|
BLAKE2b-256 checksum How to use checksums |
b32df11099473dbae7adde9ee4df6fcf91b339b019561ffaecc3de76b33c47f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|