import pydicom as dicomio
import numpy as np
import os

dcm_root = '/data/job_678/job_data_preprocess/output/tmp'
uids = os.listdir(dcm_root)
patient_infos = {}
for uid in uids:
    dcms = os.listdir(os.path.join(dcm_root, uid))
    dcm_meta = dicomio.read_file(os.path.join(dcm_root, uid, dcms[0]), force=True)
    patientid = dcm_meta.get('PatientID', '')
    if patientid:
        if patientid not in patient_infos.keys():
            patient_infos[patientid] = []
            patient_infos[patientid].append(os.path.join(dcm_root, uid))
        else:
            patient_infos[patientid].append(os.path.join(dcm_root, uid))

