Here- is the directory(+= folder contents)
D:/Data/…/Train/
PX1_0000- T2W.nii.gz + seg.nii.gz
PX1_0001- T2W.nii.gz+ seg.nii.gz
.
.
… PX1_0200- T2W.nii.gz+ seg.nii
Same follows for 200 patients.
def get_list_of_files(base_dir):
list_of_lists = []
for phase_type in [‘train’]:
current_directory = join(base_dir, phase_type)
patients = subfolders(current_directory, join=True)
for p in patients:
patient_directory = join(current_directory, p)
t2_file = join(patient_directory, p + “T2W.nii.gz”)
seg_file = join(patient_directory, p + “seg.nii.gz”)
this_case = [t2_file, seg_file]
assert all((isfile(i) for i in this_case)), "some file is missing for patient %s; make sure the following "
“files are there: %s” % (p, str(this_case))
list_of_lists.append(this_case)
print(“Found %d patients” % len(list_of_lists))
return list_of_lists
CAN YOU PLEASE HELP ME IN GETTING?