Skip to content

MedImages.jlMedical Image Processing in Julia

A comprehensive Julia package for loading, transforming, and analyzing 3D/4D medical images with proper spatial metadata handling

MedImages.jl Logo

What is MedImages.jl?

MedImages.jl is a Julia package for standardizing the handling of 3D and 4D medical images. It provides a unified data structure that combines voxel data with comprehensive spatial and clinical metadata, ensuring that transformations maintain physical accuracy.

Key Features

  • Unified Data Structure: The MedImage struct encapsulates voxel data, spatial metadata (origin, spacing, direction), and clinical metadata in a single container.
  • Coordinate System Aware: All operations maintain proper relationships between array indices and physical coordinates.
  • Multiple Interpolation Methods: Nearest neighbor, linear, and B-spline interpolation for different use cases.
  • Orientation Support: Work with 8 standard orientations and convert between them seamlessly.
  • ITK/SimpleITK Compatible: Uses ITKIOWrapper for I/O, ensuring compatibility with the broader medical imaging ecosystem.

Quick Start

Installation

julia
using Pkg
Pkg.add("MedImages")

Basic Usage

julia
using MedImages

# Load a CT scan
ct = load_image("/path/to/scan.nii.gz", "CT")

# Inspect properties
println("Dimensions: ", size(ct.voxel_data))
println("Spacing (mm): ", ct.spacing)
println("Origin (mm): ", ct.origin)

# Resample to isotropic spacing
isotropic = resample_to_spacing(ct, (1.0, 1.0, 1.0), Linear_en)

# Save result
create_nii_from_medimage(isotropic, "/output/isotropic_ct")

Supported Modalities

ModalityTypeSubtypes
CTCT_typeCT_subtype
MRIMRI_typeT1, T2, FLAIR, ADC, DWI
PETPET_typeFDG, PSMA

Available Transformations

FunctionDescription
crop_miExtract a region of interest
pad_miAdd voxels around the image
rotate_miRotate around an axis
translate_miShift the image origin
scale_miResize the image
resample_to_spacingChange voxel spacing
resample_to_imageRegister to another image
change_orientationConvert between orientations

Integration

MedImages.jl is designed to work with:

Documentation Sections

Contributing

Contributions are welcome! Please visit our GitHub repository to:

  • Report issues
  • Submit pull requests
  • Suggest new features

License

MedImages.jl is released under the MIT License.

Part of the JuliaHealth organization