def test_luna3d_2(): image_dir = utils.get_dir_path('analysis', pathfinder.METADATA_PATH) image_dir = image_dir + '/test_luna/' utils.auto_make_dir(image_dir) id2zyxd = utils_lung.read_luna_annotations(pathfinder.LUNA_LABELS_PATH) luna_data_paths = [ '/mnt/sda3/data/kaggle-lung/luna_test_patient/1.3.6.1.4.1.14519.5.2.1.6279.6001.943403138251347598519939390311.mhd'] for k, p in enumerate(luna_data_paths): id = os.path.basename(p).replace('.mhd', '') print id img, origin, pixel_spacing = utils_lung.read_mhd(p) lung_mask = lung_segmentation.segment_HU_scan(img) annotations = id2zyxd[id] x, annotations_tf, tf_matrix, lung_mask_out = data_transforms.transform_scan3d(data=img, pixel_spacing=pixel_spacing, p_transform=p_transform, luna_annotations=annotations, p_transform_augment=None, luna_origin=origin, lung_mask=lung_mask, world_coord_system=True) y = data_transforms.make_3d_mask_from_annotations(img_shape=x.shape, annotations=annotations_tf, shape='sphere') for zyxd in annotations_tf: plot_slice_3d_3(x, lung_mask_out, y, 0, id, idx=zyxd) plot_slice_3d_3(x, lung_mask_out, y, 1, id, idx=zyxd) plot_slice_3d_3(x, lung_mask_out, y, 2, id, idx=zyxd)
def data_prep_function(data, pixel_spacing, p_transform=p_transform): # TODO: MAKE SURE THAT DATA IS PREPROCESSED THE SAME WAY lung_mask = lung_segmentation.segment_HU_scan(data) x, tf_matrix, lung_mask_out = data_transforms.transform_scan3d(data=data, pixel_spacing=pixel_spacing, p_transform=p_transform, lung_mask=lung_mask, p_transform_augment=None) x = data_transforms.pixelnormHU(x) return x, lung_mask_out, tf_matrix
def data_prep_function(data, pixel_spacing, p_transform=p_transform): # TODO: MAKE SURE THAT DATA IS PREPROCESSED THE SAME WAY lung_mask = lung_segmentation.segment_HU_scan(data) x, tf_matrix, lung_mask_out = data_transforms.transform_scan3d( data=data, pixel_spacing=pixel_spacing, p_transform=p_transform, lung_mask=lung_mask, p_transform_augment=None) x = data_transforms.pixelnormHU(x) return x, lung_mask_out, tf_matrix
def data_prep_function(data, luna_annotations, pixel_spacing, luna_origin, p_transform=p_transform, p_transform_augment=None): # make sure the data is processed the same way lung_mask = lung_segmentation.segment_HU_scan(data) x, annotations_tf, tf_matrix, lung_mask_out = data_transforms.transform_scan3d(data=data, pixel_spacing=pixel_spacing, p_transform=p_transform, luna_annotations=luna_annotations, p_transform_augment=None, luna_origin=luna_origin, lung_mask=lung_mask) x = data_transforms.pixelnormHU(x) y = data_transforms.make_3d_mask_from_annotations(img_shape=x.shape, annotations=annotations_tf, shape='sphere') return x, y, lung_mask_out, annotations_tf, tf_matrix