This code actually gets reaction times ONLY from trials in which the lick bout begins before the cue, rather than the remaining trials:
%Reaction time
temp = find(respTimes>=trialData.cueTimes(idx(i)),1,'first');
trialData.reaction(idx(i)) = CODE(respIdx(temp));
% if there is no lick for 0.5 s before cue onset (i.e., mouse not licking prior to cue)
if sum((respTimes-respTimes(temp))>-0.5 & (respTimes-respTimes(temp))<0)
trialData.reactionTimes(idx(i)) = respTimes(temp)-trialData.cueTimes(idx(i)); %relative to cue time
end
This code actually gets reaction times ONLY from trials in which the lick bout begins before the cue, rather than the remaining trials:
%Reaction time
temp = find(respTimes>=trialData.cueTimes(idx(i)),1,'first');
trialData.reaction(idx(i)) = CODE(respIdx(temp));
% if there is no lick for 0.5 s before cue onset (i.e., mouse not licking prior to cue)
if sum((respTimes-respTimes(temp))>-0.5 & (respTimes-respTimes(temp))<0)
trialData.reactionTimes(idx(i)) = respTimes(temp)-trialData.cueTimes(idx(i)); %relative to cue time
end