docstr: Compute images of contrast and contrast variance.
          
docstr_tok: ["Compute","images","of","contrast","and","contrast","variance","."]
code: def contrast(self, vector):
      """Compute images of contrast and contrast variance."""
      # Compute the overall contrast across models
      c = self.glm[0].contrast(vector)
      for g in self.glm[1:]:
          c += g.contrast(vector)
  
      def affect_inmask(dest, src, xyz):
          if xyz is None:
              dest = src
          else:
              dest[xyz] = src
          return dest
  
      con = np.zeros(self.spatial_shape)
      con_img = Image(
          affect_inmask(con, c.effect, self.xyz), self.affine
      )
      vcon = np.zeros(self.spatial_shape)
      vcon_img = Image(
          affect_inmask(vcon, c.variance, self.xyz), self.affine
      )
      z = np.zeros(self.spatial_shape)
      z_img = Image(affect_inmask(z, c.zscore(), self.xyz), self.affine)
      dof = c.dof
      return con_img, vcon_img, z_img, dof
  
imports: import numpy
  import scipy.stats
  from nibabel import Nifti1Image
  from nibabel.affines import apply_affine
  from ..algorithms.graph.field import field_from_graph_and_data
  from ..algorithms.graph.graph import wgraph_from_3d_grid
  from ..algorithms.statistics import empirical_pvalue
  from ..io.nibcompat import get_affine
  from .glm import glm
  from .group.permutation_test import permutation_test_onesample, permutation_test_twosample
label_desc: Use image node_id 3 for calling the LinearModel obj's underlying member method code with example usage: obj.contrast(vector) and returns: con_img,  vcon_img,  z_img,  dof, dest