def analyse_data(input_dir):
shapes = []
relative_volumes = []
for folder in get_sub_folders(input_dir):
print(folder)
for sub_folder in get_sub_folders(os.path.join(input_dir, folder)):
image_type = get_image_type_from_folder_name(sub_folder)
# do not save the raw data (too heavy)
if image_type != '.OT':
continue
path = os.path.join(input_dir, folder, sub_folder)
filename = next(filename for filename in os.listdir(path) if get_extension(filename) == '.nii')
path = os.path.join(path, filename)
im = nib.load(path)
image = im.get_data()
shape = image.shape
shapes.append(shape)
relative_volumes.append(100 * np.sum(image) / np.cumprod(shape)[-1])
return shapes, relative_volumes
# train
评论列表
文章目录