TechieYan Technologies

Extraction of Fetal ECG Signal and Determination of Fetal Heart Rate

Abstract

Electrocardiograms also known as ECG signals are the electrical signals generated by the heart.  Fetal ECG signal is used to monitor heart condition and to detect heart problems. The fetal ECG signal help to know the fetal health condition, fetal abnormalities during fetal development, fetal distress and intrauterine hypoxia. In most cases fetal ECG signals are masked with mothers ECG signals and other disturbances like noise. In this project with the help of the “pan tompkin” algorithm and by using a “least mean square(LMS)” adaptive filter we are going to extract the fetal ECG signal and detect the qrs complexes.fetal ECG signal

Fetal ECG signal

Code Description & Execution of Fetal ECG Signal and Fetal Heart Rate Extraction

Algorithm Description :

LMS(least mean square adaptive filter) : LMS algorithm is a type of adaptive filter which gives LMS value of the error signal inorder to mimic the desired signal by finding filter coefficient. It is used to get the desired signals from the actual fetal ECG signal. It can also be termed as the difference between the actual signal and desired  signal to reduce the error.

Block diagram of LMS algorithm

Block diagram of LMS algorithm

  • In the above diagram first a signal ‘x(n)’ is passed the variable filter which will alter the signal with respect to Wn and gives out the ‘y(n)’ signal.
  •  ‘y(n)’ signal is the altered signal which will be compared to the ‘d(n)’ signal.
  •  ‘d(n)’ signal is the desired signal and the difference between the altered signal ‘y(n)’ and desired signal ‘d(n)’ is the mean square value which is ‘e(n).’ 
  • The mean square value is then passed to the adaptive filter which will reduce the error by adjusting  the coefficient.
  • The parameter mu is used to update the filter coefficient(Wn) which is known as step size of adaptive filter. With this the steady state error and the convergence speed(The time taken to reduce the error is known as convergence speed.) are affected. The error may exactly converge to zero as the adaptive filter is not effective.
  • Adaptive filters are also affected by the length, weight and order of the vector. When order is increased the noise signals are reduced but the increase in order leads to masking the heartbeat of the fetal. The processing of the adaptive filter will increase with respect to increase in the order, which will be a time taking process.

Pan-tompkins algorithm :  The pan-tompkin algorithm is used to detect the QRS complexion and to identify QRS locations in ECG signals.

Block diagram of Pan-tompkins algorithm

Block diagram of Pan-tompkins algorithm

  • The ECG signal which were extracted using adaptive filters are now first sent into a preprocess block to check the frequency of the signal. The frequency of the signal should be 200Hz.
  • Then they are sent to the bandpass filter block which is of 5-15Hz to remove/filter the noise signals.
  • Next they are sent to the differentiator block to smoothen the signal and to know the peak values. To get the positive values the signal is squared with which the larger frequencies are emphasized.
  • As the ‘R’ wave is located the signals are sent to the integrator block to calculate the heart rate

          Heart rate = beats/minute = 1000*(60)/(RRinterval(milliseconds))

  • This method is applied to all the 4 signals which are obtained by 4 electrodes. The percentage of the error is also calculated to determine the accuracy of the method.

Code Description

There are six main codes for execution : 

  • pan_tompkin.m : This is the code of pan-tompkins algorithm

The below 5 codes contain the ECG data of 5 pregnant women.  :

  • r01fecg.m
  • r02fecg.m
  • r04fecg.m
  • r07fecg.m
  • r08fecg.m

Note: Matlab file or codes are saved in .m  and .mat format

3. A window pops up in which we can select our project folder

Steps to Execute the Code

  1. Download the zip file and unzip it, you will find all required files.
  2. Open MATLAB software and click on folder symbol located at the left corner , to load the file location
Heart Rate Signal MAtlab

3. A window pops up in which we can select our project folder

Heart Rate SIgnal extraction using MATLAB

4. Add all .m files from “current files” in that folder as shown below

fetal ECG signal

5.Run the code and get the desired output. Run any file other than pan_tompkin.m file at a time. As there is data of 5 different patients, the output of each file will change.

Result of Fetal ECG Signal and Fetal Heart Rate Extraction

fetal ECG signal

The above result is of the r01fecg.m file. You can run any file to get the output.

Issues Faced

  • The functions might be changed according to the version of matlab so, any error stating unavailable function kindly
  •  Replace the keyword according to the version.
  • Add pan_tompkins file and any one file to the script. Note* : you can add all the files to the script but kindly run only one script at a time, get the output and go for the next script.

Reference:

+91 7075575787