def __init(self, d_thr=2.0): from VascGraph.GraphIO import ReadPajek try: g = ReadPajek(self.g_path).GetOutput() if self.fix_rad: self.g = self.fixRad(g) else: self.g = g self.gtrue = ReadPajek(self.gtrue_path).GetOutput() except: g = ReadPajek(os.getcwd() + '/' + self.g_path).GetOutput() self.g = self.fixRad(g) self.gtrue = ReadPajek(os.getcwd() + '/' + self.gtrue_path).GetOutput() self.g_path = os.getcwd() + '/' + self.g_path self.gtrue_path = os.getcwd() + '/' + self.gtrue_path nodes_exp = np.array(self.g.GetNodesPos()) nodes_real = np.array(self.gtrue.GetNodesPos()) radius_exp = np.array(self.g.GetRadii())[:, None] radius_real = np.array(self.gtrue.GetRadii())[:, None] dist1 = [] for idx, i in enumerate(nodes_real): dist1.append(np.sum((i - nodes_exp)**2, axis=1)) #real nodes with the corresponding exp. ones idx1 = np.argmin(dist1, axis=1) d1 = np.array([i[idx1[j]]**.5 for j, i in enumerate(dist1)]) radius_exp_m = radius_exp[idx1] self.rad_real = radius_real[d1 < d_thr] self.rad_exp_m = radius_exp_m[d1 < d_thr] dist2 = [] for idx, i in enumerate(nodes_exp): dist2.append(np.sum((i - nodes_real)**2, axis=1)) #exp nodes with the corresponding real. ones idx2 = np.argmin(dist2, axis=1) d2 = np.array([i[idx2[j]]**.5 for j, i in enumerate(dist2)]) radius_real_m = radius_real[idx2] self.rad_exp = radius_exp[d2 < d_thr] self.rad_real_m = radius_real_m[d2 < d_thr]
Item('reset_nodes', show_label=False), Item('nodes_list', style='readonly', label='Selected nodes'), Item('connect_nodes', show_label=False), orientation='horizontal' ), Group('_', Item('save', show_label=False),'_'), label='Edit', orientation='vertical', layout='split',show_border = True, ) # The layout of the dialog created view = View( Group( Group(Item('scene', editor=SceneEditor(scene_class=MayaviScene), height=600, width=400, show_label=False)), Group(control_group, editing_group, layout='tabbed'), layout='split'), resizable=True, title = 'Nodes selection' ) if __name__=='__main__': g=ReadPajek('/home/rdamseh/GraphPaper2018V1/1.pajek') window=ModifyGraph(fixG(g.GetOutput())) window.configure_traits()
import numpy as np import networkx as nx import skimage as sk from VascGraph.Skeletonize import GenerateGraph, ContractGraph, RefineGraph from VascGraph.GeomGraph import DiGraph from VascGraph.GraphIO import ReadPajek, WritePajek from VascGraph.GraphLab import GraphPlot from matplotlib import pyplot as plt from mayavi import mlab from VascGraph.Tools.VisTools import * from VascGraph.Tools.CalcTools import * from GraphFlowSimulation import GraphObject, GraphFlowSimulation if __name__ == "__main__": g = ReadPajek('/home/rdamseh/GraphPaper2018V1' + '/flow/test_network.di.pajek').GetOutput() metadata = sio.loadmat('/home/rdamseh/GraphPaper2018V1' + '/flow/test_network.di.pajek.metadata.mat') g_object = GraphObject(g) g_object.InitGraph() g = g_object.GetGraph() # g_object.UpdateReducedGraph() # g=g_object.GetReducedGraph() # ----------- assigne resistances ---------- # print('Computes resistances ...') flow = GraphFlowSimulation(g, metadata) flow.ComputeResistance() flow.GetCloseGraph() g = flow.Graph
if len(check_result)==0: print('Item not found!!!') lines_=[] ind=[] for idx, l in enumerate(lines): if l.find('(')!=-1: lines_.append(l) ind.append(idx) attr=file.attr ''' # read/write from VascGraph.GraphIO import WritePajek, ReadPajek namepajek = ''.join(attr_filename.split('.')[:-1]) + '.pajek' WritePajek('', namepajek, g) g = ReadPajek(namepajek, mode='di').GetOutput() from OxyGraph import OxyGraph og = OxyGraph(g) og.AddType() og.AddVelocityFromFlow() og.AddSo2FromPo2() og.BuildDirectionsGraph() g = og.g gplot = GraphPlot(new_engine=True) gplot.Update(g) gplot.SetTubeRadius(3) gplot.SetTubeRadiusByScale(True) gplot.SetTubeRadiusByColor(True)
degree_threshold=degree_threshold, clustering_resolution=clustering_r, stop_param=stop_param, n_free_iteration=n_free_iteration, area_param=area_param, poly_param=poly_param) sk.UpdateWithStitching(size=size, niter1=niter1, niter2=niter2, is_parallel=is_parallel, n_parallel=n_parallel) fullgraph = sk.GetOutput() # save graph WritePajek(path='', name='mygraph.pajek', graph=fixG(fullgraph)) #load graph loaded_g = ReadPajek('mygraph.pajek').GetOutput() print('--Visualize final skeleton ...') splot = StackPlot(new_engine=True) splot.Update((s > 0).astype(int)) gplot = GraphPlot() gplot.Update(loaded_g) gplot.SetTubeRadiusByScale(True) gplot.SetTubeRadiusByColor(True) gplot.SetTubeRadius(3)