code: def create_endpoints_array(fib, voxelSize):
      """Create the endpoints arrays for each fiber.
  
      Parameters
      ----------
      fib : array-like
        the fibers data
      voxelSize : tuple
        3-tuple containing the voxel size of the ROI image
  
      Returns
      -------
      endpoints : ndarray of size [#fibers, 2, 3]
        containing for each fiber the index of its first and last point in the voxelSize volume
      endpointsmm : ndarray of size [#fibers, 2, 3]
        endpoints in millimeter coordinates
  
      """
      # Init
      n = len(fib)
      endpoints = np.zeros((n, 2, 3))
      endpointsmm = np.zeros((n, 2, 3))
  
      # Computation for each fiber
      for i, fi in enumerate(fib):
          f = fi[0]
  
          # store startpoint
          endpoints[i, 0, :] = f[0, :]
          # store endpoint
          endpoints[i, 1, :] = f[-1, :]
  
          # store startpoint
          endpointsmm[i, 0, :] = f[0, :]
          # store endpoint
          endpointsmm[i, 1, :] = f[-1, :]
  
          # Translate from mm to index
          endpoints[i, 0, 0] = int(
              endpoints[i, 0, 0] / float(voxelSize[0])
          )
          endpoints[i, 0, 1] = int(
              endpoints[i, 0, 1] / float(voxelSize[1])
          )
          endpoints[i, 0, 2] = int(
              endpoints[i, 0, 2] / float(voxelSize[2])
          )
          endpoints[i, 1, 0] = int(
              endpoints[i, 1, 0] / float(voxelSize[0])
          )
          endpoints[i, 1, 1] = int(
              endpoints[i, 1, 1] / float(voxelSize[1])
          )
          endpoints[i, 1, 2] = int(
              endpoints[i, 1, 2] / float(voxelSize[2])
          )
  
      # Return the matrices
      iflogger.info("Returning the endpoint matrix")
      return (endpoints, endpointsmm)
  
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 5 for calling a global function with example usage: create_endpoints_array(fib, voxelSize) and returns: endpoints,  endpointsmm