class_docstr: Class for masking of Niimg-like objects.
  
  MultiNiftiMasker is useful when dealing with image sets from multiple
  subjects. Use case: integrates well with decomposition by MultiPCA and
  CanICA (multi-subject models)
  
  Parameters
  ----------
  mask_img : Niimg-like object
      See :ref:`extracting_data`.
      Mask of the data. If not given, a mask is computed in the fit step.
      Optional parameters can be set using mask_args and mask_strategy to
      fine tune the mask extraction.
  %(smoothing_fwhm)s
  %(standardize_maskers)s
  %(standardize_confounds)s
  high_variance_confounds : :obj:`bool`, default=False
      If True, high variance confounds are computed on provided image with
      :func:`nilearn.image.high_variance_confounds` and default parameters
      and regressed out.
  %(detrend)s
  %(low_pass)s
  %(high_pass)s
  %(t_r)s
  target_affine : 3x3 or 4x4 :obj:`numpy.ndarray`, optional
      This parameter is passed to image.resample_img. Please see the
      related documentation for details.
  
  target_shape : 3-:obj:`tuple` of :obj:`int`, optional
      This parameter is passed to image.resample_img. Please see the
      related documentation for details.
  
  %(mask_strategy)s
  
      .. note::
          Depending on this value, the mask will be computed from
          :func:`nilearn.masking.compute_multi_background_mask`,
          :func:`nilearn.masking.compute_multi_epi_mask`, or
          :func:`nilearn.masking.compute_multi_brain_mask`.
  
      Default='background'.
  
  mask_args : :obj:`dict`, optional
      If mask is None, these are additional parameters passed to
      masking.compute_background_mask or masking.compute_epi_mask
      to fine-tune mask computation. Please see the related documentation
      for details.
  
  dtype : {dtype, "auto"}, optional
      Data type toward which the data should be converted. If "auto", the
      data will be converted to int32 if dtype is discrete and float32 if it
      is continuous.
  %(memory)s
  %(memory_level)s
  %(n_jobs)s
  %(verbose0)s
  %(masker_kwargs)s
  
  Attributes
  ----------
  mask_img_ : :obj:`nibabel.nifti1.Nifti1Image`
      The mask of the data.
  
  affine_ : 4x4 :obj:`numpy.ndarray`
      Affine of the transformed image.
  
  n_elements_ : :obj:`int`
      The number of voxels in the mask.
  
      .. versionadded:: 0.9.2
  
  See Also
  --------
  nilearn.image.resample_img: image resampling
  nilearn.masking.compute_epi_mask: mask computation
  nilearn.masking.apply_mask: mask application on image
  nilearn.signal.clean: confounds removal and general filtering of signals
docstr: Compute the mask corresponding to the data.
  
  Parameters
  ----------
  imgs : :obj:`list` of Niimg-like objects
      See :ref:`extracting_data`.
      Data on which the mask must be calculated. If this is a list,
      the affine is considered the same for all.
  
  y : None
      This parameter is unused. It is solely included for scikit-learn
      compatibility.
docstr_tok: ["Compute","the","mask","corresponding","to","the","data",".","Parameters","--","--","--","--","--","imgs",":",":","obj",":","`","list","`","of","Niimg-like","objects","See",":","ref",":","`","extracting_data","`",".","Data","on","which","the","mask","must","be","calculated",".","If","this","is","a","list",",","the","affine","is","considered","the","same","for","all",".","y",":","None","This","parameter","is","unused",".","It","is","solely","included","for","scikit-learn","compatibility","."]
code: def fit(self, imgs=None, y=None):
      """Compute the mask corresponding to the data.
  
      Parameters
      ----------
      imgs : :obj:`list` of Niimg-like objects
          See :ref:`extracting_data`.
          Data on which the mask must be calculated. If this is a list,
          the affine is considered the same for all.
  
      y : None
          This parameter is unused. It is solely included for scikit-learn
          compatibility.
  
      """
      # Load data (if filenames are given, load them)
      if self.verbose > 0:
          print(
              f"[{self.__class__.__name__}.fit] Loading data from "
              f"{_utils._repr_niimgs(imgs, shorten=False)}."
          )
  
      # Compute the mask if not given by the user
      if self.mask_img is None:
          if self.verbose > 0:
              print("[{self.__class__.__name__}.fit] Computing mask")
  
          imgs = _utils.helpers.stringify_path(imgs)
          if not isinstance(
              imgs, collections.abc.Iterable
          ) or isinstance(imgs, str):
              raise ValueError(
                  f"[{self.__class__.__name__}.fit] "
                  "For multiple processing, you should  provide a list of "
                  "data (e.g. Nifti1Image objects or filenames). "
                  f"{imgs} is an invalid input."
              )
  
          mask_args = (
              self.mask_args if self.mask_args is not None else {}
          )
          compute_mask = _get_mask_strategy(self.mask_strategy)
          self.mask_img_ = self._cache(
              compute_mask,
              ignore=["n_jobs", "verbose", "memory"],
          )(
              imgs,
              target_affine=self.target_affine,
              target_shape=self.target_shape,
              n_jobs=self.n_jobs,
              memory=self.memory,
              verbose=max(0, self.verbose - 1),
              **mask_args,
          )
      else:
          if imgs is not None:
              warnings.warn(
                  f"[{self.__class__.__name__}.fit] "
                  "Generation of a mask has been requested (imgs != None) "
                  "while a mask has been provided at masker creation. "
                  "Given mask will be used."
              )
  
          self.mask_img_ = _utils.check_niimg_3d(self.mask_img)
  
      self._reporting_data = None
      if self.reports:  # save inputs for reporting
          self._reporting_data = {
              "mask": self.mask_img_,
              "dim": None,
              "images": imgs,
          }
          if imgs is not None:
              imgs, dims = compute_middle_image(imgs)
              self._reporting_data["images"] = imgs
              self._reporting_data["dim"] = dims
  
      # If resampling is requested, resample the mask as well.
      # Resampling: allows the user to change the affine, the shape or both.
      if self.verbose > 0:
          print(
              f"[{self.__class__.__name__}.transform] Resampling mask"
          )
  
      self.mask_img_ = self._cache(image.resample_img)(
          self.mask_img_,
          target_affine=self.target_affine,
          target_shape=self.target_shape,
          interpolation="nearest",
          copy=False,
      )
  
      if self.target_affine is not None:
          self.affine_ = self.target_affine
      else:
          self.affine_ = self.mask_img_.affine
  
      # Load data in memory, while also checking that mask is binary/valid
      data, _ = masking.load_mask_img(self.mask_img_, allow_empty=True)
  
      # Infer the number of elements (voxels) in the mask
      self.n_elements_ = int(data.sum())
  
      if (
          (self.target_shape is not None)
          or (self.target_affine is not None)
          and self.reports
      ):
          resampl_imgs = None
          if imgs is not None:
              resampl_imgs = self._cache(image.resample_img)(
                  imgs,
                  target_affine=self.affine_,
                  copy=False,
                  interpolation="nearest",
              )
  
          self._reporting_data["transform"] = [
              resampl_imgs,
              self.mask_img_,
          ]
  
      return self
  
file_path: nilearn/nilearn/maskers/multi_nifti_masker.py
imports: import collections.abc
  import itertools
  import warnings
  from functools import partial
  from joblib import Memory, Parallel, delayed
  from nilearn import _utils, image, masking
  from nilearn.maskers._utils import compute_middle_image
  from nilearn.maskers.nifti_masker import NiftiMasker, _filter_and_mask
label_desc: Use image node_id 2 for calling the MultiNiftiMasker obj's underlying member method code with example usage: obj.fit(imgs, y) and returns: self