Complete I/O Support
Load and save NIfTI files with full spatial metadata preservation. HDF5 storage for efficient dataset management.
A comprehensive Julia package for loading, transforming, and analyzing 3D/4D medical images with proper spatial metadata handling

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.
MedImage struct encapsulates voxel data, spatial metadata (origin, spacing, direction), and clinical metadata in a single container.using Pkg
Pkg.add("MedImages")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")| Modality | Type | Subtypes |
|---|---|---|
| CT | CT_type | CT_subtype |
| MRI | MRI_type | T1, T2, FLAIR, ADC, DWI |
| PET | PET_type | FDG, PSMA |
| Function | Description |
|---|---|
crop_mi | Extract a region of interest |
pad_mi | Add voxels around the image |
rotate_mi | Rotate around an axis |
translate_mi | Shift the image origin |
scale_mi | Resize the image |
resample_to_spacing | Change voxel spacing |
resample_to_image | Register to another image |
change_orientation | Convert between orientations |
MedImages.jl is designed to work with:
Contributions are welcome! Please visit our GitHub repository to:
MedImages.jl is released under the MIT License.