%% check the timing of onsets

IndexC = strfind(TimeStamping(:,2), 'FlickerOnset');
Index = find(not(cellfun('isempty', IndexC)));

for indTrial = 1:numel(Index)-1
    curTimings = cell2mat(TimeStamping(Index(indTrial):Index(indTrial+1),1));
    Timing(indTrial,1:numel(curTimings)) = curTimings;
    TimingRel(indTrial,1:numel(diff(curTimings))) = diff(curTimings);
end;

figure;
subplot(1,3,1);
imagesc(Timing); title('Timing');
subplot(1,3,2);
imagesc(TimingRel, [-.1 .1]); title('Timing differences');
subplot(1,3,3);
imagesc(TimingRel-.1, [-.01 .01]); title('Timing differences (from 10 Hz)'); colorbar;

% total time

totalTime_run = TimeStamping{end-1,1} - TimeStamping{2,1};
format short g

totalTime_min = totalTime_run/60;

totalTime_est = size(trialData,2)*3 + size(trialData,2)*.9;

timeDiff_min = (totalTime_run-totalTime_est)/60;