As mentioned, I aim to activate the "LeftReward" or "RightReward" after two 'Port3In' or 'Port8In'. Meanwhile in the next trial the "LeftReward" or "RightReward" need extra two 'Port3In' or 'Port8In' to activate. So on, So on.
How may I acheive it.
for currentTrial = 1:MaxTrials
S.GUI.CurrentTrial = currentTrial;
S = BpodParameterGUI('sync', S);
sma = NewStateMachine();
sma = AddState(sma, 'Name', 'WaitForPoke', ...
'Timer', 0,...
'StateChangeConditions', {'Port3In', 'LeftReward', 'Port8In', 'RightReward'},...
'OutputActions', {});
sma = AddState(sma, 'Name', 'LeftReward', ...
'Timer', S.GUI.RewardTimeLeft,...
'StateChangeConditions', {'Tup', 'LeftLight'},...
'OutputActions', {'Valve', 3});
sma = AddState(sma, 'Name', 'RightReward', ...
'Timer', S.GUI.RewardTimeRight,...
'StateChangeConditions', {'Tup', 'RightLight'},...
'OutputActions', {'Valve', 8});
sma = AddState(sma, 'Name', 'LeftLight', ...
'Timer', S.GUI.LightTime,...
'StateChangeConditions', { 'Tup', 'Stimuli'},...
'OutputActions', {'PWM3', 255,});
sma = AddState(sma, 'Name', 'Stimuli', ...
'Timer', S.GUI.Stimuli,...
'StateChangeConditions', { 'Tup', 'ITI'},...
'OutputActions', {'BNC1', 1,});
sma = AddState(sma, 'Name', 'RightLight', ...
'Timer', S.GUI.LightTime,...
'StateChangeConditions', {'Tup', 'ITI'},...
'OutputActions', {'PWM8', 255});
sma = AddState(sma, 'Name', 'ITI', ...
'Timer', S.GUI.ITI,...
'StateChangeConditions', {'Tup', 'exit'},...
'OutputActions', {});
SendStateMachine(sma);
RawEvents = RunStateMachine;
if isempty(fieldnames(RawEvents))
BpodSystem.Data = AddTrialEvents(BpodSystem.Data,RawEvents);
BpodSystem.Data.TrialSettings(currentTrial) = S;
struct (to be saved after the trial ends)
SaveBpodSessionData;
end
HandlePauseCondition;
if BpodSystem.Status.BeingUsed == 0
return
end
end