I have EEG signal and exract PSD feature from it, then must apply it a noise reduction algorithm, I used Kalman filter,
but the output signal in the paper is much smoother than my output and
vertical axis is different in my case
I think that is because of Kalman filter initialization; initial state and predict.
Here is my output and paper output.
Here is MATLAB code:
N = length(z); % number of Klamn filter iterations Qfactor = 1; % process noise mult factor Rfactor = 1; % measurement noise mult factor F = [ 1 2 % update matrix 0 1 ]; H = [ 1 0 ]; % measurement matrix sigmaQ = 5e-5; sigmaR = 1; Q = sigmaQ^2 * [ 8/3 2 % process noise covariance matrix 2 2 ]; R = sigmaR^2 * [ 1 ]; % measurement noise covariance P = zeros(2, 2, N); x = zeros(2, N); x(:,1) = [ 0 0 ]; P(:,:,1) = Q; for i=2:N [xpred, Ppred] = predict(x(:,i-1), P(:,:,i-1), F, Q); [nu, S] = innovation(xpred, Ppred, z(i), H, R); [x(:,i), P(:,:,i)] = innovation_update(xpred, Ppred, nu, S, H); end
function [xpred, Ppred] = predict(x, P, F, Q) xpred = F * x; Ppred = F * P * F' + Q;
function [nu, S] = innovation(xpred, Ppred, z, H, R) nu = z - H * xpred; %% innnvoation S = R + H * Ppred * H'; %% innovation covariance
and Inovation update :
function [xnew, Pnew] = innovation_update(xpred, Ppred, nu, S, H) K = Ppred * H' * inv(S); %% Kalman gain xnew = xpred + K * nu; %% new state Pnew = Ppred - K * S * K'; %% new covariance