Saturday, September 25, 2010

labview Algorithms for ECG Signal Analysis

Summary: In order to accurately detect the heart rate in the ECG signal, filter banks analysis in Matlab is used on the filtered ECG signal. This algorithm can also be used to detect abnormalities in the ECG signal. LabVIEW is then used to notify the user of the results. This includes displaying the heart rate and alerting the user if an abnormality is detected.

ECG Signal Analysis: Abnormality Detection

The flowchart below breaks down the tasks needed to accomplish signal analysis in greater detail. Both LabVIEW and Matlab were used to accomplish these tasks.
Figure 1
Signal Analysis Flow Chart
Signal Analysis Flow Chart (graphics1.png)

Matlab Implementation of Filter Banks Analysis

Many scenarios deal with signals which contain specific energy distributions in the frequency domain. For example, with regard to the ECG, a significant proportion of the energy from the QRS complex extends to a frequency of 40 Hz, and even more if the Q, R, and S waves have very sharp morphologies. The P and T waves, in general, have a significant proportion of their energy only up to 10 Hz. Thus, a strategic approach to detecting heartbeats is to analyze different sub-bands of the ECG, rather than just the output of one filter which maximizes SNR of the QRS.
In this filter bank analysis technique we use 5 sub-bands, each one has bandwidth 5Hz. The ECG signal is processed by those 5 sub-band filters and downsampled. The downsampled signal is
Figure 2
Figure 2 (graphics2.png)
A variety of features which are indicative of the QRS complex can be designed by combining sub-bands of interest from l = 0, 1, … , M-1. For example a sum-of-absolute values feature P1 can be computed using sub-bands 1, 2, and 3.
Figure 3
Figure 3 (graphics3.png)
P1 has a value which corresponds to the energy in the frequency band [5.6, 22.5] Hz. Similarly, P2 and P3 can be computed using sub-bands {1, 2, 3, 4}, and {2, 3, 4}, respectively, and these values are proportional to the energy in their respective sub-bands. Heuristic beat detection logic can be used to incorporate some of the above features which are indicative of the QRS complex.
Figure 4 gives an overview of the sequential levels in the beat detection algorithm. The goal of the detection algorithm is to maximize the number of true positives (TP’s), while keeping the number of false negatives (FN’s) and false positives (FP’s) to a minimum. Since it is not possible to arrive at this goal using one simple detector, multiple detectors with complementary FN’s and FP’s performances are simultaneously operated and the results of each fused together to arrive at an overall decision. The advantage of this strategy is that multiple features which are indicative of the QRS complex can be used to detect beats.
Figure 4
Beat Detection Algorithm Schematic
Beat Detection Algorithm Schematic (graphics4.png)
A one-channel beat detection block is described in Figure 5.
Figure 5
Schematic of One-Channel Beat Detection Block
Schematic of One-Channel Beat Detection Block (graphics5.png)
The detection strength Ds of an incoming feature (e.g., P1, P2, P3) is determined by comparing with the signal and noise levels (SL and NL, respectively):
Figure 6
Figure 6 (graphics6.png)
If a feature’s value is less than NL then Ds is limited at 0, and if it is above SL then DS is limited to one. When a feature has a greater than a specified threshold (preset between zero and one) it is classified as a signal peak and the signal history is updated with the feature’s value. If the feature has a smaller than the threshold it is classified as a noise peak and the noise history is updated with the feature’s value.
The detail operations of each level can be found in the paper by V. Afonso et al (ECG beat detection using filter banks, IEEE Trans. Biomed. Eng. 46: 1999). Also, download and runECGmain.m to test out filter banks. Supplementary mfiles: nqrsdetect.m, ECGSigProc.m, t.mat, x.mat.

LabVIEW Programming for Signal Processing and Interfacing

LabVIEW is used to not only process and acquire the signal, but to also develop an user friendly interface that automatically alerts the user to any abnormalities or arrhythmias detected. This particular ECG is developed to detect left ventricular hypertrophy and old myocardial infarction. It will also automatically display the heart rate and whether or not the patient’s heart rate is within a healthy range.
Figure 7: This view of the the GUI shows a normal, healthy ECG signal. The indicator lights (6) will change color depending on the diagnosis. Additionally, the green trace turns red if any abnormality or arrhythmia is detected.
The Graphical User Interface
The Graphical User Interface (graphics7.png)
The user interface consists of several useful features. First, there is a text input for the patient’s name to avoid confusion in the clinic. Second, the ECG chart is automatically updated with the name and live signal data. Third, the user can control the data acquisition periods. The heart rate and any abnormalities are displayed in the patient report. The warning lights to the left of the patient report correspond to the current condition of the patient’s ECG. If everything is normal, the green light is on and the signal is green. If an arrhythmia is detected, the yellow light turns on and a warning message will appear in the patient report that indicates the type. Similarly, the orange light turns on if an abnormality is detected and a warning message appears in the report. For either of these, the ECG trace turns red in the chart window. A red light indicates that no recognizable signal is being detected. This can mean that the patient has flat-lined, that the circuit board is not powered or that the leads are not connected properly. As a result, the warning message will ask the user to check the lead and power connections. Finally, the form can be reset between patients. You can download our VI here to test it out.

Content actions

GIVE FEEDBACK:

labview Multicore Programming

Summary: The creation of this content was supported in some part by NSF grant 0538934.
If you have written parallel programs in G and have a multicore computer, CONGRATULATIONS!!! You have been successfully developing interactive parallel programs that execute in multicore PC processors.
Figure 1: Interactive Multicore G Program
This screencap contain a diagram with two parallel graphs of sin waves and below these two graph is a CPU usage and CPU Usage History.
The following sections discuss some multicore programming techniques to improve the performance of G programs.

Data Parallelism

Matrix multiplication is a compute intensive operation that can leverage data parallelism. Figure 2 shows a G program with 8 sequential frames to demonstrate the performance improvement via data parallelism.
Figure 2: Data Parallelism
A complex diagram of a data parallelism.
The Create Matrix function generates a square matrix based of size indicated by Size containing random numbers between 0 and 1. The Create Matrix function is shown in Figure 3.
Figure 3: Creating a Square Matrix
A diagram consisting of three box icons. From left to right you have a blue box labeled 'size'. The next element is two rectangles one large one underneath a smaller one. In the rectangles on the left of both are blue squares containing a 'N'and an 'i'. Blue lines point from the first icon to these blue squares. An orange line points from these rectangles to the third icon labeled 'matrix'.
The Split Matrix function determines the number of rows in the matrix and shifts right the resulting number of rows by one (integer divide by 2). This value is used to split the input matrix into the top half and bottom half matrices. The Split Matrix function is shown in Figure 4.
Figure 4: Split Matrix into Top & Bottom
A diagram of a split matrix into top and bottom. The diagram consist of an icon labeled matrix. Two orange lines split off from the icon and go around a center icon to connect to two rectangles which then leads to two parallel icons labeled top and bottom.
TABLE 1
Sequence FrameOperation Description
First FrameGenerates two square matrices initialized with random numbers
Second FrameRecords start time for single core matrix multiply
Third FramePerforms single core matrix multiply
Fourth FrameRecords stop time of single core matrix multiply
Fifth FrameSplits the matrix into top and bottom matrices
Sixth FrameRecords start time for multicore matrix multiply
Seventh FramePerforms multicore matrix multiply
Eighth FrameRecords stop time of multicore matrix multiply
The rest of the calculations determine the execution time in milliseconds of the single core and multicore matrix multiply operations and the performance improvement of using data parallelism in a multicore computer.
The program was executed in a dual core 1.83 GHz laptop. The results are shown in Figure 5. By leveraging data parallelism, the same operation has nearly a 2x performance improvement. Similar performance benefits can be obtained with higher multicore processors
Figure 5: Data Parallelism Performance Improvement
A diagram of Data Parallelism Performance Improvement. The diagram consists of four fields from left to right they are labeled: Matrix size with a value of 1000. Next a field 'AxB' with a value of 1161. Below this field is another field called 'parallel AxB' with a value of 598. The final field is labeled 'Performance Improvement' with a value of 1.94147.

Task Pipelining

A variety of applications require tasks to be programmed sequentially and continually iterate on these tasks. Most notably are telecommunications applications require simultaneous transmit and receive. In the following example, a simple telecommunications example illustrates how these sequential tasks can be pipelined to leverage multicore environments.
Consider the following simple modulation - demodulation example where a noisy signal is modulated transmitted and demodulated. A typical diagram is shown in Figure 6.
Figure 6: Sequential Tasks
A diagram of sequential tasks. It consists of four icons in a row. The last icon is is surrounded in a orange box. Underneath this row is a stop button surrounded in great with a red button next to it. On the left corner there is an blue square containing an 'i'.
Adding a shift register to the loop allows tasks to be pipelined and be executed in parallel in separate cores should they be available. Task pipelining is shown in Figure 7.
Figure 7: Pipelined Tasks
A diagram of 'Pipelined Task'. There are two paths of icons. The upper row of icons has two squares with a orange line connected them and then another orange line connects to the right side of the box. The bottom row begins with a orange line connected to the left side of the box and then extends to a gray box icon which is then connected via another orange line to graph icon that is in an orange box.
The program below times the sequential task and the pipelined tasks to establish its performance improvement when executed in multicore computers.
Figure 8: Task Pipelining Program Example
A diagram of a 'Task Pipelining Program Example'. The diagram is formed on a sort of film frame. There are also two rows. The upper from left to right is a box icon connected via an orange line to a box  with an 'N' with a '1000'in the upper left corner and an 'i' in the lower left. In the middle of this box are two horizontally oriented box icons. An orange line continues to the right to another box with the same setup as the previous, except the box icons are oriented vertically. The orange line continues through the upper box and ends to the right. The second row is below the other and consists of three clock icons linked by blue lines and then on the far right side there are arrows all pointing to three icons labeled from top to bottom 'pipelined', 'improvement', and 'sequential'.
Figure 9 shows the results of running the above G program in a dual core 1.8 GHz laptop. Pipelining shows nearly 2x performance improvement.
Figure 9: Pipelining Performance Improvement
A diagram of Performance Improvement due to Pipelining. There are three fields in this diagram. From left to right the fields are 'Sequential' with a value of 5953. Under that field is the another field labeled 'Pipelined' with a value of 3156. To the right of these two fields is the third and final field labeled 'improvement'with a value of 1.88625.

Pipelining Using Feedback Nodes

Feedback Nodes provide a storage mechanism between loop iterations. They are programmatically identical to the Shift Registers. Feedback Nodes consist of an Initializer Terminal and the Feedback Node itself (see Figure 10).
Figure 10: Feedback Node
A diagram of a feedback node. The diagram is arranged vertical with items top to bottom the phrase 'Feedback Node' with a orange line connecting it to an icon of an arrow above and icon of a black dot. An orange line connects that to the phrase 'Initializer Terminal'.
To add a Feedback Node, right click on the Block Diagram window and select Feedback Node from the Functions >> Programming >> Structures pop-up menu. The direction of theFeedback Node can be changed by right clicking on the node and selecting Change Direction.
Figure 11: Feedback Node Direction
A diagram of menu listing over an arrow icon.
The diagram shown in Figure 12 is programmatically identical to the diagram in Figure 7.
Figure 12: Pipelining with Feedback Node
A diagram of 'Pipelining with Feedback Node'. The diagram is oriented horizontally, and from left to right the diagram consist of a box icon connected via an orange line to another box icon connected via a orange arrow to an arrow above a dot icon. The icon is also connected to the right via an orange line to a box icon which is connected to a graph icon. In the bottom left of the diagram is a blue square with an 'i' in is and on the bottom right is a 'stop' button icon.
Similarly, the diagram in Figure 13 is programmatically identical to that in Figure 8.
Figure 13: Pipelining Tasks with Feedback Nodes
A diagram of a 'Task Pipelining Program Example'. The diagram is formed on a sort of film frame. There are also two rows. The upper from left to right is a box icon connected via an orange line to a box  with an 'N' with a '1000'in the upper left corner and an 'i' in the lower left. In the middle of this box are two horizontally oriented box icons. An orange line continues to the right to another box with the same setup as the previous, except between the two icons there is an orange arrow over a dot icon. The orange line continues through the boxes and icon and ends to the right. The second row is below the other and consists of three clock icons linked by blue lines and then on the far right side there are arrows all pointing to three icons labeled from top to bottom 'pipelined', 'improvement', and 'sequential'.

Content actions

GIVE FEEDBACK:

Related Posts Plugin for WordPress, Blogger...

Popular Projects

My Blog List

Give support

Give support
Encourage Me through Comments & Followers

Followers