如何绘制来自 MatLab 中特定通道的过滤后的 EDF 数据
how plot filtered EDF data from a specific channel in MatLab
您好,我正在尝试根据 EEG 耳机记录的 EDF 数据绘制特定通道。目前是把所有的通道都画在一起,看起来很乱。
这是过滤并使用edfread获取edf数据的脚本
clc
clear all
close all
%Convert data from edf to Matlab
[header, data] = edfread('Subject2.edf');
hFs = 128; % half of sampling rate of Emotiv EEG
%design elliptic filter
Wp = [8/64 12/64]; %passband
Ws = [7/64 13/64]; %stopband
Rp = 1; %ripple in the pass band
Rs = 30; %stopband attenuation
[N, Wn] = ellipord(Wp, Ws, Rp, Rs);
[B, A] = ellip(N, Rp, Rs, Wp);
%averaging to remove common noise
for i=1:36
datan(i,:)=data(i,:)-mean(data);
end
%filtering of entire data into alpha band
data_alpha = filtfilt(B,A,datan);
这里是使用edf读取后的EDF数据的代码,returns这个
header =
ver: 0
patientID: '2 '
recordID: '2 '
startdate: '14.07.16'
starttime: '04.41.41'
bytes: 9472
records: 1257
duration: 1
ns: 36
label: {1x36 cell}
transducer: {1x36 cell}
units: {1x36 cell}
physicalMin: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
physicalMax: [1x36 double]
digitalMin: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
digitalMax: [1x36 double]
prefilter: {1x36 cell}
samples: [1x36 double]
因此,当我使用 `plot(data_alpha) 时,我得到了下面的图像,我认为它绘制了所有通道。
我想绘制过滤后的 'MARKER' 数据,这是 edf 文件中的最后一个通道。我该怎么做?
有什么收获吗?
我认为您可以简单地绘制所选频道,如下例所示:
ch = 10;
plot(data_alpha(ch, :))
我必须下载 'Subject2.edf'(与你的不同)和 edfread.m
,它似乎有效。
我认为在您的代码中发现了另一个问题:
根据 Matlab 文档:
plot(Y) creates a 2-D line plot of the data in Y versus the index of each value.
If Y is a vector, then the x-axis scale ranges from 1 to length(Y).
If Y is a matrix, then the plot function plots the columns of Y versus their row number. The x-axis scale ranges from 1 to the number of rows in Y.
If Y is complex, then the plot function plots the imaginary part of Y versus the real part of Y, such that plot(Y) is equivalent to plot(real(Y),imag(Y)).
一维图,数据应该在列中,而在你的样本中,数据在行中。
绘制一个通道:
plot(data_alpha(10, :))
绘制两个通道:
tmp = data_alpha(10:11, :);
plot(tmp')
%tmp 被转置。
绘制所有通道(我的示例中为 25 个):
plot(data_alpha')
%data_alpha 被转置。
您好,我正在尝试根据 EEG 耳机记录的 EDF 数据绘制特定通道。目前是把所有的通道都画在一起,看起来很乱。
这是过滤并使用edfread获取edf数据的脚本
clc
clear all
close all
%Convert data from edf to Matlab
[header, data] = edfread('Subject2.edf');
hFs = 128; % half of sampling rate of Emotiv EEG
%design elliptic filter
Wp = [8/64 12/64]; %passband
Ws = [7/64 13/64]; %stopband
Rp = 1; %ripple in the pass band
Rs = 30; %stopband attenuation
[N, Wn] = ellipord(Wp, Ws, Rp, Rs);
[B, A] = ellip(N, Rp, Rs, Wp);
%averaging to remove common noise
for i=1:36
datan(i,:)=data(i,:)-mean(data);
end
%filtering of entire data into alpha band
data_alpha = filtfilt(B,A,datan);
这里是使用edf读取后的EDF数据的代码,returns这个
header =
ver: 0
patientID: '2 '
recordID: '2 '
startdate: '14.07.16'
starttime: '04.41.41'
bytes: 9472
records: 1257
duration: 1
ns: 36
label: {1x36 cell}
transducer: {1x36 cell}
units: {1x36 cell}
physicalMin: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
physicalMax: [1x36 double]
digitalMin: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
digitalMax: [1x36 double]
prefilter: {1x36 cell}
samples: [1x36 double]
因此,当我使用 `plot(data_alpha) 时,我得到了下面的图像,我认为它绘制了所有通道。
我想绘制过滤后的 'MARKER' 数据,这是 edf 文件中的最后一个通道。我该怎么做?
有什么收获吗?
我认为您可以简单地绘制所选频道,如下例所示:
ch = 10;
plot(data_alpha(ch, :))
我必须下载 'Subject2.edf'(与你的不同)和 edfread.m
,它似乎有效。
我认为在您的代码中发现了另一个问题:
根据 Matlab 文档:
plot(Y) creates a 2-D line plot of the data in Y versus the index of each value.
If Y is a vector, then the x-axis scale ranges from 1 to length(Y).
If Y is a matrix, then the plot function plots the columns of Y versus their row number. The x-axis scale ranges from 1 to the number of rows in Y.
If Y is complex, then the plot function plots the imaginary part of Y versus the real part of Y, such that plot(Y) is equivalent to plot(real(Y),imag(Y)).
一维图,数据应该在列中,而在你的样本中,数据在行中。
绘制一个通道:
plot(data_alpha(10, :))
绘制两个通道:
tmp = data_alpha(10:11, :);
plot(tmp')
%tmp 被转置。
绘制所有通道(我的示例中为 25 个):
plot(data_alpha')
%data_alpha 被转置。