Machine Learning and Cardiology
Fetal Peak Detection - Methodology
4.1 Wavelet Transform
The wavelet transform of a signal x(k) is a mapping from the time domain to the time-scale domain. In other words, a wavelet transform is a dilated translation of a signal, where the so-called mother wavelet defines the way of transformation. This transformation results in a daughter wavelet. Roughly speaking, wavelets are special filter banks.

Mathematically, the discrete wavelet transform φ(t) is defined as in Equation 4.1, where φ(t) denotes the dilation equation, Equation 4.2, with hk = gn-k. The characteristics of wavelets, the filter coefficients, have to be chosen such that certain conditions hold. These conditions may vary, depending on the purpose and type of the wavelet[4].
In general, there are two types of wavelet transformations, discrete (DWT) and continuous (CWT). A DWT creates an affine system of functions. Here, the filter coefficients are building an orthonormal basis of the function space. In contrast to the DWT, the CWT operates at every scale. The variety of scales varies from the one of the original signal to some maximum scale, depending on the available computational power (and the urge of the transformation). Furthermore, the wavelet is shifted smoothly over the full domain of the analyzed signal x(k), whereas surprisingly in the DWT it is being done discretely.
4.2 Finding the P, QRS and T wave
Before further processing can be done, it is necessary to locate the several P, QRS and T waves in the thoraic channels. This will make it possible to synchronize the different channels, allowing therefore a more focused approach to detect the fetal ECG.
First, the QRS-complexes are located, since they are the easiest to extract. They can be identified by two successive extrema (a maximum, followed by a minimum) with a significant difference in height. So, in order to successfully identify these complexes, the maxima - that are beyond a threshold considered to be where possible QRS-complexes exist - have to be found. Normal heartbeats have clearly higher QRS complexes than P- or T-waves. These maxima can be detected by computing the maximum of the complete signal, and looking for maxima within an interval of this computed value (using percentage thresholds). Then, where minima within a few milliseconds after the found maxima can be detected, QRS-complexes have been successfully identified. Note that there is not necessary a smooth transition between the successive extrema, which means a hill climbing algorithm might get stuck in a local maximum in between the actual maximum and minimum. Therefore a window is taken, starting at the found maximum and ending some ms later (eg. 50), and to locate the minimum in this window.
Next, the QRS-complexes are subtracted from the original signal, so only the P- and T-waves remain. Again, there is a significant difference between the remaining components. The T-waves tend to be much larger than the P-waves, which means they can be extracted in a similar way to the QRS complexes with first finding the maxima and then the minima of the signal. When the waves found are again subtracted from the original signal, the remainders are the P-waves (and some possible baseline wandering).
Note that the found locations of the P and T waves aren't very precise. This does not matter since only the locations of the QRS waves will be used to synchronize the channels (although the locations of the P and T waves might provide extra support in this regard).

Other possible approaches for finding these waves might be found by the use of wavelets or pattern matching.
4.3 Channel Synchronization
Having knowledge of where each wave (P, QRS and T) occurs in the thoraic channels, every channel of the signal can be synchronized with each other. It is important to use a certain reference point in order to shift the different channels. The found QRS complexes can be a great help here, as the QRS complexes are the most visible ones in both the thoraic and the abdominal channels. It is not necessary to investigate the whole channel, as it can be assumed that the shift in time will be a constant factor for every channel. Therefore, detecting these shifts can be simplified by taking the first part from every channel (eg. the first 800 ms) and locating the very first QRS complex within. In order to know the shift in time, the time difference between the detected QRS complex and a reference QRS complex (eg that one of the first thoraic channel) needs to be computed. When this strategy is repeated for every channel, they can be synchronized by shifting each one using the computed differences. The synchronization also implies that some parts of each channel will be cut. When all channels are shifted correctly, it becomes possible to average the abdominal channels.

This results in a less noisy abdominal signal, and easens the process of detecting the fetal peaks.

4.4 Fetal Peak Detection
Following the approach of Hamid Hassanpour and Amin Parsaei, it was decided to use a Gaussian wavelet for our purposes. In their paper, Hassanpour and Parsaei used Daubechie wavelets, as they are "...similar in shape to a heart beat wave" [2]. Due to the shape of a fetal heartbeat, the usage of a wavelet that is morphologically more similar to the fetal heartbeat was proposed. Among others, a Gaussian-2 wavelet matches this criterion (Figure 4.5) It was chosen, as it gave the best experimental results.

The power of the fetal heartbeat in the signal is quite low (less than 1/4 [3]). With a Gaussian-2 wavelet however, there was a strong response both at the location of the maternal QRS and fetal heartbeat. Due to the possibility of determining the maternal heartbeats in the thoraic signal, all clear responses which are at different locations than maternal heartbeats can be assigned as fetal heartbeats.
However, on some occasions (like when a fetal peak occurs at exactly the same time as a mother peak) this might result into a non-detected fetal heartbeat. A possible approach to tackle this problem is to look at the consecutive time between two 'distant' fetal heartbeats and to investigate the in-between lying mother heartbeat, so a decision can be made whether a coincidence of mother and fetal heartbeat occurred.
4.5 Fetal Peak Reconstruction
Given the locations of the fetal peaks, it is only a matter of precision reconstructing the actual fetal signal. In this respect, it is important to trace back the original QRS complex, starting from the given locations. This can be achieved by detecting each individual slope of the complex, therefore by looking for descending and ascending tracks. However, this approach is threatened by the danger of getting stuck at local maxima or minima, which means using windows as before with the finding the P, QRS and T waves might be a great help.
Finally, the amplitudes of every heartbeat are shifted, so that its wandering in the mother baseline is removed. What then remains, is a zero-signal with the fetal peaks where they were detected as such. This means the baseline wandering of the fetus is not reconstructed. Detecting this wandering might be a tricky operation, since it is enclosed by the much stronger mother baseline wandering.

