dicomselect: DICOM database and conversion software
dicomselect is a Python tool that simplifies the process of creating SQLite databases from directories containing .dcm
files. Once the database is created, you can easily perform SQL-like queries on the data directly within Python. Additionally, dicomselect allows you to convert query results into various file formats supported by SimpleITK, providing flexibility in working with your DICOM data.
Installation
Python 3.10 or higher. You can install this project using pip
. If you haven't already, it's recommended to create a virtual environment to isolate project dependencies.
pip install dicomselect
Documentation
Read the documentation.
Example
Clone this repo, install dicomselect, then run this example in the repo.
from dicomselect import Database
from pathlib import Path
db_path = Path('tests/output/example.db')
db_path.parent.mkdir(exist_ok=True)
db = Database(db_path)
db.create('tests/input/ProstateX', max_workers=4)
with db as query:
query_0000 = query.where('patient_id', '=', 'ProstateX-0000'
).where('image_direction', '=', 'transverse')
print(query_0000)
plan = db.plan('{patient_id}/prostateX_{series_description}_{instance_creation_time}', query_0000)
plan.target_dir = 'tests/output/example'
plan.extension = '.mha'
plan.max_workers = 4
print(plan.to_string())
plan.execute()
Check out the results in tests/output/example
.