-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimitPredictor.m
43 lines (33 loc) · 1.55 KB
/
limitPredictor.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function [predictorInfo_limit, param_limit] = limitPredictor(predictorInfo, dd, onsets_cat, param, option)
% created from splitPredictorByCue
% option 1: only use period with successful trials
% option 2: use period EXCEPT successful trials
[trialEndTimes,~, trialOutcome] = getRewardTimes(dd);
% trialEndTimes = sort([rewardTimes punishTimes]);
%from getCueDirMtx.m
eventTimes = [];
for itr = 1:dd.numTrials
%only register trials with reward from fixation behaviour till reward or punishment
fOnset = onsets_cat.fOnset(itr);
cOnset = onsets_cat.cOnset(itr);
if isnan(cOnset) || isnan(fOnset) || trialOutcome(itr) == -1|| isnan(trialOutcome(itr))
continue;
end
eventTimes = [eventTimes; fOnset trialEndTimes(itr)];
end
tgtPeriod = event2Trace(predictorInfo.t_r, eventTimes)';
if option == 2
tgtPeriod = 1 - tgtPeriod;
end
%% split predictor into trials with cue and trials without cue
predictorInfo_limit = predictorInfo;
%predictorInfo_limit.npredVars = [predictorInfo.npredVars; predictorInfo.npredVars];
%predictorInfo_limit.nPredictors = predictorInfo.nPredictors * 2;
%nRows_ori = size(predictorInfo.predictors_r,1);
predictorInfo_limit.predictors_r = predictorInfo.predictors_r .* tgtPeriod;
% predictorInfo_split.predictors_r(1+nRows_ori:2*nRows_ori,:) = predictorInfo.predictors_r .* tgtPeriod;
%% modify param
param_limit = param;
predictorNames_ori = param.predictorNames;
param_limit.predictorNames = [cellfun(@(x)([x '_success']),predictorNames_ori,'UniformOutput',false)];
%param_limit.lagRange = [param.lagRange; param.lagRange];