@@ -214,16 +214,16 @@ def cmat(track_file, roi_file, resolution_network_file, matrix_name, matrix_mat_
214214 nROIs = len (gp .nodes ())
215215
216216 # add node information from parcellation
217- if 'dn_position' in gp .node [ gp .nodes ()[0 ]]:
217+ if 'dn_position' in gp .nodes [ list ( gp .nodes () )[0 ]]:
218218 G = gp .copy ()
219219 else :
220220 G = nx .Graph ()
221- for u , d in gp .nodes_iter (data = True ):
222- G .add_node (int (u ), d )
221+ for u , d in gp .nodes (data = True ):
222+ G .add_node (int (u ), ** d )
223223 # compute a position for the node based on the mean position of the
224224 # ROI in voxel coordinates (segmentation volume )
225225 xyz = tuple (np .mean (np .where (np .flipud (roiData ) == int (d ["dn_correspondence_id" ])), axis = 1 ))
226- G .node [int (u )]['dn_position' ] = tuple ([xyz [0 ], xyz [2 ], - xyz [1 ]])
226+ G .nodes [int (u )]['dn_position' ] = tuple ([xyz [0 ], xyz [2 ], - xyz [1 ]])
227227
228228 if intersections :
229229 iflogger .info ("Filtering tractography from intersections" )
@@ -304,7 +304,7 @@ def cmat(track_file, roi_file, resolution_network_file, matrix_name, matrix_mat_
304304 fibmean = numfib .copy ()
305305 fibmedian = numfib .copy ()
306306 fibdev = numfib .copy ()
307- for u , v , d in G .edges_iter (data = True ):
307+ for u , v , d in G .edges (data = True ):
308308 G .remove_edge (u , v )
309309 di = {}
310310 if 'fiblist' in d :
@@ -319,7 +319,7 @@ def cmat(track_file, roi_file, resolution_network_file, matrix_name, matrix_mat_
319319 di ['fiber_length_median' ] = 0
320320 di ['fiber_length_std' ] = 0
321321 if not u == v : # Fix for self loop problem
322- G .add_edge (u , v , di )
322+ G .add_edge (u , v , ** di )
323323 if 'fiblist' in d :
324324 numfib .add_edge (u , v , weight = di ['number_of_fibers' ])
325325 fibmean .add_edge (u , v , weight = di ['fiber_length_mean' ])
@@ -747,10 +747,10 @@ def create_nodes(roi_file, resolution_network_file, out_filename):
747747 roi_image = nb .load (roi_file , mmap = NUMPY_MMAP )
748748 roiData = roi_image .get_data ()
749749 nROIs = len (gp .nodes ())
750- for u , d in gp .nodes_iter (data = True ):
751- G .add_node (int (u ), d )
750+ for u , d in gp .nodes (data = True ):
751+ G .add_node (int (u ), ** d )
752752 xyz = tuple (np .mean (np .where (np .flipud (roiData ) == int (d ["dn_correspondence_id" ])), axis = 1 ))
753- G .node [int (u )]['dn_position' ] = tuple ([xyz [0 ], xyz [2 ], - xyz [1 ]])
753+ G .nodes [int (u )]['dn_position' ] = tuple ([xyz [0 ], xyz [2 ], - xyz [1 ]])
754754 nx .write_gpickle (G , out_filename )
755755 return out_filename
756756
0 commit comments