Tiny lightweight DICOM metadata extractor
Project description
dicom-meta-lite
dicom-meta-lite is a lightweight Python utility for extracting essential metadata from DICOM medical imaging files (CT, MRI, X-ray, PET, etc.) without requiring heavy medical imaging frameworks.
It is ideal for machine learning pipelines, research, radiomics preprocessing, dataset cleaning, and oncology workflows.
✨ Features
- Extracts key DICOM metadata in a single function call
- Lightweight (minimal dependencies)
- Returns clean Python primitives (not pydicom objects)
- Optional patient anonymization
- Folder batch processing
- Designed for ML preprocessing and dataset inspection
🚀 Installation
Install via pip:
pip install dicom-meta-lite
You must also have pydicom:
pip install pydicom
📌 Usage
Extract metadata from a single DICOM file:
from dicom_meta_lite import extract_meta
meta = extract_meta("scan.dcm")
print(meta)
Example output:
{
"PatientID": "12345",
"Modality": "CT",
"StudyDate": "20240513",
"Manufacturer": "SIEMENS",
"Rows": 512,
"Columns": 512,
"PixelSpacing": [0.5, 0.5],
"SliceThickness": 1.2
}
Extract only selected keys:
extract_meta("scan.dcm", keys=["PatientID", "Modality"])
Remove sensitive identifiers:
extract_meta("scan.dcm", anonymize=True)
Removes fields such as:
- PatientName
- PatientBirthDate
- InstitutionName
Batch process a folder of DICOM files:
from dicom_meta_lite import extract_folder
results = extract_folder("dicom_folder/")
print(results)
🔬 Why this library?
Medical imaging datasets contain important metadata used for:
- Image normalization (pixel spacing, slice thickness)
- Quality checks
- Machine learning model preprocessing
- Radiotherapy planning research
- Oncology research pipelines
Existing tools (pydicom, highdicom, MONAI) are powerful but heavy for simple metadata extraction.
dicom-meta-lite gives you the essentials in seconds.
📦 Default extracted tags
By default, the library extracts:
- PatientID
- StudyDate
- Modality
- Manufacturer
- Rows
- Columns
- PixelSpacing
- SliceThickness
Custom keys are supported.
🧠 Use Cases
- ML model preprocessing
- Dataset cleaning & inspection
- Radiomics feature pipelines
- Medical research automation
- Oncology imaging workflows
🛡️ Privacy Notice
With anonymization enabled, this package removes identifiers commonly used in DICOM headers. However, compliance depends on your dataset and jurisdiction.
For sensitive projects, consult your institution’s IRB or DPO.
📁 Project Structure
dicom-meta-lite/
│ README.md
│ setup.cfg
│ pyproject.toml
│ LICENSE
│
└── dicom_meta_lite/
__init__.py
core.py
🗺️ Roadmap
Future versions will add:
- JSON export support
- CSV metadata export
- CLI (
dicom-meta file.dcm) - Tag description mapping
- Handling nested tag structures
Community contributions are welcome.
🧩 Requirements
- Python >= 3.8
- pydicom >= 2.4.0
👤 Author
Rusheel Sharma GitHub: https://github.com/Rusheel86 LinkedIN : https://www.linkedin.com/in/rusheel-sharma-0a8b70280/
📄 License
This project is licensed under the MIT License — see LICENSE for details.
⭐ Support the Project
If this package helps your research or ML workflow, please consider:
- Leaving a star on PyPI/GitHub
- Citing it in your project
- Sharing with classmates
Every bit of community visibility helps!
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 dicom_meta_lite-0.1.0.tar.gz.
File metadata
- Download URL: dicom_meta_lite-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d316bece8044ade77f3d1c986aa4b30b49033a3b8dd7575d0c7afaca2f459795
|
|
| MD5 |
d4335e5cacb88cebb88f1d8db9061f26
|
|
| BLAKE2b-256 |
5e8c05a02f7a0bc64b4fda6eebb8448ab81b59eab56acb355dde77af79e6fdc5
|
File details
Details for the file dicom_meta_lite-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dicom_meta_lite-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80931c698d1afc0f3af9a95fc7582d3dcb320e19c6e2b25ff075cfafcc014c45
|
|
| MD5 |
7f8923d66ea105ff709b97cf239b0e88
|
|
| BLAKE2b-256 |
b974982485959482164744d952e012ca8176d3ad1be994f1c0948ed936cd58df
|