forked from Pim-Mostert/decoding-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 1
/
designMatrix_BH.m
52 lines (43 loc) · 2.24 KB
/
designMatrix_BH.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
function design = designMatrix_BH(cfg0, phi)
% [design] = designMatrix_BH(cfg, phi)
% Returns hypothetical channel responses given a presented orientation, cf. Brouwer & Heeger.
%
% phi Array of length N, where N is the number of trials, that specifies the presented
% orientation on each trial. Orientation is specified in degrees and is expected to
% have a range of 0-180.
% cfg Configuration struct that can possess the following fields:
% .numC The number of hypothetical channels C to use. The
% channels are equally distributed across the circle,
% starting at 0.
% .tuningCurve The tuning curve according to which the responses
% are calculated.
% .tuningCurve = 'vonMises' Von Mises curve. Kappa: concentration parameter.
% .tuningCurve = 'halfRectCos' Half-wave rectified cosine. Kappa: power.
% .tuningCurve = [function_handle] User-specified function that can take a matrix as input,
% containing angles in radians with a range of 0-pi.
% .kappa Parameter(s) to be passed on to the tuning curve.
% .offset The orientation of the first channel. (default = 0)
%
% design The design matrix, of size C x N, containing the hypothetical channel responses.
%
% See also designMatrix_dummy designMatrix_discriminant
% Created by Pim Mostert, 2016
phi = phi(:);
numN = length(phi);
switch cfg0.tuningCurve
case 'vonMises'
cfg0.tuningCurve = @(X) vonMises_curve(X*2, cfg0.kappa);
case 'halfRectCos'
cfg0.tuningCurve = @(X) abs(cos(X)).^cfg0.kappa;
end
% Apply offset
if ~isfield(cfg0, 'offset')
cfg0.offset = 0;
end
phi = phi - cfg0.offset;
% Create matrix
design = (0:(cfg0.numC-1))'*ones(1, numN) * (180/cfg0.numC);
design = design - ones(cfg0.numC, 1)*phi';
design = design * (pi/180);
design = cfg0.tuningCurve(design);
end