|
9 | 9 | % usually take relative signal power into account. It is important to make the standardization |
10 | 10 | % window long enough that it does not factor out changes in signal power that one is interested in. |
11 | 11 | % |
| 12 | +% Note that this function requires the data to be relatively free of artifacts to work well. |
| 13 | +% |
12 | 14 | % In: |
13 | 15 | % Signal : continuous data set to be filtered |
14 | 16 | % |
|
49 | 51 | 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).'), ... |
50 | 52 | 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), ... |
51 | 53 | 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), ... |
52 | 55 | arg_nogui({'state','State'})); |
53 | 56 |
|
54 | 57 | warning off MATLAB:nearlySingularMatrix |
|
75 | 78 | state.(field) = struct('ord1',[],'ord2',[],'offset',sum(signal.(field) ,2)/size(signal.(field) ,2),'last_R',[]); |
76 | 79 | % prepend a made up data sequence |
77 | 80 | 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)) |
79 | 82 | 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).']); |
80 | 83 | end |
81 | 84 | end |
|
132 | 135 | last_n = 0; |
133 | 136 | for j=1:length(update_at) |
134 | 137 | % 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)); |
136 | 140 | % apply the reconstruction to intermediate samples (using raised-cosine blending) |
137 | 141 | n = update_at(j); |
138 | 142 | subrange = range((last_n+1):n); |
|
0 commit comments