code: def _threshold_data(data, threshold=None):
      """Threshold a data array.
  
      Parameters
      ----------
      data : Numpy array
          Data to apply threshold on.
  
      threshold : Float, optional
          Threshold to apply to data.
  
      Returns
      -------
      data : Numpy array
          Thresholded data.
  
      mask : boolean numpy array
          Boolean mask.
  
      threshold : float
          Updated threshold value.
  
      """
      # If threshold is None, do nothing
      if threshold is None:
          mask = np.full(data.shape, False)
          return data, mask, threshold
  
      # Deal with automatic settings of plot parameters
      if threshold == "auto":
          # Threshold epsilon below a percentile value, to be sure that some
          # voxels pass the threshold
          threshold = fast_abs_percentile(data) - 1e-5
  
      # Threshold
      threshold = check_threshold(
          threshold,
          data,
          percentile_func=fast_abs_percentile,
          name="threshold",
      )
  
      # Mask data
      if threshold == 0:
          mask = data == 0
          data = data * np.logical_not(mask)
      else:
          mask = (data >= -threshold) & (data <= threshold)
          data = data * np.logical_not(mask)
  
      if not np.any(mask):
          warnings.warn(
              f"Threshold given was {threshold}, "
              f"but the data has no values below {data.min()}. "
          )
      return data, mask, threshold
  
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 2 for calling a global function with example usage: _threshold_data(data, threshold) and returns: data,  mask,  threshold, data,  mask,  threshold