code: def pad_contrast(con_val, theta, stat_type):
      """Pad contrast with zeros if necessary.
  
      If the contrast is shorter than the number of parameters,
      it is padded with zeros.
  
      If the contrast is longer than the number of parameters,
      a ValueError is raised.
  
      Parameters
      ----------
      con_val : numpy.ndarray of shape (p) or (n, p)
          Where p = number of regressors
          with a value explicitly passed by the user.
          p must be <= P,
          where P is the total number of regressors in the design matrix.
  
      theta : numpy.ndarray with shape (P,m)
          theta of RegressionResults instances
          where P is the total number of regressors in the design matrix.
  
      stat_type : {'t', 'F'}, optional
          Type of the :term:`contrast`.
      """
      nb_cols = (
          con_val.shape[0] if con_val.ndim == 1 else con_val.shape[1]
      )
      if nb_cols > theta.shape[0]:
          if stat_type == "t":
              raise ValueError(
                  f"t contrasts should be of length P={theta.shape[0]}, "
                  f"but it has length {nb_cols}."
              )
          if stat_type == "F":
              raise ValueError(
                  f"F contrasts should have {theta.shape[0]} columns, "
                  f"but it has {nb_cols}."
              )
  
      pad = False
      if nb_cols < theta.shape[0]:
          pad = True
          if stat_type == "t":
              warn(
                  f"t contrasts should be of length P={theta.shape[0]}, "
                  f"but it has length {nb_cols}. "
                  "The rest of the contrast was padded with zeros.",
                  category=UserWarning,
                  stacklevel=3,
              )
          if stat_type == "F":
              warn(
                  f"F contrasts should have {theta.shape[0]} colmuns, "
                  f"but it has only {nb_cols}. "
                  "The rest of the contrast was padded with zeros.",
                  category=UserWarning,
                  stacklevel=3,
              )
  
      if pad:
          if stat_type == "t" or (
              stat_type == "F" and con_val.shape[0] == 1
          ):
              padding = np.zeros((1, theta.shape[0] - nb_cols))
          elif stat_type == "F":
              padding = np.zeros(
                  (con_val.shape[0], theta.shape[0] - nb_cols)
              )
          con_val = np.hstack((con_val, padding))
  
      return con_val
  
file_path: nilearn/nilearn/glm/_utils.py
imports: from warnings import warn
  import numpy
  import scipy.linalg
  from scipy.stats import norm
label_desc: Use image node_id 6 for calling a global function with example usage: pad_contrast(con_val, theta, stat_type) and returns: con_val