RunStateMatrix

RunStateMatrix()

Description

Runs the last state matrix that was loaded to Bpod with SendStateMatrix, and returns events, state transitions and timestamps after the matrix reaches the exit state.

  • This command will block execution until data is returned. Scripts to be run during a trial can be added as SoftCodeHandlers and triggered from the state matrix.

  • The events returned are in a raw format, and should be subsequently packaged into your session data with the AddTrialEvents function.

Syntax

RawEvents = RunStateMatrix()

Parameters

-None

Returns

  • A struct with the following fields:

    • States: a vector listing the integer codes of states visited, in sequential order.

    • Events: a vector listing the byte codes of events captured.

    • StateTimestamps: a vector listing the entry times of each state listed in the "States" field (in seconds from matrix start).

    • EventTimestamps: a vector listing the times of each event listed in the "Events" field (in seconds from matrix start).

    • TrialStartTimestamp: The time the matrix started (in seconds from session start).

Example

% This code sends "sma" (an existing state matrix) to Bpod, runs it 10 times, and packages the raw events for analysis.

SendStateMatrix(sma);

SessionData = struct;

for i = 1:10

RawEvents = RunStateMatrix;

SessionData = AddTrialEvents(SessionData, RawEvents);

end