필터 지우기
필터 지우기

Finding peaks in EEG data

조회 수: 19 (최근 30일)
Mikael
Mikael 2014년 5월 2일
댓글: Image Analyst 2014년 5월 2일
I know this question has been asked a number of times, but a thorough search did not help me find an answer and as I am very new to matlab I need some help. I need to count the number of peaks in a large body of EEG data. The code below allows me to plot what the data looks like (for 1 piece of data). I need to count the really long narrow spikes.
I know there are a bunch of peakfinder functions out there but I have no idea how to use them because they are all vector based and I don't know how to reference the vectors that are preprocessed in the script (fieldtrip). A simple threshold function wouldn't work because there is a lot of overall noise that is not related to what I want to count.
This is what the data looks like:
This is the script I have:
% create the trial definition
cfg=[];
cfg.filename = ['I:\EEG\',SubNum{subject},'\',FolderName, GroupName, SeqNum{subject}, '_', SubNum{subject}, '_Block', num2str(block), '.bdf'];
cfg.dataset = cfg.filename;
cfg.continuous = 'yes';
data_org = ft_preprocessing(cfg)
channel = 164;
plot(data_org.time{1}, data_org.trial{1}(channel, :))
xlabel('time (s)')
ylabel('channel amplitude (uV)')
legend(data_org.label(channel))
I don't know if it's asking too much, but I would really appreciate some guidance, I've been trying to use GUI's forever and it's no luck...but my coding skills are completely insufficient.

채택된 답변

Image Analyst
Image Analyst 2014년 5월 2일
You forgot to attach your data, so we can't try anything with it. Attach it if you want better help. Otherwise, if you have the Signal Processing Toolbox, you can try medfilt(), sgolayfilt(), and findpeaks(). It sounds like you tried findpeaks() and say it doesn't work for some reason, though you did not specify why it failed or what parameters you used for it.
For the Savitzky-Golay filter, use it to smooth the signal and remove spikes. This gives you like a background that you can then subtract from the original signal to give a "spikes-only" signal. Then you can use a global threshold. You can use the same basic process with the median filter, or even conv() for that matter. It looks like spikes that are more than about 20 are legitimate spikes and those less than 20 are just noise, but you can play with that number to set it optimally.

추가 답변 (1개)

Star Strider
Star Strider 2014년 5월 2일
편집: Star Strider 2014년 5월 2일
The first thing I would do is to detrend the baseline on a copy of your original data. That will make your task easier. [The polyfit (and polyval) functions are likely best for this.] You may have to do this more than once, since it’s best to use polynomial orders <10.
Digitally filtering your data might also be beneficial, at the risk of eliminating some of the data in the spikes. But if all you want to do is count them, an appropriately-designed bandpass filter might work for both baseline filtering and noise reduction, and would likely be better than simply detrending the data.
After preprocessing with baseline correction, bandpass filtering, or both, the Signal Processing Toolbox findpeaks function or a threshold function might be all that’s necessary.
AFTERTHOUGHT — Also consider using wavelets. They might be most appropriate for both denoising your signal and isolating the spikes of interest so you can count them.
  댓글 수: 1
Image Analyst
Image Analyst 2014년 5월 2일
The Savitzky-Golay filter is like polyfit() except it does it just on data within a little window that slides along, so it will be better at "detrending" the data than using polyfit on the whole dataset to create just one big global quadratic or cubic. I have a demo if needed.
I would think that findpeaks() should be able to do a decent job without leveling the curve by subtracting the "background" smooth baseline signal if you give a good 'threshold' parameter. He said that he didn't know how to pass his signal into findpeaks(). I don't know why - seems pretty straightforward to me. Just pass in the 1D array that is the signal, and pass in a threshold. What's the big deal?

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

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by