nbiatoolkit.dicomsort.helper_functions
Module Contents
Functions
|
Parse the target pattern to create a format string with named placeholders |
|
Sanitize the file name by replacing potentially dangerous characters. |
|
Truncate the UID to the last n characters (includes periods & underscores). |
- nbiatoolkit.dicomsort.helper_functions.parseDICOMKeysFromFormat(targetPattern: str) Tuple[str, List[str]][source]
Parse the target pattern to create a format string with named placeholders and extract a list of DICOM keys.
The target pattern is a string with placeholders matching ‘%<DICOMKey>’. This method converts placeholders into a format string with named placeholders and creates a list of DICOM keys contained within the placeholders.
- Returns:
A tuple containing the format string and a list of DICOM keys.
- Return type:
Tuple[str, List[str]]
- Example usage:
fmt, keys = parseDICOMKeysFromFormat(targetPattern) print(fmt) # “%(PatientID)s-%(StudyDate)s” print(keys) # [‘PatientID’, ‘StudyDate’]