Skip to main content

spydcmtk

Simple PYthon DiCoM Tool Kit

Dicom organisational, querying and conversion toolkit

spydcmtk is a pure Python package built on top of pydicom.

This package extends pydicom with a class structure based upon the Patient-Study-Series-Image hierarchy. In addition, it provides a number of built in routines for common actions when working with dicom files, such as human readable renaming, anonymisation, searching and summarising.

Installation

Using pip:

pip install spydcmtk

DICOM-SEG writing (vti_to_dcm_seg / array_to_DcmSeg) needs the optional highdicom extra:

pip install 'spydcmtk[highdicom]'

Quick start

If you installed via pip then spydcmtk console script will be exposed in your python environment.

Access via:

spydcmtk -h

to see the commandline usage available to you.

If you would like to incorporate spydcmtk into your python project, then import as:

import spydcmtk

listOfStudies = spydcmtk.dcmTK.ListOfDicomStudies.setFromDirectory(MY_DICOM_DIRECTORY)
# Example filtering
dcmStudy = listOfStudies.getStudyByDate('20230429') # Dates in dicom standard string format: YYYYMMDD
dcmSeries = dcmStudy.getSeriesBySeriesNumber(1)
# Example writing new dicom files with anonymisation
dcmStudy.writeToOrganisedFileStructure(tmpDir, anonName='Not A Name')

Configuration

spydcmtk uses a spydcmtk.conf file for configuration.

By default spydcmtk.conf files are search for in the following locations:

  1. source_code_directory/spydcmtk.conf (file with default settings)
  2. $HOME/spydcmtk.conf
  3. $HOME/.spydcmtk.conf
  4. $HOME/.config/spydcmtk.conf
  5. Full file path defined at environment variable: "SPYDCMTK_CONF"
  6. Full path passed as commandline argument to spydcmtk

Files are read in the above order with each subsequent variable present over writing any previously defined. For information on files found and variables used run:

spydcmtk -INFO

Documentation

Clear documentation of basic features can be seen by running the "spydcmtk -h" command as referenced above. For detailed documentation please see spydcmtk-documentation

Converting PDF or images to DICOM

PDF (requires DCMTK pdf2dcm on PATH):

spydcmtk -pdf2dcm /path/to/report.pdf -i /path/to/reference_dicom -o /path/to/output_dir
import spydcmtk
spydcmtk.dcmTK.pdf2dcm("report.pdf", "reference.dcm", "output_dir")

Image stack (one file or a folder of .jpg/.png/.tif slices):

spydcmtk -image2dcm /path/to/images/ -i /path/to/reference_dicom -o /path/to/output_dir
import spydcmtk
spydcmtk.dcmTK.writeImageStackToDicom(sorted_image_paths, patientMeta, "reference.dcm", "output_dir")

See the DICOM conversion docs for PatientMeta, optional tag overrides, and CLI details.

Release files for spydcmtk 1.2.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spydcmtk 1.2.28
File Size Uploaded
spydcmtk-1.2.28.tar.gz 1.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for spydcmtk 1.2.28
File Interpreter ABI Platform
spydcmtk-1.2.28-py3-none-any.whl Python 3 none any Details

Total release size: 3.1 MB

Release files / spydcmtk-1.2.28.tar.gz

Download URL spydcmtk-1.2.28.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
119f8eb17b5ef5b87ee46814861254d941a9b15e7ea1d8b78a8e0c2081e6fe8d
BLAKE2b-256 checksum
How to use checksums
00bc502f6a6baef16768a2c94cf5d4edd49ff251b138034a22990407c092510b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / spydcmtk-1.2.28-py3-none-any.whl

Download URL spydcmtk-1.2.28-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
566344b2bef2eb9815a7226bfced2e9bcff7e2dd5f480d77884ff873449c6de7
BLAKE2b-256 checksum
How to use checksums
f0aa927cd30760f4ca1968b6d7d5c37c493dfa68a8e335cd70ef22f3b4e0e01c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page