code: def _find_seeg_electrode_shaft(pos, tol=2e-3):
      # 1) find nearest neighbor to define the electrode shaft line
      # 2) find all contacts on the same line
  
      dist = squareform(pdist(pos))
      np.fill_diagonal(dist, np.inf)
  
      shafts = list()
      for i, n1 in enumerate(pos):
          if any([i in shaft for shaft in shafts]):
              continue
          n2 = pos[np.argmin(dist[i])]  # 1
          # https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
          shaft_dists = np.linalg.norm(
              np.cross((pos - n1), (pos - n2)), axis=1
          ) / np.linalg.norm(n2 - n1)
          shafts.append(np.where(shaft_dists < tol)[0])  # 2
      return shafts
  
imports: import numpy
  from numpy.polynomial.legendre import legval
  from scipy.interpolate import RectBivariateSpline
  from scipy.linalg import pinv
  from scipy.spatial.distance import pdist, squareform
  from .._fiff.meas_info import _simplify_info
  from .._fiff.pick import pick_channels, pick_info, pick_types
  from ..surface import _normalize_vectors
  from ..utils import _validate_type, logger, verbose, warn
label_desc: Use image node_id 11 for calling a global function with example usage: _find_seeg_electrode_shaft(pos, tol) and returns: shafts