Linear

ESE 531: Digital Processing ! Used to be an art " Now, lots of tools to design optimal filters

! For DSP there are two common classes Lec 17: March 26, 2019 " Infinite IIR

Design of FIR Filters " FIR ! Both classes use finite order of parameters for design

! Today we will focus on FIR designs

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 3

What is a ? Filter Specifications

! Attenuates certain frequencies ! Passes certain frequencies ! Affects both phase and magnitude

! IIR

" Mostly non- response

" Could be linear over a range of frequencies

! FIR

" Much easier to control the phase

" Both non-linear and linear phase

Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 4 Penn ESE 531 Spring 2019 - Khanna 5

Impulse Invariance Bilinear Transformation

! Let, ! The technique uses an algebraic transformation Hc ( jΩ) = 0, Ω ≥ π / T between the variables s and z that maps the entire h[n] = Thc (nT ) jΩ-axis in the s-plane to one revolution of the unit ! If sampling at Nyquist Rate then circle in the z-plane. ∞ j ⎡ ⎛ω 2πk ⎞⎤ H(e ω ) H j = ∑ c ⎢ ⎜ − ⎟⎥ k=−∞ ⎣ ⎝T T ⎠⎦

jω ⎛ ω ⎞ H(e ) = Hc ⎜ j ⎟, |ω|<π ⎝ T ⎠

Penn ESE 531 Spring 2019 - Khanna 6 Penn ESE 531 Spring 2019 - Khanna 7

1 Transformation of DT Filters CT Filters

! Butterworth CT-Time Lowpass " Monotonic in pass and stop bands ! Chebyshev, Type I Z −1 = G(z−1) " Equiripple in pass band and monotonic in stop band Hlp(Z) ! Chebyshev, Type II

" Monotonic in pass band and equiripple in pass band ! Elliptic ! Z – complex variable for the LP filter " Equiripple in pass and stop bands ! z – complex variable for the transformed filter

! Appendix B in textbook ! Map Z-plane#z-plane with transformation G

Penn ESE 531 Spring 2019 - Khanna 8 Penn ESE 531 Spring 2019 - Khanna 9

Design Comparison Butterworth

! Design specifications ! Butterworth

" passband edge frequency ωp = 0.5π " Monotonic in pass and stop bands

" stopband edge frequency ωs = 0.6π " maximum passband gain = 0 dB

" minimum passband gain = -0.3dB

" maximum stopband gain =-30dB

! Use bilinear transformation to design DT low pass filter for each type

Penn ESE 531 Spring 2019 - Khanna 10 Penn ESE 531 Spring 2019 - Khanna 11

Chebyshev Elliptic

! Type I ! Type II ! Elliptic " Equiripple in pass band and " Monotonic in pass band and " Equiripple in pass and stop bands monotonic in stop band equiripple in pass band

Penn ESE 531 Spring 2019 - Khanna 12 Penn ESE 531 Spring 2019 - Khanna 13

2 Comparisons What is a Linear Filter?

! Attenuates certain frequencies ! Passes certain frequencies ! Affects both phase and magnitude

! IIR

" Mostly non-linear phase response

" Could be linear over a range of frequencies

! FIR

" Much easier to control the phase

" Both non-linear and linear phase

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 - Khanna 14 Adapted from M. Lustig, EECS Berkeley 15

FIR GLP: Type I and II FIR GLP: Type III and IV

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 16 Adapted from M. Lustig, EECS Berkeley 17

FIR Design by Windowing Example: Moving Average

jω ! Given desired , Hd(e ) , find an impulse response

sin (N +1 2)ω w[n]↔W (e jω ) = ( ) sin(ω 2)

! Obtain the Mth order causal FIR filter by truncating/windowing it

1 e− jωM 2 sin (M 2 +1 2)ω w[n − M 2]↔W (e jω ) = ( ) M +1 M +1 sin(ω 2) Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 18 Adapted from M. Lustig, EECS Berkeley 19

3 Example: Moving Average FIR Design by Windowing

! We already saw this before,

! For Boxcar (rectangular) window

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 20 Adapted from M. Lustig, EECS Berkeley 21

FIR Design by Windowing FIR Design by Windowing

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 - Khanna 22 Adapted from M. Lustig, EECS Berkeley 23

Tapered Windows Tradeoff – vs. Transition Width

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 24 Adapted from M. Lustig, EECS Berkeley 25

4 Kaiser Window Kaiser Window

! Near optimal window quantified as the window ! M=20 maximally concentrated around ω=0

! Two parameters – M and β

! α=M/2 th ! I0(x) – zero order Bessel function of the first kind

Penn ESE 531 Spring 2019 - Khanna 26 Penn ESE 531 Spring 2019 - Khanna 27

Kaiser Window Kaiser Window

! M=20 ! β=6

Penn ESE 531 Spring 2019 - Khanna 28 Penn ESE 531 Spring 2019 - Khanna 29

Approximation Error FIR Filter Design

jω ! Choose a desired frequency response Hd(e ) " non causal (zero-delay), and infinite imp. response

" If derived from C.T, choose T and use:

! Window:

" Length M+1 ⇔ affects transition width

" Type of window ⇔ transition-width/ ripple

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 - Khanna 30 Adapted from M. Lustig, EECS Berkeley 31

5 FIR Filter Design FIR Filter Design

jω ! Choose a desired frequency response Hd(e ) ! Determine truncated impulse response h1[n] " non causal (zero-delay), and infinite imp. response

" If derived from C.T, choose T and use:

! ! Window: Apply window

" Length M+1 ⇔ affects transition width " Type of window ⇔ transition-width/ ripple ! Check:

" jω Modulate to shift impulse response " Compute Hw(e ), if does not meet specs increase M or " Force causality change window

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 32 Adapted from M. Lustig, EECS Berkeley 33

Example: FIR Low-Pass Filter Design Example: FIR Low-Pass Filter Design

! The result is a windowed sinc function

! High Pass Design:

" Design low pass n " Transform to hw[n](-1)

! General bandpass

" Transform to 2hw[n]cos(ω0n) or 2hw[n]sin(ω0n)

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 34 Adapted from M. Lustig, EECS Berkeley 35

Lowpass Filter w/ Kaiser Window Lowpass Filter w/ Kaiser Window

! Filter specs: ! Filter specs:

" passband edge frequency ωp = 0.4π " passband edge frequency ωp = 0.4π

" stopband edge frequency ωs = 0.6π " stopband edge frequency ωs = 0.6π " Max ripple (δ) = .001 " Max ripple (δ) = .001

Penn ESE 531 Spring 2019 - Khanna 36 Penn ESE 531 Spring 2019 - Khanna 37

6 Lowpass Filter w/ Kaiser Window Lowpass Filter w/ Kaiser Window

Penn ESE 531 Spring 2019 - Khanna 38 Penn ESE 531 Spring 2019 - Khanna 39

Lowpass Filter w/ Kaiser Window Characterization of Filter Shape

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 - Khanna 40 Adapted from M. Lustig, EECS Berkeley 41

Time Bandwidth Product Design through FFT

! To design order M filter: ! Over-Sample/discretize the frequency response at P points where P >> M (P=15M is good)

! Sampled at:

! Compute h1[n] = IDFTP(H1[k]) ! Apply M+1 length window:

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 42 Adapted from M. Lustig, EECS Berkeley 43

7 Example Example

! For M+1=14

" P = 16 and P = 1026

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 44 Adapted from M. Lustig, EECS Berkeley 45

Optimal Filter Design Optimality

! Window method

" Design Filters heuristically using windowed sinc functions

! Optimal design jω " Design a filter h[n] with H(e ) jω " Approximate Hd(e ) with some optimality criteria - or satisfies specs. ! Least Squares:

! Variation: Weighted Least Squares:

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 46 Adapted from M. Lustig, EECS Berkeley 47

Optimality Example of Complex Filter

! Chebychev Design (min-max) ! Larson et. al, “Multiband Excitation Pulses for Hyperpolarized 13C Dynamic Chemical Shift Imaging” JMR 2008;194(1):121-127 ! Need to design 11 taps filter with following frequency response:

" Parks-McClellan algorithm - equiripple

" Also known as Remez exchange algorithms (signal.remez)

" Can also use convex optimization

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 48 Adapted from M. Lustig, EECS Berkeley 49

8 Least-Squares v.s. Min-Max Admin

! HW 7

" Out now

" Due Sunday 3/31

" More Matlab

" Less book

Penn ESE 531 Spring 2019 – Khanna Penn ESE 531 Spring 2019 – Khanna Adapted from M. Lustig, EECS Berkeley 50 Adapted from M. Lustig, EECS Berkeley 51

9