-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulateSpatioTemporalTuning.m
More file actions
97 lines (50 loc) · 1.47 KB
/
simulateSpatioTemporalTuning.m
File metadata and controls
97 lines (50 loc) · 1.47 KB
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
92
93
94
95
96
97
function varargout = simulateSpatioTemporalTuning(args)
sep = 1; acAngle = 2.5; % degs
duration = 4;
n = 80;
nContours = 10;
sfs = logspace2(1e-3, 1, n);
tfs = logspace2(1e-1, 40, n);
[hpf, lpf] = getMantisTemporalFilters();
%% load overrides
if nargin, unpackStruct(args); end
%% body
makePlot = ~nargout;
conds = createTrial(tfs, sfs);
conds = sortrows(conds);
args = struct('conds', conds, 'sep', sep, 'acAngle', acAngle, ...
'hpf', hpf, 'lpf', lpf, 'duration', duration, 'spatialReso', 0.1);
ys = simulateMultiSinusoidal(args);
steadyState = mean(ys, 2);
steadyState = steadyState / max(steadyState);
B = reshape(steadyState, [length(sfs) length(tfs)]);
con = getContours(sfs, tfs, B, nContours);
if makePlot
clf; hold on
c1 = [0.99 0 0];
c2 = [1 1 1];
for i=1:nContours
a = i/(nContours+1);
col = c1 * a + c2 * (1-a);
plot(con{i}.data(:, 1), con{i}.data(:, 2), 'color', col);
end
xlabel('Spatial Frequency (cpd)');
ylabel('Temporal Frequency (Hz)');
axis xy
grid on; box on;
end
if nargout; varargout{1} = con; end
end
function con = getContours(sfs, tfs, B, nContours)
D = contourc(sfs, tfs, B', nContours);
D = D';
i = 1;
con = {};
while i < size(D, 1)
c.level = D(i, 1);
c.npoints = D(i, 2) + 1;
c.data = D(i+1:i+c.npoints-1, :);
con{end+1} = c; %#ok<AGROW>
i = i + c.npoints;
end
end