def get_ct_cropped(): paths_to_ct = relative_paths('./../../data_source/images/ct_nrrd', target_format='nrrd') paths_to_mask = relative_paths('./../../data_source/images/masks_nrrd', target_format='nrrd') ct_cropped = {} for num, path_to_ct in enumerate(paths_to_ct): ct_image, _ = nrrd.read(path_to_ct) mask_image, _ = nrrd.read(paths_to_mask[num]) ct_cropped[path_to_ct] = ct_image * mask_image return ct_cropped
def pet_cropped_img_value_stats(): path_to_fig = '../image_value_stats/cropped_pet_statistics.pdf' path_to_images = relative_paths('./../../data_source/images/pet_nrrd', target_format='nrrd') path_to_masks = relative_paths('./../../data_source/images/masks_nrrd', target_format='nrrd') plt.figure() plt.xlabel('Patient ID') plt.ylabel('PET Intensity Statistic') plot_img_value_stats(path_to_fig, path_to_images, path_to_masks, include_legend=True)
def plot_clustering_ct_max_stats(): path_kmeans_distort = '../image_value_stats/kmeans_elbow.pdf' path_to_images = relative_paths('./../../data_source/images/ct_nrrd', target_format='nrrd') images = load_images(path_to_images) patient_id = CONFIG.patient_axis_ticks() clustering_ct_max_stats(images, patient_id, path_kmeans_distort)
def cropping_illustration_imgs(): paths_to_ct = relative_paths('./../../data_source/images/ct_nrrd', target_format='nrrd') paths_to_pet = relative_paths('./../../data_source/images/pet_nrrd', target_format='nrrd') paths_to_mask = relative_paths('./../../data_source/images/masks_nrrd', target_format='nrrd') path_to_ct = './../../data_source/images/ct_nrrd/P222CT.nrrd' path_to_pet = './../../data_source/images/pet_nrrd/P222PET.nrrd' path_to_mask = './../../data_source/images/masks_nrrd/P222mask.nrrd' path_to_ct_img = '../illustrations/ct_img.pdf' path_to_pet_img = '../illustrations/pet_img.pdf' path_to_ct_cropped_img = '../illustrations/ct_cropped_img.pdf' path_to_pet_cropped_img = '../illustrations/pet_cropped_img.pdf' show = False ct_image, _ = nrrd.read(path_to_ct) pet_image, _ = nrrd.read(path_to_pet) mask, _ = nrrd.read(path_to_mask) n = 30 ct_image = ct_image[n, :, :] pet_image = pet_image[n, :, :] mask = mask[n, :, :] cropped_ct = ct_image * mask cropped_pet = pet_image * mask plt.figure() plt.axis('off') plt.imshow(ct_image, vmin=np.min(ct_image), vmax=np.max(ct_image)) plt.savefig( path_to_ct_img, bbox_inches='tight', transparent=True, dpi=DPI ) if show: plt.show() plt.figure() plt.axis('off') plt.imshow(cropped_ct, vmin=np.min(ct_image), vmax=np.max(ct_image)) plt.savefig( path_to_ct_cropped_img, bbox_inches='tight', transparent=True, dpi=DPI ) if show: plt.show() plt.figure() plt.axis('off') plt.imshow(pet_image, vmin=np.min(pet_image), vmax=np.max(pet_image)) plt.savefig( path_to_pet_img, bbox_inches='tight', transparent=True, dpi=DPI ) if show: plt.show() plt.figure() plt.axis('off') plt.imshow(cropped_pet, vmin=np.min(pet_image), vmax=np.max(pet_image)) plt.savefig( path_to_pet_cropped_img, bbox_inches='tight', transparent=True, dpi=DPI ) if show: plt.show()