code: def _get_cropped_cbar_ticks(
      cbar_vmin, cbar_vmax, threshold=None, n_ticks=5
  ):
      """Return ticks for cropped colorbars."""
      new_tick_locs = np.linspace(cbar_vmin, cbar_vmax, n_ticks)
      if threshold is not None:
          # Case where cbar is either all positive or all negative
          if 0 <= cbar_vmin <= cbar_vmax or cbar_vmin <= cbar_vmax <= 0:
              idx_closest = np.argmin(
                  [
                      abs(abs(new_tick_locs) - threshold)
                      for _ in new_tick_locs
                  ]
              )
              new_tick_locs[idx_closest] = threshold
          # Case where we do a symmetric thresholding
          # within an asymmetric cbar
          # and both threshold values are within bounds
          elif cbar_vmin <= -threshold <= threshold <= cbar_vmax:
              new_tick_locs = _get_cbar_ticks(
                  cbar_vmin,
                  cbar_vmax,
                  threshold,
                  nb_ticks=len(new_tick_locs),
              )
          # Case where one of the threshold values is out of bounds
          else:
              idx_closest = np.argmin(
                  [
                      abs(new_tick_locs - threshold)
                      for _ in new_tick_locs
                  ]
              )
              new_tick_locs[idx_closest] = (
                  -threshold if threshold > cbar_vmax else threshold
              )
      return new_tick_locs
  
imports: import collections.abc
  import functools
  import numbers
  import os
  import warnings
  import matplotlib
  import matplotlib.pyplot
  import numpy
  from matplotlib import gridspec
  from matplotlib.colors import LinearSegmentedColormap
  from nibabel.spatialimages import SpatialImage
  from scipy import stats
  from scipy.ndimage import binary_fill_holes
  from nilearn.image.resampling import reorder_img
  from nilearn.maskers import NiftiMasker
  from nilearn.plotting.displays import get_projector, get_slicer
  from nilearn.plotting.displays._slicers import _get_cbar_ticks
  from ..None import _utils
  from .._utils import compare_version, fill_doc
  from .._utils.extmath import fast_abs_percentile
  from .._utils.ndimage import get_border_data
  from .._utils.niimg import safe_get_data
  from .._utils.numpy_conversions import as_ndarray
  from .._utils.param_validation import check_threshold
  from ..datasets import load_mni152_template
  from ..image import get_data, iter_img, math_img, new_img_like, resample_to_img
  from ..masking import apply_mask, compute_epi_mask
  from ..signal import clean
  from .None import cm
label_desc: Use image node_id 4 for calling a global function with example usage: _get_cropped_cbar_ticks(cbar_vmin, cbar_vmax, threshold, n_ticks) and returns: new_tick_locs