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 count_proportion(): id2zyxd = utils_lung.read_luna_annotations(pathfinder.LUNA_LABELS_PATH) luna_data_paths = utils_lung.get_patient_data_paths( pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] n_white = 0 n_black = 0 for k, p in enumerate(luna_data_paths): img, origin, pixel_spacing = utils_lung.read_mhd(p) img = data_transforms.hu2normHU(img) id = os.path.basename(p).replace('.mhd', '') print id annotations = id2zyxd[id] img_out, annotations_out = data_transforms.transform_scan3d( img, pixel_spacing=pixel_spacing, p_transform=config().p_transform, p_transform_augment=None, # config().p_transform_augment, luna_annotations=annotations, luna_origin=origin) mask = data_transforms.make_3d_mask_from_annotations(img_out.shape, annotations_out, shape='sphere') n_white += np.sum(mask) n_black += mask.shape[0] * mask.shape[1] * mask.shape[2] - np.sum(mask) print 'white', n_white print 'black', n_black
def test_luna3d(): 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 = utils_lung.get_patient_data_paths(pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] # luna_data_paths = [ # pathfinder.LUNA_DATA_PATH + '/1.3.6.1.4.1.14519.5.2.1.6279.6001.287966244644280690737019247886.mhd'] 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): img, origin, pixel_spacing = utils_lung.read_mhd(p) id = os.path.basename(p).replace('.mhd', '') print id annotations = id2zyxd[id] img_out, mask, annotations_out = config().data_prep_function(img, pixel_spacing=pixel_spacing, luna_annotations=annotations, luna_origin=origin) mask[mask == 0.] = 0.1 print annotations_out for zyxd in annotations_out: plot_slice_3d_2(img_out, mask, 0, id, idx=zyxd) plot_slice_3d_2(img_out, mask, 1, id, idx=zyxd) plot_slice_3d_2(img_out, mask, 2, id, idx=zyxd)
def test_luna3d(): 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 = utils_lung.get_patient_data_paths(pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] # luna_data_paths = [ # pathfinder.LUNA_DATA_PATH + '/1.3.6.1.4.1.14519.5.2.1.6279.6001.287966244644280690737019247886.mhd'] 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): img, origin, pixel_spacing = utils_lung.read_mhd(p) id = os.path.basename(p).replace('.mhd', '') print(id) annotations = id2zyxd[id] img_out, mask, annotations_out = config().data_prep_function(img, pixel_spacing=pixel_spacing, luna_annotations=annotations, luna_origin=origin) mask[mask == 0.] = 0.1 print(annotations_out) for zyxd in annotations_out: plot_slice_3d_2(img_out, mask, 0, id, idx=zyxd) plot_slice_3d_2(img_out, mask, 1, id, idx=zyxd) plot_slice_3d_2(img_out, mask, 2, id, idx=zyxd)
def test_luna_patches_3d(): 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 = utils_lung.get_patient_data_paths(pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] # pid = '1.3.6.1.4.1.14519.5.2.1.6279.6001.138080888843357047811238713686' # luna_data_paths = [pathfinder.LUNA_DATA_PATH + '/%s.mhd' % pid] for k, p in enumerate(luna_data_paths): img, origin, pixel_spacing = utils_lung.read_mhd(p) # img = data_transforms.hu2normHU(img) id = os.path.basename(p).replace('.mhd', '') print id annotations = id2zyxd[id] print annotations for zyxd in annotations: img_out, mask = config().data_prep_function_train(img, pixel_spacing=pixel_spacing, p_transform=config().p_transform, p_transform_augment=config().p_transform_augment, patch_center=zyxd, luna_annotations=annotations, luna_origin=origin) try: plot_slice_3d_2(img_out, mask, 0, id) plot_slice_3d_2(img_out, mask, 1, id) plot_slice_3d_2(img_out, mask, 2, id) except: pass print '------------------------------------------'
def count_proportion(): id2zyxd = utils_lung.read_luna_annotations(pathfinder.LUNA_LABELS_PATH) luna_data_paths = utils_lung.get_patient_data_paths(pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] n_white = 0 n_black = 0 for k, p in enumerate(luna_data_paths): img, origin, pixel_spacing = utils_lung.read_mhd(p) img = data_transforms.hu2normHU(img) id = os.path.basename(p).replace('.mhd', '') print id annotations = id2zyxd[id] img_out, annotations_out = data_transforms.transform_scan3d(img, pixel_spacing=pixel_spacing, p_transform=config().p_transform, p_transform_augment=None, # config().p_transform_augment, luna_annotations=annotations, luna_origin=origin) mask = data_transforms.make_3d_mask_from_annotations(img_out.shape, annotations_out, shape='sphere') n_white += np.sum(mask) n_black += mask.shape[0] * mask.shape[1] * mask.shape[2] - np.sum(mask) print 'white', n_white print 'black', n_black
def test_luna3d(): 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.877026508860018521147620598474.mhd' ] candidates = utils.load_pkl( '/mnt/sda3/data/kaggle-lung/luna_test_patient/1.3.6.1.4.1.14519.5.2.1.6279.6001.877026508860018521147620598474.pkl' ) candidates = candidates[:4] print(candidates) print('--------------') print(id2zyxd[ '1.3.6.1.4.1.14519.5.2.1.6279.6001.877026508860018521147620598474']) 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_ira(img) print(np.min(lung_mask), np.max(lung_mask)) x, annotations_tf, tf_matrix, lung_mask_out = data_transforms.transform_scan3d( data=img, pixel_spacing=pixel_spacing, p_transform=p_transform, luna_annotations=candidates, p_transform_augment=None, luna_origin=origin, lung_mask=lung_mask, world_coord_system=False) print(np.min(lung_mask_out), np.max(lung_mask_out)) plot_slice_3d_2(x, lung_mask_out, 0, id) plot_slice_3d_2(x, lung_mask_out, 1, id) plot_slice_3d_2(x, lung_mask_out, 2, id) # for zyxd in annotations_tf: # plot_slice_3d_2(x, lung_mask_out, 0, id, idx=zyxd) # plot_slice_3d_2(x, lung_mask_out, 1, id, idx=zyxd) # plot_slice_3d_2(x, lung_mask_out, 2, id, idx=zyxd) for i in range(136, x.shape[1]): plot_slice_3d_2(x, lung_mask_out, 1, str(id) + str(i), idx=np.array([200, i, 200]))
def test_luna3d(): 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.877026508860018521147620598474.mhd'] candidates = utils.load_pkl( '/mnt/sda3/data/kaggle-lung/luna_test_patient/1.3.6.1.4.1.14519.5.2.1.6279.6001.877026508860018521147620598474.pkl') candidates = candidates[:4] print candidates print '--------------' print id2zyxd['1.3.6.1.4.1.14519.5.2.1.6279.6001.877026508860018521147620598474'] 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_ira(img) print np.min(lung_mask), np.max(lung_mask) x, annotations_tf, tf_matrix, lung_mask_out = data_transforms.transform_scan3d(data=img, pixel_spacing=pixel_spacing, p_transform=p_transform, luna_annotations=candidates, p_transform_augment=None, luna_origin=origin, lung_mask=lung_mask, world_coord_system=False) print np.min(lung_mask_out), np.max(lung_mask_out) plot_slice_3d_2(x, lung_mask_out, 0, id) plot_slice_3d_2(x, lung_mask_out, 1, id) plot_slice_3d_2(x, lung_mask_out, 2, id) # for zyxd in annotations_tf: # plot_slice_3d_2(x, lung_mask_out, 0, id, idx=zyxd) # plot_slice_3d_2(x, lung_mask_out, 1, id, idx=zyxd) # plot_slice_3d_2(x, lung_mask_out, 2, id, idx=zyxd) for i in xrange(136, x.shape[1]): plot_slice_3d_2(x, lung_mask_out, 1, str(id) + str(i), idx=np.array([200, i, 200]))
def test2(): image_dir = utils.get_dir_path('analysis', pathfinder.METADATA_PATH) luna_data_paths = utils_lung.get_patient_data_paths(pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] print len(luna_data_paths) pid2mm_shape = {} for k, p in enumerate(luna_data_paths): img, origin, spacing = utils_lung.read_mhd(p) id = os.path.basename(p).replace('.mhd', '') mm_shape = img.shape * spacing pid2mm_shape[id] = mm_shape print k, id, mm_shape if k % 50 == 0: print 'Saved' utils.save_pkl(pid2mm_shape, image_dir + '/pid2mm.pkl') utils.save_pkl(pid2mm_shape, image_dir + '/pid2mm.pkl')
def test1(): 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 = utils_lung.get_patient_data_paths( pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] print len(luna_data_paths) print id2zyxd.keys() for k, p in enumerate(luna_data_paths): img, origin, pixel_spacing = utils_lung.read_mhd(p) img = data_transforms.hu2normHU(img) id = os.path.basename(p).replace('.mhd', '') for nodule_zyxd in id2zyxd.itervalues(): zyx = np.array(nodule_zyxd[:3]) voxel_coords = utils_lung.world2voxel(zyx, origin, pixel_spacing) diameter_mm = nodule_zyxd[-1] radius_px = diameter_mm / pixel_spacing[1] / 2. roi_radius = (radius_px, radius_px) slice = img[voxel_coords[0], :, :] slice_prev = img[voxel_coords[0] - 1, :, :] slice_next = img[voxel_coords[0] + 1, :, :] roi_center_yx = (voxel_coords[1], voxel_coords[2]) mask = data_transforms.make_2d_mask(slice.shape, roi_center_yx, roi_radius, masked_value=0.1) plot_2d(slice, mask, id, image_dir) plot_2d_4(slice, slice_prev, slice_next, mask, id, image_dir) a = [{'center': roi_center_yx, 'diameter_mm': diameter_mm}] p_transform = { 'patch_size': (256, 256), 'mm_patch_size': (360, 360) } slice_patch, mask_patch = data_transforms.luna_transform_slice( slice, a, pixel_spacing[1:], p_transform, None) plot_2d(slice_patch, mask_patch, id, image_dir)
def test2(): image_dir = utils.get_dir_path('analysis', pathfinder.METADATA_PATH) luna_data_paths = utils_lung.get_patient_data_paths( pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] print len(luna_data_paths) pid2mm_shape = {} for k, p in enumerate(luna_data_paths): img, origin, spacing = utils_lung.read_mhd(p) id = os.path.basename(p).replace('.mhd', '') mm_shape = img.shape * spacing pid2mm_shape[id] = mm_shape print k, id, mm_shape if k % 50 == 0: print 'Saved' utils.save_pkl(pid2mm_shape, image_dir + '/pid2mm.pkl') utils.save_pkl(pid2mm_shape, image_dir + '/pid2mm.pkl')
def test1(): image_dir = utils.get_dir_path('analysis', pathfinder.METADATA_PATH) image_dir = image_dir + '/test_luna/' utils.auto_make_dir(image_dir) # sys.stdout = logger.Logger(image_dir + '/test_luna.log') # sys.stderr = sys.stdout id2zyxd = utils_lung.read_luna_annotations(pathfinder.LUNA_LABELS_PATH) luna_data_paths = utils_lung.get_patient_data_paths( pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] print len(luna_data_paths) print id2zyxd.keys() for k, p in enumerate(luna_data_paths): img, origin, spacing = utils_lung.read_mhd(p) img = data_transforms.hu2normHU(img) id = os.path.basename(p).replace('.mhd', '') for roi in id2zyxd[id]: zyx = np.array(roi[:3]) voxel_coords = utils_lung.world2voxel(zyx, origin, spacing) print spacing radius_mm = roi[-1] / 2. radius_px = radius_mm / spacing[1] print 'r in pixels =', radius_px # roi_radius = (32.5, 32.5) roi_radius = (radius_px, radius_px) slice = img[voxel_coords[0], :, :] roi_center_yx = (voxel_coords[1], voxel_coords[2]) # print slice.shape, slice_resample.shape mask = make_circular_mask(slice.shape, roi_center_yx, roi_radius) plot_2d(slice, mask, id, image_dir) slice_mm, _ = resample(slice, spacing[1:]) roi_center_mm = tuple( int(r * ps) for r, ps in zip(roi_center_yx, spacing[1:])) mask_mm = make_circular_mask(slice_mm.shape, roi_center_mm, (radius_mm, radius_mm)) plot_2d(slice_mm, mask_mm, id, image_dir)
def test_luna3d(): 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 = [ 'problem_patients/1.3.6.1.4.1.14519.5.2.1.6279.6001.877026508860018521147620598474.mhd' ] candidates = utils.load_pkl( 'problem_patients/1.3.6.1.4.1.14519.5.2.1.6279.6001.877026508860018521147620598474.pkl' ) candidates = candidates[:4] print candidates print '--------------' print id2zyxd[ '1.3.6.1.4.1.14519.5.2.1.6279.6001.877026508860018521147620598474'] 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_elias(img) x, annotations_tf, tf_matrix, lung_mask_out = data_transforms.transform_scan3d( data=img, pixel_spacing=pixel_spacing, p_transform=p_transform, luna_annotations=candidates, p_transform_augment=None, luna_origin=origin, lung_mask=lung_mask, world_coord_system=False) for zyxd in annotations_tf: plot_slice_3d_2(x, lung_mask_out, 0, id, img_dir='./', idx=zyxd) plot_slice_3d_2(x, lung_mask_out, 1, id, img_dir='./', idx=zyxd) plot_slice_3d_2(x, lung_mask_out, 2, id, img_dir='./', idx=zyxd)
def test1(): image_dir = utils.get_dir_path('analysis', pathfinder.METADATA_PATH) image_dir = image_dir + '/test_luna/' utils.auto_make_dir(image_dir) # sys.stdout = logger.Logger(image_dir + '/test_luna.log') # sys.stderr = sys.stdout id2zyxd = utils_lung.read_luna_annotations(pathfinder.LUNA_LABELS_PATH) luna_data_paths = utils_lung.get_patient_data_paths(pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] print len(luna_data_paths) print id2zyxd.keys() for k, p in enumerate(luna_data_paths): img, origin, spacing = utils_lung.read_mhd(p) img = data_transforms.hu2normHU(img) id = os.path.basename(p).replace('.mhd', '') for roi in id2zyxd[id]: zyx = np.array(roi[:3]) voxel_coords = utils_lung.world2voxel(zyx, origin, spacing) print spacing radius_mm = roi[-1] / 2. radius_px = radius_mm / spacing[1] print 'r in pixels =', radius_px # roi_radius = (32.5, 32.5) roi_radius = (radius_px, radius_px) slice = img[voxel_coords[0], :, :] roi_center_yx = (voxel_coords[1], voxel_coords[2]) # print slice.shape, slice_resample.shape mask = make_circular_mask(slice.shape, roi_center_yx, roi_radius) plot_2d(slice, mask, id, image_dir) slice_mm, _ = resample(slice, spacing[1:]) roi_center_mm = tuple(int(r * ps) for r, ps in zip(roi_center_yx, spacing[1:])) mask_mm = make_circular_mask(slice_mm.shape, roi_center_mm, (radius_mm, radius_mm)) plot_2d(slice_mm, mask_mm, id, image_dir)
def test1(): 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 = utils_lung.get_patient_data_paths(pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] print len(luna_data_paths) print id2zyxd.keys() for k, p in enumerate(luna_data_paths): img, origin, pixel_spacing = utils_lung.read_mhd(p) img = data_transforms.hu2normHU(img) id = os.path.basename(p).replace('.mhd', '') for nodule_zyxd in id2zyxd.itervalues(): zyx = np.array(nodule_zyxd[:3]) voxel_coords = utils_lung.world2voxel(zyx, origin, pixel_spacing) diameter_mm = nodule_zyxd[-1] radius_px = diameter_mm / pixel_spacing[1] / 2. roi_radius = (radius_px, radius_px) slice = img[voxel_coords[0], :, :] slice_prev = img[voxel_coords[0] - 1, :, :] slice_next = img[voxel_coords[0] + 1, :, :] roi_center_yx = (voxel_coords[1], voxel_coords[2]) mask = data_transforms.make_2d_mask(slice.shape, roi_center_yx, roi_radius, masked_value=0.1) plot_2d(slice, mask, id, image_dir) plot_2d_4(slice, slice_prev, slice_next, mask, id, image_dir) a = [{'center': roi_center_yx, 'diameter_mm': diameter_mm}] p_transform = {'patch_size': (256, 256), 'mm_patch_size': (360, 360)} slice_patch, mask_patch = data_transforms.luna_transform_slice(slice, a, pixel_spacing[1:], p_transform, None) plot_2d(slice_patch, mask_patch, id, image_dir)
def test_luna_patches_3d(): 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 = utils_lung.get_patient_data_paths( pathfinder.LUNA_DATA_PATH) luna_data_paths = [p for p in luna_data_paths if '.mhd' in p] # pid = '1.3.6.1.4.1.14519.5.2.1.6279.6001.138080888843357047811238713686' # luna_data_paths = [pathfinder.LUNA_DATA_PATH + '/%s.mhd' % pid] for k, p in enumerate(luna_data_paths): img, origin, pixel_spacing = utils_lung.read_mhd(p) # img = data_transforms.hu2normHU(img) id = os.path.basename(p).replace('.mhd', '') print(id) annotations = id2zyxd[id] print(annotations) for zyxd in annotations: img_out, mask = config().data_prep_function_train( img, pixel_spacing=pixel_spacing, p_transform=config().p_transform, p_transform_augment=config().p_transform_augment, patch_center=zyxd, luna_annotations=annotations, luna_origin=origin) try: plot_slice_3d_2(img_out, mask, 0, id) plot_slice_3d_2(img_out, mask, 1, id) plot_slice_3d_2(img_out, mask, 2, id) except: pass print('------------------------------------------')
def test_luna3d(): 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 = [ 'problem_patients/1.3.6.1.4.1.14519.5.2.1.6279.6001.877026508860018521147620598474.mhd'] candidates = utils.load_pkl( 'problem_patients/1.3.6.1.4.1.14519.5.2.1.6279.6001.877026508860018521147620598474.pkl') candidates = candidates[:4] print candidates print '--------------' print id2zyxd['1.3.6.1.4.1.14519.5.2.1.6279.6001.877026508860018521147620598474'] 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_elias(img) x, annotations_tf, tf_matrix, lung_mask_out = data_transforms.transform_scan3d(data=img, pixel_spacing=pixel_spacing, p_transform=p_transform, luna_annotations=candidates, p_transform_augment=None, luna_origin=origin, lung_mask=lung_mask, world_coord_system=False) for zyxd in annotations_tf: plot_slice_3d_2(x, lung_mask_out, 0, id, img_dir='./', idx=zyxd) plot_slice_3d_2(x, lung_mask_out, 1, id, img_dir='./', idx=zyxd) plot_slice_3d_2(x, lung_mask_out, 2, id, img_dir='./', idx=zyxd)