-
Notifications
You must be signed in to change notification settings - Fork 1
/
computeInfoIBTB.m
67 lines (61 loc) · 1.86 KB
/
computeInfoIBTB.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
function [info, infoBtsp] = computeInfoIBTB(X, Y, params)
% Compute information measures on multi-dimensional responses using
% Information Breakdown Toolbox (IBTB)
% The toolbox is introduced in Magri et al. (2009) "A toolbox for the fast
% information analysis of multiple-site LFP, EEG and spike train recordings"
% ----------------------------------------
% X - signal / neural data
% Y - response / intended BMI targets
% params - parameters structure
% Fields of the structure "params":
% "metric" - information metric to compute (see "information.m" in IBTB)
% "method" - method of computing the metric (see "information.m" in IBTB)
% "bias" - bias correction method to use (see "information.m" in IBTB)
% "dscBinNum" - number of bins to use for data discretization
% "btspNum" - number of bootstrap samples (see "information.m" in IBTB)
% verbose" - boolean on printing details of computation (see "information.m" in IBTB)
% set parameters
if ~exist('params', 'var')
params = struct;
end
if ~isfield(params, 'metric')
params.metric = 'Ish';
end
if ~isfield(params, 'method')
params.method = 'dr';
end
if ~isfield(params, 'bias')
params.bias = 'pt';
end
if ~isfield(params, 'dscBinNum')
if any(rem(X(:), 1))
params.dscBinNum = length(unique(Y))*10;
else
params.dscBinNum = 0;
end
end
if ~isfield(params, 'btspNum')
params.btspNum = 0;
end
if ~isfield(params, 'verbose')
params.verbose = false;
end
% discretize data
if params.dscBinNum>0
X = discretizeData(X, params.dscBinNum, 'eq-space');
end
% compute response matrix
[R, nt] = buildr2(Y', X');
% calculate information measures
opts.nt = nt;
opts.method = params.method;
opts.bias = params.bias;
opts.btsp = params.btspNum;
opts.verbose = params.verbose;
I = information(R, opts, params.metric);
info = I(1);
if params.btspNum>0
infoBtsp = I(2:end);
else
infoBtsp = [];
end