-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaptIncludeCertainPosFeatures.m
More file actions
36 lines (27 loc) · 948 Bytes
/
aptIncludeCertainPosFeatures.m
File metadata and controls
36 lines (27 loc) · 948 Bytes
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
function [predX,predNames] = aptIncludeCertainPosFeatures
%APTINCLUDECERTAINPOSFEATURES Looks for a distinct Pattern at a certain
%Position and extends design matrix.
%
global apt
if ~isfield(apt.pred,'CertainPosFeatures')
return
end
position = apt.pred.CertainPosFeatures.position;
pattern = apt.pred.CertainPosFeatures.pattern;
if length(pattern) ~= length(position)
error('patterns have to start at position. they need the same length!')
end
Xcpf = zeros(length(apt.sequence), length(position));
for iseq = 1:length(apt.sequence)
for iPattern = 1:length(pattern)
[startIndex,~] = regexp(apt.sequence{iseq},pattern{iPattern});
if sum(startIndex == position(iPattern)) == 1
Xcpf(iseq,iPattern) = 1;
end
end
end
for iPattern = 1:length(pattern)
apt.predNames{end+1} = ['Pattern_' pattern{iPattern} '_atPosition_' int2str(position(iPattern))];
end
apt.predX = [apt.predX; Xcpf'];
end