class_docstr: Implement the :term:`General Linear Model<GLM>` for multiple     subject :term:`fMRI` data.
  
  Parameters
  ----------
  mask_img : Niimg-like, :class:`~nilearn.maskers.NiftiMasker` or             :class:`~nilearn.maskers.MultiNiftiMasker`, optional
      Mask to be used on data. If an instance of masker is passed,
      then its mask will be used. If no mask is given,
      it will be computed automatically by a
      :class:`~nilearn.maskers.MultiNiftiMasker` with default
      parameters. Automatic mask computation assumes first level imgs have
      already been masked.
  %(target_affine)s
  
      .. note::
          This parameter is passed to :func:`nilearn.image.resample_img`.
  
  %(target_shape)s
  
      .. note::
          This parameter is passed to :func:`nilearn.image.resample_img`.
  
  %(smoothing_fwhm)s
  %(memory)s
  %(memory_level1)s
  %(verbose0)s
      If 0 prints nothing. If 1 prints final computation time.
      If 2 prints masker computation details.
  %(n_jobs)s
  minimize_memory : :obj:`bool`, default=True
      Gets rid of some variables on the model fit results that are not
      necessary for contrast computation and would only be useful for
      further inspection of model details. This has an important impact
      on memory consumption.
class_docstr_tok: ["Implement","the",":","term",":","`","General","Linear","Model","<","GLM",">","`","for","multiple","subject",":","term",":","`","fMRI","`","data",".","Parameters","--","--","--","--","--","mask_img",":","Niimg-like",",",":","class",":","`","~nilearn.maskers.NiftiMasker","`","or",":","class",":","`","~nilearn.maskers.MultiNiftiMasker","`",",","optional","Mask","to","be","used","on","data",".","If","an","instance","of","masker","is","passed",",","then","its","mask","will","be","used",".","If","no","mask","is","given",",","it","will","be","computed","automatically","by","a",":","class",":","`","~nilearn.maskers.MultiNiftiMasker","`","with","default","parameters",".","Automatic","mask","computation","assumes","first","level","imgs","have","already","been","masked",".","%","(","target_affine",")","s","..","note",":",":","This","parameter","is","passed","to",":","func",":","`","nilearn.image.resample_img","`",".","%","(","target_shape",")","s","..","note",":",":","This","parameter","is","passed","to",":","func",":","`","nilearn.image.resample_img","`",".","%","(","smoothing_fwhm",")","s","%","(","memory",")","s","%","(","memory_level1",")","s","%","(","verbose0",")","s","If","0","prints","nothing",".","If","1","prints","final","computation","time",".","If","2","prints","masker","computation","details",".","%","(","n_jobs",")","s","minimize_memory",":",":","obj",":","`","bool","`",",","default=True","Gets","rid","of","some","variables","on","the","model","fit","results","that","are","not","necessary","for","contrast","computation","and","would","only","be","useful","for","further","inspection","of","model","details",".","This","has","an","important","impact","on","memory","consumption","."]
docstr: Generate different outputs corresponding to         the contrasts provided e.g. z_map, t_map, effects and variance.
  
  Parameters
  ----------
  %(second_level_contrast)s
  first_level_contrast : :obj:`str` or :class:`numpy.ndarray` of        shape (n_col) with respect to        :class:`~nilearn.glm.first_level.FirstLevelModel`, optional
  
      - In case a :obj:`list` of
        :class:`~nilearn.glm.first_level.FirstLevelModel` was provided
        as ``second_level_input``,
        we have to provide a :term:`contrast` to
        apply to the first level models to get the corresponding list
        of images desired, that would be tested at the second level.
      - In case a :class:`~pandas.DataFrame` was provided as
        ``second_level_input`` this is the map name to extract from the
        :class:`~pandas.DataFrame` ``map_name`` column. It has to be
        a 't' contrast.
  
  second_level_stat_type : {'t', 'F'} or None, default=None
      Type of the second level contrast.
  
  output_type : {'z_score', 'stat', 'p_value',                       :term:`'effect_size'<Parameter Estimate>`,                       'effect_variance', 'all'}, default='z-score'
      Type of the output map.
  
  Returns
  -------
  output_image : :class:`~nibabel.nifti1.Nifti1Image`
      The desired output image(s). If ``output_type == 'all'``, then
      the output is a dictionary of images, keyed by the type of image.
docstr_tok: ["Generate","different","outputs","corresponding","to","the","contrasts","provided","e.g",".","z_map",",","t_map",",","effects","and","variance",".","Parameters","--","--","--","--","--","%","(","second_level_contrast",")","s","first_level_contrast",":",":","obj",":","`","str","`","or",":","class",":","`","numpy.ndarray","`","of","shape","(","n_col",")","with","respect","to",":","class",":","`","~nilearn.glm.first_level.FirstLevelModel","`",",","optional","-","In","case","a",":","obj",":","`","list","`","of",":","class",":","`","~nilearn.glm.first_level.FirstLevelModel","`","was","provided","as","``","second_level_input","``",",","we","have","to","provide","a",":","term",":","`","contrast","`","to","apply","to","the","first","level","models","to","get","the","corresponding","list","of","images","desired",",","that","would","be","tested","at","the","second","level",".","-","In","case","a",":","class",":","`","~pandas.DataFrame","`","was","provided","as","``","second_level_input","``","this","is","the","map","name","to","extract","from","the",":","class",":","`","~pandas.DataFrame","`","``","map_name","``","column",".","It","has","to","be","a","'t","'","contrast",".","second_level_stat_type",":","{","'t","'",",","'","F","'","}","or","None",",","default=None","Type","of","the","second","level","contrast",".","output_type",":","{","'z_score","'",",","'stat","'",",","'p_value","'",",",":","term",":","`","'effect_size","'","<","Parameter","Estimate",">","`",",","'effect_variance","'",",","'all","'","}",",","default=","'","z-score'","Type","of","the","output","map",".","Returns","--","--","--","-","output_image",":",":","class",":","`","~nibabel.nifti1.Nifti1Image","`","The","desired","output","image","(","s",")",".","If","``","output_type","==","'all","'","``",",","then","the","output","is","a","dictionary","of","images",",","keyed","by","the","type","of","image","."]
code: def compute_contrast(
      self,
      second_level_contrast=None,
      first_level_contrast=None,
      second_level_stat_type=None,
      output_type="z_score",
  ):
      """Generate different outputs corresponding to \
          the contrasts provided e.g. z_map, t_map, effects and variance.
  
          Parameters
          ----------
          %(second_level_contrast)s
          first_level_contrast : :obj:`str` or :class:`numpy.ndarray` of\
          shape (n_col) with respect to\
          :class:`~nilearn.glm.first_level.FirstLevelModel`, optional
  
              - In case a :obj:`list` of
                :class:`~nilearn.glm.first_level.FirstLevelModel` was provided
                as ``second_level_input``,
                we have to provide a :term:`contrast` to
                apply to the first level models to get the corresponding list
                of images desired, that would be tested at the second level.
              - In case a :class:`~pandas.DataFrame` was provided as
                ``second_level_input`` this is the map name to extract from the
                :class:`~pandas.DataFrame` ``map_name`` column. It has to be
                a 't' contrast.
  
          second_level_stat_type : {'t', 'F'} or None, default=None
              Type of the second level contrast.
  
          output_type : {'z_score', 'stat', 'p_value', \
                        :term:`'effect_size'<Parameter Estimate>`, \
                        'effect_variance', 'all'}, default='z-score'
              Type of the output map.
  
          Returns
          -------
          output_image : :class:`~nibabel.nifti1.Nifti1Image`
              The desired output image(s). If ``output_type == 'all'``, then
              the output is a dictionary of images, keyed by the type of image.
  
          """
      if self.second_level_input_ is None:
          raise ValueError("The model has not been fit yet.")
  
      # check first_level_contrast
      _check_first_level_contrast(
          self.second_level_input_, first_level_contrast
      )
  
      # check contrast and obtain con_val
      con_val = _get_con_val(second_level_contrast, self.design_matrix_)
  
      # check output type
      # 'all' is assumed to be the final entry;
      # if adding more, place before 'all'
      valid_types = [
          "z_score",
          "stat",
          "p_value",
          "effect_size",
          "effect_variance",
          "all",
      ]
      _check_output_type(output_type, valid_types)
  
      # Get effect_maps appropriate for chosen contrast
      effect_maps = _infer_effect_maps(
          self.second_level_input_, first_level_contrast
      )
      # Check design matrix X and effect maps Y agree on number of rows
      _check_effect_maps(effect_maps, self.design_matrix_)
  
      # Fit an Ordinary Least Squares regression for parametric statistics
      Y = self.masker_.transform(effect_maps)
      if self.memory:
          mem_glm = self.memory.cache(run_glm, ignore=["n_jobs"])
      else:
          mem_glm = run_glm
      labels, results = mem_glm(
          Y,
          self.design_matrix_.values,
          n_jobs=self.n_jobs,
          noise_model="ols",
      )
  
      # We save memory if inspecting model details is not necessary
      if self.minimize_memory:
          for key in results:
              results[key] = SimpleRegressionResults(results[key])
      self.labels_ = labels
      self.results_ = results
  
      # We compute contrast object
      if self.memory:
          mem_contrast = self.memory.cache(compute_contrast)
      else:
          mem_contrast = compute_contrast
      contrast = mem_contrast(
          self.labels_, self.results_, con_val, second_level_stat_type
      )
  
      output_types = (
          valid_types[:-1] if output_type == "all" else [output_type]
      )
  
      outputs = {}
      for output_type_ in output_types:
          # We get desired output from contrast object
          estimate_ = getattr(contrast, output_type_)()
          # Prepare the returned images
          output = self.masker_.inverse_transform(estimate_)
          contrast_name = str(con_val)
          output.header[
              "descrip"
          ] = f"{output_type} of contrast {contrast_name}"
          outputs[output_type_] = output
  
      return outputs if output_type == "all" else output
  
imports: import sys
  import time
  from warnings import warn
  import numpy
  import pandas
  from joblib import Memory
  from nibabel import Nifti1Image
  from sklearn.base import clone
  from nilearn._utils import fill_doc, stringify_path
  from nilearn._utils.niimg_conversions import check_niimg
  from nilearn.glm._base import BaseGLM
  from nilearn.glm.contrasts import compute_contrast, expression_to_contrast_vector
  from nilearn.glm.first_level import FirstLevelModel, run_glm
  from nilearn.glm.first_level.design_matrix import make_second_level_design_matrix
  from nilearn.glm.regression import RegressionResults, SimpleRegressionResults
  from nilearn.image import mean_img
  from nilearn.maskers import NiftiMasker
  from nilearn.mass_univariate import permuted_ols
label_desc: Use image node_id 3 for calling the SecondLevelModel obj's underlying member method code with example usage: obj.compute_contrast(second_level_contrast, first_level_contrast, second_level_stat_type, output_type) and returns: unknown