def process_dicom_file_list(dicom_file_list, parent_sorting_field='PatientName', verbose=False):
    '\n    Organise the DICOM files by the series UID\n    '
    dicom_series_dict_parent = {}
    for (i, dicom_file) in enumerate(sorted(dicom_file_list)):
        if (verbose is True):
            logger.debug(f'  Sorting file {i}')
        dicom_file = dicom_file.as_posix()
        if ('dicomdir' in dicom_file.lower()):
            logger.warning('DICOMDIR is not supported in this tool, images are read directly. Skipping.')
            continue
        dicom_object = pydicom.read_file(dicom_file, force=True)
        parent_sorting_field_data = dicom_object[parent_sorting_field].value
        if (parent_sorting_field_data not in dicom_series_dict_parent.keys()):
            dicom_series_dict_parent[parent_sorting_field_data] = {}
        series_uid = dicom_object.SeriesInstanceUID
        if (series_uid not in dicom_series_dict_parent[parent_sorting_field_data].keys()):
            dicom_series_dict_parent[parent_sorting_field_data][series_uid] = [dicom_file]
        else:
            dicom_series_dict_parent[parent_sorting_field_data][series_uid].append(dicom_file)
    return dicom_series_dict_parent
Organise the DICOM files by the series UID
def process_dicom_file_list(dicom_file_list, parent_sorting_field='PatientName', verbose=False):
    '\n    \n    '
    dicom_series_dict_parent = {}
    for (i, dicom_file) in enumerate(sorted(dicom_file_list)):
        if (verbose is True):
            logger.debug(f'  Sorting file {i}')
        dicom_file = dicom_file.as_posix()
        if ('dicomdir' in dicom_file.lower()):
            logger.warning('DICOMDIR is not supported in this tool, images are read directly. Skipping.')
            continue
        dicom_object = pydicom.read_file(dicom_file, force=True)
        parent_sorting_field_data = dicom_object[parent_sorting_field].value
        if (parent_sorting_field_data not in dicom_series_dict_parent.keys()):
            dicom_series_dict_parent[parent_sorting_field_data] = {}
        series_uid = dicom_object.SeriesInstanceUID
        if (series_uid not in dicom_series_dict_parent[parent_sorting_field_data].keys()):
            dicom_series_dict_parent[parent_sorting_field_data][series_uid] = [dicom_file]
        else:
            dicom_series_dict_parent[parent_sorting_field_data][series_uid].append(dicom_file)
    return dicom_series_dict_parent