code: def _stat_map_to_svg(
      stat_img,
      bg_img,
      cut_coords,
      display_mode,
      plot_type,
      table_details,
  ):
      """Generate SVG code for a statistical map, \
      including its clustering parameters.
  
      Parameters
      ----------
      stat_img : Niimg-like object or None
         Statistical image (presumably in z scale),
         to be plotted as slices or glass brain.
         Does not perform any thresholding.
  
      bg_img : Niimg-like object
          Only used when plot_type is 'slice'.
          See :ref:`extracting_data`.
          The background image for stat maps to be plotted on upon.
          If nothing is specified, the MNI152 template will be used.
          To turn off background image, just pass "bg_img=False".
  
  
      %(cut_coords)s
  
      display_mode : string
          Choose the direction of the cuts:
          'x' - sagittal, 'y' - coronal, 'z' - axial,
          'l' - sagittal left hemisphere only,
          'r' - sagittal right hemisphere only,
          'ortho' - three cuts are performed in orthogonal directions.
  
          Possible values are:
          'ortho', 'x', 'y', 'z', 'xz', 'yx', 'yz',
          'l', 'r', 'lr', 'lzr', 'lyr', 'lzry', 'lyrz'.
  
      plot_type : string {'slice', 'glass'}
          The type of plot to be drawn.
  
      table_details : pandas.Dataframe
          Dataframe listing the parameters used for clustering,
          to be included in the plot.
  
      Returns
      -------
      stat_map_svg : string
          SVG Image Data URL representing a statistical map.
  
      """
      if plot_type == "slice":
          stat_map_plot = plot_stat_map(
              stat_img,
              bg_img=bg_img,
              cut_coords=cut_coords,
              display_mode=display_mode,
          )
      elif plot_type == "glass":
          stat_map_plot = plot_glass_brain(
              stat_img,
              display_mode=display_mode,
              colorbar=True,
              plot_abs=False,
          )
      else:
          raise ValueError(
              "Invalid plot type provided. "
              "Acceptable options are 'slice' or 'glass'."
          )
      with pd.option_context("display.precision", 2):
          _add_params_to_plot(table_details, stat_map_plot)
      fig = plt.gcf()
      stat_map_svg = _plot_to_svg(fig)
      # prevents sphinx-gallery & jupyter from scraping & inserting plots
      plt.close()
      return stat_map_svg
  
imports: import os
  import string
  import warnings
  from collections import OrderedDict
  from collections.abc import Iterable
  from html import escape
  import numpy
  import pandas
  from matplotlib import pyplot
  from nilearn.plotting import plot_glass_brain, plot_roi, plot_stat_map
  from nilearn.plotting.img_plotting import MNI152TEMPLATE
  from nilearn.plotting.matrix_plotting import plot_contrast_matrix, plot_design_matrix
  from nilearn.reporting.html_report import HTMLReport
  from .._utils import fill_doc
  from nilearn._utils import check_niimg
  from nilearn.maskers import NiftiMasker
  from nilearn.reporting.get_clusters_table import get_clusters_table
  from nilearn.reporting.utils import figure_to_svg_quoted
label_desc: Use image node_id 14 for calling a global function with example usage: _stat_map_to_svg(stat_img, bg_img, cut_coords, display_mode, plot_type, table_details) and returns: stat_map_svg