DICOM Files#
Provides a various set of tools for DICOM header manipulation.
The anonymise subcommand is a legacy interface. It prints a notice of its
limitations on standard error when it runs. Read its limitations in
DICOM de-identification before sharing output.
usage: pymedphys dicom [-h]
{anonymise,merge-contours,adjust-machine-name,adjust-RED,adjust-RED-by-structure-name,listen,send} ...
Positional Arguments#
- dicom
Possible choices: anonymise, merge-contours, adjust-machine-name, adjust-RED, adjust-RED-by-structure-name, listen, send
Sub-commands#
anonymise#
Replace the values of a fixed list of identifying attributes in DICOM files. UIDs and most RT attributes are kept.
pymedphys dicom anonymise [-h] [-o OUTPUT_PATH] [-d] [-f] [-c]
[-k [KEYWORD ...]] [-p] [-u | -i]
input_path
Positional Arguments#
- input_path
Input file or directory path. If a directory is supplied, files matching
*.dcmwithin the directory and its subdirectories are processed. Matching is case-insensitive on Windows. The output keeps the source folder structure.
Named Arguments#
- -o, --output_path
Output file or directory path.
- -d, --delete_original_files
Use this flag to delete the original, non-anonymised files in the processed directory. Each original file will only be deleted if anonymisation completed successfully for that file.
Default:
False- -f, --preserve_filenames
Use this flag to keep the original file names, with ‘_Anonymised.dcm’ appended, instead of naming each file after its modality and original SOP Instance UID. Either way, the name can identify the source: original file names may contain patient details, and the default names contain the original SOP Instance UID.
Default:
False- -c, --clear_values
Use this flag to empty the values of the listed identifying attributes, instead of replacing them with dummy values.
Default:
False- -k, --keywords_to_leave_unchanged
A space-separated list of DICOM keywords (e.g. ‘PatientName’) to exclude from anonymisation and error checking.
- -p, --keep_private_tags
Use this flag to preserve private tags in the anonymised DICOM files.
Default:
False- -u, --delete_unknown_tags
Use this flag to delete any unrecognised tags from the anonymised DICOM files.
Default:
False- -i, --ignore_unknown_tags
Use this flag to ignore any unrecognised tags in the anonymised DICOM files.
Default:
False
merge-contours#
Merge overlapping contours within a DICOM structure file
pymedphys dicom merge-contours [-h] [--structures STRUCTURES [STRUCTURES ...]]
input_file output_file
Positional Arguments#
- input_file
- output_file
Named Arguments#
- --structures
The structures for which to run the merge on. If not provided, then all structures will be processed.
adjust-machine-name#
Change the machine name in an RT plan DICOM file
pymedphys dicom adjust-machine-name [-h]
input_file output_file new_machine_name
Positional Arguments#
- input_file
- output_file
- new_machine_name
adjust-RED#
Adjust the RED of structures within an RT structure DICOM file
pymedphys dicom adjust-RED [-h] [-i]
input_file output_file
adjustment_map [adjustment_map ...]
Positional Arguments#
- input_file
- output_file
- adjustment_map
An alternating list of structure name and then its associated RED. For example,
pymedphys dicom adjust-REDinput.dcm output.dcmstruct_name 1.5 another_struct_name 0.2
Named Arguments#
- -i, --ignore_missing_structure
Use this flag to no longer raise an error when a defined structure name doesn’t exist within the input DICOM file.
Default:
False
adjust-RED-by-structure-name#
Use structure naming conventions to automatically adjust the relative electron density of a structure within a DICOM RT Structure set. For example, naming a structure a_structure_name RED=1.15 will cause that structure to have an override of 1.15 applied.
pymedphys dicom adjust-RED-by-structure-name [-h] input_file output_file
Positional Arguments#
- input_file
input_file
- output_file
output_file
listen#
Start a DICOM listener on the specified port
pymedphys dicom listen [-h] [--host HOST] [-d STORAGE_DIRECTORY] [-a AETITLE]
port
Positional Arguments#
- port
The port on which to listen; 0 assigns a free port reported at startup
Named Arguments#
- --host
The host/IP to bind to
Default:
'0.0.0.0'- -d, --storage_directory
The folder to store received objects in, by default the current folder. Each object is stored in a folder named after its Patient ID, then in folders named after its Study and Series Instance UIDs, in a file named after its SOP Instance UID. In these names, the characters % / : * ? “ < > | and control characters are written as % and their two-digit hexadecimal code, and the names . and .. as %2E and %2E%2E.
Default:
'.'- -a, --aetitle
The AE Title of this listen service
Default:
'PYMEDPHYS'
send#
Send DICOM objects to a DICOM endpoint
pymedphys dicom send [-h] [-a AETITLE] host port [dcmfiles ...]
Positional Arguments#
- host
The host name/IP of the DICOM listener
- port
The port of the DICOM listener
- dcmfiles
Path to DICOM objects to send
Named Arguments#
- -a, --aetitle
The Called AE Title
Default:
'PYMEDPHYS'