def setUpClass(self): self.current_path = os.path.dirname(__file__) self.data_path = os.path.join(self.current_path, '..', 'data') download_test_data(self.data_path) self.image_path = os.path.join(self.data_path, 'images') self.image_name = '16B0001851_Block_Region_3.jpg' self.out_path = os.path.join(self.data_path, 'tissue_mask_test') if os.path.exists(self.out_path) and os.path.isdir(self.out_path): shutil.rmtree(self.out_path) os.makedirs(self.out_path)
def setUpClass(self): self.current_path = os.path.dirname(__file__) self.data_path = os.path.join(self.current_path, '..', 'data') download_test_data(self.data_path) self.graph_path = os.path.join(self.data_path, 'tissue_graphs') self.graph_name = '283_dcis_4.bin' self.out_path = os.path.join(self.data_path, 'graph_lrp_test') if os.path.exists(self.out_path) and os.path.isdir(self.out_path): shutil.rmtree(self.out_path) os.makedirs(self.out_path)
def setUpClass(self): self.current_path = os.path.dirname(__file__) self.data_path = os.path.join(self.current_path, '..', 'data') download_test_data(self.data_path) self.model_fname = os.path.join(self.data_path, 'models', 'tg_model.pt') self.graph_path = os.path.join(self.data_path, 'tissue_graphs') self.checkpoint_path = os.path.join(self.data_path, 'checkpoints') self.graph_name = '283_dcis_4.bin' os.makedirs(self.checkpoint_path, exist_ok=True)
def setUpClass(self): self.current_path = os.path.dirname(__file__) self.data_path = os.path.join(self.current_path, '..', 'data') download_test_data(self.data_path) self.image_path = os.path.join(self.data_path, 'images') self.image_name = '283_dcis_4.png' self.out_path = os.path.join(self.data_path, 'nuclei_extraction_test') if os.path.exists(self.out_path) and os.path.isdir(self.out_path): shutil.rmtree(self.out_path) os.makedirs(self.out_path)
def setUpClass(self): self.current_path = os.path.dirname(__file__) self.data_path = os.path.join(self.current_path, '..', 'data') download_test_data(self.data_path) self.image_path = os.path.join(self.data_path, 'images') self.image_name = '283_dcis_4.png' self.nuclei_map_path = os.path.join(self.data_path, 'nuclei_maps') self.nuclei_map_name = '283_dcis_4.h5' self.annotation_name = '283_dcis_4_annotation.png' self.out_path = os.path.join(self.data_path, 'graph_builder_test') if os.path.exists(self.out_path) and os.path.isdir(self.out_path): shutil.rmtree(self.out_path) os.makedirs(self.out_path)
def setUpClass(self): self.current_path = os.path.dirname(__file__) self.data_path = os.path.join(self.current_path, "..", "data") download_test_data(self.data_path) self.image_path = os.path.join(self.data_path, "images") self.image_name = "283_dcis_4.png" self.cell_graph_path = os.path.join(self.data_path, "cell_graphs") self.graph_name = "283_dcis_4.bin" self.tissue_graph_path = os.path.join(self.data_path, "tissue_graphs") self.tissue_graph_name = "283_dcis_4.bin" self.out_path = os.path.join(self.data_path, "visualization_test") if os.path.exists(self.out_path) and os.path.isdir(self.out_path): shutil.rmtree(self.out_path) os.makedirs(self.out_path)
graph = graph[0] graph = set_graph_on_cuda(graph) if IS_CUDA else graph # b. load corresponding image image_path = [ x for x in image_fnames if graph_name in x.replace('.png', '.bin') ][0] _, image_name = os.path.split(image_path) image = np.array(Image.open(image_path)) # c. run explainer importance_scores, _ = explainer.process(graph) # d. visualize and save the output node_attrs = {"color": importance_scores} canvas = visualizer.process(image, graph, node_attributes=node_attrs) canvas.save(os.path.join('output', 'explainer', image_name)) if __name__ == "__main__": # 1. download pre-computed images/cell_graph download_test_data('output') # 2. create output directories os.makedirs(os.path.join('output', 'explainer'), exist_ok=True) # 3. generate tissue graphs explain_cell_graphs(cell_graph_path=os.path.join('output', 'cell_graphs'), image_path=os.path.join('output', 'images'))