Hi I am trying to plot a specific channel from EDF data recorded from an EEG headset. At the moment it is plotting all the channels together, which looks really messy.
This is the script that filters and uses edfread to get the edf data
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);
Here is the code for the EDF data after using edf read, returns this
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]
So when I use `plot(data_alpha) I get the image below, which I believe is plotting all the channels.
I would like to plot the filtered 'MARKER' data, which is the last channel in the edf file. How can I do this?
Is there any catch?
I think you can simply plot the selected channel as in following sample:
ch = 10;
plot(data_alpha(ch, :))
I have to downloaded 'Subject2.edf' (different then yours), and edfread.m
, and it seems to work.
I think found another problem in your code:
According to Matlab documentation:
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)).
The plot 1-D, data should be in columns, and in your sample the data is in rows.
Plot one channel:
plot(data_alpha(10, :))
Plot two channels:
tmp = data_alpha(10:11, :);
plot(tmp')
%tmp is transposed.
Plot all channels (25 in my sample):
plot(data_alpha')
%data_alpha is transposed.