Upload
others
View
19
Download
0
Embed Size (px)
Citation preview
The Wavelet Complex
• Morlet wavelet is only 2D • EEG data has 3 dimensions that need
analysis (time, power, phase)• Key conceptual point: we need a third
dimension… and it is imaginary
Matlab Visuals
• Figure 13.1– plot3(time,real(wavelet),imag(wavelet),'m')
• Figure 13.2– plot3(time,real(wavelet),imag(wavelet),'k')
Imaginary Math
• Complex numbers have two parts– Real part and imaginary
part (eg a+ib)• Square root of negative
numbers• Can still be thought of as the
dimensions of a Cartesian plot (x and y axes) Electronics-tutorial.ws
Polar Notation• Way to characterize circular and spherical
data• Magnitude – hypotenus, point from origin to
complex number• θ (theta) – angle formed by hypotenus and
positive real axis• So θ gives the direction to point and M gives
the length– Together this gives the
location (like rectangular notion)
Conversion between Polar and Rectangular Notation
• M = sqrt(real2 +imag2)– Same as a2 + b2 = c2
• θ = arctan(imag/real)• OR
– cart2pol OR pol2cart in Matlab
Mathisfun.com
Euler’s Formula
• Meiθ = M[cos(θ)+isin(θ)]• Remember that a+ib = M[cos(θ)+isin(θ)]• So Euler’s formula allows representation
of complex numbers as points on a circle!• Help with conceptualizing this
relationship?• Matlab 13.4
– plot( (-.35+cos(time)/5) + 1i*(.35+sin(time)/5) ,'m'
Complex Morlet Wavelet
• Ae-t2/2s2 ei2πft =Complex Morlet Wavelet• ae-t2/2s2 is the Gaussian• ei2πft Euler’s combined with sine wave
– eiθ except θ is 2πft part of a sine wave
• So we have all the pieces here– Gaussian plus a complex sine wave!
• Additional points?
Creating a CMV• % parameters...• srate = 500; % sampling rate in Hz• f = 10; % frequency of wavelet in Hz• time = -1:1/srate:1; % time, from -1 to 1 second in steps of 1/sampling-rate• s = 6/(2*pi*f);• % and together they make a wavelet• wavelet = exp(2*pi*1i*f.*time) .* exp(-time.^2./(2*s^2)); • figure• plot(221)• % show the projection onto the real axis• plot3(time,real(wavelet),imag(wavelet),'r')• xlabel('Time (ms)'), ylabel('real axis')• view(0,90)• title('Projection onto real and time axes')
Complex Wavelet
Convolution•The result of the real-valued wavelets map onto the real axis (fig 12.7)•The imaginary value is ignored in these
Extracting Information from the Complex Dot Product
• “When you compute the dot product between a complex wavelet and a signal the result of the dot product is a complex number”
• We can use Euler’s formula to represent this number in polar space!
• Compare complex dot product with real-valued dot product (ignored the imaginary part of complex value)
Extracting Information from Complex Dot Product
• Bandpass-filter signal– The projection on the real axis– This was the information from chapter 12– Dependent on the phase relationship
Extracting Power from Complex Dot Product
• The length of M is defined by the result of the dot product– Length of vector (M) = amplitude– Amplitude2 = power
• The amount of similarity in the kernel and signal dictates the length
• When the EEG data contain abundant energy at thewavelet frequency the power will be high
Bme240.eng.uci.edu
Extracting Phase from Complex Dot Product
• The angle of the vector in relation to the real axis gives an estimate of the phase angle
• Estimated as the point in time correspond-ing to the center of the wavelet and at the peak frequency ofthe wavelet
• Can anyone unpack this statement?
Time Points to Time Series• Extracting the information from a series of
dot products gives us time series data• Gives information across 3-dimensions for a
recording • This can then be used to create plots in up to
3 dimensions (e.g. time series of power for a frequency band
• Mteiθt Euler’s formulavarying over time
• Figure 13.9
Parameters of Wavelets
• Basically they will vary depending on what you are looking for
• Frequencies– At least a few cycles per epoch– Nyquist frequency upper limit– 20-30 wavelets at varying
frequencies is usually a good number– Higher frequency = more data points = good
Parameters: Scaling
• If you want to highlight the low frequencies use logarithmic scaling
• If you want to emphasize high frequencies use linear scaling
• Keep an eye on what you use!
Logarithmic frequency scaling
0 500 10002
4.2
8.7
18.3
38.3
80Linear frequency scaling
0 500 1000
10
20
30
40
50
60
70
Wavelet Length
• Long enough so that the ends taper to zero• Definitely better to overshoot here
– Avoid edge effects and there is no negative affect of multiplying data by more zeros
-0.5 0 0.5-1
0
1Good.
-0.5 0 0.5-1
0
1Not good.
-0.5 0 0.5-1
0
1
Time
Still works.
Cycles for the Gaussian Taper• Altering this number creates a trade off
between temporal and frequency precisions
• Larger number of cycles gives better frequency precision
• Smaller yields better temporal precision
-0.5 0 0.5-1
-0.5
0
0.5
1
Time
Wavelet at 10 Hz with 3 cycles
-0.5 0 0.5-1
-0.5
0
0.5
1
Time
Wavelet at 10 Hz with 7 cycles
Cycles for the Gaussian Taper
• Smaller number of cycles: – Better for detecting transient activations– More precise at localizing dynamics
• Larger number of cycles – More sensitive to longer activations – More precise at determining the frequency of the
dynamic
Plaza.ufl.edu
0 10 20 30 40 500
50
100
150
200
250
300
Frequency (Hz)
3 cycles7 cycles
Frequency Smoothing
• FWHM for a Gaussian distribution• Reports the influence of neighboring
frequencies on the result of wavelet convolution
0 5 10 15 20 25 300
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1Wavelet spectrum and FWHM
Frequency (Hz)
Nor
mal
ized
pow
er
0 10 20 30 40 50 60 70 800
10
20
30
40
50
60
70FWHM by Frequency
Frequency (Hz)
FWH
M (
Hz)
3103-10
Smoothing Continued
• Normalize power spectrum • Identify the points around peak• Then subtract these points
terpconnect.umd.edu/~toh/spectrum/iSignal.html
Tips
• FFT only needs to be computed once before looping over frequencies– Using conv function causes FFT redundancy
• Use an FFT that is a power of two– Zero-padding to get this
• Concatenate those trials!– Only need to perform one convolution