code: def standardize_signal(
      signals,
      detrend=False,
      standardize="zscore",
  ):
      """Center and standardize a given signal (time is along first axis).
  
      Parameters
      ----------
      signals : :class:`numpy.ndarray`
          Timeseries to standardize.
  
      detrend : :obj:`bool`, default=False
          If detrending of timeseries is requested.
  
      standardize : {'zscore_sample', 'zscore', 'psc', True, False}, \
                    default='zscore'
          Strategy to standardize the signal:
  
              - 'zscore_sample': The signal is z-scored. Timeseries are shifted
                to zero mean and scaled to unit variance. Uses sample std.
              - 'zscore': The signal is z-scored. Timeseries are shifted
                to zero mean and scaled to unit variance. Uses population std
                by calling :obj:`numpy.std` with N - ``ddof=0``.
              - 'psc':  Timeseries are shifted to zero mean value and scaled
                to percent signal change (as compared to original mean signal).
              - True: The signal is z-scored (same as option `zscore`).
                Timeseries are shifted to zero mean and scaled to unit variance.
              - False: Do not standardize the data.
  
  
      Returns
      -------
      std_signals : :class:`numpy.ndarray`
          Copy of signals, standardized.
      """
      if standardize not in [
          True,
          False,
          "psc",
          "zscore",
          "zscore_sample",
      ]:
          raise ValueError(
              f"{standardize} is no valid standardize strategy."
          )
  
      signals = (
          _detrend(signals, inplace=False)
          if detrend
          else signals.copy()
      )
  
      if standardize:
          if signals.shape[0] == 1:
              warnings.warn(
                  "Standardization of 3D signal has been requested but "
                  "would lead to zero values. Skipping."
              )
              return signals
  
          elif standardize == "zscore_sample":
              if not detrend:
                  # remove mean if not already detrended
                  signals = signals - signals.mean(axis=0)
  
              std = signals.std(axis=0, ddof=1)
              # avoid numerical problems
              std[std < np.finfo(np.float64).eps] = 1.0
              signals /= std
  
          elif (standardize == "zscore") or (standardize is True):
              std_strategy_default = (
                  "The default strategy for standardize is currently 'zscore' "
                  "which incorrectly uses population std to calculate sample "
                  "zscores. The new strategy 'zscore_sample' corrects this "
                  "behavior by using the sample std. In release 0.13, the "
                  "default strategy will be replaced by the new strategy and "
                  "the 'zscore' option will be removed. Please use "
                  "'zscore_sample' instead."
              )
              warnings.warn(
                  category=DeprecationWarning,
                  message=std_strategy_default,
                  stacklevel=3,
              )
  
              if not detrend:
                  # remove mean if not already detrended
                  signals = signals - signals.mean(axis=0)
  
              std = signals.std(axis=0)
              # avoid numerical problems
              std[std < np.finfo(np.float64).eps] = 1.0
  
              signals /= std
  
          elif standardize == "psc":
              mean_signals = signals.mean(axis=0)
              invalid_ix = (
                  np.absolute(mean_signals) < np.finfo(np.float64).eps
              )
              signals = (signals - mean_signals) / np.absolute(
                  mean_signals
              )
              signals *= 100
  
              if np.any(invalid_ix):
                  warnings.warn(
                      "psc standardization strategy is meaningless "
                      "for features that have a mean of 0. "
                      "These time series are set to 0."
                  )
                  signals[:, invalid_ix] = 0
  
      return signals
  
imports: import warnings
  import numpy
  import pandas
  from scipy import linalg, signal
  from scipy.interpolate import CubicSpline
  from sklearn.utils import as_float_array, gen_even_slices
  from nilearn._utils import fill_doc, stringify_path
  from nilearn._utils.numpy_conversions import as_ndarray, csv_to_array
  from nilearn._utils.param_validation import check_run_sample_masks
label_desc: Use image node_id 1 for calling a global function with example usage: standardize_signal(signals, detrend, standardize) and returns: signals, signals