def test_get_tree_simple(self): from fibrous.tb_volume import TBVolume tvg = TBVolume() yaml_path = os.path.join(path_to_script, "./hist_stats_test.yaml") tvg.importFromYaml(yaml_path) # tvg.init_data3d(shape=[100, 100, 100]) # output = tvg.buildTree() # noqa from fibrous.tb_vtk import gen_tree_simple # from fibrous.tree import single_tree_compatibility_to_old vtk_tree = gen_tree_simple(tvg.tube_skeleton) self.assertTrue(vtk_tree is not None)
def test_surface_measurement_find_edge(self): tvg = TBVolume() yaml_path = os.path.join(path_to_script, "./hist_stats_test.yaml") tvg.importFromYaml(yaml_path) tvg.voxelsize_mm = [1, 1, 1] tvg.shape = [100, 100, 100] data3d = tvg.buildTree() self.assertGreater(np.sum(data3d), 10, "Image should be not empty")
def test_read_portal_vein_data(self): import fibrous.tree from fibrous.tree import TreeBuilder # tvg = TreeBuilder() tvg = TBVolume() # yaml_path = os.path.join(path_to_script, "vt_biodur_simple.yaml") yaml_path = r"e:/vessel_tree_data/ep_hcc2_porta1d.yaml" tree = fibrous.tree.read_tube_skeleton_from_yaml(yaml_path)
def test_import_new_vt_format(self): # tvg = TreeBuilder() tvg = TBVolume() yaml_path = os.path.join(path_to_script, "vt_biodur_simple.yaml") tvg.importFromYaml(yaml_path) tvg.set_area_sampling(voxelsize_mm=[1,1,1], shape=[150, 150, 150]) # tvg.voxelsize_mm = [1, 1, 1] # tvg.shape = [150, 150, 150] data3d = tvg.buildTree()
def test_synthetic_volumetric_data_generation(self): """ Generovani umeleho stromu do 3D a jeho evaluace. V testu dochazi ke kontrole predpokladaneho objemu a deky cev """ # from skelet3d.tree import TreeGenerator # from fibrous.tree import TubeSkeletonBuilder as TreeGenerator # from fibrous.tree import TreeBuilder as TreeGenerator from fibrous.tb_volume import TBVolume as TreeGenerator # print("zacatek podezreleho testu") # import segmentation # import misc # generate 3d data from yaml for testing tvg = TreeGenerator() yaml_path = os.path.join(path_to_script, "./hist_stats_test.yaml") tvg.importFromYaml(yaml_path) tvg.set_area_sampling(voxelsize_mm=[1, 1, 1], shape=[100, 101, 102]) # tvg.voxelsize_mm = [1, 1, 1] # tvg.shape = [100, 100, 100] # data3d = tvg.generateTree() data3d = tvg.buildTree() self.assertEqual(data3d.shape[0], 100) self.assertEqual(data3d.shape[1], 101) self.assertEqual(data3d.shape[2], 102)
def test_vessel_tree_volume_with_new_subclass_on_artifical_sample_data(self): tube_skeleton = self.sample_tube_skeleton() tvg = TBVolume() tvg.set_model1d(model1d=tube_skeleton) # yaml_path = os.path.join(path_to_script, "./hist_stats_test.yaml") # tvg.importFromYaml(yaml_path) tvg.voxelsize_mm = [1, 1, 1] tvg.shape = [100, 100, 100] output = tvg.buildTree() # noqa self.assertTrue(type(output) == np.ndarray)
def test_get_vt_from_file_and_save_it_to_vtk_with_not_simple_method(self): # TODO findout what is wrong with VTK export with boolean operations import fibrous.tb_vtk fn = "output.vtk" if os.path.exists(fn): os.remove(fn) tvg = TBVolume() yaml_path = os.path.join(path_to_script, "./hist_stats_test.yaml") fibrous.tb_vtk.vt_file_2_vtk_file( yaml_path, outfile=fn, tube_shape=False, use_simple_cylinder_method=False ) self.assertTrue(os.path.exists(fn))
def test_vessel_tree_volume_with_new_subclass(self): from fibrous.tb_volume import TBVolume tvg = TBVolume() yaml_path = os.path.join(path_to_script, "./hist_stats_test.yaml") tvg.importFromYaml(yaml_path) tvg.init_data3d(shape=[100, 100, 100]) output = tvg.buildTree() # noqa # import sed3 # ed = sed3.sed3(output) # ed.show() self.assertEqual(output[50, 20, 20], 200) self.assertEqual(output[5, 5, 5], 20)
def test_surface_measurement_find_edge(self): import imtools.surface_measurement as sm tvg = TBVolume() yaml_path = os.path.join(path_to_script, "./hist_stats_test.yaml") tvg.importFromYaml(yaml_path) tvg.voxelsize_mm = [1, 1, 1] tvg.shape = [100, 100, 100] data3d = tvg.buildTree() # init histology Analyser # metadata = {'voxelsize_mm': tvg.voxelsize_mm} # data3d = data3d * 10 # threshold = 2.5 im_edg = sm.find_edge(data3d, 0) # in this area should be positive edge self.assertGreater(np.sum(im_edg[25:30, 25:30, 30]), 3)
def test_synthetic_volumetric_data_generation(): """ Generovani umeleho stromu do 3D a jeho evaluace. V testu dochazi ke kontrole predpokladaneho objemu a deky cev """ # from skelet3d.tree import TreeGenerator # from fibrous.tree import TubeSkeletonBuilder as TreeGenerator # from fibrous.tree import TreeBuilder as TreeGenerator from fibrous.tb_volume import TBVolume as TreeGenerator # print("zacatek podezreleho testu") # import segmentation # import misc # generate 3d data from yaml for testing tvg = TreeGenerator() yaml_path = os.path.join(path_to_script, "./hist_stats_test.yaml") tvg.importFromYaml(yaml_path) tvg.set_area_sampling(voxelsize_mm=[1, 1, 1], shape=[100, 101, 102]) # tvg.voxelsize_mm = [1, 1, 1] # tvg.shape = [100, 100, 100] # data3d = tvg.generateTree() data3d = tvg.buildTree() assert data3d.shape[0] == 100 assert data3d.shape[1] == 101 assert data3d.shape[2] == 102 # plt.imshow(data3d[:,:,50]) # plt.colorbar() # plt.show() io3d.write(data3d.astype(np.uint8), path="./slice{:04d}.jpg") # self.assertEqual(data3d.shape[0], 100) # self.assertEqual(data3d.shape[1], 101) # self.assertEqual(data3d.shape[2], 102) tvg = TreeGenerator() yaml_path = os.path.join(path_to_script, "./hist_stats_test.yaml") tvg.importFromYaml(yaml_path) tvg.set_area_sampling(voxelsize_mm=[0.5, 0.5, 0.5], shape=[100, 101, 102]) io3d.write(data3d.astype(np.uint8), path="./ssslice{:04d}.jpg")