code: def _load_scrub(
      confounds_raw, scrub, fd_threshold, std_dvars_threshold
  ):
      """Remove volumes if FD and/or DVARS exceeds threshold.
  
      Parameters
      ----------
      confounds_raw : pandas.DataFrame
          DataFrame of confounds.
  
      scrub : int, default=5
          Minimal segment length.
          Segment smaller than the given value will be removed.
  
      fd_threshold : float
          Threshold for the framewise displacement. Volumes with FD larger
          than the threshold will be removed.
  
      std_dvars_threshold : float
          Threshold for the standard deviation of DVARS.
          Volumes with DVARS larger than the threshold will be removed.
  
      Returns
      -------
      motion_outlier_regressors : pandas.DataFrame
          DataFrame of one-hot encoded motion outlier regressors.
      """
      n_scans = len(confounds_raw)
      # Get indices of fd outliers
      fd_outliers_index = np.where(
          confounds_raw["framewise_displacement"] > fd_threshold
      )[0]
      dvars_outliers_index = np.where(
          confounds_raw["std_dvars"] > std_dvars_threshold
      )[0]
      motion_outliers_index = np.sort(
          np.unique(
              np.concatenate((fd_outliers_index, dvars_outliers_index))
          )
      )
      # when motion outliers were detected, remove segments with too few
      # timeframes if desired
      if scrub > 0 and len(motion_outliers_index) > 0:
          motion_outliers_index = optimize_scrub(
              motion_outliers_index, n_scans, scrub
          )
      # Make one-hot encoded motion outlier regressors
      motion_outlier_regressors = pd.DataFrame(
          np.transpose(np.eye(n_scans)[motion_outliers_index]).astype(
              int
          )
      )
      column_names = [
          f"motion_outlier_{num}"
          for num in range(np.shape(motion_outlier_regressors)[1])
      ]
      motion_outlier_regressors.columns = column_names
      return motion_outlier_regressors
  
file_path: nilearn/nilearn/interfaces/fmriprep/load_confounds_components.py
imports: import numpy
  import pandas
  from .load_confounds_compcor import find_compcor
  from .load_confounds_scrub import optimize_scrub
  from .load_confounds_utils import MissingConfound, add_suffix, check_params, find_confounds
label_desc: Use image node_id 7 for calling a global function with example usage: _load_scrub(confounds_raw, scrub, fd_threshold, std_dvars_threshold) and returns: motion_outlier_regressors