-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetExpVal_tgt.m
More file actions
23 lines (20 loc) · 921 Bytes
/
getExpVal_tgt.m
File metadata and controls
23 lines (20 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function [expval_tgt, corr_tgt] = getExpVal_tgt(PSTH_f, predicted, catEvTimes, t_r, tWin, includeTrials)
% expval_tgt = getExpVal_tgt(PSTH_f, predicted, catEvTimes, t_r, tWin)
if nargin < 6
includeTrials = 1:numel(catEvTimes.tOnset);
end
%% explained variance for target response
idxTgtOnsets = [];
onsetTimes = catEvTimes.tOnset(includeTrials);
onsetTimes = onsetTimes(~isnan(onsetTimes));
for ievent = 1:numel(onsetTimes)
idxTgtOnsets = cat(1, idxTgtOnsets, ...
find((t_r>=onsetTimes(ievent)+tWin(1)) .* (t_r<onsetTimes(ievent)+tWin(2))));
end
expval_tgt = zeros(size(predicted,2),1);
corr_tgt = zeros(size(predicted,2),1);
for ivar = 1:size(predicted,2)
expval_tgt(ivar,1) = getExpVal(PSTH_f(idxTgtOnsets)-mean(PSTH_f(idxTgtOnsets)), ...
predicted(idxTgtOnsets,ivar)-mean(predicted(idxTgtOnsets,ivar)));
corr_tgt(ivar,1) = corr(PSTH_f(idxTgtOnsets),predicted(idxTgtOnsets,ivar));
end