Syntax
On first call (before first trial):
TrialTypeOutcomePlot(AxisHandle,'init',TrialTypes);
On subsequent calls (once per trial):
TrialTypeOutcomePlot(AxisHandle,'update',CurrentTrial,TrialTypes,Outcomes)
Parameters
AxisHandle: The handle of the axes where you intend display the plot
TrialTypes: A vector listing the trial types for all trials in the session. Each trial type must be a positive integer.
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 trial type outcome plot in its own window, and updates it on each trial.
% All correct trials are rewarded, and all error trials are punished with time-out.
TrialTypes = ceil(rand(1,5000)*2); % Trial types randomly interleaved, type 1 or 2
%% Initialize plots
BpodSystem.ProtocolFigures.OutcomePlotFig = figure('Position', [200 200 1000 200],'name','Trial type outcome plot',... 'numbertitle','off', 'MenuBar', 'none', 'Resize', 'off'); % Create a figure for the outcome plot
BpodSystem.GUIHandles.OutcomePlot = axes('Position', [.075 .3 .89 .6]); % Create axes for the trial type outcome plot
TrialTypeOutcomePlot(BpodSystem.GUIHandles.OutcomePlot,'init',TrialTypes);
% Run 1000 trials:
for currentTrial = 1:1000
...Create, send and run state matrix 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
TrialTypeOutcomePlot(BpodSystem.GUIHandles.OutcomePlot,'update',BpodSystem.Data.nTrials+1,TrialTypes,Outcomes)
end