Problem with x-axis of FFT eeg signal plot

5 ビュー (過去 30 日間)
Andrei Agius Anastasi
Andrei Agius Anastasi 2014 年 8 月 30 日
コメント済み: Star Strider 2014 年 8 月 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

回答 (1 件)

Star Strider
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
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
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 ExchangeEEG/MEG/ECoG についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by