Skip to main content

I/O routines for medical imaging data

Project description

Voxel

License GitHub Workflow Status codecov Documentation Status

Documentation | Installation | Basic Usage

This is a fork of the original pyvoxel from Arjun Desai. The original repository can be found here. This repository is maintained by ORMIR.

Voxel provides fast Pythonic data structures and tools for wrangling with medical images.

Installation

Voxel requires Python 3.7+. The core module depends on numpy, nibabel, pydicom, requests, and tqdm.

To install Voxel, run:

pip install ormir-pyvoxel

Features

Simplified, Efficient I/O

Voxel provides efficient readers for DICOM and NIfTI formats built on nibabel and pydicom. Multi-slice DICOM data can be loaded in parallel with multiple workers and structured into the appropriate 3D volume(s). For example, multi-echo and dynamic contrast-enhanced (DCE) MRI scans have multiple volumes acquired at different echo times and trigger times, respectively. These can be loaded into multiple volumes with ease:

import voxel as vx

xray = vx.load("path/to/xray.dcm")
ct_scan = vx.load("path/to/ct/folder/")

multi_echo_scan = vx.load("/path/to/multi-echo/scan", group_by="EchoNumbers")
dce_scan = vx.load("/path/to/dce/scan", group_by="TriggerTime")

Data-Embedded Medical Images

Voxel's MedicalVolume data structure supports array-like operations (arithmetic, slicing, etc.) on medical images while preserving spatial attributes and accompanying metadata. This structure supports NumPy interoperability intelligent reformatting, fast low-level computations, and native GPU support. For example, given MedicalVolumes mv_a and mv_b we can do the following:

# Reformat image into Superior->Inferior, Anterior->Posterior, Left->Right directions.
mv_a = mv_a.reformat(("SI", "AP", "LR"))

# Get and set metadata
study_description = mv_a.get_metadata("StudyDescription")
mv_a.set_metadata("StudyDescription", "A sample study")

# Perform NumPy operations like you would on image data.
rss = np.sqrt(mv_a**2 + mv_b**2)

# Move to GPU 0 for CuPy operations
mv_gpu = mv_a.to(vx.Device(0))

# Take slices. Metadata will be sliced appropriately.
mv_subvolume = mv_a[10:20, 10:20, 4:6]

Easily Prepare Data for AI Pipelines

Voxel enables you to preprocess DICOM images for deep learning in a few lines of code:

# Load a scan, and prepare it for AI/visualization
mv = (
  vx.load("/dicoms")
  .apply_rescale()
  .apply_window()
  .to_grayscale()
)

# Zero-copy to PyTorch
arr = mv.to_torch()

Connect with PACS

Voxel provides easy access to data stored in a PACS environment through DICOMweb. This makes loading data from a remote server just as easy as using the local filesystem.

# Download an MRI from a local Orthanc instance
mv = vx.load("http://localhost:8042/dicom-web/studies/x/series/y", params={"Modality": "MR"})

# Re-use the session for multiple requests
with vx.HttpReader(verbose=True) as hr:
  mv_a = hr.load("http://localhost:8042/dicom-web/studies/v/series/w")
  mv_b = hr.load("http://localhost:8042/dicom-web/studies/x/series/y")

Contribute

If you would like to contribute to Voxel, we recommend you clone the repository and install Voxel with pip in editable mode.

git clone git@github.com:pyvoxel/pyvoxel.git
cd pyvoxel
pip install -e '.[dev,docs]'
make dev

To run tests, build documentation and contribute, run

make autoformat test build-docs

Citation

Voxel is a refactored version of the DOSMA package that focuses on medical image data structures and I/O. If you use Voxel in your research, please cite the following work:

@inproceedings{desai2019dosma,
  title={DOSMA: A deep-learning, open-source framework for musculoskeletal MRI analysis},
  author={Desai, Arjun D and Barbieri, Marco and Mazzoli, Valentina and Rubin, Elka and Black, Marianne S and Watkins, Lauren E and Gold, Garry E and Hargreaves, Brian A and Chaudhari, Akshay S},
  booktitle={Proc 27th Annual Meeting ISMRM, Montreal},
  pages={1135},
  year={2019}
}

In addition to Voxel, please also consider citing the work that introduced the method used for analysis.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ormir_pyvoxel-0.0.10.tar.gz (72.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ormir_pyvoxel-0.0.10-py3-none-any.whl (67.9 kB view details)

Uploaded Python 3

File details

Details for the file ormir_pyvoxel-0.0.10.tar.gz.

File metadata

  • Download URL: ormir_pyvoxel-0.0.10.tar.gz
  • Upload date:
  • Size: 72.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for ormir_pyvoxel-0.0.10.tar.gz
Algorithm Hash digest
SHA256 9ec3e00d8a4b87c7fbdbb3628e43c42ed14f570752d5cf49bf03cbd4e92683fd
MD5 1968e0f39da4d1677828363f4664a9dc
BLAKE2b-256 04340332a735d12ae0c5d49b9972527fd42829cef67fc53ba6ffba2c9449d4da

See more details on using hashes here.

File details

Details for the file ormir_pyvoxel-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: ormir_pyvoxel-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 67.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for ormir_pyvoxel-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 396c16962c89eef7a8e0033ae721405a43c99515f432c2de1fbc16890a6a059e
MD5 2ec1bb09221607f611e5a42352c34f79
BLAKE2b-256 e9f53aedef4b134439401af87bf987361e7e073201133cd0081b7944d7a73d99

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page