Commit 6eb102f5fb68c062f24cc52df6014b81c5efe67d

Authored by Pavel Govyadinov
1 parent 9f9f1788

Fixed issue cause by splitting up the code and hid the DEBUG messages behind a variable

@@ -21,6 +21,8 @@ import network_dep as nwt @@ -21,6 +21,8 @@ import network_dep as nwt
21 from graph_shaders import vert, frag, vs, fs 21 from graph_shaders import vert, frag, vs, fs
22 from subgraph_shaders import vert_s, frag_s, vs_s, fs_s 22 from subgraph_shaders import vert_s, frag_s, vs_s, fs_s
23 23
  24 +DEBUG = False
  25 +
24 #The graph canvas class that 26 #The graph canvas class that
25 class GraphCanvas(scene.SceneCanvas): 27 class GraphCanvas(scene.SceneCanvas):
26 28
@@ -229,12 +231,13 @@ class GraphCanvas(scene.SceneCanvas): @@ -229,12 +231,13 @@ class GraphCanvas(scene.SceneCanvas):
229 len_array = np.zeros(location.shape[0]) 231 len_array = np.zeros(location.shape[0])
230 offset_array = np.zeros(location.shape, dtype=np.float32) 232 offset_array = np.zeros(location.shape, dtype=np.float32)
231 cam_array[:][0:3] = camera_pos 233 cam_array[:][0:3] = camera_pos
232 - offset = [(bbu[0]-bbl[0])/2, (bbu[1]-bbl[1])/2, (bbu[2]-bbl[2])/2] 234 + offset = [(self.bbu[0]-self.bbl[0])/2, (self.bbu[1]-self.bbl[1])/2, (self.bbu[2]-self.bbl[2])/2]
233 location = location - offset 235 location = location - offset
234 location = location - camera_pos 236 location = location - camera_pos
235 for i in range(location.shape[0]): 237 for i in range(location.shape[0]):
236 len_array[i] = np.sqrt(np.power(location[i][0],2) + np.power(location[i][1],2) + np.power(location[i][2],2)) 238 len_array[i] = np.sqrt(np.power(location[i][0],2) + np.power(location[i][1],2) + np.power(location[i][2],2))
237 239
  240 +
238 G.vertex_properties['dist_from_camera'] = G.new_vertex_property('float', vals=len_array) 241 G.vertex_properties['dist_from_camera'] = G.new_vertex_property('float', vals=len_array)
239 self.data['a_size'] = nwt.Network.map_vertices_to_range(G, [1*self.pixel_scale, 60*self.pixel_scale], 'dist_from_camera').get_array() 242 self.data['a_size'] = nwt.Network.map_vertices_to_range(G, [1*self.pixel_scale, 60*self.pixel_scale], 'dist_from_camera').get_array()
240 243
@@ -266,7 +269,7 @@ class GraphCanvas(scene.SceneCanvas): @@ -266,7 +269,7 @@ class GraphCanvas(scene.SceneCanvas):
266 len_array = np.zeros(location.shape[0]) 269 len_array = np.zeros(location.shape[0])
267 #offset_array = np.zeros(location.shape, dtype=np.float32) 270 #offset_array = np.zeros(location.shape, dtype=np.float32)
268 cam_array[:][0:3] = camera_pos 271 cam_array[:][0:3] = camera_pos
269 - offset = [(bbu[0]-bbl[0])/2, (bbu[1]-bbl[1])/2, (bbu[2]-bbl[2])/2] 272 + offset = [(self.bbu[0]-self.bbl[0])/2, (self.bbu[1]-self.bbl[1])/2, (self.bbu[2]-self.bbl[2])/2]
270 location = location - offset 273 location = location - offset
271 location = location - camera_pos 274 location = location - camera_pos
272 for i in range(location.shape[0]): 275 for i in range(location.shape[0]):
@@ -350,7 +353,7 @@ class GraphCanvas(scene.SceneCanvas): @@ -350,7 +353,7 @@ class GraphCanvas(scene.SceneCanvas):
350 self.data['a_selection'] = G.vertex_properties["selection"].get_array() 353 self.data['a_selection'] = G.vertex_properties["selection"].get_array()
351 #self.data['a_graph_size'] = [bbu-bbl] 354 #self.data['a_graph_size'] = [bbu-bbl]
352 355
353 - self.program['u_graph_size'] = [bbu-bbl] 356 + self.program['u_graph_size'] = [self.bbu-self.bbl]
354 357
355 self.vbo = gloo.VertexBuffer(self.data) 358 self.vbo = gloo.VertexBuffer(self.data)
356 self.gen_line_vbo(G) 359 self.gen_line_vbo(G)
@@ -363,7 +366,8 @@ class GraphCanvas(scene.SceneCanvas): @@ -363,7 +366,8 @@ class GraphCanvas(scene.SceneCanvas):
363 if(self.subgraphs): 366 if(self.subgraphs):
364 #self.program_e_s.bind(self.vbo_s) 367 #self.program_e_s.bind(self.vbo_s)
365 self.program_s.bind(self.vbo_s) 368 self.program_s.bind(self.vbo_s)
366 - print(self.view) 369 + if DEBUG:
  370 + print(self.view)
367 self.update() 371 self.update()
368 372
369 """ 373 """
@@ -720,7 +724,8 @@ class GraphCanvas(scene.SceneCanvas): @@ -720,7 +724,8 @@ class GraphCanvas(scene.SceneCanvas):
720 if(self.subgraphs): 724 if(self.subgraphs):
721 #self.program_e_s.bind(self.vbo_s) 725 #self.program_e_s.bind(self.vbo_s)
722 self.program_s.bind(self.vbo_s) 726 self.program_s.bind(self.vbo_s)
723 - print(self.view) 727 + if DEBUG:
  728 + print(self.view)
724 self.update() 729 self.update()
725 730
726 731
@@ -797,11 +802,13 @@ class GraphCanvas(scene.SceneCanvas): @@ -797,11 +802,13 @@ class GraphCanvas(scene.SceneCanvas):
797 for j in range(len(arc_length_vertex)): 802 for j in range(len(arc_length_vertex)):
798 if j != 0: 803 if j != 0:
799 arc_length_vertex[j] += arc_length_vertex[j-1] 804 arc_length_vertex[j] += arc_length_vertex[j-1]
800 - print("arc_length before ", arc_length_vertex, " and sum to ", sum(arc_length_vertex)) 805 + if DEBUG:
  806 + print("arc_length before ", arc_length_vertex, " and sum to ", sum(arc_length_vertex))
801 arc_length_vertex = np.asarray(arc_length_vertex, dtype = np.float32) 807 arc_length_vertex = np.asarray(arc_length_vertex, dtype = np.float32)
802 arc_length_vertex = (np.pi - -np.pi)/(max(arc_length_vertex) - min(arc_length_vertex)) \ 808 arc_length_vertex = (np.pi - -np.pi)/(max(arc_length_vertex) - min(arc_length_vertex)) \
803 * (arc_length_vertex- min(arc_length_vertex)) + (-np.pi) 809 * (arc_length_vertex- min(arc_length_vertex)) + (-np.pi)
804 - print(arc_length_vertex) 810 + if DEBUG:
  811 + print(arc_length_vertex)
805 #print(arc_length) 812 #print(arc_length)
806 813
807 814
@@ -821,7 +828,8 @@ class GraphCanvas(scene.SceneCanvas): @@ -821,7 +828,8 @@ class GraphCanvas(scene.SceneCanvas):
821 828
822 temp.append(np.sum(g.vertex_properties['degree'].get_array())) 829 temp.append(np.sum(g.vertex_properties['degree'].get_array()))
823 G.clear_filters() 830 G.clear_filters()
824 - print(self.clusters['a_outer_arc_length']) 831 + if DEBUG:
  832 + print(self.clusters['a_outer_arc_length'])
825 maximum = max(temp) 833 maximum = max(temp)
826 minimum = min(temp) 834 minimum = min(temp)
827 if len(temp) > 1: 835 if len(temp) > 1:
@@ -873,7 +881,8 @@ class GraphCanvas(scene.SceneCanvas): @@ -873,7 +881,8 @@ class GraphCanvas(scene.SceneCanvas):
873 self.program.bind(self.vbo) 881 self.program.bind(self.vbo)
874 if(self.subgraphs): 882 if(self.subgraphs):
875 self.program_s.bind(self.vbo_s) 883 self.program_s.bind(self.vbo_s)
876 - print(self.view) 884 + if DEBUG:
  885 + print(self.view)
877 self.update() 886 self.update()
878 887
879 """ 888 """
@@ -881,7 +890,8 @@ class GraphCanvas(scene.SceneCanvas): @@ -881,7 +890,8 @@ class GraphCanvas(scene.SceneCanvas):
881 spectral clustering on the graph passed if the subgraph is set to true. 890 spectral clustering on the graph passed if the subgraph is set to true.
882 """ 891 """
883 def set_data(self, G, bbl, bbu, subgraph=True): 892 def set_data(self, G, bbl, bbu, subgraph=True):
884 - print("Setting data") 893 + if DEBUG:
  894 + print("Setting data")
885 self.G = G 895 self.G = G
886 self.bbl = bbl 896 self.bbl = bbl
887 self.bbu = bbu 897 self.bbu = bbu
@@ -942,7 +952,8 @@ class GraphCanvas(scene.SceneCanvas): @@ -942,7 +952,8 @@ class GraphCanvas(scene.SceneCanvas):
942 if(self.subgraphs): 952 if(self.subgraphs):
943 #self.program_e_s.bind(self.vbo_s) 953 #self.program_e_s.bind(self.vbo_s)
944 self.program_s.bind(self.vbo_s) 954 self.program_s.bind(self.vbo_s)
945 - print(self.view) 955 + if DEBUG:
  956 + print(self.view)
946 self.update() 957 self.update()
947 958
948 """ 959 """
@@ -1057,7 +1068,7 @@ class GraphCanvas(scene.SceneCanvas): @@ -1057,7 +1068,7 @@ class GraphCanvas(scene.SceneCanvas):
1057 if(self.view[0][0] > 0.0010): 1068 if(self.view[0][0] > 0.0010):
1058 c_id = self.get_clicked_id(event) 1069 c_id = self.get_clicked_id(event)
1059 if(c_id != None): 1070 if(c_id != None):
1060 - self.original_point = G.vertex_properties["pos"][G.vertex(c_id)] 1071 + self.original_point = self.G.vertex_properties["pos"][self.G.vertex(c_id)]
1061 self.location = event.pos 1072 self.location = event.pos
1062 self.moving = True 1073 self.moving = True
1063 self.down = True 1074 self.down = True
@@ -1067,7 +1078,8 @@ class GraphCanvas(scene.SceneCanvas): @@ -1067,7 +1078,8 @@ class GraphCanvas(scene.SceneCanvas):
1067 #print("Clicked on:", event.pos) 1078 #print("Clicked on:", event.pos)
1068 else: 1079 else:
1069 c_id = self.get_clicked_id(event, True) 1080 c_id = self.get_clicked_id(event, True)
1070 - print(c_id) 1081 + if DEBUG:
  1082 + print(c_id)
1071 if(c_id != None): 1083 if(c_id != None):
1072 self.original_point = self.cluster_pos[c_id] 1084 self.original_point = self.cluster_pos[c_id]
1073 self.location = event.pos 1085 self.location = event.pos
@@ -1090,10 +1102,10 @@ class GraphCanvas(scene.SceneCanvas): @@ -1090,10 +1102,10 @@ class GraphCanvas(scene.SceneCanvas):
1090 self.update() 1102 self.update()
1091 1103
1092 def add_to_path(self, source, target): 1104 def add_to_path(self, source, target):
1093 - vl, el = nwt.gt.graph_tool.topology.shortest_path(G, G.vertex(source), G.vertex(target), weights=G.edge_properties["av_radius"]) 1105 + vl, el = nwt.gt.graph_tool.topology.shortest_path(self.G, self.G.vertex(source), self.G.vertex(target), weights=self.G.edge_properties["av_radius"])
1094 for v in vl: 1106 for v in vl:
1095 if(int(v) not in self.path): 1107 if(int(v) not in self.path):
1096 - G.vertex_properties["selection"][v] = 2.0 1108 + self.G.vertex_properties["selection"][v] = 2.0
1097 self.data['a_selection'][int(v)] = 2.0 1109 self.data['a_selection'][int(v)] = 2.0
1098 if(int(v) not in self.full_path): 1110 if(int(v) not in self.full_path):
1099 self.full_path.append(int(v)) 1111 self.full_path.append(int(v))
@@ -1105,7 +1117,7 @@ class GraphCanvas(scene.SceneCanvas): @@ -1105,7 +1117,7 @@ class GraphCanvas(scene.SceneCanvas):
1105 #check whether this is the first node to be selected 1117 #check whether this is the first node to be selected
1106 if(self.pathing == False): 1118 if(self.pathing == False):
1107 #if it is, select that node and turn the pathing variable on. 1119 #if it is, select that node and turn the pathing variable on.
1108 - G.vertex_properties["selection"][G.vertex(c_id)] = 1.0 1120 + self.G.vertex_properties["selection"][self.G.vertex(c_id)] = 1.0
1109 self.pathing = True 1121 self.pathing = True
1110 if(c_id not in self.path): 1122 if(c_id not in self.path):
1111 self.path.append(c_id) 1123 self.path.append(c_id)
@@ -1113,14 +1125,14 @@ class GraphCanvas(scene.SceneCanvas): @@ -1113,14 +1125,14 @@ class GraphCanvas(scene.SceneCanvas):
1113 update_vbo(self) 1125 update_vbo(self)
1114 print("I turned on the first node") 1126 print("I turned on the first node")
1115 else: 1127 else:
1116 - if(G.vertex_properties["selection"][G.vertex(c_id)] == 1.0):  
1117 - G.vertex_properties["selection"][G.vertex(c_id)] = 0.0 1128 + if(self.G.vertex_properties["selection"][self.G.vertex(c_id)] == 1.0):
  1129 + self.G.vertex_properties["selection"][self.G.vertex(c_id)] = 0.0
1118 self.path.remove(c_id) 1130 self.path.remove(c_id)
1119 self.data['a_selection'][c_id] = 0.0 1131 self.data['a_selection'][c_id] = 0.0
1120 update_vbo(self) 1132 update_vbo(self)
1121 print("I turned off a node") 1133 print("I turned off a node")
1122 - elif(G.vertex_properties["selection"][G.vertex(c_id)] == 0.0):  
1123 - G.vertex_properties["selection"][G.vertex(c_id)] = 1.0 1134 + elif(self.G.vertex_properties["selection"][self.G.vertex(c_id)] == 0.0):
  1135 + self.G.vertex_properties["selection"][self.G.vertex(c_id)] = 1.0
1124 if(c_id not in self.path): 1136 if(c_id not in self.path):
1125 self.path.append(c_id) 1137 self.path.append(c_id)
1126 self.data['a_selection'][c_id] = 1.0 1138 self.data['a_selection'][c_id] = 1.0
@@ -1131,7 +1143,7 @@ class GraphCanvas(scene.SceneCanvas): @@ -1131,7 +1143,7 @@ class GraphCanvas(scene.SceneCanvas):
1131 add_to_path(self, self.path[i], self.path[i+1]) 1143 add_to_path(self, self.path[i], self.path[i+1])
1132 update_vbo(self) 1144 update_vbo(self)
1133 #THIS IS WHERE I LEFT IT OFF. 1145 #THIS IS WHERE I LEFT IT OFF.
1134 - if(np.sum(G.vertex_properties["selection"].get_array()) == 0): 1146 + if(np.sum(self.G.vertex_properties["selection"].get_array()) == 0):
1135 self.pathing = False 1147 self.pathing = False
1136 1148
1137 1149
@@ -1236,7 +1248,7 @@ class GraphCanvas(scene.SceneCanvas): @@ -1236,7 +1248,7 @@ class GraphCanvas(scene.SceneCanvas):
1236 #Project into GLSpace and get before and after move coordinates 1248 #Project into GLSpace and get before and after move coordinates
1237 coord = self.transforms.get_transform('canvas', 'render').map(self.location)[:2] 1249 coord = self.transforms.get_transform('canvas', 'render').map(self.location)[:2]
1238 coord2 = self.transforms.get_transform('canvas', 'render').map(event.pos)[:2] 1250 coord2 = self.transforms.get_transform('canvas', 'render').map(event.pos)[:2]
1239 - cur_pos = G.vertex_properties["pos"][G.vertex(self.c_id[0])] 1251 + cur_pos = self.G.vertex_properties["pos"][self.G.vertex(self.c_id[0])]
1240 #print(cur_pos, " Before") 1252 #print(cur_pos, " Before")
1241 1253
1242 #Adjust the position of the node based on the current view matrix. 1254 #Adjust the position of the node based on the current view matrix.
@@ -1245,13 +1257,13 @@ class GraphCanvas(scene.SceneCanvas): @@ -1245,13 +1257,13 @@ class GraphCanvas(scene.SceneCanvas):
1245 1257
1246 #print(cur_pos, " After") 1258 #print(cur_pos, " After")
1247 #Upload the changed data. 1259 #Upload the changed data.
1248 - G.vertex_properties["pos"][G.vertex(self.c_id[0])] = cur_pos 1260 + self.G.vertex_properties["pos"][self.G.vertex(self.c_id[0])] = cur_pos
1249 self.data['a_position'][self.c_id[0]] = cur_pos 1261 self.data['a_position'][self.c_id[0]] = cur_pos
1250 1262
1251 #update the edge data by finding all edges connected to the vertex 1263 #update the edge data by finding all edges connected to the vertex
1252 v = self.G.vertex(self.c_id[0]) 1264 v = self.G.vertex(self.c_id[0])
1253 for e in v.all_edges(): 1265 for e in v.all_edges():
1254 - d = np.subtract(G.vertex_properties["pos"][e.source()], G.vertex_properties["pos"][e.target()]) 1266 + d = np.subtract(self.G.vertex_properties["pos"][e.source()], self.G.vertex_properties["pos"][e.target()])
1255 d_norm = d[0:2] 1267 d_norm = d[0:2]
1256 d_norm = d_norm / np.sqrt(np.power(d_norm[0],2) + np.power(d_norm[1],2)) 1268 d_norm = d_norm / np.sqrt(np.power(d_norm[0],2) + np.power(d_norm[1],2))
1257 norm = np.zeros((2,), dtype=np.float32) 1269 norm = np.zeros((2,), dtype=np.float32)
@@ -1319,7 +1331,7 @@ class GraphCanvas(scene.SceneCanvas): @@ -1319,7 +1331,7 @@ class GraphCanvas(scene.SceneCanvas):
1319 cur_pos[0] = cur_pos[0] - (coord[0]-coord2[0])/self.view[0][0] 1331 cur_pos[0] = cur_pos[0] - (coord[0]-coord2[0])/self.view[0][0]
1320 cur_pos[1] = cur_pos[1] - (coord[1]-coord2[1])/self.view[0][0] 1332 cur_pos[1] = cur_pos[1] - (coord[1]-coord2[1])/self.view[0][0]
1321 1333
1322 - self.update_cluster_position(G, cur_pos, offset, self.c_id[0]) 1334 + self.update_cluster_position(self.G, cur_pos, offset, self.c_id[0])
1323 #self.original_point = cur_pos 1335 #self.original_point = cur_pos
1324 self.vbo = gloo.VertexBuffer(self.data) 1336 self.vbo = gloo.VertexBuffer(self.data)
1325 self.vbo_line = gloo.VertexBuffer(self.line_data) 1337 self.vbo_line = gloo.VertexBuffer(self.line_data)
@@ -10,6 +10,7 @@ from GraphCanvas import GraphCanvas @@ -10,6 +10,7 @@ from GraphCanvas import GraphCanvas
10 from pyqtgraph.Qt import QtCore, QtGui, QtWidgets 10 from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
11 import network_dep as nwt 11 import network_dep as nwt
12 12
  13 +DEBUG = False
13 14
14 """ 15 """
15 Initializes the entire QTlayout and sets the mouse press events. 16 Initializes the entire QTlayout and sets the mouse press events.
@@ -68,21 +69,24 @@ class GraphWidget(QtGui.QWidget): @@ -68,21 +69,24 @@ class GraphWidget(QtGui.QWidget):
68 #EXP_adv = menu.addAction('Export VTK Advanced') 69 #EXP_adv = menu.addAction('Export VTK Advanced')
69 NL = menu.addAction('New Layout') 70 NL = menu.addAction('New Layout')
70 action = menu.exec_(event.native.globalPos()) 71 action = menu.exec_(event.native.globalPos())
71 - print(action) 72 + if DEBUG:
  73 + print(action)
72 for i in range(len(vertex_actions)): 74 for i in range(len(vertex_actions)):
73 if action == vertex_actions[i]: 75 if action == vertex_actions[i]:
74 if vertex_props[i] == "clusters": 76 if vertex_props[i] == "clusters":
75 self.canvas.color_vertices(self.canvas.G, vertex_props[i], dtype=True) 77 self.canvas.color_vertices(self.canvas.G, vertex_props[i], dtype=True)
76 else: 78 else:
77 self.canvas.color_vertices(self.canvas.G, vertex_props[i]) 79 self.canvas.color_vertices(self.canvas.G, vertex_props[i])
78 - print(vertex_props[i]) 80 +
  81 + if DEBUG:
  82 + print(vertex_props[i])
79 if action == NS: 83 if action == NS:
80 if self.use_3D == False: 84 if self.use_3D == False:
81 self.use_3D = True 85 self.use_3D = True
82 else: 86 else:
83 self.use_3D = False 87 self.use_3D = False
84 self.canvas.size_vertices(self.canvas.G, 'degree' ) 88 self.canvas.size_vertices(self.canvas.G, 'degree' )
85 - self.canvas.color_vertices(self.canvas.G) 89 + self.canvas.color_vertices(self.canvas.G, 'degree')
86 #if action == NC: 90 #if action == NC:
87 # self.canvas.color_vertices(self.canvas.G, not self.color) 91 # self.canvas.color_vertices(self.canvas.G, not self.color)
88 # self.color = not self.color 92 # self.color = not self.color
@@ -94,7 +98,8 @@ class GraphWidget(QtGui.QWidget): @@ -94,7 +98,8 @@ class GraphWidget(QtGui.QWidget):
94 # nwt.Network.write_vtk(self.canvas.G, "./nwt_points_wise_binned.vtk", camera=self.camera, binning = True) 98 # nwt.Network.write_vtk(self.canvas.G, "./nwt_points_wise_binned.vtk", camera=self.camera, binning = True)
95 # nwt.Network.write_vtk(self.canvas.G, "./nwt_points_wise_non_binned.vtk", camera=self.camera, binning = False) 99 # nwt.Network.write_vtk(self.canvas.G, "./nwt_points_wise_non_binned.vtk", camera=self.camera, binning = False)
96 if action == tmp: 100 if action == tmp:
97 - print("Stuff") 101 + if DEBUG:
  102 + print("Stuff")
98 #self.cb = QtWidgets.QComboBox() 103 #self.cb = QtWidgets.QComboBox()
99 #vertex_props = self.canvas.G.vertex_properties.keys() 104 #vertex_props = self.canvas.G.vertex_properties.keys()
100 #for i in range(len(vertex_props)): 105 #for i in range(len(vertex_props)):
@@ -171,7 +176,8 @@ class GraphWidget(QtGui.QWidget): @@ -171,7 +176,8 @@ class GraphWidget(QtGui.QWidget):
171 self.camera = [x,y,z] 176 self.camera = [x,y,z]
172 self.canvas.vertexSizeFromDistance(self.canvas.G, [x,y,z]) 177 self.canvas.vertexSizeFromDistance(self.canvas.G, [x,y,z])
173 self.canvas.vertexAlphaFromDistance(self.canvas.G, [x,y,z]) 178 self.canvas.vertexAlphaFromDistance(self.canvas.G, [x,y,z])
174 - #print("got signal", x, y, z) 179 + if DEBUG:
  180 + print("got signal", x, y, z)
175 181
176 """ 182 """
177 Initialization method that connects the slot to the function that handles 183 Initialization method that connects the slot to the function that handles
@@ -25,6 +25,9 @@ from GraphWidget import GraphWidget @@ -25,6 +25,9 @@ from GraphWidget import GraphWidget
25 from TubeWidget import TubeWidget 25 from TubeWidget import TubeWidget
26 26
27 27
  28 +DEBUG = False
  29 +
  30 +
28 #set the backend. for different versions of PyQt 31 #set the backend. for different versions of PyQt
29 app.use_app(backend_name='PyQt5') 32 app.use_app(backend_name='PyQt5')
30 33
@@ -93,7 +96,9 @@ G, bbl, bbu = load_nwt("/home/pavel/Documents/Python/GraphGuiQt/network_4.nwt") @@ -93,7 +96,9 @@ G, bbl, bbu = load_nwt("/home/pavel/Documents/Python/GraphGuiQt/network_4.nwt")
93 #ret = nwt.Network.get_affinity_matrix(G, "length") 96 #ret = nwt.Network.get_affinity_matrix(G, "length")
94 node_image = QtGui.QImage("/home/pavel/Documents/Python/GraphGuiQt/node_tex.jpg") 97 node_image = QtGui.QImage("/home/pavel/Documents/Python/GraphGuiQt/node_tex.jpg")
95 node_tex = QtGui.QBitmap.fromImage(node_image) 98 node_tex = QtGui.QBitmap.fromImage(node_image)
96 -print(node_tex.depth()) 99 +
  100 +if DEBUG:
  101 + print(node_tex.depth())
97 center = (bbu-bbl)/2.0 102 center = (bbu-bbl)/2.0
98 #fibers.opts['distance'] = 5 103 #fibers.opts['distance'] = 5
99 # item = NodeItem(G) 104 # item = NodeItem(G)
@@ -23,6 +23,12 @@ import network_dep as nwt @@ -23,6 +23,12 @@ import network_dep as nwt
23 23
24 from tube_shaders import FRAG_SHADER, VERT_SHADER 24 from tube_shaders import FRAG_SHADER, VERT_SHADER
25 25
  26 +from mpl_toolkits.mplot3d import Axes3D
  27 +import matplotlib
  28 +import matplotlib.pyplot as plt
  29 +
  30 +DEBUG = False
  31 +
26 class TubeDraw(scene.SceneCanvas): 32 class TubeDraw(scene.SceneCanvas):
27 #sigUpdate = QtCore.pyqtSignal(float, float, float) 33 #sigUpdate = QtCore.pyqtSignal(float, float, float)
28 34
@@ -105,7 +111,8 @@ class TubeDraw(scene.SceneCanvas): @@ -105,7 +111,8 @@ class TubeDraw(scene.SceneCanvas):
105 for j in range(3): 111 for j in range(3):
106 self.bb[i,j] = bb[i][j] 112 self.bb[i,j] = bb[i][j]
107 self.program['u_bb'] = self.bb 113 self.program['u_bb'] = self.bb
108 - print('bb is ', self.bb) 114 + if DEBUG:
  115 + print('bb is ', self.bb)
109 # for i in range(len(self.translate)): 116 # for i in range(len(self.translate)):
110 # self.camera[i] += self.translate[i] 117 # self.camera[i] += self.translate[i]
111 118
@@ -127,7 +134,8 @@ class TubeDraw(scene.SceneCanvas): @@ -127,7 +134,8 @@ class TubeDraw(scene.SceneCanvas):
127 def on_resize(self, event): 134 def on_resize(self, event):
128 width, height = event.physical_size 135 width, height = event.physical_size
129 gloo.set_viewport(0, 0, width, height) 136 gloo.set_viewport(0, 0, width, height)
130 - print(self.physical_size) 137 + if DEBUG:
  138 + print(self.physical_size)
131 139
132 #overloaded function called during the self.update() call to update the current 140 #overloaded function called during the self.update() call to update the current
133 #frame using the GLSL frag/vert shaders 141 #frame using the GLSL frag/vert shaders
@@ -294,32 +302,32 @@ class TubeDraw(scene.SceneCanvas): @@ -294,32 +302,32 @@ class TubeDraw(scene.SceneCanvas):
294 #Add the caps for each of the endpoints. 302 #Add the caps for each of the endpoints.
295 303
296 304
297 -  
298 - if(i == 2):  
299 - fig = plt.figure()  
300 - ax = fig.add_subplot(111, projection='3d')  
301 - #ax.scatter(circle_pts[:,:,0], circle_pts[:,:,1], circle_pts[:,:,2])  
302 - ax.plot(pts[:,0], pts[:,1], pts[:,2])  
303 - for j in range(pts.shape[0]):  
304 - ax.plot(circle_pts[j,:,0], circle_pts[j,:,1], circle_pts[j,:,2])  
305 - for j in range(triangles.shape[0]):  
306 - tri = np.zeros((3,4))  
307 - tri[:,0] = self.cylinder_data['a_position'][triangles[j][0]]  
308 - tri[:,1] = self.cylinder_data['a_position'][triangles[j][1]]  
309 - tri[:,2] = self.cylinder_data['a_position'][triangles[j][2]]  
310 - tri[:,3] = self.cylinder_data['a_position'][triangles[j][0]]  
311 - ax.plot(tri[0,:], tri[1,:], tri[2,:], c='b')  
312 - for j in range(triangles.shape[0]):  
313 - tri = np.zeros((3,3))  
314 - tri[:,0] = self.cylinder_data['a_position'][triangles[j][0]]  
315 - tri[:,1] = self.cylinder_data['a_position'][triangles[j][1]]  
316 - tri[:,2] = self.cylinder_data['a_position'][triangles[j][2]]  
317 - norm = np.zeros((3,3))  
318 - norm[:,0] = self.cylinder_data['a_normal'][triangles[j][0]]  
319 - norm[:,1] = self.cylinder_data['a_normal'][triangles[j][1]]  
320 - norm[:,2] = self.cylinder_data['a_normal'][triangles[j][2]]  
321 - ax.quiver(tri[0,:], tri[1,:], tri[2,:], norm[0,:], norm[1,:], norm[2,:], colors = 'r')  
322 - plt.show() 305 + if DEBUG:
  306 + if(i == 2):
  307 + fig = plt.figure()
  308 + ax = fig.add_subplot(111, projection='3d')
  309 + #ax.scatter(circle_pts[:,:,0], circle_pts[:,:,1], circle_pts[:,:,2])
  310 + ax.plot(pts[:,0], pts[:,1], pts[:,2])
  311 + for j in range(pts.shape[0]):
  312 + ax.plot(circle_pts[j,:,0], circle_pts[j,:,1], circle_pts[j,:,2])
  313 + for j in range(triangles.shape[0]):
  314 + tri = np.zeros((3,4))
  315 + tri[:,0] = self.cylinder_data['a_position'][triangles[j][0]]
  316 + tri[:,1] = self.cylinder_data['a_position'][triangles[j][1]]
  317 + tri[:,2] = self.cylinder_data['a_position'][triangles[j][2]]
  318 + tri[:,3] = self.cylinder_data['a_position'][triangles[j][0]]
  319 + ax.plot(tri[0,:], tri[1,:], tri[2,:], c='b')
  320 + for j in range(triangles.shape[0]):
  321 + tri = np.zeros((3,3))
  322 + tri[:,0] = self.cylinder_data['a_position'][triangles[j][0]]
  323 + tri[:,1] = self.cylinder_data['a_position'][triangles[j][1]]
  324 + tri[:,2] = self.cylinder_data['a_position'][triangles[j][2]]
  325 + norm = np.zeros((3,3))
  326 + norm[:,0] = self.cylinder_data['a_normal'][triangles[j][0]]
  327 + norm[:,1] = self.cylinder_data['a_normal'][triangles[j][1]]
  328 + norm[:,2] = self.cylinder_data['a_normal'][triangles[j][2]]
  329 + ax.quiver(tri[0,:], tri[1,:], tri[2,:], norm[0,:], norm[1,:], norm[2,:], colors = 'r')
  330 + plt.show()
323 i+=1 331 i+=1
324 #create the data. 332 #create the data.
325 333
@@ -387,7 +395,8 @@ class TubeDraw(scene.SceneCanvas): @@ -387,7 +395,8 @@ class TubeDraw(scene.SceneCanvas):
387 395
388 theta = (coord[0]-coord2[0])*360.0/2.0/np.pi 396 theta = (coord[0]-coord2[0])*360.0/2.0/np.pi
389 phi = (coord[1]-coord2[1])*360.0/2.0/np.pi 397 phi = (coord[1]-coord2[1])*360.0/2.0/np.pi
390 - print(theta*360.0/2.0/np.pi, -phi*360.0/2.0/np.pi) 398 + if DEBUG:
  399 + print(theta*360.0/2.0/np.pi, -phi*360.0/2.0/np.pi)
391 self.camera = self.camera - self.translate 400 self.camera = self.camera - self.translate
392 q1 = Quaternion.create_from_axis_angle(angle=phi, ax=0.0, ay=1.0, az=0.0, degrees=True) 401 q1 = Quaternion.create_from_axis_angle(angle=phi, ax=0.0, ay=1.0, az=0.0, degrees=True)
393 q2 = Quaternion.create_from_axis_angle(angle=theta, ax=1.0, ay=0.0, az=0.0, degrees=True) 402 q2 = Quaternion.create_from_axis_angle(angle=theta, ax=1.0, ay=0.0, az=0.0, degrees=True)
@@ -432,7 +441,8 @@ class TubeDraw(scene.SceneCanvas): @@ -432,7 +441,8 @@ class TubeDraw(scene.SceneCanvas):
432 #self.camera[0] = self.camera[0] + self.center[0] 441 #self.camera[0] = self.camera[0] + self.center[0]
433 #self.camera[1] = self.camera[1] + self.center[1] 442 #self.camera[1] = self.camera[1] + self.center[1]
434 #self.camera[2] = self.camera[2] - self.center[2] 443 #self.camera[2] = self.camera[2] - self.center[2]
435 - print("current position ", self.camera, " and up vector ", self.up) 444 + if DEBUG:
  445 + print("current position ", self.camera, " and up vector ", self.up)
436 self.program['u_eye'] = self.camera 446 self.program['u_eye'] = self.camera
437 self.program['u_up'] = self.up 447 self.program['u_up'] = self.up
438 self.program['u_LightPos'] = [self.camera[0], self.camera[1], self.camera[2]] 448 self.program['u_LightPos'] = [self.camera[0], self.camera[1], self.camera[2]]
@@ -14,6 +14,8 @@ Created on Mon Aug 5 15:53:16 2019 @@ -14,6 +14,8 @@ Created on Mon Aug 5 15:53:16 2019
14 from pyqtgraph.Qt import QtCore, QtGui, QtWidgets 14 from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
15 from TubeCanvas import TubeDraw 15 from TubeCanvas import TubeDraw
16 16
  17 +DEBUG = False
  18 +
17 class TubeWidget(QtGui.QWidget): 19 class TubeWidget(QtGui.QWidget):
18 sigUpdate = QtCore.pyqtSignal(float, float, float) 20 sigUpdate = QtCore.pyqtSignal(float, float, float)
19 #Initializes the QT wrapper class. 21 #Initializes the QT wrapper class.
@@ -60,6 +62,7 @@ class TubeWidget(QtGui.QWidget): @@ -60,6 +62,7 @@ class TubeWidget(QtGui.QWidget):
60 #self.view = self.canvas.view 62 #self.view = self.canvas.view
61 self.camera = self.canvas.camera 63 self.camera = self.canvas.camera
62 #print("stuff", self.view[3, 0], self.view[3, 1], self.view[3, 2]) 64 #print("stuff", self.view[3, 0], self.view[3, 1], self.view[3, 2])
63 - print("stuff", self.camera[0], self.camera[1], self.camera[2]) 65 + if DEBUG:
  66 + print("stuff", self.camera[0], self.camera[1], self.camera[2])
64 self.sigUpdate.emit(self.camera[0], self.camera[1], self.camera[2]) 67 self.sigUpdate.emit(self.camera[0], self.camera[1], self.camera[2])
65 68
@@ -27,6 +27,8 @@ import copy @@ -27,6 +27,8 @@ import copy
27 #import matplotlib.pyplot as plt 27 #import matplotlib.pyplot as plt
28 #from matplotlib import cm 28 #from matplotlib import cm
29 29
  30 +DEBUG = False
  31 +
30 ''' 32 '''
31 Definition of the Node class 33 Definition of the Node class
32 Duplicate of the node class in network 34 Duplicate of the node class in network
@@ -81,9 +83,9 @@ class Fiber: @@ -81,9 +83,9 @@ class Fiber:
81 for i in range(len(self.points)-1): 83 for i in range(len(self.points)-1):
82 length = length + math.sqrt(pow(self.points[i][0]- self.points[i+1][0],2) + pow(self.points[i][1]- self.points[i+1][1],2) + pow(self.points[i][2]- self.points[i+1][2],2)) 84 length = length + math.sqrt(pow(self.points[i][0]- self.points[i+1][0],2) + pow(self.points[i][1]- self.points[i+1][1],2) + pow(self.points[i][2]- self.points[i+1][2],2))
83 if(length == 0): 85 if(length == 0):
84 - print(self.points)  
85 - print(len(self.points))  
86 - print(self.v0, " ", self.v1) 86 + print("NON-CRITICAL ERROR: edge with length 0 is detected: IDX = "\
  87 + , i, ", points = ", self.points, " len(points) = ", len(self.points)\
  88 + , " vertices = ", self.v0, " ", self.v1)
87 return length 89 return length
88 90
89 ''' 91 '''
@@ -396,12 +398,12 @@ class AABB(): @@ -396,12 +398,12 @@ class AABB():
396 398
397 399
398 vertices = list(np.unique(np.array(vertices), axis=0)) 400 vertices = list(np.unique(np.array(vertices), axis=0))
399 - import matplotlib.pyplot as plt  
400 - fig = plt.figure()  
401 - ax = plt.axes(projection='3d')  
402 - ax.scatter3D(np.array(vertices)[:, 0], np.array(vertices)[:, 1], np.array(vertices)[:, 2]) 401 + #import matplotlib.pyplot as plt
  402 + #fig = plt.figure()
  403 + #ax = plt.axes(projection='3d')
  404 + #ax.scatter3D(np.array(vertices)[:, 0], np.array(vertices)[:, 1], np.array(vertices)[:, 2])
403 405
404 - print("THERE ARE THIS MANY ", len(vertices)) 406 + #print("THERE ARE THIS MANY ", len(vertices))
405 return vertices 407 return vertices
406 408
407 def getVolume(self): 409 def getVolume(self):
@@ -417,42 +419,49 @@ class AABB(): @@ -417,42 +419,49 @@ class AABB():
417 temp = copy.deepcopy(self.A) 419 temp = copy.deepcopy(self.A)
418 temp[0] = temp[0] + size[0] 420 temp[0] = temp[0] + size[0]
419 points.append(temp) 421 points.append(temp)
420 - print('1', temp) 422 + if DEBUG:
  423 + print('1', temp)
421 424
422 temp = copy.deepcopy(self.A) 425 temp = copy.deepcopy(self.A)
423 temp[1] = temp[1] + size[1] 426 temp[1] = temp[1] + size[1]
424 points.append(temp) 427 points.append(temp)
425 - print('1', temp) 428 + if DEBUG:
  429 + print('1', temp)
426 430
427 temp = copy.deepcopy(self.A) 431 temp = copy.deepcopy(self.A)
428 temp[2] = temp[2] + size[2] 432 temp[2] = temp[2] + size[2]
429 points.append(temp) 433 points.append(temp)
430 - print('1', temp) 434 + if DEBUG:
  435 + print('1', temp)
431 436
432 temp = copy.deepcopy(self.A) 437 temp = copy.deepcopy(self.A)
433 temp[1] = temp[1] + size[1] 438 temp[1] = temp[1] + size[1]
434 temp[0] = temp[0] + size[0] 439 temp[0] = temp[0] + size[0]
435 points.append(temp) 440 points.append(temp)
436 - print('1', temp) 441 + if DEBUG:
  442 + print('1', temp)
437 443
438 temp = copy.deepcopy(self.A) 444 temp = copy.deepcopy(self.A)
439 temp[2] = temp[2] + size[2] 445 temp[2] = temp[2] + size[2]
440 temp[0] = temp[0] + size[0] 446 temp[0] = temp[0] + size[0]
441 points.append(temp) 447 points.append(temp)
442 - print('1', temp) 448 + if DEBUG:
  449 + print('1', temp)
443 450
444 temp = copy.deepcopy(self.A) 451 temp = copy.deepcopy(self.A)
445 temp[1] = temp[1] + size[1] 452 temp[1] = temp[1] + size[1]
446 temp[2] = temp[2] + size[2] 453 temp[2] = temp[2] + size[2]
447 points.append(temp) 454 points.append(temp)
448 - print('1', temp) 455 + if DEBUG:
  456 + print('1', temp)
449 457
450 temp = copy.deepcopy(self.A) 458 temp = copy.deepcopy(self.A)
451 temp[0] = temp[0] + size[0] 459 temp[0] = temp[0] + size[0]
452 temp[1] = temp[1] + size[1] 460 temp[1] = temp[1] + size[1]
453 temp[2] = temp[2] + size[2] 461 temp[2] = temp[2] + size[2]
454 points.append(temp) 462 points.append(temp)
455 - print('1', temp) 463 + if DEBUG:
  464 + print('1', temp)
456 465
457 return points 466 return points
458 467
@@ -908,7 +917,8 @@ class Network: @@ -908,7 +917,8 @@ class Network:
908 917
909 def simulate_fractures(self, G, remove=10): 918 def simulate_fractures(self, G, remove=10):
910 num_removed = int(np.floor(G.num_edges()*remove/100)) 919 num_removed = int(np.floor(G.num_edges()*remove/100))
911 - print("num of edges to begin with = ", G.num_edges()) 920 + if DEBUG:
  921 + print("num of edges to begin with = ", G.num_edges())
912 indices = np.random.randint(0, int(G.num_edges()), size = [num_removed,1]) 922 indices = np.random.randint(0, int(G.num_edges()), size = [num_removed,1])
913 #aabb = AABB(G, is_dual) 923 #aabb = AABB(G, is_dual)
914 tf = np.full((G.num_edges(), 1), True, dtype=bool) 924 tf = np.full((G.num_edges(), 1), True, dtype=bool)
@@ -921,9 +931,10 @@ class Network: @@ -921,9 +931,10 @@ class Network:
921 G1.clear_filters() 931 G1.clear_filters()
922 G1 = self.filterDisconnected(G1) 932 G1 = self.filterDisconnected(G1)
923 G1.vertex_properties["degree"] = G1.degree_property_map("total") 933 G1.vertex_properties["degree"] = G1.degree_property_map("total")
924 - print("num of edges left = ", G1.num_edges())  
925 - print("I should have removed, ", num_removed)  
926 - print("Instead I removed, ", G.num_edges() - G1.num_edges()) 934 + if DEBUG:
  935 + print("num of edges left = ", G1.num_edges())
  936 + print("I should have removed, ", num_removed)
  937 + print("Instead I removed, ", G.num_edges() - G1.num_edges())
927 938
928 return G1 939 return G1
929 940
@@ -992,7 +1003,8 @@ class Network: @@ -992,7 +1003,8 @@ class Network:
992 1003
993 G.edge_properties["mst"] = gt.graph_tool.topology.min_spanning_tree(G, weights=G.edge_properties["length"]) 1004 G.edge_properties["mst"] = gt.graph_tool.topology.min_spanning_tree(G, weights=G.edge_properties["length"])
994 G.graph_properties["mst_ratio"] = np.double(np.sum(G.edge_properties["mst"].get_array()))/np.double(G.num_edges()) 1005 G.graph_properties["mst_ratio"] = np.double(np.sum(G.edge_properties["mst"].get_array()))/np.double(G.num_edges())
995 - print(np.double(np.sum(G.edge_properties["mst"].get_array()))/np.double(G.num_edges())) 1006 + if DEBUG:
  1007 + print(np.double(np.sum(G.edge_properties["mst"].get_array()))/np.double(G.num_edges()))
996 G.vertex_properties["degree"] = G.degree_property_map("total") 1008 G.vertex_properties["degree"] = G.degree_property_map("total")
997 G.vertex_properties["degree_volume"] = G.degree_property_map("total", weight=G.edge_properties["volume"]) 1009 G.vertex_properties["degree_volume"] = G.degree_property_map("total", weight=G.edge_properties["volume"])
998 G.vertex_properties["degree_tortuosity"] = G.degree_property_map("total", G.edge_properties["tortuosity"]) 1010 G.vertex_properties["degree_tortuosity"] = G.degree_property_map("total", G.edge_properties["tortuosity"])
@@ -1065,9 +1077,11 @@ class Network: @@ -1065,9 +1077,11 @@ class Network:
1065 G1 = self.filterBorder(G, is_dual=dual); 1077 G1 = self.filterBorder(G, is_dual=dual);
1066 if(erode == True): 1078 if(erode == True):
1067 while(np.any(G1.degree_property_map("total").get_array() == True)): 1079 while(np.any(G1.degree_property_map("total").get_array() == True)):
1068 - print(G1.num_vertices()) 1080 + if DEBUG:
  1081 + print(G1.num_vertices())
1069 G1 = self.filterBorder(G1, is_dual=dual) 1082 G1 = self.filterBorder(G1, is_dual=dual)
1070 - print(G1.num_vertices()) 1083 + if DEBUG:
  1084 + print(G1.num_vertices())
1071 G1 = self.recalculate_metrics(G1, is_dual=dual, ) 1085 G1 = self.recalculate_metrics(G1, is_dual=dual, )
1072 else: 1086 else:
1073 G1 = self.recalculate_metrics(G1, is_dual=dual) 1087 G1 = self.recalculate_metrics(G1, is_dual=dual)
@@ -1331,7 +1345,7 @@ class Network: @@ -1331,7 +1345,7 @@ class Network:
1331 r_edge[G.edge(v0,v1)] = r 1345 r_edge[G.edge(v0,v1)] = r
1332 av_edge[G.edge(v0,v1)] = self.F[i].av_radius() 1346 av_edge[G.edge(v0,v1)] = self.F[i].av_radius()
1333 else: 1347 else:
1334 - print("WTF") 1348 + print("NON-CRITICAL ERROR: edge with length 0 detected--SKIPPED")
1335 1349
1336 1350
1337 #generate centrality map 1351 #generate centrality map
@@ -1574,7 +1588,8 @@ class Network: @@ -1574,7 +1588,8 @@ class Network:
1574 #This is when the property map is integers 1588 #This is when the property map is integers
1575 #int32_t when integer 1589 #int32_t when integer
1576 value_type = propertymap.value_type() 1590 value_type = propertymap.value_type()
1577 - print(value_type) 1591 + if DEBUG:
  1592 + print(value_type)
1578 if(value_type == "int32_t"): 1593 if(value_type == "int32_t"):
1579 array = propertymap.get_array() 1594 array = propertymap.get_array()
1580 colors = cm.get_cmap(colormap, len(np.unique(array))) 1595 colors = cm.get_cmap(colormap, len(np.unique(array)))
@@ -1589,7 +1604,8 @@ class Network: @@ -1589,7 +1604,8 @@ class Network:
1589 colors = cm.ScalarMappable(norm=norm, cmap=colormap) 1604 colors = cm.ScalarMappable(norm=norm, cmap=colormap)
1590 if key_type =='v': 1605 if key_type =='v':
1591 for v in G.vertices(): 1606 for v in G.vertices():
1592 - print(colors.to_rgba(propertymap[v])) 1607 + if DEBUG:
  1608 + print(colors.to_rgba(propertymap[v]))
1593 G.vertex_properties["RGBA"][v] = colors.to_rgba(propertymap[v]) 1609 G.vertex_properties["RGBA"][v] = colors.to_rgba(propertymap[v])
1594 return G.vertex_properties["RGBA"] 1610 return G.vertex_properties["RGBA"]
1595 elif(value_type == 'vector<double>' or value_type == 'vector<float>'): 1611 elif(value_type == 'vector<double>' or value_type == 'vector<float>'):
@@ -1628,6 +1644,7 @@ class Network: @@ -1628,6 +1644,7 @@ class Network:
1628 if d < dist: 1644 if d < dist:
1629 idx = M 1645 idx = M
1630 dist = d 1646 dist = d
  1647 + #if DEBUG:
1631 print(idx, " vertex[",p[0][idx], p[1][idx], p[2][idx], "], point [", x[i], y[j], z[k], "]") 1648 print(idx, " vertex[",p[0][idx], p[1][idx], p[2][idx], "], point [", x[i], y[j], z[k], "]")
1632 clusters = G.new_vertex_property("int", vals=np.full((G.num_vertices(), 1), -1, dtype=int)) 1649 clusters = G.new_vertex_property("int", vals=np.full((G.num_vertices(), 1), -1, dtype=int))
1633 #eclusters = G.new_edge_property("int", vals=np.full((G.num_edges(), 1), -1, dtype=int)) 1650 #eclusters = G.new_edge_property("int", vals=np.full((G.num_edges(), 1), -1, dtype=int))
@@ -1741,10 +1758,12 @@ class Network: @@ -1741,10 +1758,12 @@ class Network:
1741 eclusters = G1.new_edge_property("int", vals = np.full((G1.num_edges(), 1), 3, dtype=int)) 1758 eclusters = G1.new_edge_property("int", vals = np.full((G1.num_edges(), 1), 3, dtype=int))
1742 G1.vertex_properties["cycle"] = clusters 1759 G1.vertex_properties["cycle"] = clusters
1743 G1.edge_properties["cycle"] = eclusters 1760 G1.edge_properties["cycle"] = eclusters
1744 - print("Number of vertices in Path is:", len(Vl)) 1761 + if DEBUG:
  1762 + print("Number of vertices in Path is:", len(Vl))
1745 for v in Vl: 1763 for v in Vl:
1746 G1.vertex_properties["cycle"][G1.vertex(v)] = 10 1764 G1.vertex_properties["cycle"][G1.vertex(v)] = 10
1747 - print(str(v)) 1765 + if DEBUG:
  1766 + print(str(v))
1748 #Create the arrays to be histogrammed later regarding every loop 1767 #Create the arrays to be histogrammed later regarding every loop
1749 length_total = 0 1768 length_total = 0
1750 volume_total = 0 1769 volume_total = 0
@@ -1815,10 +1834,10 @@ class Network: @@ -1815,10 +1834,10 @@ class Network:
1815 n_components = G1.num_vertices() 1834 n_components = G1.num_vertices()
1816 eigenvalues, eigenvectors = eigsh(L, k=n_components, which = "LM", sigma=1.0, maxiter = 5000) 1835 eigenvalues, eigenvectors = eigsh(L, k=n_components, which = "LM", sigma=1.0, maxiter = 5000)
1817 1836
1818 - plt.figure()  
1819 - plt.scatter(np.arange(len(eigenvalues)), eigenvalues)  
1820 - plt.grid()  
1821 - plt.show() 1837 + #plt.figure()
  1838 + #plt.scatter(np.arange(len(eigenvalues)), eigenvalues)
  1839 + #plt.grid()
  1840 + #plt.show()
1822 1841
1823 count = sum(eigenvalues > 1.01) 1842 count = sum(eigenvalues > 1.01)
1824 return count 1843 return count
@@ -1915,8 +1934,9 @@ class Network: @@ -1915,8 +1934,9 @@ class Network:
1915 if binning: 1934 if binning:
1916 index = np.digitize(G.edge_properties["RGBA"][e][3], bins, right=True) 1935 index = np.digitize(G.edge_properties["RGBA"][e][3], bins, right=True)
1917 if (index >= len(bins) or index < 0): 1936 if (index >= len(bins) or index < 0):
1918 - print(G.edge_properties["RGBA"][e][3])  
1919 - print(index) 1937 + if DEBUG:
  1938 + print(G.edge_properties["RGBA"][e][3])
  1939 + print(index)
1920 f.write("%.15f\n" % bins[index]) 1940 f.write("%.15f\n" % bins[index])
1921 else: 1941 else:
1922 f.write("%.15f\n" % G.edge_properties["RGBA"][e][3]) 1942 f.write("%.15f\n" % G.edge_properties["RGBA"][e][3])
@@ -2036,7 +2056,7 @@ class Network: @@ -2036,7 +2056,7 @@ class Network:
2036 #generate a KD-Tree out of the network point array 2056 #generate a KD-Tree out of the network point array
2037 tree = sp.spatial.cKDTree(P) 2057 tree = sp.spatial.cKDTree(P)
2038 2058
2039 - plt.scatter(P[:, 0], P[:, 1]) 2059 + #plt.scatter(P[:, 0], P[:, 1])
2040 2060
2041 #specify the resolution of the ouput grid 2061 #specify the resolution of the ouput grid
2042 R = (200, 200, 200) 2062 R = (200, 200, 200)