Command Line Tools#

dicom_crawler#

DICOM DIRECTORY CRAWLER

This tool makes it easier to bulk-convert DICOM files into other formats (default NifTI). There are quite a lot of options, but most do not need to be changed.

You need to provide the input directory (-i), from which the crawler will recursively search through.

You might also like to change the naming format (using –image_format and –structure_format). The default is quite long, better suited for datasets with lots of imaging for a single patient.

Some examples:

[simple] –image_format {parent_sorting_data}

[compact] –image_format {parent_sorting_data}_{study_uid_index}

You can separate series using different values (–sort_by ). This would typically be PatientName, or PatientID, although any DICOM header tag is allowed.

I hope you find this tool useful!

If you have any feedback, let us know on github.com/pyplati/platipy

dicom_crawler [OPTIONS]

Options

-i, --input_dir <input_dir>#

Required Input DICOM directory. This should be at the same level as the parent field (default=PatientName).

-o, --output_dir <output_dir>#

Output directory. A folder structure will be created at this location.

Default:

./

-b, --sort_by <sort_by>#

DICOM tag to sort at the highest level.

Default:

PatientName

--image_format <image_format>#

Format for output images. There are three special options that can be used: parent_sorting_data (same as sort_by option), study_uid_index (a counter for distinct DICOM studies), image_desc (info from DICOM header, more nicely formatted). Additionally, any DICOM header tag can be used (e.g. Modality, SeriesNumber, AcquisitionData). Any DICOM header tag that doesn’t exist will return a 0.

Default:

{parent_sorting_data}_{study_uid_index}_{Modality}_{image_desc}_{SeriesNumber}

--structure_format <structure_format>#

Format for output structures. Any of the options for images can be used, as well as: structure_name

Default:

{parent_sorting_data}_{study_uid_index}_{Modality}_{structure_name}

--dose_format <dose_format>#

Format for output radiotherapy dose distributions.

Default:

{parent_sorting_data}_{study_uid_index}_{DoseSummationType}

--overwrite#

Overwrite files if they exist.

Default:

False

--file_suffix <file_suffix>#

Output file suffix. Defines the file type.

Default:

.nii.gz

-s, --short_description#

Use less verbose descriptions for DICOM images.

Default:

False

-v, --verbose#

Print more information while running.

Default:

False

segmentation#

Run an auto-segmentation on an input image. Choose which algorithm to run and pass the path to the Nitfti input image OR a directory containing a DICOM series.

Optionally, pass in a configuration file for the segmentation algorithm. Output the default configuration for an algorithm using the –default flag.

segmentation [OPTIONS] {cardiac|bronchus} [INPUT_PATH]

Options

-c, --config <config>#

Path to JSON file containing algorithm settings

-d, --default#

Print the default configuration for the selected algorithm

-o, --output <output>#

Path to directory for output

Arguments

ALGORITHM#

Required argument

INPUT_PATH#

Optional argument

nifti_to_rtstruct#

Convert Nifti masks to Dicom RTStruct

nifti_to_rtstruct [OPTIONS]

Options

-d, --dcm_file <dcm_file>#

Required Reference DICOM file from which header tags will be copied

-m, --mask <mask>#

Required Mask pairs with name,filename

-o, --out_rt_filename <out_rt_filename>#

Required Name of RT struct output

nifti_to_series#

Convert a Nifti image to a Dicom image series

nifti_to_series [OPTIONS]

Options

-d, --dcm <dcm>#

Required Reference DICOM folder containing series from which header tags will be copied

-i, --image <image>#

Required Nifti Image file to convert to Dicom series

-t, --tag <tag>#

Override Dicom Tags by providing key:value pairs

-o, --output_directory <output_directory>#

Directory in which Dicom series files will be generated

Default:

.

rtstruct_to_nifti#

Convert a DICOM RTSTRUCT file to Nifti format.

rtstruct_to_nifti [OPTIONS]

Options

-i, --dcm_img <dcm_img>#

Required Directory containing the image series linked to the contour to convert

-r, --dcm_rt_file <dcm_rt_file>#

Required Dicom RTStruct file containing the contours to convert

-p, --prefix <prefix>#

Prefix for output files (e.g. Case_01_

-od, --output_dir <output_dir>#

Directory in which to place converted files

Default:

.

-oi, --output_img <output_img>#

Output name of converted image series

--spacing <spacing>#

DICOM image spacing override with format x,y,z (0 indicates to leave as is, e.g. 0,0,3)