c12 = c12.subs(t, t2) c22 = utils.events([1, 3.2, 9], f=h2) c22 = c22.subs(t, t2) c32 = utils.events([2, 4.2, 8], f=h2) c32 = c32.subs(t, t2) d2 = utils.fourier_basis([0.3, 0.5, 0.7]) d2 = d2.subs(t, t2) # Formula for run 2 signal in terms of time in run 2 (t2) f2 = Formula([c12, c22, c32]) + d2 # Factor giving constant for run. The [1, 2] means that there are two levels to # this factor, and that when we get to pass in values for this factor, # instantiating an actual design matrix (see below), a value of 1 means level # 1 and a value of 2 means level 2. run_factor = Factor('run', [1, 2]) run_1_coder = run_factor.get_term(1) # Term coding for level 1 run_2_coder = run_factor.get_term(2) # Term coding for level 2 # The multi run formula will combine the indicator (dummy value) terms from the # run factor with the formulae for the runs (which are functions of (run1, run2) # time. The run_factor terms are step functions that are zero when not in the # run, 1 when in the run. f = Formula([run_1_coder]) * f1 + Formula([run_2_coder]) * f2 + run_factor # Now, we evaluate the formula. So far we've been entirely symbolic. Now we # start to think about the values at which we want to evaluate our symbolic # formula. # We'll use these values for time within run 1. The times are in seconds from # the beginning of run 1. In our case run 1 was 20 seconds long. 101 below