BpodSystem_BeingUsed
BpodSystem.BeingUsed
Description
Equal to 1 if a state matrix has started running, and returned to 0 when a protocol is ended.
The protocol can be manually ended, returning BpodSystem.BeingUsed to 0, by the user pressing the "play/pause" button in the Bpod console.
The protocol can also be ended programatically by finishing the protocol's main script.
Example
% 1. This code runs 100 trials, but checks on each trial to see if the user has ended the protocol and exits if true.
for currentTrial = 1:100
SendStateMatrix(sma); RawEvents = RunStateMatrix; % Send and run state matrix
if ~isempty(fieldnames(RawEvents)) % If trial data was returned
BpodSystem.Data = AddTrialEvents(BpodSystem.Data,RawEvents); % Computes trial events from raw data
SaveBpodSessionData; % Saves the field BpodSystem.Data to the current data file
end
if BpodSystem.BeingUsed == 0
return
end
end