code: def _json_view_to_html(json_view):
      """Fill a brainsprite html template with relevant parameters and data.
  
      Returns: html_view
  
      """
      # Fix the size of the viewer
      width, height = _json_view_size(json_view["params"])
  
      # Populate all missing keys with html-ready data
      json_view["INSERT_PAGE_TITLE_HERE"] = (
          json_view["params"]["title"] or "Slice viewer"
      )
      json_view["params"] = json.dumps(json_view["params"])
      js_dir = os.path.join(os.path.dirname(__file__), "data", "js")
      with open(os.path.join(js_dir, "jquery.min.js")) as f:
          json_view["js_jquery"] = f.read()
      with open(os.path.join(js_dir, "brainsprite.min.js")) as f:
          json_view["js_brainsprite"] = f.read()
  
      # Load the html template, and plug in all the data
      html_view = get_html_template("stat_map_template.html")
      html_view = html_view.safe_substitute(json_view)
  
      return StatMapView(html_view, width=width, height=height)
  
imports: import copy
  import json
  import os
  import warnings
  from base64 import b64encode
  from io import BytesIO
  import matplotlib
  import numpy
  from matplotlib.image import imsave
  from nibabel.affines import apply_affine
  from nilearn.plotting.html_document import HTMLDocument
  from .._utils import fill_doc
  from .._utils.extmath import fast_abs_percentile
  from .._utils.niimg import safe_get_data
  from .._utils.niimg_conversions import check_niimg_3d
  from .._utils.param_validation import check_threshold
  from ..datasets import load_mni152_template
  from ..image import get_data, new_img_like, reorder_img, resample_to_img
  from ..plotting import cm
  from ..plotting.find_cuts import find_xyz_cut_coords
  from ..plotting.img_plotting import load_anat
  from .js_plotting_utils import colorscale, get_html_template
label_desc: Use image node_id 13 for calling a global function with example usage: _json_view_to_html(json_view) and returns: StatMapView