code: def _line_sample_locations(
      mesh, affine, segment_half_width=3.0, n_points=10, depth=None
  ):
      """Locations to draw samples from to project volume data onto a mesh.
  
      For each mesh vertex, the locations of `n_points` points evenly spread in a
      segment of the normal to the vertex are returned. The line segment has
      length 2 * `segment_half_width` and is centered at the vertex.
  
      Parameters
      ----------
      mesh : pair of :obj:`numpy.ndarray`
          `mesh[0]` contains the 3d coordinates of the vertices
          (shape n_vertices, 3)
          `mesh[1]` contains, for each triangle,
          the indices into `mesh[0]` of its vertices (shape n_triangles, 3)
  
      affine : :obj:`numpy.ndarray` of shape (4, 4)
          Affine transformation from image voxels to the vertices' coordinate
          space.
  
      segment_half_width : :obj:`float`, default=3.0
          Size in mm of the neighbourhood around each vertex in which to draw
          samples.
  
      n_points : :obj:`int`, default=10
          Number of samples to draw for each vertex.
  
      depth : sequence of :obj:`float` or None, optional
          Cortical depth, expressed as a fraction of segment_half_width.
          Overrides n_points.
  
      Returns
      -------
      sample_location_voxel_space : :obj:`numpy.ndarray`, \
              shape (n_vertices, n_points, 3)
          The locations, in voxel space, from which to draw samples.
          First dimension iterates over mesh vertices, second dimension iterates
          over the sample points associated to a vertex, third dimension is x, y,
          z in voxel space.
  
      """
      vertices, faces = mesh
      normals = _vertex_outer_normals(mesh)
      if depth is None:
          offsets = np.linspace(
              segment_half_width, -segment_half_width, n_points
          )
      else:
          offsets = -segment_half_width * np.asarray(depth)
      sample_locations = (
          vertices[np.newaxis, :, :]
          + normals * offsets[:, np.newaxis, np.newaxis]
      )
      sample_locations = np.rollaxis(sample_locations, 1)
      sample_locations_voxel_space = np.asarray(
          resampling.coord_transform(
              *np.vstack(sample_locations).T,
              affine=np.linalg.inv(affine),
          )
      ).T.reshape(sample_locations.shape)
      return sample_locations_voxel_space
  
imports: import gzip
  import os
  import warnings
  from collections import namedtuple
  from collections.abc import Mapping
  import nibabel
  import numpy
  import sklearn.cluster
  import sklearn.preprocessing
  from nibabel import freesurfer, gifti
  from scipy import interpolate, sparse
  from nilearn import _utils, datasets
  from nilearn._utils import stringify_path
  from nilearn._utils.path_finding import resolve_globbing
  from nilearn.image import get_data, load_img, resampling
label_desc: Use image node_id 8 for calling a global function with example usage: _line_sample_locations(mesh, affine, segment_half_width, n_points, depth) and returns: sample_locations_voxel_space