Problem with x-axis of FFT eeg signal plot
조회 수: 5 (최근 30일)
이전 댓글 표시
I have currently started working with EEG signal processing in Matlab ( I only have a background in medicine and close to none in computing so bare with me). I want to use FFT to compare power distribution in the frequency domain from different segments of a sample.
I am using the following code for FFT calculation and plotting:
hinfo = hdf5info(filename);
Dataset_groupnum = 2;
EEGEMGdata = double(hdf5read(hinfo.GroupHierarchy.Groups(Dataset_groupnum).Datasets(4))).';
EEGdata = EEGEMGdata(:,1:32);
EMGdata = EEGEMGdata(:,33:34); % Last two channels of EEGEMGdata are EMG so are removed
Fs1 = 1200;
t1range = [0:(size(EEGEMGdata,1)-1)]/Fs1;
EEGdatasq = EEGdata.^2;
T30 = find (t1range == 30); % to get sample point at 30 seconds
T60 = find (t1range == 60); % to get sample point at 60 seconds
ya = EEGdatasq(T30:T60,:)
La=size(ya,1);
NFFTa = 2^nextpow2(La);
Ya = fft(ya,La,1)/La;
fa = Fs1/2*linspace(0,1,NFFTa/2+1);
YMa = abs(Ya);
figure; plot(fa,YMa(1:NFFTa/2+1,20),'b');
My problem is that the plot does not show half the FFT as it should, instead it seems to be shifted or compressed in some way, with the far right mirror-image of the FFT peaking on the right side of the graph and the bottom scale not showing the true frequency.
Further more, by changing the length of the signal sample taken (example replacing T60 with T100) the shape of the FFT becomes different.
Can anyone help identify where the mistake is please?
Thank you so much in advance
댓글 수: 0
답변 (1개)
Star Strider
2014년 8월 30일
I can’t run your code, but just looking, I would change your fft call to:
Ya = fft(ya,NFFTa,1)/La;
and see if that improves things.
-----------------------------------------------------------------
(FWIW: M.D., B/C IM, M.S. BME here!)
댓글 수: 2
Star Strider
2014년 8월 30일
Andrei Agius Anastasi’s ‘Answer’ movde here because it was a comment:
Yap that solved it! Thanks for that kind Sir, much appreciated ;)
Star Strider
2014년 8월 30일
My pleasure!
(The most sincere expression of thanks here on MATLAB Answers is to Accept the Answer that most closely solves your problem.)
참고 항목
카테고리
Help Center 및 File Exchange에서 EEG/MEG/ECoG에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!