After applying EMD method for removing artifacts with the help of global thresholding the SNR and MSE value are calculated. Is it correct or not? Please check this and guide .
4 次查看(过去 30 天)
显示 更早的评论
Here is my dataset.
%%
clc
clear
close all;
load B02T.mat;
fs=250;
% t = 0.004:1/fs:1;
eeg1 = data{1,1}.X;
channel_1= eeg1(:,1);
ch_1=channel_1(1:3000);
figure;
subplot(2,1,1);
plot(ch_1);
xlabel('Time (s)');
ylabel('Amplitude');
legend('ch1');
title("Plot channel "+1+ " for Structure 1X1");
hold on;
grid on;
eeg_signal = eeg1(1:3000); % first 2000 samples
subplot(2,1,2);
plot(eeg_signal,'black');
hold on;
grid on;
legend('EEG Signal');
title('Raw EEG Signal');
%%
[IMF, residual, info] = emd(eeg_signal);
imf_count = max(info.NumIMF);
figure;
for i=1:imf_count
subplot(6,2,i)
plot(IMF(:,i))
title("IMF"+i);
end
subplot(6,2,imf_count+1)
plot(residual)
title("Residue");
%%
thresholds = thselect(IMF, 'rigrsure'); % determine threshold for each IMF using universal thresholding
for i = 1:imf_count
IMF(:,i) = wthresh(IMF(:,i), 's', thresholds(i));
end
% Reconstruct denoised signal from thresholded IMFs
adaptive_thr=1.5;
sum1=0;
sum2=0;
for i=1:imf_count
if(thresholds(i)<adaptive_thr)
sum1=sum1+IMF(:,i);
else
sum2=sum2+IMF(:,i);
end
end
clean_EEG=sum1;
denoised_signal=sum2;
% Plot results
figure;
subplot(3,1,1);
plot(eeg_signal);
title('Contaminated EEG signal');
subplot(3,1,2);
plot(denoised_signal);
legend( 'Noise signal');
title('Noise signal');
subplot(3,1,3);
plot(clean_EEG);
legend( 'Clean signal');
title('Pure EEG signal');
%%
% Calculate SNR
SNR = 20 * log10(norm(eeg_signal)/norm(clean_EEG));
% Calculate MSE
MSE = ((norm(eeg_signal) - norm(clean_EEG)).^2) / 3000;
% MSE2 = immse(norm(eeg_signal), norm(clean_EEG))/3000;
%
disp(['SNR: ', num2str(SNR), ' dB']);
disp(['MSE: ', num2str(MSE)]);
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 EEG/MEG/ECoG 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!