-
Notifications
You must be signed in to change notification settings - Fork 26
/
setupfitting_GLM.m
44 lines (32 loc) · 1.49 KB
/
setupfitting_GLM.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
function [prs0,Xstruct] = setupfitting_GLM(gg, Stim)
% [prs0,Xstruct] = setupfitting_GLM(gg, Stim)
%
% Set initial parameters and build design matrix structure for GLM fitting
%
% Inputs:
% gg = glm param structure
% Stim = stimulus (time along columns, other dims along rows)
% maxsize = maximum # floats to store in design matrix
% (Affects # of chunks used to compute likelihood)
% Output:
% prs0 = initial parameters extracted from gg
% Xstruct = struct with design matrix for stim and spike-history terms
% Initialize optimization param structure
% ---- Create struct and make stimulus design matrix ---------------------
if strcmp(gg.ktype, 'linear') % standard GLM
Xstruct = initfit_stimDesignMat(gg,Stim); % create design matrix structure
% extract parameter vector
prs0 = [gg.kt(:); gg.dc; gg.ihw(:); gg.ihw2(:)];
elseif strcmp(gg.ktype, 'bilinear') % bilinearly-parametrized stim filter
Xstruct = initfit_stimDesignMat_bi(gg,Stim); % create design matrix structure
% extract parameter vector
prs0 = [gg.kt(:); gg.kx(:); gg.dc; gg.ihw(:); gg.ihw2(:)];
else
error('unknown filter type (allowed types are ''linear'' or ''bilinear'')');
end
% ---- Make spike-history design matrix -----------------------------------
Xstruct = initfit_sphistDesignMat(gg,Xstruct);
% set nonlinearity
Xstruct.nlfun = gg.nlfun;
% compute mask (time bins to use for likelihood)
Xstruct.bmask = initfit_mask(gg.mask,Xstruct.dtSp,Xstruct.rlen);