TrialTypeOutcomePlot
TrialTypeOutcomePlot()
Description
Plots trial types and trial outcomes for a customizable window of trials surrounding the current trial.
Future trials are indicated with filled blue circles.
The current trial is indicated with a black cross.
Correct trials are indicated in green. Filled circles indicate rewarded trials, unfilled circles indicate unrewarded trials..
Error trials are indicated in red. Filled circles indicate punished trials, unfilled circles indicate unpunished trials.
Trials with no decision response are indicated as unfilled blue circles.
The plot is shown here for an example session. The current trial shown is trial#24, trial type 2:
Syntax
On first call:
TrialTypeOutcomePlot(AxisHandle,'init',TrialTypes);
On subsequent calls:
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.
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