read all images in folder python : I am trying to execute this code to read a set of images present in a folder with python language but I have a problem if you can help me

    patient_uids = train_annotations.seriesuid.unique()

    patients_processed_files = glob.glob(OUTPUT_FOLDER + '[0-9\.]*_X.npy')
    patients_processed = set()
    for filename in patients_processed_files:
        m = re.match(r'([0-9\.]*)_X.npy', os.path.basename(filename))
        patients_processed.add(m.group(1))

    print(len(patient_uids))

    graph = tf.Graph()
    with graph.as_default():
        img_chunk = tf.placeholder(tf.float32, shape=[CHUNK_SIZE, CHUNK_SIZE, CHUNK_SIZE], name='img_chunk')
        img_flipped_up_down = tf.image.flip_up_down(img_chunk)
        img_flipped_left_right = tf.image.flip_left_right(img_chunk)
        img_rot_90 = tf.image.rot90(img_chunk)
        img_trans = tf.image.transpose_image(img_chunk)

    weird_chunks = {}

    for patient_uid in patient_uids:
        if patient_uid in patients_processed:
            print('Skipping already processed patient {}'.format(patient_uid))
            continue
        print('Processing patient {}'.format(patient_uid))
    
        patient_annotations = train_annotations[train_annotations.seriesuid == patient_uid]
        patient_scans_path = glob.glob(DATA_PATH + 'subset?/{}.mhd'.format(patient_uid))[0]
        img, origin, spacing = load_itk(patient_scans_path)


but the execution of my code returns me:

IndexError: list index out of range

