Skip to main content

dicomsort

A project to provide custom sorting and renaming of dicom files

Description

Given DICOM files in a random folder structure, this program copies all into a user-defined folder hierarchy, creating folders as necessary and changing DICOM file names to be more meaningful.

The user can define the target folder structure and file naming by using a string consisting of concatenated tag names (like 'PatientName'), underscores and slashes. The last part of the string (as separated by slashes) denotes the naming convention for the file parts.

An Example: a target string of 'Modality/PatientName_PatientID' means that all DICOM images are arranged in a base folder and named by PatientName_PatientID, followed by an underscore and a unique number for every file that falls into the same category (and is not the same..?)

dicomsort returns with a count for both DICOM files organized and non-DICOM (or invalid DICOM) files skipped. It aborts with an error if it is to overwrite any existing file.

Installation

pip install thedicomsort
% dicomsort --help
dicomsort [options...] sourceDir targetDir/<patterns>

 where [options...] can be:
    [-z,--compressTargets] - create a .zip file in the target directory
    [-d,--deleteSource] - remove source files/directories after sorting
    [-f,--forceDelete] - remove source without confirmation
    [-k,--keepGoing] - report but ignore duplicate target files
    [-v,--verbose] - print diagnostics while processing
    [-s,--symlink] - create a symlink to dicom files in sourceDir instead of copying them
    [-t,--test] - run the built in self test (requires internet)
    [-u,--unsafe] - do not replace unsafe characters with '_' in the path
    [--help] - print this message

 where sourceDir is directory to be scanned or "" (null string) to read file list from stdin

 where targetDir/<patterns...> is a string defining the output file and directory
 names based on the dicom tags in the file.

If patterns are not specified, the following default is used:

  %PatientName-%Modality%StudyID-%StudyDescription-%StudyDate/%SeriesNumber_%SeriesDescription-%InstanceNumber.dcm

Example 1:

  dicomsort data sorted/%PatientName/%StudyDate/%SeriesDescription-%InstanceNumber.dcm

  could create a folder structure like:

  sorted/JohnDoe/2013-40-18/FLAIR-2.dcm

Example 2:

  find DicomSourceDir/ | grep "IMA$" | dicomsort -s "" DicomTargetDir

  would scan DicomSourceDir for file path names ending in IMA and create an
  output directory DicomTargetDir. The folder structure will be created using
  the default pattern with symbolic links to the source dicom data files.

Metadata

Release files for thedicomsort 1.0.1

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

Source distribution (sdist)

Source distribution for thedicomsort 1.0.1
File Size Uploaded
thedicomsort-1.0.1.tar.gz 7.4 kB Details

Built distribution (wheel)

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

Total release size: 15.6 kB

Release files / thedicomsort-1.0.1.tar.gz

Download URL thedicomsort-1.0.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ac590d85cff5b4a24a22651b43a021807b505dd43ab60288b358769db470f5d6
BLAKE2b-256 checksum
How to use checksums
be4a68323885dd865ef2a03674cf54f6dd721e2ba2d6d5c5f81f65853bf9fdb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.10.9 Darwin/22.2.0

Release files / thedicomsort-1.0.1-py3-none-any.whl

Download URL thedicomsort-1.0.1-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
798abd616ee9e88bd58f8fcae58952842763499c5a4a88242b8225925f92b027
BLAKE2b-256 checksum
How to use checksums
b878a6769a23476bb8e522e517927cabfa79951b4980475639c71a65ed979fd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.10.9 Darwin/22.2.0

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

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