def write_masks(patient_dir, contour_path, image_path, index, img_format='nii'): for folder, path in contour_path.items(): print(contour_path[folder]) if contour_path[folder] is not None: ReadMasks.create_image_mask_files(folder, contour_path[folder][0], image_path[folder], index, img_format) else: print("No Structure Set found") print("Done Writing masks")
""" Script that loads PETCT and Planning CT and writes to .nii such that registration can be performed. """ import os import pydicom import shutil from imageReg import ImageReg from readMasks import ReadMasks ImageReg = ImageReg() ReadMasks = ReadMasks() patient_dir = "E:\\Mphys\\Patients\\" #pet_outdir = "E:\\Mphys\\NiftyPatients\\PET\\" #planning_outdir = "E:\\Mphys\\NiftyPatients\\PlanningCT\\" def load_files(patient_dir): """ Function that takes the patient directory and navigates through the tree to find relevant files File paths are returned as dict with key = Patient filename and value = path to scan folders """ pet_paths = {} pct_paths = {} struct_path = {} for f in os.listdir(patient_dir): try: