Hi Josh,
I have a very simple protocol with just 2 states (see at the bottom), but I seem to be getting a delay of ~0.48s between trials that I can't account for.
e.g. after running 500 trials, I get the data and run the code below:
for trial = 2:SessionData.nTrials
report.delays(trial) = SessionData.TrialStartTimestamp(1,trial) - SessionData.TrialEndTimestamp(1,trial-1);
end
In this case, report.delays(1) will be 0, but report.delays(2) ~0.45 and then increasing steadily with each (trial) reaching ~0.57s
This issue is apparent if I look at the overall task time as well, e.g. if I check the overall task time and compare it with what I would expect from just summing the trial times.
report.totalTaskTimeBpod = SessionData.TrialEndTimestamp(1,max(SessionData.nTrials)) - SessionData.TrialStartTimestamp(1,1);
report.totalTaskTimeBpodExpected = (SessionData.TrialEndTimestamp(1,1) - SessionData.TrialStartTimestamp(1,1)) * SessionData.nTrials;
report.timeDiff = report.totalTaskTimeBpod - report.totalTaskTimeBpodExpected;
%Difference betwen expected and actual time - Ideally zero
>>
The difference between the two ends up at ~0.48s [>>>report.timeDiff / SessionData.nTrials]
Is this normal/common? Is this just time taken up by the PC/Matlab to save files etc. or something I'm missing about the state machine/data file structure?
Thank you in advance for your help.
Best wishes,
Raul
Protocol:
>>
sma = NewStateMatrix();
sma = AddState(sma, 'Name', 'presentStimulus',...
'Timer', stimDuration,...
'StateChangeCondition', {'Tup', 'InterTrialInterval'},...
'OutputActions', {'BNCState',3});
sma = AddState(sma, 'Name', 'InterTrialInterval',...
'Timer', ITI,...
'StateChangeConditions', {'Tup', 'exit'},...
'OutputActions', {});
SendStateMatrix(sma);
RawEvents = RunStateMatrix;
if ~isempty(fieldnames(RawEvents))
%Compute trial events from raw
BpodSystem.Data = AddTrialEvents(BpodSystem.Data, RawEvents);
%Adds the settings used for the current trial to the Data struct
BpodSystem.Data.TrialSettings(trial) = S;
%Adds the trial type of the current trial to the Data struct
BpodSystem.Data.TrialTypes(trial) = TrialTypes(trial);
%Save the data (see function code for details)
SaveBpodSessionData;
end
>>
Configuration:
Matlab 2019a running on Windows 10 Enterprise
Bpod r0.5
System: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz, 16GB RAM