code: def _check_fun(X, stat_fun, threshold, tail=0, kind="within"):
      """Check the stat_fun and threshold values."""
      if kind == "within":
          if threshold is None:
              if (
                  stat_fun is not None
                  and stat_fun is not ttest_1samp_no_p
              ):
                  warn(
                      "Automatic threshold is only valid for stat_fun=None "
                      "(or ttest_1samp_no_p), got %s" % (stat_fun,)
                  )
              p_thresh = 0.05 / (1 + (tail == 0))
              n_samples = len(X)
              threshold = -tstat.ppf(p_thresh, n_samples - 1)
              if np.sign(tail) < 0:
                  threshold = -threshold
              logger.info(f"Using a threshold of {threshold:.6f}")
          stat_fun = ttest_1samp_no_p if stat_fun is None else stat_fun
      else:
          assert kind == "between"
          if threshold is None:
              if stat_fun is not None and stat_fun is not f_oneway:
                  warn(
                      "Automatic threshold is only valid for stat_fun=None "
                      "(or f_oneway), got %s" % (stat_fun,)
                  )
              elif tail != 1:
                  warn(
                      'Ignoring argument "tail", performing 1-tailed F-test'
                  )
              p_thresh = 0.05
              dfn = len(X) - 1
              dfd = np.sum([len(x) for x in X]) - len(X)
              threshold = fstat.ppf(1.0 - p_thresh, dfn, dfd)
              logger.info(f"Using a threshold of {threshold:.6f}")
          stat_fun = f_oneway if stat_fun is None else stat_fun
      return stat_fun, threshold
  
imports: import numpy
  from scipy import ndimage, sparse
  from scipy.sparse.csgraph import connected_components
  from scipy.stats import f
  from scipy.stats import t
  from ..fixes import has_numba, jit
  from ..parallel import parallel_func
  from ..source_estimate import MixedSourceEstimate, SourceEstimate, VolSourceEstimate
  from ..source_space import SourceSpaces
  from ..utils import ProgressBar, _check_option, _pl, _validate_type, check_random_state, logger, split_list, verbose, warn
  from .parametric import f_oneway, ttest_1samp_no_p
label_desc: Use image node_id 25 for calling a global function with example usage: _check_fun(X, stat_fun, threshold, tail, kind) and returns: stat_fun,  threshold