code: def load_confounds(
      img_files,
      strategy=("motion", "high_pass", "wm_csf"),
      motion="full",
      scrub=5,
      fd_threshold=0.2,
      std_dvars_threshold=3,
      wm_csf="basic",
      global_signal="basic",
      compcor="anat_combined",
      n_compcor="all",
      ica_aroma="full",
      demean=True,
  ):
      """
      Use confounds from :term:`fMRIPrep`.
  
      To enable easy confound variables loading from :term:`fMRIPrep` outputs,
      `load_confounds` provides an interface that groups subsets of confound
      variables into noise components and their parameters. It is possible to
      fine-tune a subset of noise components and their parameters through this
      function.
  
      The implementation will only support :term:`fMRIPrep` functional derivative
      directory from the 1.2.x series. The `compcor` noise component requires
      1.4.x series or above.
  
      .. versionadded:: 0.9.0
  
      Parameters
      ----------
      img_files : :obj:`str` or :obj:`list` of :obj:`str`
          Path of processed nii.gz/dtseries.nii/func.gii file reside in a
          :term:`fMRIPrep` generated functional derivative directory (i.e.The
          associated confound files should be in the same directory as the image
          file). As long as the image file, confound related tsv and json are in
          the same directory with BIDS-complied names, `load_confounds` can
          retrieve the relevant files correctly.
  
          - `nii.gz` or `dtseries.nii`: path to files, optionally as a list.
          - `func.gii`: list of a pair of paths to files, optionally as a list
            of lists.
  
      strategy : :obj:`tuple` or :obj:`list` of :obj:`str`, \
                 default=("motion", "high_pass", "wm_csf")
          The type of noise components to include.
  
          - "motion":  head motion estimates. Associated parameter: `motion`
          - "wm_csf" confounds derived from white matter and cerebrospinal fluid.
            Associated parameter: `wm_csf`
          - "global_signal" confounds derived from the global signal.
            Associated parameter: `global_signal`
          - "compcor" confounds derived from CompCor (:footcite:t:`Behzadi2007`).
            When using this noise component, "high_pass" must also be applied.
            Associated parameter: `compcor`, `n_compcor`
          - "ica_aroma" confounds derived
            from ICA-AROMA (:footcite:t:`Pruim2015`).
            Associated parameter: `ica_aroma`
          - "scrub" regressors for :footcite:t:`Power2014` scrubbing approach.
            Associated parameter: `scrub`, `fd_threshold`, `std_dvars_threshold`
  
          For each component above, associated parameters will be applied if
          specified. If associated parameters are not specified, any values
          supplied to the parameters are ignored.
          For example, `strategy=('motion', 'global_signal')` will allow users
          to supply input to associated parameter `motion` and `global_signal`;
          if users pass `wm_csf` parameter, it will not be applied as it is not
          part of the `strategy`.
  
          There are two additional noise components with no optional parameters.
  
          - "non_steady_state" denotes volumes collected before
            the :term:`fMRI` scanner has reached a stable state.
          - "high_pass" adds discrete cosines transformation
            basis regressors to handle low-frequency signal drifts.
  
          Non-steady-state volumes will always be checked. There's no need to
          supply this component to the strategy.
  
      motion : :obj:`str`, default="full"
          Type of confounds extracted from head motion estimates.
  
          - "basic" translation/rotation (6 parameters)
          - "power2" translation/rotation + quadratic terms (12 parameters)
          - "derivatives" translation/rotation + derivatives (12 parameters)
          - "full" translation/rotation + derivatives + quadratic terms + power2d
            derivatives (24 parameters)
  
      wm_csf : :obj:`str`, default="basic"
          Type of confounds extracted from masks of white matter and
          cerebrospinal fluids.
  
          - "basic" the averages in each mask (2 parameters)
          - "power2" averages and quadratic terms (4 parameters)
          - "derivatives" averages and derivatives (4 parameters)
          - "full" averages + derivatives + quadratic terms + power2d derivatives
            (8 parameters)
  
      global_signal : :obj:`str`, default="basic"
          Type of confounds extracted from the global signal.
  
          - "basic" just the global signal (1 parameter)
          - "power2" global signal and quadratic term (2 parameters)
          - "derivatives" global signal and derivative (2 parameters)
          - "full" global signal + derivatives + quadratic terms + power2d
            derivatives (4 parameters)
  
      scrub : :obj:`int`, default=5
          After accounting for time frames with excessive motion, further remove
          segments shorter than the given number. The default value is referred
          as full scrubbing in :footcite:t:`Power2014`. When the value is 0,
          remove time frames based on excessive framewise displacement and
          DVARS only.
  
      fd_threshold : :obj:`float`, default=0.2
          Framewise displacement threshold for scrub in mm.
  
      std_dvars_threshold : :obj:`float`, default=3
          Standardized DVARS threshold for scrub.
          DVARs is defined as root mean squared intensity difference of volume N
          to volume N+1 :footcite:t:`Power2012`.
          D referring to temporal derivative of timecourses,
          VARS referring to root mean squared variance over voxels.
  
      compcor : :obj:`str`, default="anat_combined"
  
          .. warning::
              Require :term:`fMRIPrep` >= v:1.4.0.
  
          Type of confounds extracted from a component based noise correction
          method :footcite:t:`Behzadi2007`.
  
          - "anat_combined" noise components calculated using a white matter and
            CSF combined anatomical mask
          - "anat_separated" noise components calculated using white matter mask
            and CSF mask compcor separately; two sets of scores are concatenated
          - "temporal" noise components calculated using temporal compcor
          - "temporal_anat_combined" components of "temporal" and "anat_combined"
          - "temporal_anat_separated" components of "temporal" and
            "anat_separated"
  
      n_compcor : :obj:`str` or :obj:`int`, default="all"
          The number of noise components to be extracted.
          For acompcor_combined=False, and/or compcor="full", this is the number
          of components per mask.
          "all": select all components (50% variance explained by
          :term:`fMRIPrep` defaults)
  
      ica_aroma : :obj:`str`, default="full"
  
          - "full": use :term:`fMRIPrep` output
            `~desc-smoothAROMAnonaggr_bold.nii.gz`.
          - "basic": use noise independent components only.
  
      demean : :obj:`bool`, default=True
          If True, the confounds are standardized to a zero mean (over time).
          When using :class:`nilearn.maskers.NiftiMasker` with default
          parameters, the recommended option is True.
          When using :func:`nilearn.signal.clean` with default parameters, the
          recommended option is False.
          When `sample_mask` is not None, the mean is calculated on retained
          volumes.
  
      Returns
      -------
      confounds : :class:`pandas.DataFrame`, or :obj:`list` of \
          :class:`pandas.DataFrame`
          A reduced version of :term:`fMRIPrep` confounds based on selected
          strategy and flags.
          The columns contains the labels of the regressors.
  
      sample_mask : None, :class:`numpy.ndarray` or, :obj:`list` of \
          :class:`numpy.ndarray` or None
          When no volumns require removal, the value is None.
          Otherwise, shape: (number of scans - number of volumes removed, )
          The index of the niimgs along time/fourth dimension for valid volumes
          for subsequent analysis.
          This attribute should be passed to parameter `sample_mask` of
          :class:`nilearn.maskers.NiftiMasker` or
          :func:`nilearn.signal.clean`.
          Volumns are removed if flagged as following:
  
          - Non-steady-state volumes (if present)
          - Motion outliers detected by scrubbing
  
      Notes
      -----
      The noise components implemented in this class are adapted from
      :footcite:t:`Ciric2017`. Band-pass filter is replaced by high-pass filter.
      Low-pass filters can be implemented, e.g., through `NifitMaskers`.
      Other aspects of the preprocessing listed
      in :footcite:t:`Ciric2017` are controlled
      through :term:`fMRIPrep`, e.g. distortion correction.
  
      See Also
      --------
      :func:`nilearn.interfaces.fmriprep.load_confounds_strategy`
  
      References
      ----------
      .. footbibliography::
  
      """
      _check_strategy(strategy)
  
      # load confounds per image provided
      img_files, flag_single = sanitize_confounds(img_files)
      confounds_out = []
      sample_mask_out = []
      for file in img_files:
          sample_mask, conf = _load_confounds_for_single_image_file(
              file,
              strategy,
              demean,
              motion=motion,
              scrub=scrub,
              fd_threshold=fd_threshold,
              std_dvars_threshold=std_dvars_threshold,
              wm_csf=wm_csf,
              global_signal=global_signal,
              compcor=compcor,
              n_compcor=n_compcor,
              ica_aroma=ica_aroma,
          )
          confounds_out.append(conf)
          sample_mask_out.append(sample_mask)
  
      # If a single input was provided,
      # send back a single output instead of a list
      if flag_single:
          confounds_out = confounds_out[0]
          sample_mask_out = sample_mask_out[0]
      return confounds_out, sample_mask_out
  
file_path: nilearn/nilearn/interfaces/fmriprep/load_confounds.py
imports: import warnings
  import pandas
  from .None import load_confounds_components
  from .load_confounds_utils import MissingConfound, get_confounds_file, get_json, load_confounds_file_as_dataframe, load_confounds_json, prepare_output, sanitize_confounds
label_desc: Use image node_id 3 for calling a global function with example usage: load_confounds(img_files, strategy, motion, scrub, fd_threshold, std_dvars_threshold, wm_csf, global_signal, compcor, n_compcor, ica_aroma, demean) and returns: confounds_out,  sample_mask_out