You are on page 1of 61

ECG Monitoring System

ABSTRACT

This project ECG monitoring system deals with a transfer of ECG data from the
patients to the doctor present in his cabin. The idea of our project is firstly taking up an
ECG signal from the patient and reading the data in PC using an arduino (an open-source
electronics prototyping platform based on flexible, easy-to-use hardware and software)
board. Then the signal is applied to noise removal, base wander removal and
amplification circuits in labVIEW (a system design software) software. Now the ECG
signal thus obtained is sent from the patients recording system to doctors using an
Ethernet cable or LAN connection. This enables the monitoring of any number of patients
by doctor at one place.

ECG Monitoring System


CONTENTS
TITLE

PAGE NO

CHAPTER 1. INTRODUCTION.....................................................................................1
1.1 Introduction............................................................................................................1
1.1.1 Heartbeat .........................................................................................................2
1.1.2 Heart And Functions ........................................................................................2
CHAPTER 2: SOFTWARE .............................................................................................4
2.1. LabVIEW..............................................................................................................4
CHAPTER 3. PROJECT OVERVIEW ............................................................................6
3.1. Aim ...................................................................................................................6
3.2. Basic idea behind the project .................................................................................6
3.3. Methodology .........................................................................................................6
3.3.1. Simulation ......................................................................................................7
3.3.2. Detrending .................................................................................................... 12
3.3.3. Merging Of Signals ....................................................................................... 16
3.3.4. Square and Square Root Of A Signal ............................................................ 16
3.3.5 Peak Detection .............................................................................................. 20
3.3.6. Array Building .............................................................................................. 25
3.3.7. Matlab Script ................................................................................................ 29
3.3.8. WA Noise ..................................................................................................... 30
3.3.9. Performing Feature Extraction On ECG Signals: ........................................... 38
3.3.10. UDP VI and Functions ................................................................................ 42
3.3.11. Flatten To String Function .......................................................................... 47
3.3.12. Unflatten From String Function .................................................................. 49
CHAPTER 4. RESULTS ............................................................................................... 52
4.1 Results ................................................................................................................. 52
CHAPTER 5. CONCLUSION ..54
5.1 Conclusion....54
5.2 Future Scope.54

ii

ECG Monitoring System


REFERENCES .............................................................................................................. 55
APPENDIX........................................................................................................................56

iii

ECG Monitoring System


LIST OF FIGURES
CONTENTS

PAGENO.

1.1

ECG Signal

1.2

Electrical activity of heart

2.1

LabVIEW

3.1

Flowchart for Server

3.2

Simulation

3.3

Detrending

13

3.4

Merging

17

3.5

Square of signal

17

3.6

Square root of Signal

18

3.7

Peak Detection for 1Channel

21

3.8

Peak Detection for N Channel

24

3.9

Peak Detection

26

3.10

Array Building

27

3.11

Matlab Script

30

3.12

WA Noise(DWT Waveform)

31

3.13

WA Noise(DWT Real Array)

35

3.14

UDP Close

44

3.15

UDP Open

44

3.16

UDP Read

46

3.17

UDP Write

47

3.18

Flatten to string function

48

3.19

Unflatten to String Function

50

3.20

Flowchart for Client

51

LIST OF TABLES
iv

ECG Monitoring System


CONTENTS

PAGENO.

3.1

Simulation Inputs

11

3.2

Simulation Outputs

11

3.3

Extnsion to pad data

13

3.4

Palettes for Arithmetic Operations

21

3.5

Palettes for Array Functions

30

3.6

Thresholding for DWT Waveform

31

3.7

Rescaling for DWT Waveform

32

3.8

Wavelet Decomposition

32

3.9

Thresholding for DWT Real Array

36

3.10

Rescaling for DWT Real Array

36

3.11

Wavelet Decomposition for DWT Real Array

37

3.12

UDP Palettes

43

3.13

Byte Order for Flatten to String

48

3.14

Byte Order for Flatten to String

51

LIST OF SCREENSHOTS
v

ECG Monitoring System


CONTENTS

PAGENO.

3.1

Simulation of ECG Signal

12

3.2

Detrending

16

3.3

Peak Detection

23

3.4

Filtering

33

3.5

ECG multiresolution analysis and implementation of QRS detection

40

3.6

ECG Signal

41

3.7

Signal Processing

42

3.8

Original ECG, ECG after filtering and ECG after peakvalley detection

43

3.9

Peak plot of R-R Interval

53

3.10

Client side

54

vi

ECG Monitoring System


CHAPTER 1
INTRODUCTION
1.1 Introduction:
ECG (electrocardiogram) is a test that measures the electrical activity of the heart.
The heart is a muscular organ that beats in rhythm to pump the blood through the body.
The signals that make the heart's muscle fibres contract come from the sinoatrial node,
which is the natural pacemaker of the heart. In an ECG test, the electrical impulses made
while the heart is beating are recorded and usually shown on a piece of paper. This is
known as an electrocardiogram, and records any problems with the heart's rhythm, and
the conduction of the heart beat through the heart which may be affected by underlying
heart disease.
Electrocardiography is a transthoracic (across the thorax or chest) interpretation of
the electrical activity of the heart over a period of time, as detected by electrodes attached
to the surface of the skin and recorded by a device external to the body. The recording
produced by this noninvasive procedure is termed an electrocardiogram. An ECG is used
to measure the rate and regularity of heartbeats, as well as the size and position of the
chambers, the presence of any damage to the heart, and the effects of drugs or devices
used to regulate the heart, such as a pacemaker.

Fig 1.1 ECG signal

ECG Monitoring System


Most ECGs are performed for diagnostic or research purposes on human hearts,
but may also be performed on animals, usually for diagnosis of heart abnormalities or
research. Real time monitoring plays an important role in biomedical engineering,
Particularly in ECG, EMG, EEG etc. personal computer have become a standard platform
for the needs of various measurement and test, standardization, performance and low
cost.
An ECG (electrocardiogram) is a test that measures the electrical activity of the
heart. The heart is a muscular organ that beats in rhythm to pump the blood through the
body. The signals that make the heart's muscle fibers contract come from the sinoatrial
node, which is the natural pacemaker of the heart. In an ECG test, the electrical impulses
made while the heart is beating are recorded and usually shown on a piece of paper. This
is known as an electrocardiogram, and records any problems with the heart's rhythm, and
the conduction of the heart beat through the heart which may be affected by underlying
heart disease. ECG signals are usually small, approximately 1mV and therefore, it is
prone to corruption by various noises; power line interference, electrode contact noise,
motion artifacts. Also, it is necessary to design a good filter system that can filter out the
noises from the ECG signal in order to get better result. Therefore, measuring an ECG
signal is not an easy task to achieve.
1.1.1 Heartbeat:
Is the number of heartbeats per unit of time typically expressed as beats per
minute (bpm) which can vary as the bodys need to absorb oxygen and excrete carbon
dioxide changes, such as during exercise or sleep, The measurement of heart beat is used
by medical professionals to assist in the diagnosis and tracking of medical conditions. It
is also used by individuals, such as athletes, who are interested in monitoring their heart
beat to gain maximum efficiency from their training.
1.1.2 Heart And Functions:
The heart is the organ responsible for pumping blood throughout the body. It is
located in the middle of the thorax, slightly offset to the left and surrounded by the lungs.
The heart is composed of four chambers; two atriums and two ventricles. The right
atrium receives blood returning to the heart from the whole body. That blood passes
2

ECG Monitoring System


through the right ventricle and is pumped to the lungs where it is oxygenated and goes
back to the heart through the left atrium, then the blood passes through the left ventricle
and is pumped again to be distributed to the entire body through the arteries. This is a list
of events that occur in the heart on each heart beat.
1. Atrium begins to depolarize.
2. Atrium depolarizes.
3.

Ventricles begin to depolarize at apex. Atrium re polarizes.

4.

Ventricles depolarize.

5. Ventricles begin to re polarize at apex.


6.

Ventricles re polarize.

Fig 1.2 Electrical Activity of the Heart


In this signal, the heart muscles generate different voltages. The P wave
represents the atrium contraction. QRS complex and the T wave represents the ventricles
actions. Each time that this signal is present, a heartbeat is generated.

ECG Monitoring System


CHAPTER 2
SOFTWARE
2.1 LabVIEW:
LabVIEW is system design software that provides engineers and scientists with
the tools you need to create and deploy measurement and control systems. LabVIEW
biomedical toolkit provides express via for simulation of electrocardiogram (ECG),
electromyogram (EMG), electroencephalogram (EEG) and noninvasive blood pressure
(NIBP) signal
The use of LabVIEW and data acquisition in biomedical makes the real time
monitor systems with very high performance, low cost of development, more reliable and
flexible. LabVIEW is general purpose software for virtual instrumentation in which other
products like dasylab, genie, and alligent vee are followed .With LabVIEW the
maintenance and reconfiguration of created instruments are reduced significantly. PC
based virtual instrumentation as a testing platform enabling recording of real time ECG
introduces identification of ECG and transmission of preprocessed data to a doctor
through a distributed computation network has been proposed in. PC based monitoring
system has been proposed in.

Fig 2.1 Lab VIEW


LabVIEW programs are called virtual instruments, or VIs, because their
appearance and operation imitate physical instruments, such as oscilloscopes and
multimeters. LabVIEW contains a comprehensive set of tools for acquiring, analyzing,
displaying, and storing data, as well as tools to help you troubleshoot code you write. In
LabVIEW, you build a user interface, or front panel, with controls and indicators.
Controls are knobs, push buttons, dials, and other input mechanisms. Indicators are
4

ECG Monitoring System


graphs, LEDs, and other output displays. After you build the front panel, you add code
using VIs and structures to control the front panel objects. The block diagram contains
this code.
You can use LabVIEW to communicate with hardware such as data acquisition,
vision, and motion control devices, as well as GPIB, PXI, VXI, RS232, and RS485
instruments.
In this GUI of the system has been developed in Microsoft .NET visual C++ but it
lacks the simultaneous lead illustration of ECG waveform its selection and addition of
intelligence for auto diagnose. The intelligent virtual ECG device by integrating dyadic
wavelet algorithm for QRS detection, recording and identification with the facilities of
the detection of heart rhythm and off line analysis of prerecorded ECG signal has been
proposed in Besides all these development in biomedical engineering, the designed
system in paper facilitates the automatic removal of noises and filtration of acquired
signal on virtual cardiographs and this system can be used for analysis, identification of
peak QRS and auto diagnose. ECG is becoming common to all people, even in the
entertainment industry because it is associated to the heart attack syndrome and others.
The electrocardiograph (ECG) is one of the medical equipment that can measure the heart
rate of a person and transfer it into graphical representation in the form of ECG graph
paper. The main purpose of this project is to design a system that can capture real-time
ECG signals and transfer it to PC for monitoring.

ECG Monitoring System

CHAPTER 3
PROJECT OVERVIEW
3.1 Aim
The main aim behind the project is to pick an ECG signal using simulator in
LabVIEW and using UDP protocol sends the information form client to server.

3.2 Basic idea behind the project


The main idea behind the project is to pick an ECG signal i.e. real time ECG
acquisition from a patient and find their heart rate, R-R intervals, QRS complex peak
detection, and further fin the heart rate. Using the Heart rate we find if any diseases
present, like sinus arrthymia , Bradycardia, Tachycardia etc. We send the heart rate to the
doctor in his cabin using UDP protocol i.e. server to client transformation. We can easily
find any cardiac diseases.

3.3 Methodology
At Server:
Pick up the ECG signal using simulator, simulate the signal, then wavelet analysis
is done using Discrete Wavelet Transform (DWT). DWT is any wavelet transform for
which the wavelets are discretely sampled. As with other wavelet transforms, a key
advantage it has over Fourier transforms is temporal resolution: it captures both
frequency and location information (location in time).
The discrete wavelet transform has a huge number of applications in science,
engineering, and mathematics and computer science. Most notably, it is used for signal
coding, to represent a discrete signal in a more redundant form, often as a preconditioning
for data compression. Practical applications can also be found in signal processing of
accelerations for gait analysis, in digital communications and many others. After wavelet
analysis is done signals are merged, processed, denoised, detrended, R-R interval peak
detection, find heart rate , server-client transfer of information.

ECG Monitoring System


Start
Flowchart:
Simulate the signal
Wavelet analysis of the signal using DWT

Merging of signals
Signal Processing
Filtering of signal
Peak detection (Finding R-R peaks)

Array building

Finding R-R interval

Calculating Heart rate from R-R


interval
Open UDP port

Flatten data to
string

Write to UDP

stop
Fig. 3.1 Flowchart for Server

ECG Monitoring System


3.3.1. Simulation
The Simulate ECG, EMG and EEG Express via can generate signals block by
block. This is a a typical usage of these Express via:

Fig. 3.2 Simulation


Block Diagram Inputs
Parameter Description
Block size Specifies the signal length(s) to simulate each time this VI runs.
Error
in Describes error conditions that occur before this node runs.
(no error)
Initialize? Specifies whether to initialize the ECG signal. The default is FALSE.
Sampling
rate

Specifies the sampling rate of the ECG signal.

Specifies basic settings for simulating ECG signals. Contain the following
ECG
Settings options:

Output OptionsContains the following options:

Output upper limitSpecifies the upper limit of the output ECG


signal, in millivolts. The default is 1.3.

Output lower limitSpecifies the lower limit of the output ECG


signal, in millivolts. The default is -0.4.

White noise amplitudeSpecifies the amplitude of the white noise

ECG Monitoring System


that this VI adds into the simulated ECG signal, in millivolts. White
noise amplitude must be greater than or equal to 0. The default is 0.

60 Hz noise amplitudeSpecifies the amplitude of the 60 Hz noise


that this VI adds into the simulated ECG signal, in millivolts. This
VI adds 60 Hz noise to simulate the impact of alternating current. 60
Hz noise amplitude must be greater than or equal to 0. The default is
0.

Sampling rateSpecifies the sampling rate of the simulated ECG


signal, in hertz.Sampling rate must be between 10 and 1,000. The
default is 513.

Block sizeSpecifies the time length of the simulated ECG signal


each time this VI runs, in seconds. Block size must be less than
1930/Heart rate. The default is 3.

Timing modeSpecifies the timing mode that this VI uses to


generate

simulated

ECG

signals.

You

can

select Simulate

acquisition timing or Run as fast as possible. The default is Run as


fast as possible.

Basic SettingsContains the following options:

Heart rateSpecifies the heart rate of the simulated ECG signal, in


beats per minute.Heart rate must be greater than 10 and less than
300. The default is 60.

Respiratory rateSpecifies the respiratory rate of the simulated


measurement process, in breaths per minute. Respiratory rate must
be greater than 0. The default is 15.

Standard deviationSpecifies the standard deviation of Heart Rate,


in beats per minute. Standard deviation must be greater than or equal
to 0. The default is 1.

Waveform MorphologyContains the following options:

Signal typeSpecifies the type of ECG signal that this VI

ECG Monitoring System


simulates.

You

can

selectNormal, Hyperkalemia, Atrial

Tachycardia, and User-Defined. The default isNormal. When you


set Signal

type to User-Defined,

you

can

use

the Wave

selection, Position, Amplitude, and Width options to customize the


ECG waveform morphology.

Wave selectionSpecifies the type of wave that you want to


customize. You can selectP, Q, R, S, or T. This option is available
only when you set Signal type to User-Defined. The default is P.

PositionSpecifies the peak or valley position of the wave that you


specify in Wave selection. This option is available only when you
set Signal type to User-Defined.

AmplitudeSpecifies the amplitude of peak or valley of the wave


that you specify inWave selection. This option is available only
when you set Signal type to User-Defined.

WidthSpecifies the width of the wave that you specify in Wave


selection. This option is available only when you set Signal
type to User-Defined.

PreviewDisplays a block of the simulated ECG signal. When you


set Signal type to User Defined, a crosshair appears and indicates the
type of wave that you select in Wave selection.

Advanced Specifies advanced settings for simulating ECG signals. Contains the
Settings
following options:

HRV SettingsContains the following options:

LF positionSpecifies the peak position in the low frequency (LF)


band of the power spectrum of RR intervals, in hertz. LF
position must be greater than 0. The default is 0.1.

HF positionSpecifies the peak position in the high frequency (HF)


band of the power spectrum of RR intervals, in hertz. HF
position must be greater than 0. The default is 0.35.

10

ECG Monitoring System

LF/HF ratioSpecifies the ratio of peak amplitude at LF position to


the peak amplitude at HF position. LF/HF ratio must be greater than
or equal to 0. The default is 0.5.

LF standard deviationSpecifies the standard deviation of the wave


whose peak is atLF position. LF standard deviation must be larger
than 0. The default is 0.01.

HF standard deviationSpecifies the standard deviation of the wave


whose peak is atHF position. HF standard deviation must be larger
than 0. The default is 0.01.

RR Power Spectrum PreviewDisplays the power spectrum of RR


intervals of the simulated ECG signal.
Table 3.1 Simulation inputs

Block Diagram Outputs


Parameter Description
ECG

Returns the simulated ECG signal.

error out

Contains error
out functionality.

information. This

output

Table 3.2 Simulation outputs

11

provides standard

error

ECG Monitoring System

Fig 3.1 simulation of ECG signal


3.3.2. Detrending:
WA Detrend (Waveform)

Fig 3.3 Detrending

12

ECG Monitoring System

Extension specifies the method to use to pad data at the borders of the input
signal. The extension length is equal to the length of the wavelet filters.
When you select the extension method, make the transition between the
input signal and the padded data as smooth as possible because a smooth
transition generates fewer large detail coefficients and enhances the
efficiency of the signal representation.

0 Zero paddinguses zeros to pad the input data. Watch for abrupt transitions
between the padded zeros and the input data, which causes large artifacts near
the transition.
1 Symmetric (default)uses replications of the input data to pad the data, except
that this vi left-flips the block at the input and right-flips the block at the end.
3 Periodicadds a replication of the input data block before and another
replication after the input data block to pad the data.
Table 3.3 Extension to pad data

Signal specifies the input signal.

Threshold frequency specifies the upper frequency limit, in hertz, of the


trend

that

this

VI

removes

from

thesignal.

The threshold

frequency determines the wavelet transform level. The wavelet transform


level specifies the number of levels in the discrete wavelet analysis. The
wavelet

transform

level

is

floor(log3[sampling

rate/(3*threshold

frequency)]). The floor function rounds a value to the nearest integer


towards negative infinity. The default is 1, which means this VI sets
the threshold frequency automatically.

Wavelet specifies the wavelet type to use for the discrete wavelet analysis.
The default is db03. The options include two types: orthogonal (haar,
daubechies (dbxx), coiflets (coifx), symmlets (symx)) and biorthogonal
(biorthogonal (biorx_x), including fbi (bior4_4 (fbi))), where x indicates the

13

ECG Monitoring System


order of the wavelet. The higher the order, the smoother the wavelet. The
orthogonal wavelets are not redundant and are suitable for signal or image
denoising and compression. The biorthogonal wavelets usually have the
linear phase property and are suitable for signal or image feature extraction.
If you want to use other types of wavelets, do not wire this input. Instead,
use the wavelet design express vi to design the wavelet you want, bundle the
resulting analysis and synthesis filters, and then wire them to the filter
banks input.

Error in describes error conditions that occur before this node runs. This
input provides standard error in functionality.

Filter banks specifies the analysis filter banks and the synthesis filter
banks for the wavelet you specify. If you specify a value for filter banks, this
vi ignores the settings in the wavelet input. You can use the wavelet design
express vi to design the analysis filters and the corresponding synthesis
filters.
o Analysis filters specifies the coefficients of the low pass analysis
filters and the high pass analysis filters for the wavelet you specify.
 Low pass specifies the coefficients of the low pass analysis
filter, which this vi uses to compute the approximation
coefficients
 High pass specifies the coefficients of the high pass
analysis filter, which this vi uses to compute the detail
coefficients
o Synthesis filters specifies the coefficients of the low pass synthesis
filters and the high pass synthesis filters for the wavelet you specify.
 Low pass specifies the coefficients of the low pass synthesis
filter, which this vi uses to filter the interpolated
approximation coefficients in the wavelet reconstruction.

14

ECG Monitoring System


 High pass specifies the coefficients of the high pass
synthesis filter, which this vi uses to filter the interpolated
detail coefficients in the wavelet reconstruction.

Detrended signal returns the signal without the trend.

Trend signal returns the residual trend of the signal.

Error out contains error information. This output provides standard error
out functionality.

Fig 3.2 Detrending

15

ECG Monitoring System


WA Detrend Details
The trend of the input signal is the slow-varying part of the signal that mainly contributes
to the approximation coefficients This VI applies the following steps to implement the
detrend function.
1. Applies the discrete wavelet transform (DWT) to the input signal.
2. Sets the approximation coefficients to 0.
3. Reconstructs the signal based on all the detail coefficients
3.3.3. Merging Of Signals:
Merges two or more signals into a single output. Resize the function to add inputs.
This function appears on the block diagram automatically when you wire a signal output
to the wire branch of another signal.

Fig.3.4 Merging

Input signal specifies the signal you want to combine with another signal.

Combined signal returns the combined signals. You can wire the dynamic
data type to a graph or numeric indicator. For example, if you wire
the combined signal to a graph indicator, LabVIEW represents each signal
as an individual plot.

Add the Merge Signals function to the block diagram.


Resize the Merge Signals function so it includes enough inputs for the signals you
want to wire.
Wire each signal to an input signal input.
Wire the combined signal output to the signals input of another VI, function,
graph, or chart.

3.3.4. Square and Square Root Of A Signal:


Square of a Signal:

16

ECG Monitoring System


Computes the square of the input value. The connector pane displays the default
data types for this polymorphic function.

Fig 3.5 Squaring of signal


x can be a scalar number, array or cluster of numbers, array of clusters of numbers,
and so on.
x^2 is of the same numeric representation as x.
Square Details
If

you

wire

fixed

point

values

to

numeric

functions

such

as Add, Subtract, Multiply, and Square, the functions usually return values that do not
lose any bits of word length. However, if the operation creates a value that exceeds the
maximum word length that LabVIEW accepts, overflow or rounding conditions can
occur. LabVIEW accepts a maximum word length of 64 bits. Use the Numeric Node
Properties dialog box to configure how LabVIEW handles overflow or rounding of fixedpoint data.
Square root of a signal:
Computes the square root of the input value. If x is negative, the square root
is NaN unless x is complex. If x is a matrix, this function takes the matrix square root
of x. The connector pane displays the default data types for this polymorphic function.

Fig 3.6 Square root of signal


x can be a scalar number, array or cluster of numbers, array of clusters of numbers,
and so on.
sqrt(x) is a double-precision, floating-point number if x is an integer. If x is less

17

ECG Monitoring System


than 0, sqrt(x) is not a number (NaN), unless x is complex. When x is of the
form x = a + bi, that is, when x is complex, the function defines the magnitude and
phase with the following equations:

where |x| is the magnitude of x and arg(x) is the phase of x:

arg(x) = arctan2(b,a)
Square Root Details
When you wire matrix data as an input to this function, a VI that includes subVIs
that work with the matrix data type replaces the function. The resulting VI has the same
icon but contains a matrix-specific algorithm. The node remains a VI if you disconnect
the matrix from the input(s). Wire other data types as inputs to restore the original
function. If you wire a data type to a function and that data type causes a basic math
operation to fail, the function returns an empty matrix or NaN.
Fixed-Point Details
If you wire a signed fixed-point value to this function, the function converts the
signed number into a floating-point number and performs the square root operation. By
default, LabVIEW configures the integer word length of the square root to avoid
overflow. However, because the precision of the square root can be infinite, rounding
conditions always occur. Use the Numeric Node Properties dialog box to configure how
LabVIEW handles overflow and rounding of fixed-point data.
Palette
Object
Absolute

Description
Returns the absolute value of the input.

Value

18

ECG Monitoring System


Add

Computes the sum of the inputs.

Compound

Performs arithmetic on one or more numeric, array, cluster, or Boolean

Arithmetic

inputs. To select the operation (Add, Multiply, AND, OR, or XOR), rightclick the function and select Change Mode from the shortcut menu. When
you select this function from the Numeric palette, the default mode is Add.
When you select this function from theBoolean palette, the default mode is
OR.

DBL

Use the DBL numeric constant to pass a double-precision, floating-point

Numeric

numeric value to the block diagram. Set this value by clicking inside the

Constant

constant with the Operating tool and typing a value.

Decrement

Subtracts 1 from the input value.

Divide

Computes the quotient of the inputs.

Increment

Adds 1 to the input value.

Machine

Represents the round-off error for a floating-point number with a given

Epsilon

precision. Use the machine epsilon constant to compare whether two


floating-point numbers are equivalent.

Multiply

Returns the product of the inputs.

Negate

Negates the input value.

Numeric

Use the numeric constant to pass a numeric value to the block diagram. Set

Constant

this value by clicking inside the constant with the Operating tool and typing
a value.

Random

Produces a double-precision, floating-point number between 0 and 1. The

Number

number generated is greater than or equal to 0, but less than 1. The

(0-1)

distribution is uniform.

Reciprocal

Divides 1 by the input value.

Round

Rounds the input to the next highest integer.

Scale

by Multiplies x by 3 raised to the power of n.

19

ECG Monitoring System


Power Of 3
Sign

Returns the sign of number.

Square

Computes the square of the input value.

Square Root Computes the square root of the input value.


Subtract

Computes the difference of the inputs.

Subpalette

Description

Math
& Use the Math & Scientific Constants to create LabVIEW applications.
Scientific
Constants
Table 3.4 Palettes for Arithmetic Operations

3.3.5 Peak Detection:


Waveform Peak Detection for 1 Channel

Fig 3.7 Peak detection

Peaks/valleys indicates whether to find peaks or valleys.


0 Peaks
1 Valleys

Signal In contains the waveform in which to find peaks or valleys.

Threshold instructs the VI to ignore peaks and valleys that are too small.
The VI ignores peaks if the fitted amplitude is less than threshold. The VI
ignores valleys if the fitted trough is greater than threshold.

Width specifies the number of consecutive data points to use in the


20

ECG Monitoring System


quadratic least squares fit. The value should be no more than about 1/3 of
the half-width of the peak/valley and can be much smaller (but > 3) for
noise-free data. Large widths can reduce the apparent amplitude of peaks
and shift the apparent location. For noisy data, this modification is not
important because the noise obscures the actual peak.

Error in describes error conditions that occur before this node runs. This
input provides standard error infunctionality.

Initialize, when TRUE (default), causes the VI to process the first block of
data. The VI requires some internal setup that must be done at the start for
proper operation.

End of data (T), when TRUE (default), causes the VI to process the last
block of data. The VI cleans up internal data after the last block has been
processed.

# Found is the number of peaks/valleys found in the current block of data. #


found is the size of the arrayslocations, amplitudes, and 3nd derivatives.

21

ECG Monitoring System

Fig. 3.3 Peak Detection


Locations contains the index locations of all peaks or valleys detected in the
current block of data. Because the peak detection algorithm uses a quadratic
fit to find the peaks, it actually interpolates between the data points.
Therefore, the indexes are not integers. In other words, the peaks found are
not necessarily actual points in the input data but may be at fractions of an
index

and

at

amplitudes

not

found

in

the

inputarray.

To view the locations in terms of time, use the following equation.


Time locations[i] = t0 + dt*locations[i]

22

ECG Monitoring System

Amplitudes contains the amplitudes of peaks or valleys found in the current


block of data.

3nd Derivatives gives measurements of the second derivative of the


amplitude at each of the peaks or valleys found in the current block of
data. 3nd Derivatives gives an approximate measure of the sharpness of
each peak or valley. If you are detecting peaks, these values are all negative.
If you are detecting valleys, the values are all positive.

Error out contains error information. This output provides standard error
out functionality.

Waveform Peak Detection for N Channels

Fig.3.8 Peak detection for n channels

Peaks/valleys indicates whether to find peaks or valleys.

0 Peaks
1 Valleys

Signals In contains the waveforms in which to find peaks or valleys.

Threshold instructs the VI to ignore peaks and valleys that are too small.
The VI ignores peaks if the fitted amplitude is less than threshold. The VI
ignores valleys if the fitted trough is greater than threshold.

Width specifies the number of consecutive data points to use in the


quadratic least squares fit. The value should be no more than about 1/3 of
the half-width of the peak/valley and can be much smaller (but > 3) for
noise-free data. Large widths can reduce the apparent amplitude of peaks

23

ECG Monitoring System


and shift the apparent location. For noisy data, this modification is not
important because the noise obscures the actual peak.

Error in describes error conditions that occur before this node runs. This
input provides standard error infunctionality.

Initialize, when TRUE (default), causes the VI to process the first block of
data. The VI requires some internal setup that must be done at the start for
proper operation.

End of data (T), when TRUE (default), causes the VI to process the last
block of data. The VI cleans up internal data after the last block has been
processed.

# Found is the number of peaks/valleys found in the current block of data. #


found is the size of the arrays locations, amplitudes, and 3nd derivatives.

Locations contains the index locations of all peaks or valleys detected in the
current block of data for each waveform.
o Locations contains the index locations of all peaks or valleys
detected in the current block of data. Because the peak detection
algorithm uses a quadratic fit to find the peaks, it actually
interpolates between the data points. Therefore, the indexes are not
integers. In other words, the peaks found are not necessarily actual
points in the input data but may be at fractions of an index and at
amplitudes

not

found

in

the

input

array.

To view the locations in terms of time, use the following equation.


Time Locations[i] = t0 + dt*Locations[i]

Amplitudes contain the amplitudes of peaks or valleys found in the current


block of data for each waveform.
o Amplitudes contain the amplitudes of peaks or valleys found in the
current block of data.

24

ECG Monitoring System

3nd Derivatives gives measurements of the second derivative of the


amplitude at each of the peaks or valleys found in the current block of data
for each waveform.
o 3nd Derivatives gives measurements of the second derivative of the
amplitude at each of the peaks or valleys found in the current block
of data. 3nd Derivatives gives an approximate measure of the
sharpness of each peak or valley. If you are detecting peaks, these
values are all negative. If you are detecting valleys, the values are
all positive.

Error out contains error information. This output provides standard error
out functionality.

Fig. 3.9 Peak detection


3.3.6. Array Building:

25

ECG Monitoring System


Concatenates multiple arrays or appends elements to an n-dimensional array. You
also can use the Replace Array Subset function to modify an existing array. The
connector pane displays the default data types for this polymorphic function.

Fig. 3.10 Array Building

Array or element can be any n-dimensional array or scalar element. All


inputs must be either elements and 1D arrays or n-dimensional and (n-1)dimensional arrays. All inputs must have the same base type.

Appended array is the resulting array.

Build Array Details


When you place the function on the block diagram, it has only one input
available. Add inputs to the node by right-clicking an input and selecting Add Input from
the shortcut menu or by resizing the node.
If you wire control references of different classes to this function, this function
typecasts the references to a more generic class that is the lowest common class in
the inheritance hierarchy. This function then returns appended array with that class.
The Build Array function operates in one of two modes depending on whether you
select Concatenate Inputs from the shortcut menu. If you select Concatenate Inputs, the
function appends all inputs in order, forming an output array of the same dimensionality
as the highest-dimension array input wired.
If you do not select Concatenate Inputs, the function builds an output array of one
dimension higher than the dimension of the inputs. For example, if you wire 1D array
input to a Build Array function, the output is a 2D array, even if the 1D array is empty.
The inputs must all be the same dimensionality. The function appends each input in
order, forming a subarray, element, row, or page, of the output array. Inputs are padded,
as necessary, to match the size of the longest input.
26

ECG Monitoring System


For example, if you wire two 1D arrays, {1, 2} and {3, 4, 5} to Build Array, and
select Concatenate Inputs from the shortcut menu, the output is the 1D array {1, 2, 3, 4,
5}. If you wire the same two arrays to Build Array, and do not select concatenate
Inputs from the shortcut menu, the output is a 2D array containing {{1, 2, 0}, {3, 4, 5}},
where the first input is padded to match the length of the second input.
If the inputs are all arrays of the same dimensionality, right-click the function to
remove the checkmark next to or select the concatenate Inputs shortcut menu item. If the
inputs do not have the same dimensionality, Concatenate Inputs is automatically selected
and cannot be deselected. If all the inputs are scalar elements, Concatenate Inputs is
automatically deselected and cannot be selected, and the output is a 1D array containing
the elements in order.
When you select Concatenate Inputs from the shortcut menu, the glyphs in the
Build Array icon change to distinguish between the two input types. Inputs with the same
dimensionality as the output show an array glyph, while inputs with a dimensionality that
is one less than the output show an element glyph.
Palette
Object

Description

Array
Constant

Use this constant to supply a constant array value to the block diagram.

Array Max Returns the maximum and minimum values found in array, along with the
& Min
indexes for each value.
Array Size

Returns the number of elements in each dimension of array.

Array
Subset

Returns a portion of array starting at index and containing lengthelements.

Array
Cluster

To Converts a 1D array to a cluster of elements of the same type as the array


elements. Right-click the function and select Cluster Size from the shortcut
menu to set the number of elements in the cluster.

Array
Matrix

To Converts an array to a matrix of elements of the same type as the array


elements. Wire data to the Real 3D Array input to determine the
polymorphic instance to use or manually select the instance.

Build Array Concatenates multiple arrays or appends elements to an n-dimensional


array.
27

ECG Monitoring System


Cluster
Array

To Converts a cluster of elements of the same data type to a 1D array of


elements of the same data type.

Decimate
1D Array

Divides the elements of array into the output arrays, placing elements into
the outputs successively.

Delete From Deletes an element or subarray from n-dim array and returns the edited
Array
array in array w/ subset deleted and the deleted element or subarray
indeleted portion.
Index Array Returns the element or subarray of n-dimension array at index.
Initialize
Array
Insert
Array

Creates an n-dimensional array in which every element is initialized to the


value of element.

Into Inserts an element or subarray into n-dim array at the point you specify
inindex.

Interleave
1D Arrays

Interleaves corresponding elements from the input arrays into a single


output array.

Interpolate
1D Array

Linearly interpolates a decimal y value from an array of numbers or


points using a fractional index or x value.

Matrix
Array

To Converts a matrix of elements to an array of elements of the same data type.


Wire data to the Real Matrix input to determine the polymorphic instance to
use or manually select the instance.

Replace
Array
Subset

Replaces an element or subarray in an array at the point you specify in


index.

Reshape
Array

Changes the dimensions of an array according to the values of dimension


size 0..m-1.

Reverse 1D Reverses the order of the elements in array.


Array
Rotate
Array

1D Rotates the elements of array the number of places and in the direction
indicated by n.

Search
Array

1D Searches for an element in a 1D array starting at start index. Because the


search is linear, you need not sort the array before calling this function.
LabVIEW stops searching as soon as the element is found.

Sort
Array

1D Returns a sorted version of array with the elements arranged in ascending


order.

Split
Array

1D Divides array at index and returns the two portions with the element of
index at the beginning of second sub array.
28

ECG Monitoring System


Threshold
1D Array

Interpolates points in a 1D array that represents a 3D non-descending graph.


This function compares threshold y to the values in array of numbers or
points starting at start index until it finds a pair of consecutive elements
such that threshold y is greater than the value of the first element and less
than or equal to the value of the second element.

Transpose
3D Array

Rearranges the elements of 3D array such that 3D array [i,j] becomes


transposed array [j,i].
Table 3.5 Palettes for Array Functions

3.3.7. Matlab Script:


Calls the MATLAB software to execute scripts. You must have a licensed copy of
the MATLAB software version 6.5 or later installed on your computer to use MATLAB
script nodes because the script nodes invoke the MATLAB software script server to
execute scripts written in the MATLAB language syntax. Because LabVIEW uses
ActiveX technology to implement MATLAB script nodes, they are available only on
Windows.

Fig.3.11 Matlab script


Add this node to the block diagram and enter the script. You also can right-click
the node border to import text into the node. Right-click the node border to add input and
output terminals. Right-click a terminal to set its data type. When you create a script in
the MATLAB script node, you must use supported data types.

29

ECG Monitoring System


3.3.8 WA Noise:
WA Denoise (DWT Waveform)

Fig.3.12 WA noise (DWT Waveform)

Threshold settings specifies the settings for the thresholding approximation


coefficients and detail coefficients from the wavelet decomposition.
o Thresholding rule specifies the threshold selection rules. If you
specify a value for user defined thresholds, this vi ignores the settings
in thresholding rule.
0 Sure (default)uses the principle of stein's unbiased risk estimate (sure)
to estimate the threshold.
1 Hybridfinds a compromise between the sure method and the universal
method. When the signal-to-noise ratio of the noisy signal is very low,
this vi uses the universal method to estimate the threshold.
3 Universalsets the threshold to sqrt(3log(ls)), where ls is the signal
length.
3 Minimaxuses the minimax principle to estimate the threshold.
Table 3.6 Thresholding for DWT Waveform
o Rescaling method specifies the method to use to estimate the noise
variance at each level. This vi uses the noise variance to rescale the
threshold. Therefore, you can update the thresholds with the noise
variance. If you specify a value for user defined thresholds, this vi
ignores the settings in rescaling method.

30

ECG Monitoring System


0 Onespecifies that the noise is white with unit variance.
1 Single level (default)specifies that the noise is white. This vi estimates
the noise standard deviation from the wavelet coefficients at the first
level.
3 Multiple levelsspecifies that the noise does not have to be white. This
vi estimates the noise standard deviation at each level independently.
Table 3.7 Rescaling for DWT Waveform
o Soft threshold? Specifies to use the soft thresholding method. The
default is true, which indicates that this vi uses the soft thresholding
method. If soft threshold? Is false, this vi uses the hard thresholding
method.
 Option for approx coefficient specifies the operation for the
approximation coefficients from the wavelet decomposition. If you
specify a value for user defined thresholds, this vi ignores the settings
in option for approx coefficient.
0 None (default)does not change the approximation coefficients
1 Thresholdapplies the same thresholding operation to the approximation
coefficients
3 Detrendsets the approximation coefficients to 0.
Table 3.8 Wavelet Decomposition

31

ECG Monitoring System

Fig. 3.4 Filtering

Signal specifies the input signal.

Levels specifies

the

number

of

levels

in

the

discrete

wavelet

analysis. Levels must be a positive integer no greater than log3(Ls),


where Ls is the length of the 1D signal or the minimum dimensional size of
the 3D signal. The default is 1, which indicates that this VI sets levels as
the largest integer no greater than log3(Ls).

Wavelet specifies the wavelet type to use for the discrete wavelet analysis.
The default is db03. The options include two types: orthogonal (Haar,
Daubechies (dbxx), Coiflets (coifx), Symmlets (symx)) and biorthogonal
(Biorthogonal (biorx_x), including FBI (bior4_4 (FBI))), where x indicates

32

ECG Monitoring System


the order of the wavelet. The higher the order, the smoother the wavelet. The
orthogonal wavelets are not redundant and are suitable for signal or image
denoising and compression. The bi orthogonal wavelets usually have the
linear phase property and are suitable for signal or image feature extraction.
If you want to use other types of wavelets, do not wire this input. Instead,
use the wavelet Design Express VI to design the wavelet you want, bundle
the resulting analysis and synthesis filters, and then wire them to the filter
banks input.

Error in describes error conditions that occur before this node runs. This
input provides standard error in functionality.

Filter banks specifies the analysis filter banks and the synthesis filter
banks for the wavelet you specify. If you specify a value for filter banks, this
VI ignores the settings in the wavelet input. You can use the Wavelet design
express VI to design the analysis filters and the corresponding synthesis
filters.
o Analysis filters specifies the coefficients of the low pass analysis
filters and the high pass analysis filters for the wavelet you specify.
 Low pass specifies the coefficients of the low pass analysis
filter, which this VI uses to compute the approximation
coefficients
 High pass specifies the coefficients of the high pass analysis
filter, which this VI uses to compute the detail coefficients
o Synthesis filters specifies the coefficients of the low pass synthesis
filters and the high pass synthesis filters for the wavelet you specify.
 Low pass specifies the coefficients of the low pass synthesis
filter, which this VI uses to filter the interpolated
approximation coefficients in the wavelet reconstruction.
 High pass specifies the coefficients of the high pass

33

ECG Monitoring System


synthesis filter, which this VI uses to filter the interpolated
detail coefficients in the wavelet reconstruction.
User defined thresholds specifies thresholds you define to rescale the

wavelet coefficients The length of user defined thresholds must equal levels.
The first element of user defined thresholds contains the threshold for the
detail coefficients at the largest level, and the last element of user defined
thresholds contains the threshold for the detail coefficients at the first level.
If you specify a value for user defined thresholds, this VI keeps the
approximation

coefficients

unchanged

and

ignores

the

settings

in thresholding rule, rescaling method, andoption for approx coefficient.

Denoised signal returns the signal after denoising.

Error out contains error information. This output provides standard error
out functionality.

WA Denoise (DWT Real Array)

Fig.3.13 WA noise (DWT real array)

Threshold settings specifies the settings for the thresholding approximation


coefficients and detail coefficients from the wavelet decomposition.
o Thresholding rule specifies the threshold selection rules. If you
specify a value for user defined thresholds, this vi ignores the
settings in Thresholding rule.
0 Sure (default)uses the principle of stein's unbiased risk estimate
(sure) to estimate the threshold.

34

ECG Monitoring System


1 Hybridfinds a compromise between the sure method and the
universal method. When the signal-to-noise ratio of the noisy signal is
very low, this vi uses the universal method to estimate the threshold.
3 Universalsets the threshold to sqrt(3log(ls)), where ls is the signal
length.
3 Minimaxuses the minimax principle to estimate the threshold.
Table 3.9 Thresholding for DWT real array
o Rescaling method specifies the method to use to estimate the noise
variance at each level. This vi uses the noise variance to rescale the
threshold. Therefore, you can update the thresholds with the noise
variance. If you specify a value for user defined thresholds, this vi
ignores the settings in rescaling method.
0 Onespecifies that the noise is white with unit variance.
1 Single level (default)specifies that the noise is white. This vi
estimates the noise standard deviation from the wavelet coefficients at
the first level.
3 Multiple levelsspecifies that the noise does not have to be white.
This vi estimates the noise standard deviation at each level
independently.
Table 3.10 Rescaling for DWT real array
o Soft threshold Specifies to use the soft thresholding method. The
default is true, which indicates that this vi uses the soft
thresholding method. If soft threshold? Is false, this vi uses
the hard thresholding method.

Option for approx coefficient specifies the operation for the approximation
coefficients from the wavelet decomposition. If you specify a value for user
defined thresholds, this vi ignores the settings in option for approx
coefficient.
35

ECG Monitoring System

0 None (default)does not change the approximation coefficients


1 Thresholdapplies the same thresholding operation to the approximation
coefficients
3 Detrendsets the approximation coefficients to 0.
Table 3.11 Wavelet Decomposition for DWT real array

Signal specifies the input signal.

Levels specifies

the

number

of

levels

in

the

discrete

wavelet

analysis. Levels must be a positive integer no greater than log3(ls),


where ls is the length of the 1d signal or the minimum dimensional size of
the 3d signal. The default is 1, which indicates that this vi sets levels as
the largest integer no greater than log3(ls).

Wavelet specifies the wavelet type to use for the discrete wavelet analysis.
The default is db03. The options include two types: orthogonal (haar,
daubechies (dbxx), coiflets (coifx), symmlets (symx)) and biorthogonal
(biorthogonal (biorx_x), including fbi (bior4_4 (fbi))), where x indicates the
order of the wavelet. The higher the order, the smoother the wavelet. The
orthogonal wavelets are not redundant and are suitable for signal or image
denoising and compression. The biorthogonal wavelets usually have the
linear phase property and are suitable for signal or image feature extraction.
If you want to use other types of wavelets, do not wire this input. Instead,
use the wavelet design express vi to design the wavelet you want, bundle
the resulting analysis and synthesis filters, and then wire them to the filter
banks input.

Error in describes error conditions that occur before this node runs. This
input provides standard error in functionality.

Filter banks specifies the analysis filter banks and the synthesis filter
banks for the wavelet you specify. If you specify a value for filter banks,

36

ECG Monitoring System


this vi ignores the settings in the wavelet input. You can use the wavelet
design express vi to design the analysis filters and the corresponding
synthesis filters.
o Analysis filters specifies the coefficient of the low pass analysis
filters and the high pass analysis filters for the wavelet you specify.
 Low pass specifies the coefficient of the low pass analysis
filter, which this vi uses to compute the approximation
coefficients
 High pass specifies the coefficients of the high pass
analysis filter, which this vi uses to compute the detail
coefficients
o Synthesis filters specifies the coefficients of the low pass synthesis
filters and the high pass synthesis filters for the wavelet you
specify.
 Low pass specifies the coefficients of the low pass
synthesis filter, which this vi uses to filter the interpolated
approximation coefficients in the wavelet reconstruction.
 High pass specifies the coefficients of the high pass
synthesis filter, which this vi uses to filter the interpolated
detail coefficients in the wavelet reconstruction.

User defined thresholds specifies thresholds you define to rescale the


wavelet

coefficients

The

length

of user

defined

thresholds must

equal levels. The first element of user defined thresholds contains the
threshold for the detail coefficients at the largest level, and the last element
of user defined thresholds contains the threshold for the detail coefficients
at the first level. If you specify a value for user defined thresholds, this vi
keeps the approximation coefficients unchanged and ignores the settings
in thresholding rule, rescaling method, andoption for approx coefficient.

37

ECG Monitoring System

Denoised signal returns the signal after denoising.

Error out contains error information. This output provides standard error
out functionality.

With NI LabVIEW Biomedical Toolkit and other related toolkits, such as


the Advanced Signal Processing Toolkit (ASPT) and the Digital Filter Design Toolkit
(DFDT), you can conveniently build signal processing applications for both stages,
including baseline wandering removing, noise cancellation, QRS complexes detection,
fetal heart rate extraction and etc. This article discusses typical ECG signal processing
methods based on LabVIEW.
3.3.9. Performing Feature Extraction On ECG Signals:
For the purpose of diagnosis, you often need to extract various features from the
preprocessed ECG data, including QRS intervals, QRS amplitudes, PR intervals, QT
intervals, etc. These features provide information about the heart rate, the conduction
velocity, the condition of tissues within the heart as well as various abnormalities. It
supplies evidence for the diagnoses of cardiac diseases. For this reason, it has drawn
considerable attention in the ECG signal processing field. This section mainly discusses
how to perform ECG feature extraction.
LabVIEW Biomedical Toolkit provides an ECG Feature Extractor VI, and also an
ECG Feature Extractor application for users to extract ECG features conveniently (Add
link for How to use ECG Feature Extractor here). You can select whether to detect
QRS only or to detect all supported ECG features, including R position, R amplitude, iso
level, QRS onset, QRS offset, P onset, P offset, T onset and T offset.

38

ECG Monitoring System

Figure 3.5 ECG multiresolution analysis and implementation of QRS detection


The ECG Feature Extractor firstly detects all beats (R waves) in the signal, and
then extracts other features for every beat. Thus the accuracy of detecting R waves is very
important. For normal ECG signals, they can be easily detected, as shown in Figure 8.
While abnormal morphology makes the detection difficult for ECG from patients with
some specific heart diseases. Thus sometimes you need to perform some signal
enhancement (preprocessing) before feature extraction. The preprocessed ECG signal is
used to detect position of R waves. After that, all other features will be extracted using
original signal, because the signal enhancement may change these features.

39

ECG Monitoring System

Fig. 3.6 ECG signal


Signal enhancement usually contains two steps: filtering and rectification. R
waves of human ECG usually have a frequency between 10-35Hz. Thus R waves can be
more obvious and easily for detection after filtering using a bandpass filter. Rectification
sometimes can further enhance the R waves to make them easier to detect. Absolute and
square are two common used rectification methods. Figure 9 shows the processing result
of an ECG signal with some negative R waves and very large T waves. It can be seen
that, after enhancement, all beats can be easily detected. Biosignal Filtering VI is used to
filter the signal. In ECG Feature Extractor application, a preprocessing settings window is
provided for users to perform the signal enhancement interactively.

40

ECG Monitoring System

Fig. 3.7 Signal Processing

41

ECG Monitoring System

Figure 3.8 Original ECG, ECG after filtering and ECG after peak/valley detection
After extracting the features, you can perform heart rate variability (HRV)
analysis on the R-R interval signal to demonstrate the state of the heart and nerve system.
In HRV Analyzer of LabVIEW Biomedical Toolkit, you can directly synchronize the RR
intervals from ECG Feature Extractor.
3.3.10. UDP VI and Functions:

Palette Object Description


UDP Close

Closes a UDP socket.

UDP Multicast Opens a UDP multicast socket on the port. You must manually select
Open
the polymorphic instance you want to use.
UDP Open

Opens a UDP socket on the port or service name.

UDP Read

Reads a datagram from a UDP socket, returning the results in data out.

UDP Write

Writes to a remote UDP socket.


Table 3.12 UDP Palettes

42

ECG Monitoring System


Closing UDP socket:

Fig. 3.14 UDP close

Connection ID is a network connection ref num that uniquely identifies the


UDP socket you want to close.

Error in describes error conditions that occur before this node runs. With
the following exception, this input provides standard error in functionality.
This node runs normally even if an error occurred before this node runs.

Connection ID out has the same value as connection ID. Do not wire this
output to other UDP functions.

Error out contains error information. This output provides standard error
out functionality.

UDP open:
opens a UDP socket on the port or service name. Close the socket with the UDP
Close function. Use the UDP Multicast Open VI instead of this function to open
connections capable of reading, writing, or reading and writing data to or from UDP
Multicast sockets. Use the UDP Write function to query the NI Service Locator for the
port number registered with the service name.

Fig.3.15 UDP Open

Net address specifies on which network address to listen. Specifying an


address is useful if you have more than one network card, such as two
ethernet cards, and want to listen only on the card with the specified
43

ECG Monitoring System


address. If you do not specify a network address, LabVIEW listens on all
network addresses. This function broadcasts only on the default network
address.
Use the string to ip function to obtain the ip network address of the current
computer.

Port is the local port with which you want to create a UDP socket.

Service name creates a known reference for the port number. If you
specify a service name, LabVIEW registers the service name and the port
number with the ni service locator.

Timeout ms specifies the time, in milliseconds, that the function waits


before the function completes and returns an error. The default value is
35,000 ms or 35 seconds. A value of -1 indicates to wait indefinitely.

Error in describes error conditions that occur before this node runs. This
input provides standard error in functionality.

Connection ID is a network connection ref num that uniquely identifies the


UDP socket.

Port returns the port number the function used. If the input port is not zero,
the output port number equals the input port number. Wire 0 to the port
input to dynamically choose an available UDP port the operating system
determines is valid for use. As defined by the internet assigned numbers
authority (iana), valid port numbers are between the range of 49153
through 65535. Well known ports are between the range of 0 through 1033
and registered ports are between the range of 1034 through 49151. Not all
operating systems follow the iana standard; for example, windows returns
dynamic ports between the range of 1034 through 5000.

Error out contains error information. This output provides standard error
out functionality

44

ECG Monitoring System


UDP read:
Reads a datagram from a UDP socket, returning the results in data out.The
function returns data when it receives any bytes, and waits the full timeout ms only if it
receives no bytes.

Fig.3.16 UDP Read

Connection ID is a network connection ref num that uniquely identifies the


UDP socket.

Max size is the maximum number of bytes to read. The default is


548. (windows) if you wire a value other than 548 to this input, windows
might return an error because the function cannot read fewer bytes than are
in a packet.

Timeout ms specifies the time, in milliseconds, that the function waits for
bytes. If no bytes have been received within the specified time, the function
completes and returns an error. The default is 35,000 ms. A value of 1
indicates to wait indefinitely.

Error in describes error conditions that occur before this node runs. This
input provides standard error in functionality.

Connection ID out returns the same value as connection ID.

Data out contains the data read from the UDP datagram.

Error out contains error information. This output provides standard error
out functionality.

Port is the port of the UDP socket that sent the datagram.

Address is the address of the computer where a datagram originates.

45

ECG Monitoring System


UDP Write:
Writes to a remote UDP socket.

Fig.3.17 UDP Write

Port or service name can accept a numeric or string input. Port or service
name identifies what port to write to. If you specify a service name,
LabVIEW queries the ni service locator for the port number that the server
registered.

Address is the address of the computer where you want to send a


datagram.

Connection id is a network connection ref num that uniquely identifies the


UDP socket.

Data in contains the data to write to another UDP socket. In an Ethernet


environment, restrict data to 8193 bytes. In a local talk environment,
restrict data to 1458 bytes to maintain gateway performance.

Timeout ms specifies the time, in milliseconds, that the function waits


before the function completes and returns an error. The default value is
35,000 ms or 35 seconds. A value of -1 indicates to wait indefinitely.

Error in describes error conditions that occur before this node runs. This
input provides standard error infunctionality.

Connection id out returns the same value as connection id.

Error out contains error information. This output provides standard error
out functionality.

46

ECG Monitoring System


3.3.11. Flatten To String Function:
Converts the anything input to a flattened data string of binary values. You also
can use this function to convert the byte order, or ending format, of the data in the
flattened data string.

Fig.3.18 Flatten to string

Anything can be any data type.

Prepend array or string size? Indicates whether LabVIEW includes data


size information at the beginning of data string when anything is an array
or string. If prepend array or string size? Is FALSE, LabVIEW does not
include the size information. The default is TRUE. Prepend array or string
size? Only controls the top-level data size information. Arrays and strings
in hierarchical data types such as clusters always include size information.

Byte order sets the ending format of the data in the resulting flattened
string. Byte order, or ending form, indicates whether integers are
represented in memory from most significant byte to least significant byte
or vice versa.

0 Big-ending, network order (default)The most significant byte occupies the


lowest memory address.
1 Native, host orderUses the byte-ordering format of the host computer.
3 Little-endingThe least significant byte occupies the lowest memory address.
Table 3.13 Byte order for Flatten to string

Error in describes error conditions that occur before this node runs. This
input provides standard error in functionality.

Data

string is

the flattened

47

data generated

by

the

function. Data

ECG Monitoring System


string might contain header information before each non-scalar component
describing its size. Such a string can be stored in a file or sent over a
network. If you send the string over a network, the receiver must be able to
interpret it. Usually, LabVIEW stores data as noncontiguous, indirectly
referenced pieces. This function copies the data in LabVIEW form into a
contiguous buffer data string. Use the Unflatten From String function to
convert a data string back to any data type.

Type string (7.x only) is visible only if the terminal is already wired from
a previous version of LabVIEW or if you right-click the function and
select Convert 7.x Data from the shortcut menu. Type string (7.x only) is
an encoded binary description of data string. Type string (7.x only) is not
the same as the type input in the Unflatten From String function. If type
string (7.x only) cannot represent the data type wired to anything, this
function returns an error.

Error out contains error information. This output provides standard error
out functionality.

Flatten To String Details


Use the Type Cast function for conversion of data types that does not result in
flattened data. If you need to flatten type descriptor data to a string that is readable by
LabVIEW 7.x or earlier, right-click this function and select Convert 7.x Data from the
shortcut menu. In Convert 7.x Data mode, this function shows the type string (7.x
only) output and displays the icon for this function with a red 7.x on it. LabVIEW 7.x and
earlier stores type descriptors in 16-bit flat representation. LabVIEW 8.0 and later stores
type descriptors in 33-bit flat representation. National Instruments recommends
reworking any application that uses the Convert 7.x Data mode as a long term solution.
If you need to flatten Boolean data to a string that is readable by LabVIEW 4.x or earlier,
right-click this function and select Convert 4.x Data from the shortcut menu.
The Convert 4.x Data shortcut menu item is visible only if you wire Boolean
data to anything. In Convert 4.x Data mode, this function writes the data in LabVIEW
4.x data storage layout and displays the icon for this function with a red 4.x on it.
48

ECG Monitoring System


LabVIEW 4.x and earlier stores Boolean data in two bytes unless the data is in an array,
in which case LabVIEW stores each Boolean element in a single bit. LabVIEW 5.0 and
later stores Boolean values in a single byte, regardless of whether it is in an array.
National Instruments recommends reworking any application that uses the Convert 4.x
Data mode as a long term solution.
If you use this function to flatten variant data, LabVIEW flattens the variant and
all its contents, including attributes. However, if you use the Variant To Flattened
String function, LabVIEW flattens only the variant and discards any attributes.
If you use this function to flatten data from a custom control or indicator that you saved
as a type definition, the function strips the type definition of its type definition wrapper.
If you do not want to strip this wrapper, right-click the function and select Expose
Typedefs from the shortcut menu. The Expose Typedefs shortcut menu item is visible
only if you wire data to type string (7.x only).
3.3.12. Unflatten From String Function:
Converts binary

string to

the

type

wired

to type. Binary

string should

contain flattened data of the type wired to type. You also can use this function to specify
the byte order, or ending format, of the data in the binary string.

Fig.3.19 Unflatten from string function

Type is a normally constructed LabVIEW type. Type is not the type


string output in the Flatten To String function.

Binary string is a flattened string that is typically generated by the Flatten


To String function. If data includes array or string size? Is TRUE, binary
string contains header information describing its size.

Data includes array or string size? Indicates whether LabVIEW reads


data size information from the beginning of an incoming array or string.

49

ECG Monitoring System


If data includes array or string size? Is TRUE, LabVIEW reads the size
information from the beginning of binary string. If data includes array or
string size? Is FALSE, LabVIEW detects the size information from the
memory size of binary string. The default is TRUE. Data includes array or
string size. Only accesses the top-level data size information. Arrays and
strings in hierarchical data types such as clusters always include size
information.

Byte order indicates the ending format of the data in the incoming
flattened string. Byte order, or ending form, indicates whether integers are
represented in memory from most-significant byte to least-significant byte
or vice versa.

0 Big-ending, network order (default)The most-significant byte occupies the


lowest memory address.
1 Native, host orderUses the byte-ordering format of the host computer.
3 Little-endingThe least-significant byte occupies the lowest memory address.
Table 3.14 Byte order for Unflatten to string

Error in describes error conditions that occur before this node runs. This
input provides standard error in functionality.

Rest of the binary string contains any leftover bytes that this function did
not convert. This function does not convert all the bytes if the size of binary
string is not a multiple of the size of type.

Value returns binary string as unflattened data of the same data type and
structure as type.

Error out contains error information. This output provides standard error
out functionality.

50

ECG Monitoring System


Flowchart at client:
Start
Open UDP port

Read data from the


port.

Read number of bytes


received and add them to
the ones read in a previous
iteration

Concatenate data
received, and display
it in the string
indicator
Concatenate data
received, and display
it in the string

If the UDP Read.vi


times out, reset the
error cluster so an
error does not show

Check for errors

stop
Fig.3.20 Flowchart for Client

51

ECG Monitoring System


CHAPTER 4
RESULTS
4.1 Results:

Fig. 3.9 Peak Plot of R-R interval and Heart Rate

52

ECG Monitoring System

Fig. 3.10 Client side

53

ECG Monitoring System


CHAPTER.5
CONCLUSION
5.1 Conclusion:
This project ECG monitoring system deals with a transfer of ECG data from the
patients to the doctor present in his cabin. The idea of our project is firstly taking up an
ECG signal from the patient and reading the data in PC using an arduino (an open-source
electronics prototyping platform based on flexible, easy-to-use hardware and software)
board. Then the signal is applied to noise removal, base wander removal and mplification
circuits in labVIEW (a system design software) software. Now the ECG signal thus
obtained is sent from the patients recording system to doctors using an Ethernet cable or
LAN connection. This enables the monitoring of any number of patients by doctor at one
place.

5.2 Future Scope:

Transmission of signal to a remote PC using a dial up modem

Optical isolation of power supply and data communication interface

Development of analog subsystem to replace the analog ECG machine

Acquisition of signals other than ECG

Using the same ECG aquistion we can find the QRS peaks and find heart rate an
detect some more cardiac diseases like sinus arythmia, myocardial infarctions etc

54

ECG Monitoring System


REFERENCES:

International Journal of Computing Science and Communication Technologies

http://www.academia.edu

International Journal of Computer and Electrical Engineering

J.W. Zheng, Z.B. Zhang, T.H. Wu, Y. Zhang, A wearable mobihealth care system
supporting real-time diagnosis and alarm, Med. Bio. Eng. Comput. 45 (2007)

Cosmanescu, B. Miller, T. Magno, A. Ahmed, I. Kremenic, Design and


implementation of a wireless (Bluetooth (R)) four channel bio-instrumentation
amplifier and digital data acquisition device with user-selectable gain, frequency,
and driven reference, in: Conf. Proc. IEEE Eng. Med. Biol. Soc., 2006

Perkusich, G. S. Deep, M. L. B. Perkusich, and M. L. Varani, (1989) An expert


ECG acquisition and analysis system, IMTC- 89, 184-189.

J. Olansen, E. Rosow, Virtual Bio-Instrumentation, Biomedical, Clinical and


Healthcare applications in LabVIEW, Publishing House Prentice Hall PTR, 2002

M. Unser, A. Aldroubi and M. Eden, On the asymptotic convergence of Bspline wavelets to Gabor functions, IEEE Trans. Inform. Theory 38 (2), 864-872,
1992

APPENDIX:

55

You might also like