Question 1
Question
1a
Question
(a) Draw a data flow diagram of the filter. [7]

1b
Question
(b) Explain the roles of r and ω on the frequency response of the filter. [8]
In this case r affects both the stability (i.e. ), as well as the notch width and attenuation depth, where larger r corresponds to a narrower width and deeper attenuation, affects the center frequency of the notch, and therefore the cutoff frequencies. On top of this, it directly affects the position of the zeros and poles on the unit circle
1c
Question
(c) The high level python commands you used in the lab create the bandstop response by combining a high- and a low-pass. Provide one advantage of this approach and one disadvantage against the filter above, taking into account real world inaccuracies. [10]
An advantage of using a combination of high and lowpass to create bandstop effects, is that it’s less sensitive to imprecision, and it’s much easier to modify this filter on either side if the requirements change. A disadvantage is that youre using 2 filters instead of 1 so itll be more computationally intensive, and therefore slower
Question 2
2a
Question
Q2. FIR filter design in the frequency domain (a) Sketch the frequency response of an ideal highpass filter. [5]
Classic Graph from Memory
Question
(b) Perform an inverse Fourier transform of a ideal highpass amplitude response to obtain the impulse response of the filter. [10]
2c
Question
(c) Explain which minimal additional steps need to be untertaken after having obtained the impulse response in Q2b) with the help of an IDFT so that it can be implemented as an linear phase FIR filter. [5]
We need to truncate our infinitely long impulse response to some finite quantity, as well as applying a window to reduce the oscillations that ensue.
We also need to shift our signal by N//2 sample to ensure that our signal is still causal (as the integral goes into “negative” time, which isnt possible)
2d
Question
(d) Suggest an advantage of using the (numerical) inverse Discrete Fourier Transform (IDFT) to obtain the impulse response in contrast to Q2b). [5]
This approach is better as it by definition gives us a finite length response, is more computationally efficient, and contains much less steps to implement
Question 3
3a
Question
Q3. Practical FIR filtering (a) An ECG has an unwanted slowly changing drift which must be eliminated by means of a filter. State the type of filter which should be applied (lowpass, highpass, bandstop or bandpass). [3]
Drift tends to be a form of Ultra Low Frequency noise, which means we need a high-pass that attenuates these very low frequencies
3b
Question
(b) Considering the heart rate of a healthy person, what is the cut-off frequency of the filter from Q3a: i. theoretically, and [3] ii. and in practise. [3] In both cases provide an explanation.
We can assume that the heart rate of a healthy person wont go much below 40, which means we could place the cutoff around 0.5Hz (30bpm) in theory. In practice however, since it isnt a perfect cutoff, and there is a transition between the two, we potentially need to shift the cutoff lower, as it can attenuate too much of the real low bpm signals.
3c
Question
(c) State how many taps for an FIR implementation of Q3(b)ii are required at a sampling rate of 250Hz. [6]
Assuming the cutoff around 0.4Hz, and is 250Hz, we get a theoretical min number of taps around taps, or for a more practical estimate, around 1250, to allow for a better transition
3d
Question
(d) In the lab you have implemented the FIR filter as a class. Explain: i. what data structures need to be implemented within an FIR filter class, and ii. what methods (functions) the class should contain). [10]
i) We should implement a ring or shift buffer the size of the number of taps, for hold both the coefficients and previous values
ii)
__init__() which sets the coefficients for our filter initially.
filter(v) which given a single sample, filters it
Question 4
4a
Question
Q4. Detection (a) In the assignment you detected the heart beat of an ECG with a matched filter. What kind of pre-processing digital filtering is highly beneficial for the detection process for both the template and the signal and why? [10]
We can use a bandpass filter, for frequencies between 0.5Hz and 15Hz, as we can assume any high frequency components are noise, and lower frequency is just drift
4b
Question
(b) The output of the matched filter will contain the detected signal but also noise. Which non-linear function can be applied which compresses the noise and amplifies the signal? [5]
In general, a good non-linear approach is to square the signal, as the large components (actual signal) get significantly larger, and the smaller components (noise) get smaller. Which means in general, the signal compounds heavily, and the noise cancels itself out roughly.
4c
Question
(c) Even with improved signal to noise ratio the detection of the heartbeats with a threshold is never perfect with most certainly some heartbeats being missed or wrongly detected. What is the standard approach to correct or identify such errors as much as possible? [5]
We can check for peak to peak interval, and check there isnt sudden sharp deviations, we can also check for physically impossible heart rates, such as 240bpm or above.
4d
Question
(d) Discuss the advantages and disadvantages of taking either the ECG peak as template or the ECG complex with its PQRST waves. [5]
The full PQRST complex is more information, meaning for cleaner signals it is much better for matching, but it is less robust to noise, and is more computationally intensive than matching against just the peak, though just the peak can be more suceptible to false peaks.