How to interpret the following complex demodulation code?
2 次查看(过去 30 天)
显示 更早的评论
Hi all,
I am still pretty new to MATLAB and using it to analyze EEG data. Following is a code passed on to me which performs complex demodulation on EEG data. However, I am trying to really understand what this code does based on the set paramters so can someone please help me by explaining what exactly is this piece of code doing with my EEG data?
[b, a] = butter(PARAM.cdemod_forder, PARAM.cdemod_filter_lowpass / EEG.srate, 'low');
carArray = exp(-2*pi * li * PARAM.cdemod_freq * (0:size(EEG.data,2) - 1)) / EEG.srate);
x = double(EEG.data(iChan, :, iTrial)) .* carArray;
x = filtfilt(b, a, x);
Following are the paramter info:
PARAM.cdemod_forder = 4
PARAM.cdemod_filter_lowpass = 5
EEG.srate = 250
PARAM.cdemod_freq = 13.5
iChan and iTrial are just variables within a for loop basically the selected channels and trials from the EEG data.
Your help is very much appreciated. Please let me know if the question is not clear or if you require further information on it.
Thanks,
Mo
0 个评论
回答(1 个)
dfl
2019-7-6
编辑:dfl
2019-7-6
Hi Mo, here's what is happening:
line 1 makes a butterworth lowpass filter
line 2 makes a complex sinusoid at the demodulation frequency
line 3 multiplies the EEG signal with the complex sinusoid (multiplication in the time domain is convultion in the frequency domain... resulting in a frequency shift). This shifts the spectral components at the demodulation frequency down to zero (DC).
line 4 uses the demodulation filter (from line 1) to lowpass filter the signal (removing the high frequency components) around the positive and negative frequencies near the band edge.
The filtfilt command does forward/backward filtering, which ends up filtering twice (essentially doubling the filter order) but ends up with no phase shift.
0 个评论
另请参阅
类别
在 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!