-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute_coherence.m
91 lines (78 loc) · 4.2 KB
/
compute_coherence.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
%% compute_coherences
function coherence = compute_coherence(num_trials,coherence_type)
switch coherence_type
case 2 %'one value'
coherence = ones(1,num_trials);
output = 'one val'
case 1%'training'
output = 'training'
nt = num_trials;
num_trials = num_trials + 3;
coherence_vals = [1.0 0.8 0.7 0.4];
%coherence_probs = [0.3 0.3 0.25 .15];
coherence_probs = [0.5 0.3 0.1 .1];
coherence_nums = round(coherence_probs.*num_trials);
coherence_nums(end) = num_trials-sum(coherence_nums(1:end-1));
coherence = [];
for i = 1:length(coherence_vals)
coherence = [coherence coherence_vals(i)*ones(1,coherence_nums(i))];
end
% randomly permute
coherence = coherence(randperm(num_trials));
coherence = coherence(1:nt);
case 3%'testing'
%coherence_vals = [1.0 0.7 0.45 0.25 .1];
nt = num_trials;
num_trials = num_trials + 3;
coherence_vals = [1.0 .8, .6, .4, .2];
coherence_probs = [0.2 0.2, 0.2, 0.2, .2];
coherence_nums = round(coherence_probs.*num_trials);
coherence_nums(end) = num_trials-sum(coherence_nums(1:end-1));
coherence = [];
for i = 1:length(coherence_vals)
coherence = [coherence coherence_vals(i)*ones(1,coherence_nums(i))];
end
% randomly permute
coherence = coherence(randperm(num_trials));
coherence = coherence(1:nt);
case 3%'testing'
%coherence_vals = [1.0 0.7 0.45 0.25 .1];
nt = num_trials;
num_trials = num_trials + 3;
coherence_vals = [1.0 .7, .45, .25, .1];
coherence_probs = [0.1 0.2, 0.25, 0.25, .2];
coherence_nums = round(coherence_probs.*num_trials);
coherence_nums(end) = num_trials-sum(coherence_nums(1:end-1));
coherence = [];
for i = 1:length(coherence_vals)
coherence = [coherence coherence_vals(i)*ones(1,coherence_nums(i))];
end
% randomly permute
coherence = coherence(randperm(num_trials));
coherence = coherence(1:nt);
case 4
coherence_vals = [1.0 0.9 0.7 0.5];
coherence_probs = [0.4 0.3 0.2 0.1];
coherence_nums = round(coherence_probs.*num_trials);
coherence_nums(end) = num_trials-sum(coherence_nums(1:end-1));
coherence = [];
for i = 1:length(coherence_vals)
coherence = [coherence coherence_vals(i)*ones(1,coherence_nums(i))];
end
% randomly permute
coherence = coherence(randperm(num_trials));
end
end
% %% compute_coherences old version
% function coherence = compute_coherence(coherence_diff,num_trials)
% % choose coherences from an exponential distribution
% coherence = exprnd(coherence_diff,[1,num_trials]); % increase this number to make it harder
%
% % take all trials with coherence > 1 and randomly distribute
% coherence(coherence>1) = rand(1,length(coherence(coherence>1)));
%
% % flip the exponential distribution so that it is weighted
% % toward coherence of 1
% coherence = -coherence + 1;
%
% end