5.1 Programming of PCG: Software Development Using Labview For Medical Instruments
5.1 Programming of PCG: Software Development Using Labview For Medical Instruments
5.1 Programming of PCG: Software Development Using Labview For Medical Instruments
The software used for analyzing the PCG signal obtained from the hardware is
LabVIEW. The software acquires the PCG signals from the hardware through NI DAQ.
Once the PCG signals data is obtained it is processed using various stages.
The flow chart to analyze the heart signal is shown in the fig 5.1. It gives the step
by step procedure of the backend operation of the analysis form. The developed program
i. Sampling
sampling is used. The value of the signal is measured at certain intervals in time. Each
measurement is referred to as a sample. To convert the acquired signal into a form that
can be treated by a computer has to be digitized, i.e. reduced from an analog form (time-
and value-continuous) to digital (time- and value-discrete). This process is called A/D
a. First, the analog signal s(t) is converted to a time-discrete form x(n) by sampling its
value (in the more specific sense of the word) in periodical intervals of duration ts, the
sampling period,.
1
Start
DAQ
Filter
Wideband Noise
Suppression
Peak Detection
Envelope Development
Feature Extraction
Time Interval
Fig 5.1: Flowchart for Analyzing Heart sounds and Displaying Heart Rate
2
This type of power line interference is eliminated by using a programmable digital
The LabVIEW advanced signal processing tool kit (ASPT) provides WA Detrend Virtual
Instrument (VI) which cab be used to remove the low frequency baseline wandering (or
trend) of a signal. An internal parameter called trend level is required for base line
Where t is the sampling duration and N is the number of sampling points in t time.
After the baseline wandering is suppressed, the PCG signal becomes more
stationary and explicit than the raw PCG signals. The remaining noise is complex
stochastic process with wideband nature. To suppress the wide band noise, the wavelet
This VI first Decomposes the PCG signal into several sub bands by applying the
wavelet transform, and then modifies each wavelet coefficients by applying a threshold
or shrinkage function, and finally reconstructs the denoised signal. In the present study,
we have used undecimated wavelet transform (UWT) sym 5 with single level and soft
thresholding for the wavelet denoising VI block setup. These settings perform perfect
denoising on the original PCG signal, and smoothen the signal without suppressing PCG
features such as peaks of the first, second and so on. For effective feature extraction, we
12
apply a wavlet denise VI with UWT sym5 and multiple level on the detrended signal to
make only the peaks of first and second if possible third and fourth signal more distinct.
For the purpose of diagnosis, we often need to extract various features from the
preprocessed PCG data, including the peaks of first and second heart beats.
level, Daubechies 6 (db6) wavelets and then reconstructs the signal with D4,D5 & D6 sub
bands. D4, D5 and D6 sub bands will be kept for reconstruction of PCG signals because
c. Feature Extraction:
After detrending the PCG signal and applying denoising VI, the resulting signal is
applied to the wave peak detection VI. Peak detection is one of the most important time
domain function performed in signal monitoring. Peak detection is the process of finding
the locations and amplitudes of local maxima and minima in a signal that satisfies certain
threshold value. In the present study the waveform detector used records the locations of
the signal peak above some threshold value in an output array in terms of indices.
The peak detector function used has some important features, such as
The function can process many blocks of data that are part of the same signal.
13
This function retains the internal states and history information from one call to the next.
This VI internally allocates the structure that contains the information on the first block
The peak location function gives the peak locations at fractional indices. It uses the
quadratic fit algorithm and returns the peak locations as floating point numbers, not as
The function allows implicit noise reduction while finding the peaks. Using the width
parameter effectively reduces the noise in the input signal when finding the peaks.
The function performs a quadratic curve fitting to find the peaks. The core of the peak
number to width. The function uses the coefficients from the fit to determine whether a
For each set of points, the algorithm performs the least-square quadratic fit, and then
performs a series of tests on the coefficients to see whether they meets the criteria for a
peak. The function checks whether each parabola is at a local maxima, determines the
sign of the quadratic coefficients, which indicate the parabola’s concavity, and finally
At the output of waveform detector both amplitude and time locations are taken
into considerations for the construction of envelope. The envelope will be constructed for
14
To develop the envelope the following notations are considered
The technique used for PCG feature extraction is an approach which employs
peak or valley detection and to construct envelopes based on the peak values detected
which satisfies certain threshold conditions. The developed envelopes of the PCG give an
envelopes are easier to process the PCG while they retain enough information to detect
2. Merge the peaks that are above THR that are very close to MT1 about (20 msec apart) to
3. If the peaks are lower than the threshold ignore that and search for the new local maxima
4. Assign systole the envelope that has short intervals which do not vary much over time
6. Assign S1 or S2 labels to each peak so that S1 signals the start of systole and S2 the start
of diastole.
15
5.2 Programming of Pulse Oximeter.
Our aim is to design and build an inexpensive, accurate, and user friendly pulse
oximeter that will allow doctors to receive pertinent data, which can be used to provide
The program control elements and the control functions used in programming of
1. Sequence Structure
4. Curve Fitting.
16
Start
End
17
i.Sequence Structure:
certain sequence is called control flow. In labVIEW there are sequence structures to
obtain control flow within a data flow frame work. A sequence structure is an ordered set
frame 1, then frame 2, until the last frame executes. Only when the last frame completes
does the data leave the structure. There are two types of sequence structures the flat
Fig 7a: Flat Sequence Structure Fig 7b: Stack Sequence Structure
The Flat sequence structure is a program control element whose sub diagrams are
organized from left to right, side by side. In my present work flat Sequence Structure is
used because the program code designed for determining of SPO2 and heart rate needs to
execute separately for RED LED and IR LED with necessary delay in-between them. A
18
It is a signal manipulation Sub VI which Extracts portions of data from the input
signals and returns the extracted data. A point or a range of data can be extracted, and the
extracted data can be by time or index. The time and index of the first occurrence of a
This sub VI can be configured so that a portion of the acquired signal is extracted
from which the DC valve and AC valve is determined which will be used for processing
19
This sub VI can be configured to measure to measure values such as DC ,RMS
As the usage of digital measurement instruments during the test and measurement
process increases, acquiring large quantities of data becomes easier. However, the
methods of processing and extracting useful information from the acquired data become a
challenge.
During the test and measurement process, you often see a mathematical
that results from an inaccurate measuring device. One way to find the mathematical
relationship is curve fitting, which defines an appropriate curve to fit the observed values
and uses a curve function to analyze the relationship between the variables.
Find the mathematical relationship or function among variables and use that
20
Different fitting methods can evaluate the input data to find the curve fitting
model parameters. Each method has its own criteria for evaluating the fitting residual in
finding the fitted curve. By understanding the criteria for each method, you can choose
the most appropriate method to apply to the data set and fit the curve. In LabVIEW, you
can apply the Least Square (LS), Least Absolute Residual (LAR), or Bisquare fitting
method to the Linear Fit, Exponential Fit, Power Fit, Gaussian Peak Fit, or Logarithm Fit
Percent oxygenation
Pulse rate
21
The percent oxygen in the blood of a patient can be calculated by measuring the
amount of light that is transmitted through the fingertip using a photodiode as a sensor
and two LEDs (red and IR) as the light source. The photodiode detects the transmitted
light and the DAQ device outputs a voltage that corresponds to the amount of light
detected. The final signal appears as the waveform of a pulse. There will be two
waveforms: one signal for the red LED and a second for the IR LED. Once these signals
are generated using the DAQ device, several measurements are made. First, the amount
of time that elapses in between peaks will be determined in order to calculate the pulse
rate. Second, the AC and DC of the voltage signals will be determined in order to
calculate the percent of oxygenation. Once these values are found, the modulation ratio
is calculated. The modulation ratio is essentially the ratio of the magnitude of the red
To be able to record and calculate all of these measurements, the code is split into
a series of 5 different events that occur from left to right of our code.
The first event that occurs is turning ON the red LED by generating step voltage
using the DAQ device, this is shown in the first frame of the flat sequence structure used
There is first a 5 second delay before anything happens to ensure that the red light
is turned on
22
The light transmittance is detected by the photodiode and outputs as a voltage
The generated signal is cut into a section containing time between 3 secs to 8
seconds
The peak to peak time interval obtained is divided by 60 in order to obtain the
pulse rate.
All the above steps are performed by the sub diagram placed in the second frame
The third event turns on the IR LED and turns off the Red LED by generating step
voltage using the DAQ device, this is shown in the third frame of the flat sequence
structure.
The fourth event includes is a repeat of the second step, however all values will be
found for the IR signal instead of the red LED signal. Also, it is unnecessary to find the
peak to peak time interval for the IR signal because the pulse rate should be the same for
both LED signals, and therefore, calculating pulse rate from the red LED only is
sufficient. This is performed by the sub diagram placed in the fourth frame of the flat
sequence structure.
23
The fifth event turns off both Red and IR LEDs.
After these values are determined, the modulation ratio can be calculated by using
the equation R = (AC/DC) RED / (AC/DC) IR. Then, the empirical data is referenced in
order to find the percentage of oxygenation. The calibration curve was obtained from the
24
Electrocardiogram (ECG) is a diagnostic tool that measures and records the
electrical activity of the heart in exquisite detail. Interpretation of these details allows
Generally, the recorded ECG signal is often contaminated by noise and artifacts
that can be within the frequency band of interest and manifest with similar characteristics
as the Preprocessing ECG signals helps to remove contaminants from the ECG signals.
Broadly speaking, ECG contaminants can be classified into the following categories
• baseline wandering
Among these noises, the power line interference and the baseline wandering are
the most significant and can strongly affect ECG signal analysis. Except for these two
noises, other noises may be wideband and usually a complex stochastic process which
25
Start
Filter
Wideband Noise
Suppression
Stop
Fig 5.8 : Flow Chart for ECG Signal Capture, Process and Display
26
The power line interference is narrow-band noise centered at 60 Hz (or 50 Hz)
with a bandwidth of less than 1 Hz. Usually the ECG signal acquisition hardware can
remove the power line interference. However the baseline wandering and other wideband
noises are not easy to be suppressed by hardware equipments. Instead, the software
scheme is more powerful and feasible for offline ECG signal processing.
between 0.15 and 0.3 Hz, and we can suppress it by a high pass digital filter. We also can
use the wavelet transform to remove baseline wandering by eliminating the trend of the
ECG signal. The Lab VIEW DFDT provides an intuitive and interactive way to design
and implement finite impulse response (FIR) or infinite impulse response (IIR) filters
27
In addition to digital filters, the wavelet transform is also an effective way to
remove signals within specific subbands. The LabVIEW ASPT provides the WA Detrend
VI which can remove the low frequency trend of a signal. We can see that the resulting
ECG signals contain little baseline wandering information but retain the main
characteristics of the original ECG signal. It is also seen that the wavelet transform-based
approach is better because this approach introduces no latency and less distortion than the
After we remove baseline wandering, the resulting ECG signal is more stationary
and explicit than the original signal. However, some other types of noise might still affect
feature extraction of the ECG signal. The noise may be complex stochastic processes
within a wideband, so you cannot remove them by using traditional digital filters. To
remove the wideband noises, we can use the Wavelet Denoise Express VI. This
LabVIEW based higher-level Express VI first decomposes the ECG signal into several
sub-bands by applying the wavelet transform, and then modifies each wavelet coefficient
signal. The following figure shows an example of applying the un-decimated wavelet
For the purpose of diagnosis, we often need to extract various features from the
intervals, The detection of the R-peaks and consequently of the QRS complexes in an
28
ECG signal provides information about the heart rate, the conduction velocity, the
Fig 5.10: Removing wideband noises from an ECG signal by applying the UWT
It supplies evidence for the diagnoses of cardiac diseases. For this reason, it has
drawn considerable attention in the ECG signal processing field. After extracting the
features by performing QRS complex detection, we can analyze the features with other
methods. For example, we can perform heart rate variability (HRV) analysis on the R-R
interval signal to demonstrate the state of the heart and nerve system.
calculate the heart rate. The normal value of heart beat lies in the range of 60 to 100
beats/minute. A slower rate than this is called bradycardia (Slow heart) and a higher rate
is called tachycardia (Fast heart). If the cycles are not evenly spaced, an arrhythmia may
be indicated. If the P-R interval is greater than 0.2 seconds, it may suggest blockage of
the AV node. Wavelet is found to be superior to the conventional FFT method in finding
the small abnormalities in ECG signals. The equation to calculate heart rate is given
below:
29
Heart Rate = (1/RR Interval) * 60
humidity with time graphically. It also keeps record of the relative humidity and
temperature, which can also be stored as numeric value in file and perform as backup.
(virtual instrument) that is able to communicate with the measuring circuit and control
the measuring procedure. It is able to record the data acquired in real-time, since the
program can afterwards save the measurements into files for later processing. It can also
provide some means of signal processing. For example it can help acquiring maximum
and minimum values automatically for each inhale and exhale which is needed in this
kind of measurements. The measurements are saved in a file format that is easy to open
by typical spreadsheet programs. Also, the LabVIEW suite provides many ways of
drawing the measurements into graphs, thus making it easier to view different
Special care has been given so that the measuring procedure itself is quite simple
for an operator, where cooperation with a subject is needed. So, the interface is quite
simple in appearance, but nevertheless significant programming has been made on the
LabVIEW so that the result is satisfactory for our purpose in terms of automation and
accuracy.
30
1. “A color spectrographic phonocardiography (CSP) applied to the detection and
characterization of heart murmurs: preliminary results”.- Reza Ramezani
Sarbandi, John D Doyle, Mahdi Navidbakhsh, Kamran Hassani, Hassan Torabiyan
31