{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "97Ad8yROpHV8" }, "source": [ "# Filtering Signals\n", "In this tutorial we will practice filtering MIMIC waveform signals.\n", "\n", "Our **objectives** are to:\n", "- Filter signals using the [SciPy signal processing package](https://docs.scipy.org/doc/scipy/reference/signal.html).\n", "- Understand how to interpret the amplitude-response of a filter.\n", "- Gain experience in filtering PPG signals.\n", "- Be able to use filters to obtain the derivatives of a signal" ] }, { "cell_type": "markdown", "metadata": { "id": "efztffyOpHV-" }, "source": [ "
Context: Filtering is used to eliminate noise from physiological signals. For instance, ECG signals can contain mains frequency noise due to electrical interference. Ideally, a filter would attenuate unwanted frequency content in a signal whilst retaining the physiological frequency content.
Extension: If you've not seen it before, then have a look at the SciPy signal processing package. How might it be helpful for processing PPG signals?
Question: What does this plot tell us about the filter characteristics? What types of noise does the filter attenuate?
Explanation: This function generates the co-efficients for a Butterworth filter. The filter-type is specified as 'bp' - a bandpass filtter. The filter frequencies are specified in Hz (because the sampling frequency, fs, has also been specified): a high-pass frequency of 0.7 Hz, and a low-pass frequency of 10 Hz.
Question: The filter designed here has an order of 10. What would be the impact of reducing the order, to say 4?
Extension 1: How could we re-design the filter to retain frequency content of up to 20 Hz, but eliminate mains frequencies?
Extension 2: What would be appropriate cut-off frequencies when using the PPG for different purposes, e.g. heart rate monitoring, or blood pressure estimation? See this book chapter (Sections 2.2.4 to 2.2.5 on Sampling Frequency and Bandwidth) for details.
Note: The PPG signals in MIMIC have already been filtered somewhat by the clinical monitors used to record them.
Further work: Several different types of filters have been used to filter the PPG signal (e.g. Chebyshev filter, Butterworth filter). Have a look at this article for examples of several filter types (on pp.8-9). Which type of filter do the authors recommend? Can you re-design the filter above to use this type of filter?
Resource: Savitzky-Golay filtering, which is used here to calculate derivatives, is described in this article.
Question: Can you summarise how Savitzky-Golay filtering works? What are its advantages in physiological signal processing?
Question: How would the derivatives have looked different if the PPG signal hadn't been filtered before differentiation?
Hint: In the differentiation step above, try replacing 'ppg_filt' with 'ppg'.
Question: How would the derivatives have been different if the PPG signal had been filtered using different co-efficients?\n",
"
Hint: Above, try replacing the relatively wide band-pass frequencies '[0.7, 10]' with '[0.8, 3]'. \n",
"
Consider: Which band-pass frequencies would be most suitable for pulse wave analysis? How about heart rate estimation?
Question: How does this pulse wave shape and derivatives compare to the shape of those obtained from MIMIC data above? What might explain the differences?
Extension: Try using 'rel_segment_n=3' above (i.e. analysing segment '82439920_0004'). How do the pulse waves in this signal compare? What might that tell us about this patient?
Further reading: this article provides further information on how age affects the shape of the PPG's second derivative.