def _test_performance(self): roi_begin = [10, 1000, 1000] roi_end = [60, 1512, 1512] bb = tuple(slice(rb, re) for rb, re in zip(roi_begin, roi_end)) times = [] graph_file = './tmpdir/subgraph.n5' for _ in range(10): if os.path.exists('./tmpdir'): rmtree('./tmpdir') os.mkdir('./tmpdir') f_graph = z5py.File(graph_file, use_zarr_format=False) t0 = time.time() ndist.computeMergeableRegionGraph(self.labels_path, self.labels_key, roi_begin, roi_end, graph_file, 'block0') times.append(time.time() - t0) print("Mean extraction time:", np.mean(times), "s") # load the graph from file nodes, edges = self.load_graph(f_graph, 'block0') # check that nodes were extracted correctly labels = z5py.File(self.labels_path)[self.labels_key][bb] self.check_nodes(labels, nodes) self.check_rag(labels, nodes, edges)
def extract_subgraph(block_id): block = blocking.getBlockWithHalo(block_id, halo) outer_block, inner_block = block.outerBlock, block.innerBlock # we only need the halo into one direction, # hence we use the outer-block only for the end coordinate begin = inner_block.begin end = outer_block.end block_key = 'sub_graphs/s0/block_%i' % block_id ndist.computeMergeableRegionGraph(self.labels_path, self.labels_key, begin, end, graph_path, block_key)
def extract_subgraph(block_id): print("Extracting subgraph", block_id, "/", blocking.numberOfBlocks) block = blocking.getBlockWithHalo(block_id, halo) outer_block, inner_block = block.outerBlock, block.innerBlock # we only need the halo into one direction, # hence we use the outer-block only for the end coordinate begin = inner_block.begin end = outer_block.end # TODO groups for different scale levels block_key = 'sub_graphs/s0/block_%i' % block_id ndist.computeMergeableRegionGraph(path, labels_key, begin, end, graph_path, block_key)
def test_subgraph(self): roi_begin = [0, 0, 0] roi_end = [50, 512, 512] bb = tuple(slice(rb, re) for rb, re in zip(roi_begin, roi_end)) # distributed graph extraction graph_path = './tmpdir/graph.n5' graph_key = 'block0' ndist.computeMergeableRegionGraph(self.labels_path, self.labels_key, roi_begin, roi_end, graph_path, graph_key) # check that nodes were extracted correctly labels = z5py.File(self.labels_path)[self.labels_key] self.check_subgraph(graph_path, graph_key, labels, bb)
def _graph_block(block_id, blocking, input_path, input_key, graph_path, ignore_label): fu.log("start processing block %i" % block_id) block = blocking.getBlock(block_id) # we only need the halo into one direction, # hence we use the outer-block only for the end coordinate subgraph_key = 's0/sub_graphs' ndist.computeMergeableRegionGraph(input_path, input_key, block.begin, block.end, graph_path, subgraph_key, ignore_label, increaseRoi=True, serializeToVarlen=True) # log block success fu.log_block_success(block_id)
def extract_subgraph_from_roi(block_id, blocking, labels_path, labels_key, graph_path): print("Processign block", block_id) t0 = time.time() halo = [1, 1, 1] block = blocking.getBlockWithHalo(block_id, halo) outer_block, inner_block = block.outerBlock, block.innerBlock # we only need the halo into one direction, # hence we use the outer-block only for the end coordinate begin = inner_block.begin end = outer_block.end block_key = 'sub_graphs/s0/block_%i' % block_id ndist.computeMergeableRegionGraph(labels_path, labels_key, begin, end, graph_path, block_key) print("done", block_id) return time.time() - t0