code: def group_analysis_signs(design, contrast, mask, signs=None):
      """Refit the EM model with a vector of signs.
  
      Used in the permutation tests.
  
      Returns the maximum of the T-statistic within mask
  
      Parameters
      ----------
      design: one of 'block', 'event'
      contrast: str
          name of contrast to estimate
      mask : ``Image`` instance or array-like
          image containing mask, or array-like
      signs: ndarray, optional
           Defaults to np.ones. Should have shape (*,nsubj)
           where nsubj is the number of effects combined in the group analysis.
  
      Returns
      -------
      minT: np.ndarray, minima of T statistic within mask, one for each
           vector of signs
      maxT: np.ndarray, maxima of T statistic within mask, one for each
           vector of signs
      """
      if api.is_image(mask):
          maska = mask.get_fdata()
      else:
          maska = np.asarray(mask)
      maska = maska.astype(np.bool_)
  
      # Which subjects have this (contrast, design) pair?
      subj_con_dirs = futil.subj_des_con_dirs(design, contrast)
  
      # Assemble effects and sds into 4D arrays
      sds = []
      Ys = []
      for s in subj_con_dirs:
          sd_img = load_image(pjoin(s, "sd.nii"))
          effect_img = load_image(pjoin(s, "effect.nii"))
          sds.append(sd_img.get_fdata()[maska])
          Ys.append(effect_img.get_fdata()[maska])
      sd = np.array(sds)
      Y = np.array(Ys)
  
      if signs is None:
          signs = np.ones((1, Y.shape[0]))
  
      maxT = np.empty(signs.shape[0])
      minT = np.empty(signs.shape[0])
  
      for i, sign in enumerate(signs):
          signY = sign[:, np.newaxis] * Y
          varest = onesample.estimate_varatio(signY, sd)
          random_var = varest["random"]
  
          adjusted_var = sd**2 + random_var
          adjusted_sd = np.sqrt(adjusted_var)
  
          results = onesample.estimate_mean(Y, adjusted_sd)
          T = results["t"]
          minT[i], maxT[i] = np.nanmin(T), np.nanmax(T)
      return minT, maxT
  
imports: import warnings
  from copy import copy
  from imp import reload
  from os.path import join
  from tempfile import NamedTemporaryFile
  import ds105_util
  import numpy
  from nipy.algorithms.statistics import onesample
  from nipy.algorithms.statistics.api import ARModel, OLSModel, isestimable, make_recarray
  from nipy.core import api
  from nipy.core.api import Image
  from nipy.core.image.image import rollimg
  from nipy.io.api import load_image, save_image
  from nipy.modalities.fmri import design
  from nipy.modalities.fmri.fmristat import hrf
label_desc: Use image node_id 4 for calling a global function with example usage: group_analysis_signs(design, contrast, mask, signs) and returns: minT,  maxT