Skip to content

Commit f653130

Browse files
committed
Added support for regularized sphering in flt_standardize.m
1 parent cee238a commit f653130

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

RELEASE NOTES.TXT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ Minor New Features
236236
- added UnLocBox toolbox to dependencies (primarily for some of its prox operators)
237237
- added the ability to read private plugins from ~/.bcilab/code
238238
- added robust re-referencing
239+
- flt_standarize now uses regularization for sphering
239240

240241
Major Changes:
241242
- arg_tovals: now by default sets the arg_direct flag to false rather than true, meaning that some

code/filters/flt_standardize.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
% usually take relative signal power into account. It is important to make the standardization
1010
% window long enough that it does not factor out changes in signal power that one is interested in.
1111
%
12+
% Note that this function requires the data to be relatively free of artifacts to work well.
13+
%
1214
% In:
1315
% Signal : continuous data set to be filtered
1416
%
@@ -49,6 +51,7 @@
4951
arg({'multivariate_sphering','Sphere','sphere'}, false, [], 'Perform multivariate sphering. This removes correlations between channels but maintains. Assumes that the data is approximately zero-mean (i.e., first highpass filtered).'), ...
5052
arg({'stepsize','StepSize'}, 1/3, [], 'Step size between updates. The sphering matrix will be updated every this many samples. If this is below 1, it is assumed to be in seconds.','guru',true), ...
5153
arg({'usegpu','UseGPU'}, false, [], 'Use the GPU for sphering.'), ...
54+
arg({'lambda','CovarianceRegularization'}, 0.001, [], 'Covariance regularization. This is a regularization parameter for the covariance estimate used in sperhing.','guru',true), ...
5255
arg_nogui({'state','State'}));
5356

5457
warning off MATLAB:nearlySingularMatrix
@@ -75,7 +78,7 @@
7578
state.(field) = struct('ord1',[],'ord2',[],'offset',sum(signal.(field) ,2)/size(signal.(field) ,2),'last_R',[]);
7679
% prepend a made up data sequence
7780
signal.(field) = [repmat(2*signal.(field) (:,1),1,N) - signal.(field)(:,(N+1):-1:2) signal.(field)];
78-
elseif ~isequal(signal.(field),1)
81+
elseif ~isequal(signal.(field),1) && ~isempty(signal.(field))
7982
disp_once(['Not filtering the field .' field ': needs to be longer than the set data window length (for this data set ' num2str(window_len) ' seconds).']);
8083
end
8184
end
@@ -132,7 +135,8 @@
132135
last_n = 0;
133136
for j=1:length(update_at)
134137
% update the sphering matrix
135-
R = real(Xcov(:,:,j)^-1/2);
138+
V = Xcov(:,:,j);
139+
R = real((V*(1-lambda) + lambda*eye(C)*trace(V)/C)^(-1/2));
136140
% apply the reconstruction to intermediate samples (using raised-cosine blending)
137141
n = update_at(j);
138142
subrange = range((last_n+1):n);

0 commit comments

Comments
 (0)