code: def create_nodes(roi_file, resolution_network_file, out_filename):
      G = nx.Graph()
      gp = nx.read_graphml(resolution_network_file)
      roi_image = nb.load(roi_file)
      # Preserve on-disk type unless scaled
      roiData = np.asanyarray(roi_image.dataobj)
      for u, d in gp.nodes(data=True):
          G.add_node(int(u), **d)
          xyz = tuple(
              np.mean(
                  np.where(
                      np.flipud(roiData)
                      == int(d["dn_correspondence_id"])
                  ),
                  axis=1,
              )
          )
          G.nodes[int(u)]["dn_position"] = tuple(
              [xyz[0], xyz[2], -xyz[1]]
          )
      with open(out_filename, "wb") as f:
          pickle.dump(G, f, pickle.HIGHEST_PROTOCOL)
      return out_filename
  
imports: import pickle
  import os.path
  import numpy
  import nibabel
  import networkx
  from ...None import logging
  from ...utils.filemanip import split_filename
  from ..base import BaseInterface, BaseInterfaceInputSpec, traits, File, TraitedSpec, Directory, OutputMultiPath, isdefined
label_desc: Use image node_id 8 for calling a global function with example usage: create_nodes(roi_file, resolution_network_file, out_filename) and returns: out_filename