<div dir="ltr">Dear Andreas,<div><br></div><div>Thank you very much again for detailed analysis.</div><div>I replicated the figure you suggested/intended by adding slight modification to your code. I attached the modified code below. I thought your point is really reasonable. I filed your suggestions and solutions to Bugzilla 1880. You can also see the figure generated by your code with modification.</div><div><br></div><div><a href="https://sccn.ucsd.edu/bugzilla/process_bug.cgi">https://sccn.ucsd.edu/bugzilla/process_bug.cgi</a><br></div><div><br></div><div>The EEGLAB developers will address the issue.</div><div>I deeply appreciate your careful investigation and kind contribution.</div><div><br></div><div>Makoto</div><div><br></div><div><br></div><div>EEG = eeg_emptyset;<br></div><div><div>EEG.srate = 500; EEG.pnts = 5000; EEG.trials = 1; EEG.nbchan = 3;</div><div>t = ( 0:EEG.pnts - 1 ) / EEG.srate;</div><div>EEG.data( 1, : ) = 2 * sin( 2 * pi * 50 * t );                     % 50 Hz sine</div><div>EEG.data( 2, : ) = 2 * sin( 2 * pi * 50 * t ) + t;                 % with drift</div><div>EEG.data( 3, : ) = 2 * sin( 2 * pi * 50 * t ) + sum(t) / EEG.pnts; % or offset</div><div><br></div><div>pop_spectopo(EEG, 1, [ 0 0 ], 'EEG', 'freqrange', [ 0 100 ], 'electrodes', 'off' )</div><div>legend({'Sine' 'Sine with Drift' 'Sine with Offset'}) % Makoto added this line</div><div><br></div><div>figure; set(gcf, 'Color', [0.93 0.96 1]);</div><div>h( 1 )  = subplot( 2, 2, 1 );</div><div>[sine1, F]   = pwelch( EEG.data(1,:)', hamming( EEG.srate ), 0, 1024, EEG.srate );</div><div>[drift1, F]  = pwelch( EEG.data(2,:)', hamming( EEG.srate ), 0, 1024, EEG.srate );</div><div>[offset1, F] = pwelch( EEG.data(3,:)', hamming( EEG.srate ), 0, 1024, EEG.srate );</div><div>semilogy(F, sine1',   'r'); hold on</div><div>semilogy(F, drift1',  'g'); </div><div>semilogy(F, offset1', 'b');</div><div>title( 'Hamming win w/ zero-padding' )</div><div>legend( 'Sine', 'w/ drift', 'w/ offset' )</div><div><br></div><div>h( 2 )  = subplot( 2, 2, 2 );</div><div>[sine2, F]   = pwelch( EEG.data(1,:)', hamming( EEG.srate ), 0, EEG.srate, EEG.srate );</div><div>[drift2, F]  = pwelch( EEG.data(2,:)', hamming( EEG.srate ), 0, EEG.srate, EEG.srate );</div><div>[offset2, F] = pwelch( EEG.data(3,:)', hamming( EEG.srate ), 0, EEG.srate, EEG.srate );</div><div>semilogy(F, sine2',   'r'); hold on</div><div>semilogy(F, drift2',  'g'); </div><div>semilogy(F, offset2', 'b');</div><div>title( 'Hann win w/o zero-padding' )</div><div><br></div><div>h( 3 )  = subplot( 2, 2, 3 );</div><div>[sine3, F]   = pwelch( EEG.data(1,:)', hann( EEG.srate ), 0, EEG.srate, EEG.srate );</div><div>[drift3, F]  = pwelch( EEG.data(2,:)', hann( EEG.srate ), 0, EEG.srate, EEG.srate );</div><div>[offset3, F] = pwelch( EEG.data(3,:)', hann( EEG.srate ), 0, EEG.srate, EEG.srate );</div><div>semilogy(F, sine3',   'r'); hold on</div><div>semilogy(F, drift3',  'g'); </div><div>semilogy(F, offset3', 'b');</div><div>title( 'Hann win w/o zero-padding' )</div><div><br></div><div>h( 4 )  = subplot( 2, 2, 4 );</div><div>[sine4, F]   = pwelch( EEG.data(1,:)', blackmanharris( EEG.srate ), 0, EEG.srate, EEG.srate );</div><div>[drift4, F]  = pwelch( EEG.data(2,:)', blackmanharris( EEG.srate ), 0, EEG.srate, EEG.srate );</div><div>[offset4, F] = pwelch( EEG.data(3,:)', blackmanharris( EEG.srate ), 0, EEG.srate, EEG.srate );</div><div>semilogy(F, sine4',   'r'); hold on</div><div>semilogy(F, drift4',  'g'); </div><div>semilogy(F, offset4', 'b');</div><div>title( 'Blackman-Harris win w/o zero-padding' )</div><div><br></div><div>set( h, 'XLim', [ 0 100 ], 'YLim', [10^-15 10^1] )</div><div>set(findall(gcf, '-property', 'fontsize'), 'fontsize', 14)</div></div><div><br></div><div><br></div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 1, 2016 at 9:07 AM, Andreas Widmann <span dir="ltr"><<a href="mailto:widmann@uni-leipzig.de" target="_blank">widmann@uni-leipzig.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Dear Isaiah and Makoto,<br>
<br>
the problem is presumably related to spectral leakage due to (a) the Hamming window used by default in pwelch combined with (b) larger offsets and/or drifts in the data and possibly (c) zero padding.<br>
(a) The Hamming window type does not end at zero amplitude at the edges, thus, it allows a certain amount of spectral leakage. Purpose is to improve spectral resolution by suppressing the first side lobes.<br>
<br>
I will add some demo code below demonstrating the problem. Depending on your EEGLAB version either the upper left or the upper right panel will resemble the corresponding EEGLAB spectopo plot. In the recent EEGLAB versions (at least the git developer version; not sure whether there is a public version yet) zero-padding is not applied unless necessary/requested. Hann or more elaborate window types as used in the two lower panels will efficiently suppress leakage at the cost of spectral resolution (obvious for Blackman-Harris).<br>
<br>
Makoto, this issue is reappearing on the quite regularly (monthly?). I would like to suggest some changes:<br>
* The issue should be mentioned in the help text of (pop_)spectopo, optimally with a reference to a FAQ or something similar (e.g. <a href="http://sccn.ucsd.edu/wiki/TIPS_and_FAQ" rel="noreferrer" target="_blank">http://sccn.ucsd.edu/wiki/TIPS_and_FAQ</a>) explaining the problem in more detail.<br>
* A window type parameter could be added to spectopo (at least allowing to check whether the observed effects disappear). I quickly scanned through the code and if I didn’t miss something major the necessary adjustments should be limited.<br>
* In theory it should be possible to automatically check whether offset and/or drift exceed a certain threshold and either issue a warning or even automatically adjust the applied window type. However, I would consider this as a major endeavor. Not really sure whether it’s worth (or even works).<br>
<br>
Best,<br>
Andreas<br>
<br>
%%<br>
EEG = eeg_emptyset;<br>
EEG.srate = 500; EEG.pnts = 5000; EEG.trials = 1; EEG.nbchan = 3;<br>
t = ( 0:EEG.pnts - 1 ) / EEG.srate;<br>
EEG.data( 1, : ) = 2 * sin( 2 * pi * 50 * t ); % 50 Hz sine<br>
EEG.data( 2, : ) = 2 * sin( 2 * pi * 50 * t ) + t; % with drift<br>
EEG.data( 3, : ) = 2 * sin( 2 * pi * 50 * t ) + sum(t) / EEG.pnts; % or offset<br>
<br>
pop_spectopo(EEG, 1, [ 0 0 ], 'EEG', 'freqrange', [ 0 100 ], 'electrodes', 'off' )<br>
<br>
figure<br>
h( 1 ) = subplot( 2, 2, 1 );<br>
pwelch( EEG.data', hamming( 512 ), 0, 1024, EEG.srate );<br>
title( 'Hamming win w/ zero-padding' )<br>
legend( 'Sine', 'w/ drift', 'w/ offset' )<br>
<br>
h( 2 ) = subplot( 2, 2, 2 );<br>
pwelch( EEG.data', hamming( EEG.srate ), 0, EEG.srate, EEG.srate );<br>
title( 'Hamming win w/o zero-padding' )<br>
<br>
h( 3 ) = subplot( 2, 2, 3 );<br>
pwelch( EEG.data', hann( EEG.srate ), 0, EEG.srate, EEG.srate );<br>
title( 'Hann win w/o zero-padding' )<br>
<br>
h( 4 ) = subplot( 2, 2, 4 );<br>
pwelch( EEG.data', blackmanharris( EEG.srate ), 0, EEG.srate, EEG.srate );<br>
title( 'Blackman-Harris win w/o zero-padding' )<br>
<br>
set( h, 'XLim', [ 0 100 ], 'YLim', [ -150 20 ] )<br>
%%<br>
<div><div><br>
> Am 25.03.2016 um 14:25 schrieb Isaiah Innis <<a href="mailto:isainnis@indiana.edu" target="_blank">isainnis@indiana.edu</a>>:<br>
><br>
> That is good to know, thank you. I'm relieved it's not a problem with copying the ICA weights.<br>
><br>
> 2016-03-22 5:33 GMT-04:00 Makoto Miyakoshi <<a href="mailto:mmiyakoshi@ucsd.edu" target="_blank">mmiyakoshi@ucsd.edu</a>>:<br>
> Dear Isaiah,<br>
><br>
> There is a known problem that if you have a big low frequency drift, EEGLAB's spectrum analysis fails. Once I understood how this happens when I discussed a related issue with Andreas, but now I don't remember it. Anyway, if you want to make the spectrum plot work, excessive low-frequency drift should be removed.<br>
><br>
> Makoto<br>
><br>
> On Fri, Feb 19, 2016 at 6:02 AM, Isaiah Innis <<a href="mailto:isainnis@umail.iu.edu" target="_blank">isainnis@umail.iu.edu</a>> wrote:<br>
> Hello eeglablist:<br>
><br>
><br>
> Some of our datasets have displayed a large amount of slow frequency drifts. See here for an example: <a href="https://onedrive.live.com/redir?resid=A1398B0A4C8F85DE!2199&authkey=!AD6I0359QqJH5eA&v=3&ithint=photo%2cpng" rel="noreferrer" target="_blank">https://onedrive.live.com/redir?resid=A1398B0A4C8F85DE!2199&authkey=!AD6I0359QqJH5eA&v=3&ithint=photo%2cpng</a><br>
><br>
> In order to address this, we have tried the suggestion mentioned on this list of:<br>
> 1 Filtering each dataset with a 1Hz highpass<br>
> 2 Run ICA on this dataset<br>
> 3 Copy the ICA weights from the 1Hz dataset and apply them to our normal 0.1Hz filtered dataset<br>
><br>
> However when viewing the components in the 0.1Hz dataset (the one we copied weights onto), I have noticed jagged spectra in the properties of several components.<br>
> Here are a few examples (the 1Hz component is on the right in the image, and the 0.1Hz is on the left):<br>
><br>
> <a href="https://onedrive.live.com/redir?resid=A1398B0A4C8F85DE!2191&authkey=!ALiODmU2Hqc5HZE&ithint=folder%2cpng" rel="noreferrer" target="_blank">https://onedrive.live.com/redir?resid=A1398B0A4C8F85DE!2191&authkey=!ALiODmU2Hqc5HZE&ithint=folder%2cpng</a><br>
><br>
> Is there something wrong here? These steps were suggested in vol 130 issue 5 of the eeglab digest for reference.<br>
><br>
> Thank you in advance,<br>
><br>
> --<br>
> Isaiah Innis<br>
> Indiana University '13<br>
> EEG Technician, IUB IRF<br>
><br>
><br>
> _______________________________________________<br>
> Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" rel="noreferrer" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
> To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu" target="_blank">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>
> For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu" target="_blank">eeglablist-request@sccn.ucsd.edu</a><br>
><br>
><br>
><br>
> --<br>
> Makoto Miyakoshi<br>
> Swartz Center for Computational Neuroscience<br>
> Institute for Neural Computation, University of California San Diego<br>
><br>
><br>
><br>
> --<br>
> Isaiah Innis<br>
> Indiana University '13<br>
> EEG Technician, IUB IRF<br>
><br>
> _______________________________________________<br>
> Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" rel="noreferrer" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>
> To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu" target="_blank">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>
> For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu" target="_blank">eeglablist-request@sccn.ucsd.edu</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<br></div></div>
</div></div></div>