code: def _make_morph_map_hemi(
      subject_from, subject_to, subjects_dir, reg_from, reg_to
  ):
      """Construct morph map for one hemisphere."""
      # add speedy short-circuit for self-maps
      if subject_from == subject_to and reg_from == reg_to:
          fname = subjects_dir / subject_from / "surf" / reg_from
          n_pts = len(read_surface(fname, verbose=False)[0])
          return eye(n_pts, n_pts, format="csr")
  
      # load surfaces and normalize points to be on unit sphere
      fname = subjects_dir / subject_from / "surf" / reg_from
      from_rr, from_tri = read_surface(fname, verbose=False)
      fname = subjects_dir / subject_to / "surf" / reg_to
      to_rr = read_surface(fname, verbose=False)[0]
      _normalize_vectors(from_rr)
      _normalize_vectors(to_rr)
  
      # from surface: get nearest neighbors, find triangles for each vertex
      nn_pts_idx = _compute_nearest(from_rr, to_rr, method="KDTree")
      from_pt_tris = _triangle_neighbors(from_tri, len(from_rr))
      from_pt_tris = [
          from_pt_tris[pt_idx].astype(int) for pt_idx in nn_pts_idx
      ]
      from_pt_lens = np.cumsum([0] + [len(x) for x in from_pt_tris])
      from_pt_tris = np.concatenate(from_pt_tris)
      assert from_pt_tris.ndim == 1
      assert from_pt_lens[-1] == len(from_pt_tris)
  
      # find triangle in which point lies and assoc. weights
      tri_inds = []
      weights = []
      tri_geom = _get_tri_supp_geom(dict(rr=from_rr, tris=from_tri))
      weights, tri_inds = _find_nearest_tri_pts(
          to_rr,
          from_pt_tris,
          from_pt_lens,
          run_all=False,
          reproject=False,
          **tri_geom,
      )
  
      nn_idx = from_tri[tri_inds]
      weights = np.array(weights)
  
      row_ind = np.repeat(np.arange(len(to_rr)), 3)
      this_map = csr_matrix(
          (weights.ravel(), (row_ind, nn_idx.ravel())),
          shape=(len(to_rr), len(from_rr)),
      )
      return this_map
  
file_path: mne-python/mne/morph_map.py
imports: import os
  import numpy
  from scipy.sparse import csr_matrix, eye
  from ._fiff.constants import FIFF
  from ._fiff.open import fiff_open
  from ._fiff.tag import find_tag
  from ._fiff.tree import dir_tree_find
  from ._fiff.write import end_block, start_and_end_file, start_block, write_float_sparse_rcs, write_int, write_string
  from .surface import _compute_nearest, _find_nearest_tri_pts, _get_tri_supp_geom, _normalize_vectors, _triangle_neighbors, read_surface
  from .utils import get_subjects_dir, logger, verbose, warn
label_desc: Use image node_id 6 for calling a global function with example usage: _make_morph_map_hemi(subject_from, subject_to, subjects_dir, reg_from, reg_to) and returns: this_map, eye