Syntax
On first call (before first trial):
SideOutcomePlot(AxisHandle,'init',TrialSides);
On subsequent calls (once per trial):
SideOutcomePlot(AxisHandle,'update',CurrentTrial,TrialSides,Outcomes)
Parameters
AxisHandle: The handle of the axes where you intend display the plot
TrialSides: A vector listing the correct response side for all trials in the session. For each trial in the vector, right = 0, left = 1.
CurrentTrial: The current trial number (will be marked with a cross)
Outcomes: A vector for each completed trial, listing outcomes:
-1 = error, unpunished (unfilled red circle)
0 = error, punished (filled red circle)
1 = correct, rewarded (filled green circle)
2 = correct, unrewarded (unfilled green circle)
3 = no response (unfilled black circle)
Returns
-None
Example
% This code initializes the outcome plot in its own window, and updates it on each trial.
% All correct trials are rewarded, and all error trials are punished.
TrialTypes = ceil(rand(1,5000)*2); % Trial types randomly interleaved, type 1 or 2.
% type 1 = rewarded left. type 2 = rewarded right.
%% Initialize plots
% Create a figure for the outcome plot
BpodSystem.ProtocolFigures.OutcomePlotFig = figure('Position', [200 200 1000 200],'name','Outcome plot',... 'numbertitle','off', 'MenuBar', 'none', 'Resize', 'off');
% Create axes for the outcome plot
BpodSystem.GUIHandles.OutcomePlot = axes('Position', [.075 .3 .89 .6]);
SideOutcomePlot(BpodSystem.GUIHandles.OutcomePlot,'init',2-TrialTypes);
% Run 1000 trials:
for currentTrial = 1:1000
...Create, send and run state machine with a state called "Reward"
and a state called "Punish", add and save events...
Outcomes = zeros(1,BpodSystem.Data.nTrials);
for x = 1:BpodSystem.Data.nTrials
if ~isnan(BpodSystem.Data.RawEvents.Trial{x}.States.Reward(1))
Outcomes(x) = 1;
elseif ~isnan(BpodSystem.Data.RawEvents.Trial{x}.States.Punish(1))
Outcomes(x) = 0;
else
Outcomes(x) = 3;
end
end
SideOutcomePlot(BpodSystem.GUIHandles.OutcomePlot,'update',BpodSystem.Data.nTrials+1,2-TrialTypes,Outcomes)
end