[Eeglablist] Units in output of timefreq

Makoto Miyakoshi mmiyakoshi at ucsd.edu
Mon Aug 8 18:10:12 PDT 2016


Dear Niko (cc to Scott and EEGLAB developers),

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.

I investigated it running your example code (thank you very much). I found
that in timefreq line 453-454,

tmpX = sum(wav .* tmpX);
tmpall( freqind, index, :) = tmpX;

'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.

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.

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.

I filed this issue to EEGLAB mailing list.

Thanks Niko for your question! I feel better now by solving the decade-long
question...

Makoto



On Wed, Aug 3, 2016 at 10:25 AM, Niko Busch <niko.busch at gmail.com> wrote:

> Hi everyone,
>
> can you help me understand the output of the timefreq function? The main
> output is "tf", and abs(tf) is a measure of spectral power. But what
> exactly do the units of tf represent?
>
> Below, I attach a simple script that simulates a synthetic oscillation of
> known frequency and amplitude. Using timefreq 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.
>
> So, what do values in tf represent and how should I "normalize" these
> values to match the amplitude of the input signal?
>
> Thanks,
> Niko
>
>
> %% Create sine wave
> clear all
> D = 4;       % total signal duration in seconds.
> sigD = 1;    % duration of the test oscillation within the signal.
> F = 10;      % frequency of the test oscillationin Hz.
> P = .25;     % Phase of the test oscillation. 2 pi radians = 360 degrees
> srate = 256; % sampling rate, i.e. N points per sec used to represent sine
> wave.
> T = 1/srate; % sampling period, i.e. for this e.g. points at 1 ms
> intervals
> t = [T:T:D]; % time vector.
>
> sigpoints = length(t)/2 - (sigD*srate)/2:(length(t)/2 + (sigD*srate)/2)-1;
> mysig = zeros(1,D*srate);
> mysig(sigpoints) = sin(2*F*t(sigpoints)*pi+ 2*pi*P);
>
> %% TF computation
> [tf, outfreqs, outtimes] = timefreq(mysig', srate, ...
>     'cycles', 4, 'wletmethod', 'dftfilt3', 'freqscale', 'linear', ...
>     'freqs', F);
>
> %% Plot
> figure; hold all
> plot(t,mysig);
> plot(outtimes./1000,abs(tf))
> xlabel('Time (seconds)');
> ylabel('Amplitude');
> legend('input signal', 'wavelet result')
>
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.
> ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to
> eeglablist-request at sccn.ucsd.edu
>



-- 
Makoto Miyakoshi
Swartz Center for Computational Neuroscience
Institute for Neural Computation, University of California San Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20160808/45896f5e/attachment.html>


More information about the eeglablist mailing list