# 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
```bash
pip install medimgkit
```
### From Source
```bash
pip install git+https://github.com/SonanceAI/medimgkit
```
## Quick Start
### DICOM Operations
```python
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
```python
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
```python
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 data
- `anonymize_dicom(ds, retain_codes=[], copy=False, token_mapper=None)`: Anonymize DICOM following standards
- `assemble_dicoms(files_path, return_as_IO=False)`: Combine multiple DICOMs into multi-frame
- `is_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 coordinates
- `get_image_position(ds, slice_index=None)`: Get image position in patient coordinates
- `get_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 volume
- `get_slice_from_line(data, world_point1, world_point2)`: Get slice defined by line
- `slice_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 slice
- `axis_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 reader
- `read_image(file_path)`: Read standard image formats (PNG, JPEG)
- `read_nifti(file_path, mimetype=None)`: Read NIfTI files
- `read_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
```bash
pytest
```
## License
MIT License - see LICENSE file for details.
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Submit a pull request
Raw data
{
"_id": null,
"home_page": null,
"name": "medimgkit",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "medical, imaging, dicom, nifti, healthcare, radiology, medical-imaging, image-processing",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/20/3f/57f7bf2d825f496683e20a11faab25a4ed28f61cbd6ad9b21a0721b079de/medimgkit-0.1.0.tar.gz",
"platform": null,
"description": "# MedImgKit\n\nA comprehensive toolkit for medical image processing, providing utilities for DICOM, NIfTI, and other medical image formats with seamless multi-format I/O operations.\n\n## Features\n\n- **DICOM Support**: Read, anonymize, and manipulate DICOM files\n- **NIfTI Support**: Work with neuroimaging data in NIfTI format\n- **Multi-format I/O**: Unified interface for reading various image formats\n- **Anonymization**: DICOM anonymization following DICOM standards\n- **Coordinate Conversion**: Convert between pixel and patient coordinates\n- **Multi-frame Assembly**: Combine multiple DICOM files into multi-frame volumes\n\n## Installation\n\n### From PyPI\n```bash\npip install medimgkit\n```\n\n### From Source\n```bash\npip install git+https://github.com/SonanceAI/medimgkit\n```\n\n## Quick Start\n\n### DICOM Operations\n```python\nimport medimgkit as mik\nimport pydicom\n\n# Read and normalize DICOM image\nds = pydicom.dcmread('path/to/dicom.dcm')\nimage_array = mik.load_image_normalized(ds)\n\n# Anonymize DICOM\nanonymized_ds = mik.anonymize_dicom(ds)\n\n# Convert pixel coordinates to patient coordinates\npatient_coords = mik.pixel_to_patient(ds, pixel_x=100, pixel_y=150)\n```\n\n### NIfTI Operations\n```python\nimport nibabel as nib\nimport medimgkit as mik\n\n# Load NIfTI file\nnifti_data = nib.load('path/to/image.nii.gz')\n\n# Get a specific slice\nslice_image = mik.get_slice(nifti_data, slice_index=50, slice_axis=2)\n\n# Convert world coordinates to slice index\nslice_idx, axis = mik.line_to_slice_index(nifti_data, point1, point2)\n```\n\n### Multi-format Reading\n```python\nimport medimgkit as mik\n\n# Read any supported format\nimage_array = mik.read_array_normalized('path/to/image.dcm')\nimage_array = mik.read_array_normalized('path/to/image.nii.gz')\nimage_array = mik.read_array_normalized('path/to/image.png')\n```\n\n## API Reference\n\n### DICOM Utils (`medimgkit.dicom_utils`)\n\n#### Core Functions\n- `load_image_normalized(dicom, index=None)`: Load and normalize DICOM pixel data\n- `anonymize_dicom(ds, retain_codes=[], copy=False, token_mapper=None)`: Anonymize DICOM following standards\n- `assemble_dicoms(files_path, return_as_IO=False)`: Combine multiple DICOMs into multi-frame\n- `is_dicom(f)`: Check if file is a DICOM\n\n#### Coordinate Conversion\n- `pixel_to_patient(ds, pixel_x, pixel_y, slice_index=None)`: Convert pixel to patient coordinates\n- `get_image_position(ds, slice_index=None)`: Get image position in patient coordinates\n- `get_pixel_spacing(ds, slice_index)`: Get pixel spacing information\n\n#### Anatomical Analysis\n- `determine_anatomical_plane_from_dicom(ds, slice_axis, alignment_threshold=0.95)`: Determine anatomical plane\n\n### NIfTI Utils (`medimgkit.nifti_utils`)\n\n#### Slice Operations\n- `get_slice(data, slice_index, slice_axis)`: Extract 2D slice from 3D volume\n- `get_slice_from_line(data, world_point1, world_point2)`: Get slice defined by line\n- `slice_location_to_slice_index(data, slice_location, slice_axis)`: Convert location to index\n\n#### Coordinate Conversion\n- `line_to_slice_index(data, world_point1=None, world_point2=None, coplanar_vector=None)`: Convert line to slice\n- `axis_name_to_axis_index(data, axis_name)`: Convert axis name to index\n\n#### Utilities\n- `is_nifti_file(file_path)`: Check if file is NIfTI format\n\n### I/O Utils (`medimgkit.io_utils`)\n\n#### Reading Functions\n- `read_array_normalized(file_path, index=None, return_metainfo=False, use_magic=False)`: Universal image reader\n- `read_image(file_path)`: Read standard image formats (PNG, JPEG)\n- `read_nifti(file_path, mimetype=None)`: Read NIfTI files\n- `read_video(file_path, index=None)`: Read video files\n\n## Supported Formats\n\n- **DICOM**: .dcm, .dicom (and files without extension)\n- **NIfTI**: .nii, .nii.gz\n- **Images**: .png, .jpg, .jpeg\n- **Video**: .mp4, .avi, .mov, .mkv\n- **NumPy**: .npy\n\n## Development\n\n### Running Tests\n```bash\npytest\n```\n## License\n\nMIT License - see LICENSE file for details.\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Submit a pull request\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A comprehensive toolkit for medical image processing, including DICOM, NIfTI, and multi-format I/O utilities",
"version": "0.1.0",
"project_urls": {
"Bug Tracker": "https://github.com/SonanceAI/medimgkit/issues",
"Homepage": "https://github.com/SonanceAI/medimgkit",
"Repository": "https://github.com/SonanceAI/medimgkit"
},
"split_keywords": [
"medical",
" imaging",
" dicom",
" nifti",
" healthcare",
" radiology",
" medical-imaging",
" image-processing"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ac018d57bb2a7270cda1fed6707c941200818c94690ac8fae430922c6493f61b",
"md5": "6f0e785b3541d46920ca00f1d9063434",
"sha256": "f671fafea90df5009a5b2d007f7b3915fd0bafd435a22a4f89c316be8431b812"
},
"downloads": -1,
"filename": "medimgkit-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6f0e785b3541d46920ca00f1d9063434",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 16396,
"upload_time": "2025-07-24T17:11:35",
"upload_time_iso_8601": "2025-07-24T17:11:35.316101Z",
"url": "https://files.pythonhosted.org/packages/ac/01/8d57bb2a7270cda1fed6707c941200818c94690ac8fae430922c6493f61b/medimgkit-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "203f57f7bf2d825f496683e20a11faab25a4ed28f61cbd6ad9b21a0721b079de",
"md5": "139530df83223555bca8c6197bbd248c",
"sha256": "66bfdf84cdefa98bd32acabc122d8fb6d9ffedf2145db5d2812cadfd79bd7933"
},
"downloads": -1,
"filename": "medimgkit-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "139530df83223555bca8c6197bbd248c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 17936,
"upload_time": "2025-07-24T17:11:36",
"upload_time_iso_8601": "2025-07-24T17:11:36.442875Z",
"url": "https://files.pythonhosted.org/packages/20/3f/57f7bf2d825f496683e20a11faab25a4ed28f61cbd6ad9b21a0721b079de/medimgkit-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-24 17:11:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "SonanceAI",
"github_project": "medimgkit",
"github_not_found": true,
"lcname": "medimgkit"
}