dicomsort - Man Page

Synopsis

dicomsort [-h] [-i PREFIX] [-j PREFIX] [-f SCHEME] [-n SCHEME] [-p PATTERN] [--force] [-d] sourcefolder

Description

Sorts and/or renames DICOM files into local subfolders, e.g. with 3-digit SeriesNumber-SeriesDescription folder names (i.e. following the same listing as on the scanner console)

Supports flat DICOM as well as multi-subject/session DICOMDIR file structures.

sourcefolder

The root folder containing the [sub/][ses/] dicomfiles or the DICOMDIR file

Options

-i PREFIX, --subprefix PREFIX

Provide a prefix string to recursively sort sourcefolder/subject subfolders (e.g. "sub-" or "S_")

-j PREFIX, --sesprefix PREFIX

Provide a prefix string to recursively sort sourcefolder/subject/session subfolders (e.g. "ses-" or "T_")

-f SCHEME, --folderscheme SCHEME

Naming scheme for the sorted DICOM Series subfolders. Follows the Python string formatting syntax with DICOM field names in curly bracers with an optional number of digits for numeric fields. Sorting in subfolders is skipped when an empty folderscheme is given (but note that renaming the filenames can still be performed)

-n SCHEME, --namescheme SCHEME

Optional naming scheme that can be provided to rename the DICOM files. Follows the Python string formatting syntax with DICOM field names in curly bracers with an optional number of digits for numeric fields. Use e.g. "{PatientName}_{SeriesNumber:03d}_{SeriesDescription}_{AcquisitionNumber:05d}_{InstanceNumber:05d}.dcm" or "{InstanceNumber:05d}_{SOPInstanceUID}.IMA" for default names

-p PATTERN, --pattern PATTERN

The regular expression pattern used in re.match(pattern, dicomfile) to select the DICOM files

--force

Sort the DICOM data even the DICOM fields of the folder/name scheme are not in the data

-d,  --dryrun

Only print the dicomsort commands without actually doing anything

Comments

examples:
 dicomsort raw/sub-011/ses-mri01
 dicomsort raw --subprefix sub- --sesprefix ses-
 dicomsort myproject/raw/DICOMDIR --subprefix pat^ --sesprefix
 dicomsort sub-011/ses-mri01/DICOMDIR -n '{AcquisitionNumber:05d}_{InstanceNumber:05d}.dcm'

Author

Marcel Zwiers <m.zwiers@donders.ru.nl>

Info

2025-11-06 bidscoin 4.6.2 Generated Python Manual