class_docstr: This class handles the so-called on General Linear Model
  
  Most of what it does in the fit() and contrast() methods
  fit() performs the standard two-step ('ols' then 'ar1') GLM fitting
  contrast() returns a contrast instance, yileding statistics and p-values.
  The link between fit() and contrast is done vis the two class members:
  
  glm_results : dictionary of nipy.algorithms.statistics.models.
               regression.RegressionResults instances,
               describing results of a GLM fit
  
  labels : array of shape(n_voxels),
          labels that associate each voxel with a results key
class_docstr_tok: ["This","class","handles","the","so-called","on","General","Linear","Model","Most","of","what","it","does","in","the","fit","(",")","and","contrast","(",")","methods","fit","(",")","performs","the","standard","two-step","(","'ols","'","then","'ar1","'",")","GLM","fitting","contrast","(",")","returns","a","contrast","instance",",","yileding","statistics","and","p-values",".","The","link","between","fit","(",")","and","contrast","is","done","vis","the","two","class","members",":","glm_results",":","dictionary","of","nipy.algorithms.statistics.models",".","regression.RegressionResults","instances",",","describing","results","of","a","GLM","fit","labels",":","array","of","shape","(","n_voxels",")",",","labels","that","associate","each","voxel","with","a","results","key"]
docstr: Specify and estimate a linear contrast
  
  Parameters
  ----------
  con_val : numpy.ndarray of shape (p) or (q, p)
      where q = number of contrast vectors and p = number of regressors
  contrast_type : {None, 't', 'F' or 'tmin-conjunction'}, optional
      type of the contrast.  If None, then defaults to 't' for 1D
      `con_val` and 'F' for 2D `con_val`
  
  Returns
  -------
  con: Contrast instance
docstr_tok: ["Specify","and","estimate","a","linear","contrast","Parameters","--","--","--","--","--","con_val",":","numpy.ndarray","of","shape","(","p",")","or","(","q",",","p",")","where","q","=","number","of","contrast","vectors","and","p","=","number","of","regressors","contrast_type",":","{","None",",","'t","'",",","'","F","'","or","'tmin-conjunction","'","}",",","optional","type","of","the","contrast",".","If","None",",","then","defaults","to","'t","'","for","1D","`","con_val","`","and","'","F","'","for","2D","`","con_val","`","Returns","--","--","--","-","con",":","Contrast","instance"]
code: def contrast(self, con_val, contrast_type=None):
      """Specify and estimate a linear contrast
  
      Parameters
      ----------
      con_val : numpy.ndarray of shape (p) or (q, p)
          where q = number of contrast vectors and p = number of regressors
      contrast_type : {None, 't', 'F' or 'tmin-conjunction'}, optional
          type of the contrast.  If None, then defaults to 't' for 1D
          `con_val` and 'F' for 2D `con_val`
  
      Returns
      -------
      con: Contrast instance
      """
      if self.labels_ is None or self.results_ is None:
          raise ValueError("The model has not been estimated yet")
      con_val = np.asarray(con_val)
      if con_val.ndim == 1:
          dim = 1
      else:
          dim = con_val.shape[0]
      if contrast_type is None:
          if dim == 1:
              contrast_type = "t"
          else:
              contrast_type = "F"
      if contrast_type not in ["t", "F", "tmin-conjunction"]:
          raise ValueError(f"Unknown contrast type: {contrast_type}")
  
      effect_ = np.zeros((dim, self.labels_.size), dtype=np.float64)
      var_ = np.zeros((dim, dim, self.labels_.size), dtype=np.float64)
      if contrast_type == "t":
          for l in self.results_:
              resl = self.results_[l].Tcontrast(con_val)
              effect_[:, self.labels_ == l] = resl.effect.T
              var_[:, :, self.labels_ == l] = (resl.sd**2).T
      else:
          for l in self.results_:
              resl = self.results_[l].Fcontrast(con_val)
              effect_[:, self.labels_ == l] = resl.effect
              var_[:, :, self.labels_ == l] = resl.covariance
  
      dof_ = self.results_[l].df_resid
      return Contrast(
          effect=effect_,
          variance=var_,
          dof=dof_,
          contrast_type=contrast_type,
      )
  
imports: from warnings import warn
  import numpy
  import scipy.stats
  from nibabel import Nifti1Image, load
  from nipy.algorithms.statistics.models.regression import ARModel, OLSModel
  from nipy.algorithms.statistics.utils import multiple_mahalanobis, z_score
  from nipy.io.nibcompat import get_affine, get_header
  from nipy.labs.mask import compute_mask_sessions
label_desc: Use image node_id 6 for calling the GeneralLinearModel obj's underlying member method code with example usage: obj.contrast(con_val, contrast_type) and returns: Contrast