code: def expression_to_contrast_vector(expression, design_columns):
      """Convert a string describing a :term:`contrast` \
         to a :term:`contrast` vector.
  
      Parameters
      ----------
      expression : string
          The expression to convert to a vector.
  
      design_columns : list or array of strings
          The column names of the design matrix.
  
      """
      if expression in design_columns:
          contrast_vector = np.zeros(len(design_columns))
          contrast_vector[list(design_columns).index(expression)] = 1.0
          return contrast_vector
      df = pd.DataFrame(
          np.eye(len(design_columns)), columns=design_columns
      )
      try:
          contrast_vector = df.eval(expression, engine="python").values
      except Exception:
          raise ValueError(
              f"The expression ({expression}) is not valid. "
              "This could be due to "
              "defining the contrasts using design matrix columns that are "
              "invalid python identifiers."
          )
      return contrast_vector
  
imports: from warnings import warn
  import numpy
  import pandas
  import scipy.stats
  from nilearn._utils import rename_parameters
  from nilearn.glm._utils import pad_contrast, z_score
  from nilearn.maskers import NiftiMasker
label_desc: Use image node_id 1 for calling a global function with example usage: expression_to_contrast_vector(expression, design_columns) and returns: contrast_vector, contrast_vector