A comprehensive toolkit for medical image processing, including DICOM, NIfTI, and multi-format I/O utilities
Project description
MedImgKit
A comprehensive toolkit for medical image processing, providing utilities for DICOM, NIfTI, and other medical image formats with seamless multi-format I/O operations.
Features
- DICOM Support: Read, anonymize, and manipulate DICOM files
- NIfTI Support: Work with neuroimaging data in NIfTI format
- Multi-format I/O: Unified interface for reading various image formats
- Anonymization: DICOM anonymization following DICOM standards
- Coordinate Conversion: Convert between pixel and patient coordinates
- Multi-frame Assembly: Combine multiple DICOM files into multi-frame volumes
Installation
From PyPI
pip install medimgkit
From Source
pip install git+https://github.com/SonanceAI/medimgkit
Quick Start
DICOM Operations
import medimgkit as mik
import pydicom
# Read and normalize DICOM image
ds = pydicom.dcmread('path/to/dicom.dcm')
image_array = mik.load_image_normalized(ds)
# Anonymize DICOM
anonymized_ds = mik.anonymize_dicom(ds)
# Convert pixel coordinates to patient coordinates
patient_coords = mik.pixel_to_patient(ds, pixel_x=100, pixel_y=150)
NIfTI Operations
import nibabel as nib
import medimgkit as mik
# Load NIfTI file
nifti_data = nib.load('path/to/image.nii.gz')
# Get a specific slice
slice_image = mik.get_slice(nifti_data, slice_index=50, slice_axis=2)
# Convert world coordinates to slice index
slice_idx, axis = mik.line_to_slice_index(nifti_data, point1, point2)
Multi-format Reading
import medimgkit as mik
# Read any supported format
image_array = mik.read_array_normalized('path/to/image.dcm')
image_array = mik.read_array_normalized('path/to/image.nii.gz')
image_array = mik.read_array_normalized('path/to/image.png')
API Reference
DICOM Utils (medimgkit.dicom_utils)
Core Functions
load_image_normalized(dicom, index=None): Load and normalize DICOM pixel dataanonymize_dicom(ds, retain_codes=[], copy=False, token_mapper=None): Anonymize DICOM following standardsassemble_dicoms(files_path, return_as_IO=False): Combine multiple DICOMs into multi-frameis_dicom(f): Check if file is a DICOM
Coordinate Conversion
pixel_to_patient(ds, pixel_x, pixel_y, slice_index=None): Convert pixel to patient coordinatesget_image_position(ds, slice_index=None): Get image position in patient coordinatesget_pixel_spacing(ds, slice_index): Get pixel spacing information
Anatomical Analysis
determine_anatomical_plane_from_dicom(ds, slice_axis, alignment_threshold=0.95): Determine anatomical plane
NIfTI Utils (medimgkit.nifti_utils)
Slice Operations
get_slice(data, slice_index, slice_axis): Extract 2D slice from 3D volumeget_slice_from_line(data, world_point1, world_point2): Get slice defined by lineslice_location_to_slice_index(data, slice_location, slice_axis): Convert location to index
Coordinate Conversion
line_to_slice_index(data, world_point1=None, world_point2=None, coplanar_vector=None): Convert line to sliceaxis_name_to_axis_index(data, axis_name): Convert axis name to index
Utilities
is_nifti_file(file_path): Check if file is NIfTI format
I/O Utils (medimgkit.io_utils)
Reading Functions
read_array_normalized(file_path, index=None, return_metainfo=False, use_magic=False): Universal image readerread_image(file_path): Read standard image formats (PNG, JPEG)read_nifti(file_path, mimetype=None): Read NIfTI filesread_video(file_path, index=None): Read video files
Supported Formats
- DICOM: .dcm, .dicom (and files without extension)
- NIfTI: .nii, .nii.gz
- Images: .png, .jpg, .jpeg
- Video: .mp4, .avi, .mov, .mkv
- NumPy: .npy
Development
Running Tests
pytest
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file medimgkit-0.14.9.tar.gz.
File metadata
- Download URL: medimgkit-0.14.9.tar.gz
- Upload date:
- Size: 50.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2344edec984adb4b7c3715bfb326db4b61cda6087ae1d577ca54fdf62b2be1d
|
|
| MD5 |
4419a30df2eb853760ea7b65d7b03871
|
|
| BLAKE2b-256 |
cb05d9013d0fbd6ed0b89b31cf8af47e95e4e0dc762eeb1d70e7b9288d936b39
|
Provenance
The following attestation bundles were made for medimgkit-0.14.9.tar.gz:
Publisher:
release_pypi.yaml on SonanceAI/medical-image-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
medimgkit-0.14.9.tar.gz -
Subject digest:
b2344edec984adb4b7c3715bfb326db4b61cda6087ae1d577ca54fdf62b2be1d - Sigstore transparency entry: 1268536515
- Sigstore integration time:
-
Permalink:
SonanceAI/medical-image-utils@2a09b1949ffc1944992643f4db35046c2c21ae23 -
Branch / Tag:
refs/tags/v0.14.9 - Owner: https://github.com/SonanceAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release_pypi.yaml@2a09b1949ffc1944992643f4db35046c2c21ae23 -
Trigger Event:
push
-
Statement type:
File details
Details for the file medimgkit-0.14.9-py3-none-any.whl.
File metadata
- Download URL: medimgkit-0.14.9-py3-none-any.whl
- Upload date:
- Size: 45.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52e9a1ea0de11a4a4b141eef3bbaa3286b88d2490c482d8708fd83ac1bc9f2f8
|
|
| MD5 |
2d4096ee668657af3e95b285bcf1b268
|
|
| BLAKE2b-256 |
bd0f9e26db58e07d32ffea242afccc3c21ca4ef32e08f9bfb6d15af9d9387f77
|
Provenance
The following attestation bundles were made for medimgkit-0.14.9-py3-none-any.whl:
Publisher:
release_pypi.yaml on SonanceAI/medical-image-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
medimgkit-0.14.9-py3-none-any.whl -
Subject digest:
52e9a1ea0de11a4a4b141eef3bbaa3286b88d2490c482d8708fd83ac1bc9f2f8 - Sigstore transparency entry: 1268536613
- Sigstore integration time:
-
Permalink:
SonanceAI/medical-image-utils@2a09b1949ffc1944992643f4db35046c2c21ae23 -
Branch / Tag:
refs/tags/v0.14.9 - Owner: https://github.com/SonanceAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release_pypi.yaml@2a09b1949ffc1944992643f4db35046c2c21ae23 -
Trigger Event:
push
-
Statement type: