OutcomePlot

SideOutcomePlot()

Description

Plots correct sides and trial outcomes for a two-sided decision task.

  • 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:

Syntax

On first call:

SideOutcomePlot(AxisHandle,'init',TrialSides);

On subsequent calls:

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

%% Initialize plots

BpodSystem.ProtocolFigures.OutcomePlotFig = figure('Position', [200 200 1000 200],'name','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 outcome plot

SideOutcomePlot(BpodSystem.GUIHandles.OutcomePlot,'init',2-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

SideOutcomePlot(BpodSystem.GUIHandles.OutcomePlot,'update',BpodSystem.Data.nTrials+1,2-TrialTypes,Outcomes)

end