Unrecognized function or variable 'correct_Fz'. so I can't plot correct_Fz
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
clc
clear
close all
%% Data Acquisition
%Import Data
data = load('Contaminated_Data'); %Fz|Cz|O2
data2 = load('HEOG');
%Data Extraction
eog_HEOG = -data2.heog_1(1,:); %HEOG artifact
eeg_Fz = data.sim1_con(1,:); %Raw at Fz
%% RLS ALGORITHM EXECUTION FOR Denoising at Fz is a easy, stable and fast convergence method suitable for online removal of EOG artifacts
% Execution for Fz electrode
% Variable Initialization
sample_no = size(eeg_Fz); % No of samples/time points
order = 3; % Order of the Adaptive Filter (User Tunable)
sigma = 0.01; % Initializing variable
lambda = 0.9999; % Forgetting Factor for RLS Algorithm (User Tunable)
H = zeros(order,1); % Initial filter Coefficients
R = sigma*eye(order,order); % Initial value for Reference combination
% RLS Algorithm for Adaptive Denoising
for n = 1:sample_no % Loop to simulate reality situation
s = eeg_Fz(1,n); % eeg @ Fz at that time point
if n>=order
j = 1; % calculation of last "order" reference vector
for i = n:-1:(n+1-order)
r(1,j) = eog_HEOG(1,i);
j = j+1;
end
% Calculation of Filter Coefficients
K = ((inv(R))*r)*(inv(lambda+r'*(inv(R))*r));
e = s - (r'*H);
H = H + (K*e);
R = inv((inv(lambda)*inv(R)) - ((inv(lambda))*(K)*((r)')*(inv(R))));
% Calculation Of RLS algorithm estimated signal
correct_Fz(1,n) = s - (r'*H);
end
end
% Fz Denoising plot
figure(2)
subplot(3,1,1) %HEOG plot
plot(eog_HEOG)
title('Horizontal EOG Artifact')
xlabel('sample number')
ylabel('HEOG mu volts')
subplot(3,1,2) %Raw at Fz plot
plot(eeg_Fz)
title('Raw EEG at Fz')
xlabel('sample number')
ylabel('EEG mu volts')
subplot(3,1,3) %denoised eeg at Fz plot
plot(correct_Fz)
title('Corrected EEG at Fz')
xlabel('sample number')
ylabel('EEG mu volts')
0 comentarios
Respuestas (1)
Geoff Hayes
el 20 de Dic. de 2021
@hue phan - how do you know if correct_Fz is getting intialized or updated with data? You have a condition in your for loop that will only update this variable under if
for n = 1:sample_no % Loop to simulate reality situation
s = eeg_Fz(1,n); % eeg @ Fz at that time point
if n>=order
Or maybe your sample_no is invalid (empty or zero?) and so you don't even enter the for loop. I recommend that you use the MATLAB debugging tools to add a breakpoint to your code and then step through it to see if the correct_Fz is being created and updated as you expect.
(I'm assuming that it is the call to plot that is failing.)
0 comentarios
Ver también
Categorías
Más información sobre Biomedical Signal Processing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!