code: def event_design(
      event_spec, t, order=2, hrfs=(glover,), level_contrasts=False
  ):
      """Create design matrix at times `t` for event specification `event_spec`
  
      Create a design matrix for linear model based on an event specification
      `event_spec`, evaluating the design rows at a sequence of time values `t`.
      Each column in the design matrix will be convolved with each HRF in `hrfs`.
  
      Parameters
      ----------
      event_spec : np.recarray
         A recarray having at least a field named 'time' signifying the event
         time, and all other fields will be treated as factors in an ANOVA-type
         model.  If there is no field other than time, add a single-level
         placeholder event type ``_event_``.
      t : np.ndarray
         An array of np.float64 values at which to evaluate the design. Common
         examples would be the acquisition times of an fMRI image.
      order : int, optional
         The highest order interaction to be considered in constructing
         the contrast matrices.
      hrfs : sequence, optional
         A sequence of (symbolic) HRFs that will be convolved with each event.
         Default is ``(glover,)``.
      level_contrasts : bool, optional
         If True, generate contrasts for each individual level of each factor.
  
      Returns
      -------
      X : np.ndarray
         The design matrix with ``X.shape[0] == t.shape[0]``. The number of
         columns will depend on the other fields of `event_spec`.
      contrasts : dict
         Dictionary of contrasts that is expected to be of interest from the
         event specification. Each interaction / effect up to a given order will
         be returned. Also, a contrast is generated for each interaction / effect
         for each HRF specified in `hrfs`.
      """
      fields = list(event_spec.dtype.names)
      if "time" not in fields:
          raise ValueError('expecting a field called "time"')
      fields.pop(fields.index("time"))
      if len(fields) == 0:  # No factors specified, make generic event
          event_spec = make_recarray(
              zip(event_spec["time"], itertools.cycle([1])),
              ("time", "_event_"),
          )
          fields = ["_event_"]
      e_formula, e_contrasts = _build_formula_contrasts(
          event_spec, fields, order
      )
      # Design and contrasts in block space
      # TODO: make it so I don't have to call design twice here
      # to get both the contrasts and the e_X matrix as a recarray
      e_X = e_formula.design(event_spec)
      e_dtype = e_formula.dtype
  
      # Now construct the design in time space
      t_terms = []
      t_contrasts = {}
      for l, h in enumerate(hrfs):
          for n in e_dtype.names:
              term = events(event_spec["time"], amplitudes=e_X[n], f=h)
              t_terms += [term]
              if level_contrasts:
                  t_contrasts["%s_%d" % (n, l)] = Formula([term])
          for n, c in e_contrasts.items():
              t_contrasts["%s_%d" % (n, l)] = Formula(
                  [
                      events(event_spec["time"], amplitudes=c[nn], f=h)
                      for i, nn in enumerate(c.dtype.names)
                  ]
              )
      t_formula = Formula(t_terms)
  
      tval = make_recarray(t, ["t"])
      X_t, c_t = t_formula.design(tval, contrasts=t_contrasts)
      return X_t, c_t
  
imports: import itertools
  from functools import reduce
  from operator import mul
  import numpy
  from nipy.algorithms.statistics.formula import formulae
  from nipy.algorithms.statistics.formula.formulae import Factor, Formula, Term, make_recarray
  from nipy.algorithms.statistics.utils import combinations
  from .hrf import glover
  from .utils import T, blocks, convolve_functions, events
  from .utils import fourier_basis
label_desc: Use image node_id 4 for calling a global function with example usage: event_design(event_spec, t, order, hrfs, level_contrasts) and returns: X_t,  c_t