I used a deep learning model to predict seizures in EEG data. I want to plot a graph to show where the model predicted the seizures on the EEG data and where the actual seizures are. The predicted values are categorical values 1 for seizure and -1 for no seizure. The EEG signal can be ploted using plot(channel).

 채택된 답변

Image Analyst
Image Analyst 2022년 4월 18일

0 개 추천

You could shade the zones where a seizure was detected, or you could just plot the seizure in a plot below your data.
subplot(2, 1, 1);
plot(eegData, 'b-', 'LineWidth', 2);
title('EEG Signal')
grid on;
subplot(2, 1, 2);
plot(predictedValues, 'b-', 'LineWidth', 2);
grid on;
title('Prediction')

댓글 수: 1

LOMenz
LOMenz 2022년 4월 18일
Thank you. I would like to shade the predictions on my EEG signal. How can I shade please?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 4월 18일

1 개 추천

You can use patch():
numSamples = 30;
x = linspace(0, 2*pi, numSamples);
eegData = 5 + 10 * sin(2 * pi * x / 3);
threshold = 6;
predictedValues = eegData > threshold;
subplot(2, 1, 1);
plot(x, eegData, 'b.-', 'LineWidth', 2, 'MarkerSize', 18);
yline(threshold, 'LineWidth', 2)
yl = ylim;
title('EEG Signal. Red Zones = Seizures')
grid on;
subplot(2, 1, 2);
plot(x, predictedValues, 'b.-', 'LineWidth', 2, 'MarkerSize', 18);
grid on;
title('Is Seizure')
ylim([0, 1.2])
% Shade regions
subplot(2, 1, 1); % Switch back to the EEG axes.
for k = 2 : numSamples
if (predictedValues(k) == 1 && predictedValues(k-1) == 1)
% Shade this region
x1 = x(k-1);
x2 = x(k);
y1 = yl(1);
y2 = yl(2);
xData = [x1; x1; x2; x2; x1];
yData = [y1; y2; y2; y1; y1];
patch(xData, yData, 'r', 'FaceAlpha', 0.2, 'EdgeColor', 'none')
end
end

카테고리

도움말 센터File Exchange에서 EEG/MEG/ECoG에 대해 자세히 알아보기

질문:

2022년 4월 18일

댓글:

2022년 4월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by