A tool to convert DICOM cine movies to GIF format (and others).
Project description
dicom2gif
A Python tool to convert DICOMs of MRI cine series to GIF/APNG/TIFF format.
Features
- Convert enhanced DICOM files (multi-frame) to GIF, APNG, or TIFF
- Convert legacy DICOM series to GIF, APNG, or TIFF
- Automatic detection of frame duration from DICOM metadata
- Support for windowing (brightness/contrast) adjustment
- Batch processing of entire directories
Installation
pip install dicom2gif
Usage
Command Line
After installation, you can use the tool in three ways:
# As an installed script
dicom2gif path/to/dicom/file.dcm
# Using python -m
python -m dicom2gif path/to/dicom/file.dcm
# With custom output and duration
dicom2gif input.dcm -o output.gif -d 100
Command Line Options
dcm_path: Input DICOM file or directory-p, --pattern: Pattern to select DICOM files whendcm_pathis a directory (defaults to *.dcm)-o, --out_file: Output file path (defaults to input name with .gif extension)-f, --format: Output file format, can be gif, apng, or tiff/tif (ignored if--out_fileis given)-d, --duration: Duration per frame in milliseconds (optional, auto-detected from DICOM if available)-w, --windowing: Can be two comma-separated integers for window center and width, 'auto' for automatic windowing to full dynamic range, or None to use windowing parameters from DICOM metadata (defaults to None)
Process a Directory
When given a directory, the tool will recursively:
- Create a separate GIF for each enhanced DICOM file
- Create a separate GIF for each series of legacy DICOM files as determined by their Series Instance UID
dicom2gif path/to/dicom/directory
Python API
from dicom2gif import dicom2gif, read_dcm, read_dir, write_gif
# Single DICOM file
cine = read_dcm("path/to/file.dcm")
write_gif(cine, "output.gif", duration=50)
# Directory of DICOM files
cines = read_dir("path/to/directory")
for path, cine in cines:
out_file = path.with_suffix(".apng")
write_gif(cine, out_file, windowing="auto")
# Or directly
dicom2gif("path/to/file.dcm", out_file="output.gif", duration=50)
dicom2gif("path/to/directory", format="apng", windowing="auto")
Requirements
- Python ≥ 3.10
- numpy
- Pillow ≥ 7.1.2
- pydicom
Project details
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 dicom2gif-0.0.1.tar.gz.
File metadata
- Download URL: dicom2gif-0.0.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
384a9fffbf6bcdcdb7ff27010333a3e654163ab742dc3532d0a9e2e27d930ce4
|
|
| MD5 |
6eda78a53204ead8ce3ca3c6fa54069a
|
|
| BLAKE2b-256 |
0425573d357975838bc2cbcff595f8ebb0a7c757ed3dd208ee1c8c37c8854ddd
|
Provenance
The following attestation bundles were made for dicom2gif-0.0.1.tar.gz:
Publisher:
publish-to-pypi.yml on marcvornehm/dicom2gif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicom2gif-0.0.1.tar.gz -
Subject digest:
384a9fffbf6bcdcdb7ff27010333a3e654163ab742dc3532d0a9e2e27d930ce4 - Sigstore transparency entry: 763990321
- Sigstore integration time:
-
Permalink:
marcvornehm/dicom2gif@1507328bcf7a893aa2b92acd9a81c83dcf241333 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/marcvornehm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@1507328bcf7a893aa2b92acd9a81c83dcf241333 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dicom2gif-0.0.1-py3-none-any.whl.
File metadata
- Download URL: dicom2gif-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd56f434fda9325715b67648c808222902e6b6a7f178b0a1be10d2773f1ba829
|
|
| MD5 |
bf07210e7072f236474f71c841ecbb78
|
|
| BLAKE2b-256 |
17d84ddbc32a79960bc9c4d8305e4d68c2670410777bb4322f570e8f8b453ff8
|
Provenance
The following attestation bundles were made for dicom2gif-0.0.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on marcvornehm/dicom2gif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dicom2gif-0.0.1-py3-none-any.whl -
Subject digest:
dd56f434fda9325715b67648c808222902e6b6a7f178b0a1be10d2773f1ba829 - Sigstore transparency entry: 763990322
- Sigstore integration time:
-
Permalink:
marcvornehm/dicom2gif@1507328bcf7a893aa2b92acd9a81c83dcf241333 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/marcvornehm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@1507328bcf7a893aa2b92acd9a81c83dcf241333 -
Trigger Event:
release
-
Statement type: