-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathseq_feargen_cloudseq.m
92 lines (74 loc) · 2.63 KB
/
seq_feargen_cloudseq.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function [s] = seq_feargen_cloudseq(csp,phase)
%SEQ_FEARGEN_SEQ2FACES
%takes a pruned mseq (seq_feargen_mseq_pruned) and adds the remaining
%needed information
ok=0;
while ~ok
%create sequence until one passes the constraint-test
%method 2= baseline&test, 22 = conditioning
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5fprintf('Starting Constraint Check....\n')
if strcmp(phase,'baseline')
[s0]=seq_feargen_mseq_pruned(2,0.3,0.01);
elseif strcmp(phase,'cond')
[s0]=seq_feargen_mseq_pruned(22,0.3,0.01);
elseif strcmp(phase,'test')
s0=[];
for n=1:2
[s0]=[s0; seq_feargen_mseq_pruned(2,0.3,0.01)];
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%fprintf('Found appropriate sequence....\n')
%s has conditions only, so now we set up the whole seq structure as we had
%it in all versions
s.cond_id = s0;
%assign ucs seq
s.ucs = (s.cond_id==(max(s.cond_id)-1));
%assign oddball seq
s.oddball = (s.cond_id==max(s.cond_id));
%got a sequence, see if it holds.
ok=seq_feargen_constraints(s,1,1,1,1,1);
end
%assign isis (uniform so far)
s.isi = ones(length(s.cond_id),1)*3;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%phase specific cond2stim assignments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s.stim_id = s.cond_id;
%ucs condition is csp face (cond+test)
if ~strcmp(phase,'baseline')
s.stim_id(s.cond_id==(max(s.cond_id)-1))=csp;
end
%cond 2 means csn in conditioning, 1 and 3 csp
if strcmp(phase,'cond')
s.stim_id(s.cond_id==2)=mod( csp + 8/2-1, 8)+1;
s.stim_id(s.cond_id==1)=csp;
s.stim_id(s.cond_id==4)=10;
end
s.tTrial = length(s.cond_id);
s.tFacetrial = sum(s.stim_id~=0);
%we want an index that gives us the distance from the csp face, e.g. for
%plotting it later
s.dist = MinimumAngle((s.stim_id-1)*45,(csp-1)*45);
s.dist(s.cond_id==0)=NaN;
%oddball=1000
s.dist(s.cond_id==max(s.cond_id))=1000;
%ucs=500
s.dist(s.cond_id==max(s.cond_id)-1)=500;
%get fixation crosses from that function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%fprintf('Balancing fixation cross positions....\n')
s.CrossPosition = seq_feargen_fixcross(s);
function [a]=MinimumAngle(y,x)
%[a]=MinimumAngle(x,y);
%
%finds the minimum angle between two angles given in degrees, the answer is
%also in degrees. The clockwise distances from Y to X are considered as
%positive. Opposite angles are considered as positive 180.
x = deg2rad(x);
y = deg2rad(y);
a = atan2(sin(x-y), cos(x-y));
a = -round(rad2deg(a));
if any(abs(a) == 180);
a(abs(a) == 180) = 180;
end
end
end