BME452 Biomedical Signal Processing

Slides:



Advertisements
Similar presentations
DCSP-12 Jianfeng Feng
Advertisements

An Introduction to Fourier and Wavelet Analysis: Part I Norman C. Corbett Sunday, June 1, 2014.
Department of Kinesiology and Applied Physiology Spectrum Estimation W. Rose
ECE 8443 – Pattern Recognition EE 3512 – Signals: Continuous and Discrete Objectives: Response to a Sinusoidal Input Frequency Analysis of an RC Circuit.
ECE 8443 – Pattern Recognition ECE 8423 – Adaptive Signal Processing Objectives: Periodograms Bartlett Windows Data Windowing Blackman-Tukey Resources:
Digital Kommunikationselektronik TNE027 Lecture 5 1 Fourier Transforms Discrete Fourier Transform (DFT) Algorithms Fast Fourier Transform (FFT) Algorithms.
DFT/FFT and Wavelets ● Additive Synthesis demonstration (wave addition) ● Standard Definitions ● Computing the DFT and FFT ● Sine and cosine wave multiplication.
Let’s go back to this problem: We take N samples of a sinusoid (or a complex exponential) and we want to estimate its amplitude and frequency by the FFT.
Digital Signal Processing
Short Time Fourier Transform (STFT)
Chapter 12 Fourier Transforms of Discrete Signals.
Discrete Fourier Transform(2) Prof. Siripong Potisuk.
Spectral Analysis Spectral analysis is concerned with the determination of the energy or power spectrum of a continuous-time signal It is assumed that.
Introduction To Signal Processing & Data Analysis
Introduction to Spectral Estimation
Goals For This Class Quickly review of the main results from last class Convolution and Cross-correlation Discrete Fourier Analysis: Important Considerations.
DTFT And Fourier Transform
Lecture 1 Signals in the Time and Frequency Domains
Motivation Music as a combination of sounds at different frequencies
Chapter 4 The Frequency Domain of Signals and Systems.
ECE 8443 – Pattern Recognition ECE 3163 – Signals and Systems Objectives: Introduction to the IEEE Derivation of the DFT Relationship to DTFT DFT of Truncated.
Transforms. 5*sin (2  4t) Amplitude = 5 Frequency = 4 Hz seconds A sine wave.
Preprocessing Ch2, v.5a1 Chapter 2 : Preprocessing of audio signals in time and frequency domain  Time framing  Frequency model  Fourier transform 
Spectral Analysis AOE March 2011 Lowe 1. Announcements Lectures on both Monday, March 28 th, and Wednesday, March 30 th. – Fracture Testing –
T – Biomedical Signal Processing Chapters
1 BIEN425 – Lecture 10 By the end of the lecture, you should be able to: –Describe the reason and remedy of DFT leakage –Design and implement FIR filters.
Speech Signal Representations I Seminar Speech Recognition 2002 F.R. Verhage.
EE104: Lecture 5 Outline Review of Last Lecture Introduction to Fourier Transforms Fourier Transform from Fourier Series Fourier Transform Pair and Signal.
Real time DSP Professors: Eng. Julian S. Bruno Eng. Jerónimo F. Atencio Sr. Lucio Martinez Garbino.
1 Spectrum Estimation Dr. Hassanpour Payam Masoumi Mariam Zabihi Advanced Digital Signal Processing Seminar Department of Electronic Engineering Noushirvani.
Lecture#10 Spectrum Estimation
GG313 Lecture 24 11/17/05 Power Spectrum, Phase Spectrum, and Aliasing.
Lecture 5 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013)1 BME 452 Biomedical Signal Processing Lecture 5  Digital filtering.
Lecture 21: Fourier Analysis Using the Discrete Fourier Transform Instructor: Dr. Ghazi Al Sukkar Dept. of Electrical Engineering The University of Jordan.
Fourier Analysis Using the DFT Quote of the Day On two occasions I have been asked, “Pray, Mr. Babbage, if you put into the machine wrong figures, will.
Lecture 3: The Sampling Process and Aliasing 1. Introduction A digital or sampled-data control system operates on discrete- time rather than continuous-time.
ECE 8443 – Pattern Recognition EE 3512 – Signals: Continuous and Discrete Objectives: Derivation of the DFT Relationship to DTFT DFT of Truncated Signals.
Power Spectral Estimation
Learning from the Past, Looking to the Future James R. (Jim) Beaty, PhD - NASA Langley Research Center Vehicle Analysis Branch, Systems Analysis & Concepts.
Short Time Fourier Transform (STFT) CS474/674 – Prof. Bebis.
EE422G Signals and Systems Laboratory Fourier Series and the DFT Kevin D. Donohue Electrical and Computer Engineering University of Kentucky.
Lecture 19 Spectrogram: Spectral Analysis via DFT & DTFT
Chapter 4 Discrete-Time Signals and transform
Fourier series With coefficients:.
Discrete Fourier Transform (DFT)
Ch. 2 : Preprocessing of audio signals in time and frequency domain
CS 591 S1 – Computational Audio
Speech Signal Processing
Spectral Analysis Spectral analysis is concerned with the determination of the energy or power spectrum of a continuous-time signal It is assumed that.
NONPARAMETRIC METHODs (NPM) OF POWER SPECTRAL DENSITY ESTIMATION P. by: Milkessa Negeri (…M.Tech) Jawaharlal Nehru Technological University,India December.
EE Audio Signals and Systems
Fourier Analysis of Signals Using DFT
Laboratory in Oceanography: Data and Methods
Ideal Filters One of the reasons why we design a filter is to remove disturbances Filter SIGNAL NOISE We discriminate between signal and noise in terms.
Advanced Digital Signal Processing
Lecture 18 DFS: Discrete Fourier Series, and Windowing
Lecture 17 DFT: Discrete Fourier Transform
LECTURE 18: FAST FOURIER TRANSFORM
9.4 Enhancing the SNR of Digitized Signals
Chapter 8 The Discrete Fourier Transform
Chapter 4. Time Response I may not have gone where I intended to go, but I think I have ended up where I needed to be. Pusan National University Intelligent.
Chapter 8 The Discrete Fourier Transform
INTRODUCTION TO THE SHORT-TIME FOURIER TRANSFORM (STFT)
Lec.6:Discrete Fourier Transform and Signal Spectrum
Electrical Communication Systems ECE Spring 2019
ENEE222 Elements of Discrete Signal Analysis Lab 9 1.
Matlab Tutorial #2 Kathleen Chen February 13, 2018.
LECTURE 18: FAST FOURIER TRANSFORM
Fourier Transforms of Discrete Signals By Dr. Varsha Shah
Electrical Communications Systems ECE
Presentation transcript:

BME452 Biomedical Signal Processing Lecture 4 Fourier analysis and spectral estimation Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Lecture 4 Outline In this lecture, we’ll study the frequency domain analysis methods for signals Discrete Fourier transform Classical spectral estimation Some examples of spectral estimation of signals Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Introduction Knowledge of cyclic or oscillating activity in signals is very important Fourier transform is the oldest method for analysing the cycles, i.e. obtaining frequency information Eg: analysing the cycle of variable stars is the oldest application of analysing cycles Variable stars are, quite simply, stars that change brightness An example is given below: What is the approximate period? Figure from R.Shiavi, Introduction to applied statistical signal analysis Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Discrete Fourier Transform Since we are dealing with discrete-time signals, we will skip continuous Fourier transform and move into discrete Fourier transform (DFT) Discrete time and frequency We have discrete time, similarly, we can have only discrete frequencies Discrete frequency Assume N is the number of sampled points Define the duration of the signal, P=NT, where T is the sampling interval We have the discrete frequency variable (frequency number), m The frequency number of m will run from 1 to N The actual frequency will run from 0 to fs/2 with fd intervals So, the frequency spacing, fd=1/NT or fd=fs/N Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Discrete Fourier Transform (cont) Some important points The actual frequency =m*fd=m*fs/N from 0 to fs Frequency number, m=0,1,2,3,…..N points Due to symmetry, we normally plot the values from 0 to fs/2 only Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013)

Actual frequency vs frequency number Consider the following example Time = 2s, N=12 => fs = 6 Hz Frequency plot is from 0 to 3 Hz m=0,1.....N/2 (the rest of N/2 points rejected due to symmetry in freq domain) So, m = 0,1,2,3,4,5,6 Actual frequency => (m*fs)/N So, actual frequency => 0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0 Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013)

Discrete Fourier Transform (cont) DFT is used computationally to perform Fourier analysis of discrete-time signals DFT is defined as Inverse DFT (IDFT) is defined as Note: i and j will be used to represent Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Discrete Fourier Transform (cont) Using Euler’s relation, So (why?) Now, DFT is Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Discrete Fourier Transform (cont) As you can see, DFT now consist of a real part and an imaginary for every frequency number m The magnitude spectra And phase spectra where Normally, we are interested in this for signals Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Discrete Fourier Transform using MATLAB for m=1:N, sumn=0; for n=1:N, sumn=sumn + x(n)*(cos (2*pi*(m-1)*(n-1)/N)); end dftreal(m)=T*sumn; sumn=sumn + x(n)*(sin (2*pi*(m-1)*(n-1)/N)); dftimag(m)=-T*sumn; dftmag(m)=sqrt(dftreal(m)*dftreal(m)+dftimag(m)*dftimag(m)); dftphase(m)=atan(dftimag(m)/dftreal(m)); You can also use fft function in MATLAB, do you know what is fft? Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

A worked example of DFT The table shows the intensity of ionospheric reflections starting from midnight Assume fs=24 (i.e. hours in a day) T=1/24, N=12 plot(x); axis([1 12 -20 30]); title('Ionospheric data'); xlabel('Time (h) - note it should one less'); ylabel('Intensity'); Time(hrs) Intensity 6 1 20 2 28 3 8 4 5 -7 7 9 -14 10 -19 11 -12 Figure from R.Shiavi, Introduction to applied statistical signal analysis MATLAB indexes from 1, so 1 must be reduced from this index to push it back to 0 Figure from MATLAB Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Ionospheric DFT Note the symmetry line. plot(dftreal,'+-'); xlabel('Frequency number (m)'); ylabel('Magnitude'); hold on; plot(dftimag,'r*-'); axis([1 12 -4 4]); xlabel('Frequency number (m) - note it should one less'); title('Real and imaginary parts'); Figure from R.Shiavi, Introduction to applied statistical signal analysis Note the symmetry line. DFT phase is conjugate symmetry at this line. Y= a+jb Y*=a-jb Frequency number or actual frequency value?? If the frequency number is m, the actual frequency values are m*fs/N –more on this later Figure from MATLAB Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Ionospheric Spectra Figure from R.Shiavi, Introduction to applied statistical signal analysis Figure from MATLAB For magnitude and phase spectra, the actual frequencies are m*fs/N So, actual freq => 2m, i.e. as m=0,1,2,3,4,5,….11 and 2m=0,2,4,6,8,10 cycles/day Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Ionospheric Spectra (cont.) Some points to note Normally the magnitude spectra is the output that we want from DFT Magnitude spectra measure the energy of the signal at the specific frequencies Magnitude spectra runs from f=0 to one point less than fs/2 with N/2 points, i.e. fs/N frequency spacing In the example, fs=24, N=12, so the actual frequency scale runs from 0,2,4,6,8,10 Hz But DFT is plotted in frequency numbers for N points, so frequency number runs from 0,1,2,3,4,….,11 Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Picket fence effect One of the problem with DFT is that it provides values of X(m) only at a specific set of frequencies What if an important value exist at the frequency, f≠m? In our example, we have magnitude spectra values for freq=0,2,4,6,8,10 What if there was an important cycle with freq=1? We would have missed it! This problem is known as picket fence effect Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Zero padding to increase the DFT resolution The solution is to increase the signal size by zero padding This will increase N and hence reduce the frequency spacing And increase the resolution of DFT Example, assume we pad 12 zeros to the ionospheric signal and compute the magnitude spectra So, now N=24 Freq spacing =fs/N=24/24=1 And frequency scale has 12 points and has values for freq= 0,1,2,3,4,5,6,7,8,9,10,11 From the plot, we can see that there are values for freq=1,3,5,…. Figure from R.Shiavi, Introduction to applied statistical signal analysis Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Effect of truncation When we compute DFT, we assume that the signal is one complete cycle extracted from a portion of a longer signal that is periodic This is a basic assumption of DFT That is, we have truncated the signal (though in reality we did not) If the signal was indeed periodic, it would the same starting and ending points after truncation But then for our signals, we have discontinuity, so this creates a lot of noise Technically this problem is known as spectral leakage but we won’t worry about this term In the ionospheric signal example: Ionospheric signal Truncate Discontinuity at truncation points We have this signal in reality We assume that we truncate a ‘longer periodic’ signal to computer DFT Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Windowing Now, assume if we have the triangular signal as shown below Will there be a problem with DFT? No, because the start and end points are the same Very often, we consider using windows other than rectangular window to ‘force’ the signal value at the beginning and end to the same value Normally, this value is zero, though not always But how we do this? We use spectral windows like those on the right Figure from R.Shiavi, Introduction to applied statistical signal analysis Triangular signal Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Windowing (cont.) The simplest window is the rectangular window Using this window, the value at beginning (n=0) and end of signal (n=N-1) is set to zero But this creates discontinuity at second and second last points, i.e. between points n=0 and n=1 and at points n=N-2 and n=N-1 So, if we continue to reduce discontinuity using this window, we land up with a zero signal! To solve this, we can use smoothed windows like Triangular, Blackman, Hamming, etc. The new windowed signal for every point n, y[n]=x[n]*w[n] Some window functions: Blackman: Hamming: Triangular: For these functions, n is the window size (i.e. N) These window equations will not be tested Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Windowing (examples) The following show the magnitude spectra of an EEG signal: Windowing gives a smoother DFT The choice of windowing is too complex for this course, it involves analysis of ratios of magnitudes main lobes and side lobes So, we’ll skip them and choose any window (other than rectangular) Original, no windowing Do you know the sampling frequency of the EEG from the plot? Hamming windowing Rectangular windowing Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Detrending Another aspect similar to windowing is the removal of polynomial time trends and average value The average value, which has energy around zero frequency can be removed simply by setting the mean to zero The polynomial time trends have energy at very low frequencies We’ll study some high pass filtering methods in the next lecture to remove this polynomial trend This is known as detrending. Look at the example below: After detrending Before detrending Figures from R.Shiavi, Introduction to applied statistical signal analysis Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

DFT applied to some artificial signals Consider the sinusoidal wave with frequency=10 and fs=200 N=200; X=sin(2*pi*(1:N)*10/200); plot(X); The signal and magnitude spectra are shown below The same signal but length N=20 Theoretically, is there anything wrong with computing Fourier spectra for this signal this way if fs is known? Do you need windowing for this signal? What has happened – what is the actual frequency now? Since fd=fs/N=10, MATLAB indexes from 1, so 1 must be reduced from this index to push it back to 0 Freq(Hz) =(m-1)*fs/N =(2-1)*10 Hz = 10 Hz Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

DFT applied to some artificial signals (cont.) Consider combination of sinusoidal waves with frequency=8 and 25 and fs=200 N=25;fs=200;f1=8;f2=25; X=sin(2*pi*(1:N)*f1/fs)+sin(2*pi*(1:N)*f2/fs); plot(X); The signal and magnitude spectra are shown below Theoretically, the minimum N for this signal must N=25. Why? The magnitude spectra does show two peaks but there is a problem – what is it? MATLAB indexes from 1, so 1 must be reduced from this index to push it back to 0 Remember: Freq (Hz)=(m-1)*fs/N The same signal but length N=200 - Peak at 9 and 26 =>Spectra at 8 and 25 Hz - Both have same magnitude In reality, DFT works properly only if there are multiple cycles and not just one cycle And there must enough resolution, i.e. N must be large Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

DFT- a worked example Consider the following frequency spectra (the frequency axis should be up to 500 but is shown partially only) Given N=1000 and fs=200, find out the values for f1, f2, A1, A2 for MATLAB code : X=A1*sin(2*pi*(1:N)*f1/fs)+A2*sin(2*pi*(1:N)*f2/fs); The peaks are at 51 and 91 Answer Freq (Hz)=(m-1)*fs/N A1=1.0 A2=0.5 f1=10 f2=18 The ratio of A1/A2 has to be 2 but the exact values could be different Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Power spectral density estimation, classical approaches There are 3 common PSD estimation using classical approaches Periodogram Welch method Using autocorrelation function (but will not be studied here) There is a recent advanced parametric method on PSD estimation based on autoregressive modelling but this will not be studied here. Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

What is Power Spectral Density? PSD is similar to the square of magnitude spectra Actually, the only difference is the scale factor So, PSD=power per unit frequency (in dB) If we compute magnitude spectra using DFT, convert it to PSD, then we have periodogram Sometimes known as Blackman-Tukey method You can use the codes below OR use psd(x) or periodogram(x) functions N=200;fs=100;f1=5; X=sin(2*pi*(1:N)*f1/fs); plot(X); Y=fft(X,N); Pyy = sqrt((Y.* conj(Y))) /(0.5*N); plot(Pyy(1:N/2)); PSD=10*log10(Pyy.*Pyy); plot(PSD(1:N/2)) Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Computing PSD using Welch method An improvement to periodogram Normally gives a smoother PSD The method Segmentation with overlap The sample data is divided into K segments each containing M sample points Initial data points in each segment are separated by D (i.e. non-overlap length is D) Segments overlap with M-D samples and K=(N-M)/D +1 segments are formed The percent overlap is 100*(M-D)/M Apply the conventional periodogram (i.e. DFT) to compute PSD In MATLAB, use pwelch(x) function where the percentage overlap is 50% and Hamming window is used Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Computing PSD using Welch method (example) Assume we have an EEG signal with N=125 The first plot is obtained by using psd, while the second is obtained by using pwelch with each segment, M=50 D=25 (since overlap percentage is 50%) So, overlap of M-D=25 points and K=(125-50)/25+1=4 From the plots, pwelch is more smoother and very often more accurate than psd/periodogram PSD frequency scale is normalised and in radian instead of cycles 0 to fs  0 to 2 in (Hz   rad/sample) So, 0 to fs/2  0 to  Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Homework 1 - DFT (worked example) Compute the DFT for the ionospheric data and see if you get the values as in the table Next compute the magnitude and phase spectra and see if you get the values in the plots as below Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Homework 2 For the following noise corrupted signal, window the signal using triangular window, then compute the magnitude spectra (using MATLAB) Can you get similar plots as below? Use the codes below (fft is used) N=100;fs=200;f1=35; X=sin(2*pi*(1:N)*f1/fs)+rand(1,N); plot(X); Y=fft(X,N); Pyy = sqrt((Y.* conj(Y))) /(0.5*N); plot(Pyy(1:N/2)); W=triang(N); X=X'.*W; plot(X); Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.

Study guide (Lecture 4) From this week’s lecture, you should know how to compute Discrete Fourier Transform PSD estimation using classical methods (periodogram, Welch) You will need to remember all the equations in this lecture Note: the use of MATLAB codes will never be tested in the exam. For example, you will never be tested on what is fft(x), what is psd(x), etc. or how to use them. End of lecture 4 Lecture 4 BME452 Biomedical Signal Processing 2013 (copyright Ali Işın, 2013) Copyright 2013 A. IŞIN. All rights reserved.