<div dir="ltr">Dear Niko (cc to Scott and EEGLAB developers),<div><br></div><div>Niko, I know your question is valid because I have been wondering this issue over a decade! Actually, the more critical question is why the raw data before dB conversion is so large (such as several thousands, when data are only +/- 1uV peak-to-peak). It's time for me to find it out myself.</div><div><br></div><div>I investigated it running your example code (thank you very much). I found that in timefreq line 453-454,</div><div><br></div><div>tmpX = sum(wav .* tmpX);<br></div><div><div>tmpall( freqind, index, :) = tmpX;</div></div><div><br></div><div>'wav' is a wavelet kernel generated by dftfilt3 (default) and tmpX is the chunk of EEG data provided, and the output tmpX is a complex number, and this is eventually passed to 'tf' which is the final complex output.</div><div><br></div><div>When I increased 'cycles' from 4 to 6 and 8, the length of 'wav' were 115, 171, 229 (by the way this can be calculated by 'wavelet = dftfilt3(freqs, [4|6|8], srate); length(wavelet)), the value of 'tmpX' increased as well--this is so obvious, because 'tmpX' is a simple sum of wav.*tmpX without normalization, so as 'wav' becomes longer, sum of 'tmpX' becomes larger.</div><div><br></div><div>Intuitively, I thought that the output 'tmpX' needs to be normalized by the length of data, such as /length(wav) to allow users to compare raw output. So far this has not been a major problem because most of us use the default dB conversion, so scale was not a problem. However, as Niko is asking, it becomes confusing once one try to use its the value before dB conversion.</div><div><br></div><div>I filed this issue to EEGLAB mailing list.</div><div><br></div><div>Thanks Niko for your question! I feel better now by solving the decade-long question...</div><div><br></div><div>Makoto</div><div><br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 3, 2016 at 10:25 AM, Niko Busch <span dir="ltr"><<a href="mailto:niko.busch@gmail.com" target="_blank">niko.busch@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="color:rgb(0,0,0);font-size:12.8px">Hi everyone, </span><br style="color:rgb(0,0,0);font-size:12.8px"><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">can you help me understand the output of the </span><span style="color:rgb(0,0,0);font-size:12.8px">timefreq</span><span style="color:rgb(0,0,0);font-size:12.8px"> function? The main output is "tf", and abs(tf) is a measure of spectral power. But what exactly do the units of tf represent? </span><br style="color:rgb(0,0,0);font-size:12.8px"><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">Below, I attach a simple script that simulates a synthetic oscillation of known frequency and amplitude. Using </span><span style="color:rgb(0,0,0);font-size:12.8px">timefreq</span><span style="color:rgb(0,0,0);font-size:12.8px"> on this signal, I would expect the values of abs(tf) to match the amplitude of that oscillation. But as you see, the values are orders of magnitude larger than the amplitude of the oscillation. Furthermore, I notice that the magnitude of the values in tf depends on the sampling frequency of the input signal and the number of wavelet cycles. </span><br style="color:rgb(0,0,0);font-size:12.8px"><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">So, what do values in tf represent and how should I "normalize" these values to match the amplitude of the input signal? </span><br style="color:rgb(0,0,0);font-size:12.8px"><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">Thanks, </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">Niko </span><br style="color:rgb(0,0,0);font-size:12.8px"><br style="color:rgb(0,0,0);font-size:12.8px"><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">%% Create sine wave </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">clear all </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">D = 4; % total signal duration in seconds. </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">sigD = 1; % duration of the test oscillation within the signal. </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">F = 10; % frequency of the test oscillationin Hz. </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">P = .25; % Phase of the test oscillation. 2 pi radians = 360 degrees </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">srate = 256; % sampling rate, i.e. N points per sec used to represent sine wave. </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">T = 1/srate; % sampling period, i.e. for this e.g. points at 1 ms intervals </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">t = [T:T:D]; % </span><span style="color:rgb(0,0,0);font-size:12.8px">time</span><span style="color:rgb(0,0,0);font-size:12.8px"> vector. </span><br style="color:rgb(0,0,0);font-size:12.8px"><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">sigpoints = length(t)/2 - (sigD*srate)/2:(length(t)/2 + (sigD*srate)/2)-1; </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">mysig = zeros(1,D*srate); </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">mysig(sigpoints) = sin(2*F*t(sigpoints)*pi+ 2*pi*P); </span><br style="color:rgb(0,0,0);font-size:12.8px"><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">%% TF computation </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">[tf, outfreqs, outtimes] = </span><span style="color:rgb(0,0,0);font-size:12.8px">timefreq</span><span style="color:rgb(0,0,0);font-size:12.8px">(mysig', srate, ... </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px"> 'cycles', 4, 'wletmethod', 'dftfilt3', 'freqscale', 'linear', ... </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px"> 'freqs', F); </span><br style="color:rgb(0,0,0);font-size:12.8px"><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">%% Plot </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">figure; hold all </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">plot(t,mysig); </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">plot(outtimes./1000,abs(tf)) </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">xlabel('</span><span style="color:rgb(0,0,0);font-size:12.8px">Time</span><span style="color:rgb(0,0,0);font-size:12.8px"> (seconds)'); </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">ylabel('Amplitude'); </span><br style="color:rgb(0,0,0);font-size:12.8px"><span style="color:rgb(0,0,0);font-size:12.8px">legend('input signal', 'wavelet result') </span><br></div>
<br>______________________________<wbr>_________________<br>
Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" rel="noreferrer" target="_blank">http://sccn.ucsd.edu/eeglab/<wbr>eeglabmail.html</a><br>
To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu">eeglablist-unsubscribe@sccn.<wbr>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">eeglablist-request@sccn.ucsd.<wbr>edu</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><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>