code: def length(xyz, along=False):
      """
      Euclidean length of track line
  
      Parameters
      ----------
      xyz : array-like shape (N,3)
         array representing x,y,z of N points in a track
      along : bool, optional
         If True, return array giving cumulative length along track,
         otherwise (default) return scalar giving total length.
  
      Returns
      -------
      L : scalar or array shape (N-1,)
         scalar in case of `along` == False, giving total length, array if
         `along` == True, giving cumulative lengths.
  
      Examples
      --------
      >>> xyz = np.array([[1,1,1],[2,3,4],[0,0,0]])
      >>> expected_lens = np.sqrt([1+2**2+3**2, 2**2+3**2+4**2])
      >>> length(xyz) == expected_lens.sum()
      True
      >>> len_along = length(xyz, along=True)
      >>> np.allclose(len_along, expected_lens.cumsum())
      True
      >>> length([])
      0
      >>> length([[1, 2, 3]])
      0
      >>> length([], along=True)
      array([0])
      """
      xyz = np.asarray(xyz)
      if xyz.shape[0] < 2:
          if along:
              return np.array([0])
          return 0
      dists = np.sqrt((np.diff(xyz, axis=0) ** 2).sum(axis=1))
      if along:
          return np.cumsum(dists)
      return np.sum(dists)
  
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 1 for calling a global function with example usage: length(xyz, along) and returns: np, int, np, np