How to load a specific channel from EEG into MATLAB

27 views (last 30 days)
Hi. I am just new to EEG and also MATLAB. Currently, I am having a 14 channels EEG data, however I need only signal from 2 specific channel for analysis. How can I load the only 2 channels into MATLAB using edfread? Then, I am able to convert the data into frequency domain with the following codes but it is converting all 14 channels. Therefore, what should I modify from the existing code to get only 2 channel of signal being converted?
[header,data] = edfread("data.edf");
S = data;
y=fft(S);
PS=abs(y);
N=length(S);
fs=128;
freq=(1:N)*fs/N;
plot(freq,PS)
Your help will be highly appreciated. Thanks

Accepted Answer

dpb
dpb on 28 Nov 2018
Edited: dpb on 28 Nov 2018
Often unless data files are simply humongous, it's just simpler to read it all in and then selectively keep what you're interested in...
nKeep=[3 11]; % arbitary selection; write some user input code to set the desired channel(s)
[header,S] = edfread("data.edf");
S = S(:,nKeep); % keep only the desired channels..
...
Carry on from there as before...
  1 Comment
David Lee
David Lee on 29 Nov 2018
Thanks for your answer. Is it meaning that if I want to select only channel (e.g: channel 7), the code will be like below: ?
nKeep = 7;
[header,S] = edfread("data.edf");
S = S(:,nKeep);

Sign in to comment.

More Answers (0)

Categories

Find more on EEG/MEG/ECoG in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!