-
Notifications
You must be signed in to change notification settings - Fork 18
Description
exp.SignalsExp after wiring the network adds an event handler whose callback updates events.expStart and therefore any other dependent events such as events.newTrial, events.trialNum, events.repeatNum and the conditional parameters:
Lines 350 to 353 in 4ff1a21
| %set pending handler to begin the experiment 'PreDelay' secs from now | |
| start = exp.EventHandler('experimentInit', exp.StartPhase('experiment')); | |
| start.addCallback(@(varargin) obj.Events.expStart.post(ref)); | |
| obj.Pending = dueHandlerInfo(obj, start, initInfo, obj.Clock.now + obj.PreDelay); |
Immediately after doing so it enters the main experiment loop, where the t and input signals get values. On fast computers, when the PreDelay is 0, callback is executed before entering the main loop, and therefore events.expStart, etc. updates before the inputs. On slow computers or when the PreDelay is sufficiently long, these events update after the input signals have taken their first values.
The problem here is that particular derived Signals will behave inconsistently depending on which signal updates first. In the below example, the signal trigger may never update on the first trial is t is sampled by event.newTrial before it has any value.
trigger = t - t.at(events.newTrial) > p.timeInterval;
It is reasonable to assume that the t and signal in particular should be the first to update. This problem may well be the cause of issue #45. A solution here could be to have the callback update t before anything else.