Mata wrote[quote='Mata' pid='86' dateline='1480611258']
Hello,
I deliver a stimulus at the beginning of which there is a short grace period and then follows the response period. The thing is that the response period starts before the end of the stimulus delivery. How could I implement this since I can't have two states active at the same time? I thought of something like this:
sma = NewStateMatrix();
sma = SetGlobalTimer(sma, 1, S.GUI.GracePeriod);
% State 'Start' only triggers the GracePeriod timer and starts DeliverStimulus
sma = AddState(sma,'Name', 'Start',...
'Timer', 0,...
'StateChangeConditions', {'Tup', 'DeliverStimulus'},...
'OutputActions', {'GlobalTimerTrig', 1});
% Here I would like to wait for the animal's response after the end of the grace period and while the stimulus
% is still delivered
sma = AddState(sma, 'Name', 'DeliverStimulus', ...
'Timer', S.GUI.StimulusDuration, ...
'StateChangeConditions', {'GlobalTimer1_End', 'WaitForResponse'}, ...
'OutputActions', {'BNCState', 1});
Thanks in advance,
Mata
Hi Mata
If your system delivers the stimulus while the BNC line is high, you can use:
sma = AddState(sma,'Name', 'Start',...
'Timer', S.GUI.GracePeriod,...
'StateChangeConditions', {'Tup', 'WaitForResponse_Stim'},...
'OutputActions', {'BNCState', 1});
sma = AddState(sma, 'Name', 'WaitForResponse_Stim', ...
'Timer', S.GUI.StimulusRemainder, ... % StimulusRemainder = StimulusDuration - GracePeriod
'StateChangeConditions', {'Tup', 'WaitForResponse', 'Port1In', leftResponseState, 'Port3In', rightResponseState}, ...
'OutputActions', {'BNCState', 1});
sma = AddState(sma, 'Name', 'WaitForResponse', ...
'Timer', S.GUI.StimulusRemainder, ... % StimulusRemainder = StimulusDuration - GracePeriod
'StateChangeConditions', {'Port1In', leftResponseState, 'Port3In', rightResponseState}, ...
'OutputActions', {});
With this method, you have two response states, one of which has BNC1 high (for the remainder of the grace period). Otherwise, the response states are identical, and direct the system to the appropriate reward state.
A near future update will include the ability to attach an output channel to each global timer - so the line will be high whenever the timer is running, and low otherwise. For now, this code should work.
Josh