code: def check_threshold(
      threshold, data, percentile_func, name="threshold"
  ):
      """Check if the given threshold is in correct format \
      and within the limit.
  
      If necessary, this function also returns score of the data calculated based
      upon the given specific percentile function.
      Note: This is only for threshold as string.
  
      Parameters
      ----------
      threshold : float or str
          If threshold is a float value, it should be within the range of the
          maximum intensity value of the data.
          If threshold is a percentage expressed in a string it must finish with
          a percent sign like "99.7%".
  
      data : ndarray
          An array of the input masked data.
  
      percentile_func : function {scoreatpercentile, fastabspercentile}
          Percentile function for example scipy.stats.scoreatpercentile
          to calculate the score on the data.
  
      name : str, default='threshold'
          A string just used for representing
          the name of the threshold for a precise
          error message.
  
      Returns
      -------
      threshold : number
          Returns the score of the percentile on the data or
          returns threshold as it is
          if given threshold is not a string percentile.
  
      """
      if isinstance(threshold, str):
          message = (
              f'If "{name}" is given as string it '
              "should be a number followed by the percent "
              'sign, e.g. "25.3%"'
          )
          if not threshold.endswith("%"):
              raise ValueError(message)
  
          try:
              percentile = float(threshold[:-1])
          except ValueError as exc:
              exc.args += (message,)
              raise
  
          threshold = percentile_func(data, percentile)
      elif isinstance(threshold, numbers.Real):
          # checks whether given float value exceeds the maximum
          # value of the image data
          value_check = abs(data).max()
          if abs(threshold) > value_check:
              warnings.warn(
                  f"The given float value must not exceed {value_check}. "
                  f"But, you have given threshold={threshold}.",
                  category=UserWarning,
                  stacklevel=3,
              )
      else:
          raise TypeError(
              f"{name} should be either a number "
              "or a string finishing with a percent sign"
          )
      return threshold
  
file_path: nilearn/nilearn/_utils/param_validation.py
imports: import numbers
  import warnings
  import numpy
  from sklearn.feature_selection import SelectPercentile, f_classif, f_regression
  from .niimg import _get_data
label_desc: Use image node_id 1 for calling a global function with example usage: check_threshold(threshold, data, percentile_func, name) and returns: threshold