BIOMEDICAL DIGITAL SIGNAL PROCESSING

420 downloads 774 Views 17KB Size Report
i. BIOMEDICAL. DIGITAL. SIGNAL. PROCESSING. C-Language Examples and Laboratory Experiments for the IBM® PC. WILLIS J. TOMPKINS. Editor.
BIOMEDICAL DIGITAL SIGNAL PROCESSING C-Language Examples and Laboratory Experiments for the IBM® PC WILLIS J. TOMPKINS Editor University of Wisconsin-Madison

© 2000 by Willis J. Tompkins This book was previously printed by: PRENTICE HALL, Upper Saddle River, New Jersey 07458

i

ii

Contents

Contents

1

LIST OF CONTRIBUTORS

x

PREFACE

xi

INTRODUCTION TO COMPUTERS IN MEDICINE

1

1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2

ELECTROCARDIOGRAPHY 2.1 2.2 2.3 2.4 2.5 2.6

3

Characteristics of medical data 1 What is a medical instrument? 2 Iterative definition of medicine 4 Evolution of microprocessor-based systems 5 The microcomputer-based medical instrument 13 Software design of digital filters 16 A look to the future 22 References 22 Study questions 23

Basic electrocardiography 24 ECG lead systems 39 ECG signal characteristics 43 Lab: Analog filters, ECG amplifier, and QRS detector 44 References 53 Study questions 53

SIGNAL CONVERSION 3.1 3.2 3.3 3.4 3.5 3.6 3.7

24

Sampling basics 55 Simple signal conversion systems 59 Conversion requirements for biomedical signals 60 Signal conversion circuits 61 Lab: Signal conversion 74 References 75 Study questions 75

55

Contents

4

iii

BASICS OF DIGITAL FILTERING 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9

5

6

125

Generic equations of IIR filters 125 Simple one-pole example 126 Integrators 130 Design methods for two-pole filters 136 Lab: IIR digital filters for ECG analysis 144 References 145 Study questions 145

INTEGER FILTERS 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 7.10

100

Characteristics of FIR filters 100 Smoothing filters 103 Notch filters 111 Derivatives 111 Window design 117 Frequency sampling 119 Minimax design 120 Lab: FIR filter design 121 References 123 Study questions 123

INFINITE IMPULSE RESPONSE FILTERS 6.1 6.2 6.3 6.4 6.5 6.6 6.7

7

Digital filters 78 The z transform 79 Elements of a digital filter 81 Types of digital filters 84 Transfer function of a difference equation 85 The z-plane pole-zero plot 85 The rubber membrane concept 89 References 98 Study questions 98

FINITE IMPULSE RESPONSE FILTERS 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 5.10

78

Basic design concept 151 Low-pass integer filters 157 High-pass integer filters 158 Bandpass and band-reject integer filters 160 The effect of filter cascades 161 Other fast-operating design techniques 162 Design examples and tools 164 Lab: Integer filters for ECG analysis 170 References 171 Study questions 171

151

iv

8

Contents

ADAPTIVE FILTERS 8.1 8.2 8.3 8.4 8.5 8.6

9

10

12

216

The Fourier transform 216 Correlation 222 Convolution 226 Power spectrum estimation 230 Lab: Frequency-domain analysis of the ECG 233 References 235 Study questions 235

ECG QRS DETECTION 12.1 12.2 12.3 12.4

193

Turning point algorithm 194 AZTEC algorithm 197 Fan algorithm 202 Huffman coding 206 Lab: ECG data reduction algorithms 211 References 212 Study questions 213

OTHER TIME- AND FREQUENCY-DOMAIN TECHNIQUES 11.1 11.2 11.3 11.4 11.5 11.6 11.7

184

Basics of signal averaging 184 Signal averaging as a digital filter 189 A typical averager 189 Software for signal averaging 190 Limitations of signal averaging 190 Lab: ECG signal averaging 192 References 192 Study questions 192

DATA REDUCTION TECHNIQUES 10.1 10.2 10.3 10.4 10.5 10.6 10.7

11

Principal noise canceler model 174 60-Hz adaptive canceling using a sine wave model 175 Other applications of adaptive filtering 180 Lab: 60-Hz adaptive filter 181 References 182 Study questions 182

SIGNAL AVERAGING 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8

174

Power spectrum of the ECG 236 Bandpass filtering techniques 237 Differentiation techniques 241 Template matching techniques 242

236

Contents

v

12.5 12.6 12.7 12.8 13

ECG ANALYSIS SYSTEMS 13.1 13.2 13.3 13.4 13.5

14

B

C

307

Data structures 308 Top-level device routines 309 Internal I/O device (RTD ADA2100) 309 External I/O device (Motorola 68HC11EVBU) 311 Virtual I/O device (data files) 313 References 316

DATA ACQUISITION AND CONTROL—SOME HINTS C.1 C.2 C.3

295

Installing the RTD ADA2100 in an IBM PC 297 Configuring the Motorola 68HC11EVBU 299 Configuring the Motorola 68HC11EVB 303 Virtual input/output device (data files) 305 Putting a header on a binary file: ADDHEAD 305 References 306

DATA ACQUISITION AND CONTROL ROUTINES B.1 B.2 B.3 B.4 B.5 B.6

283

Digital signal processors 283 High-performance VLSI signal processing 286 VLSI applications in medicine 290 VLSI sensors for biomedical signals 291 VLSI tools 293 Choice of custom, ASIC, or off-the-shelf components 293 References 293 Study questions 294

CONFIGURING THE PC FOR UW DIGISCOPE A.1 A.2 A.3 A.4 A.5 A.6

265

ECG interpretation 265 ST-segment analyzer 271 Portable arrhythmia monitor 272 References 280 Study questions 281

VLSI IN DIGITAL SIGNAL PROCESSING 14.1 14.2 14.3 14.4 14.5 14.6 14.7 14.8

A

A QRS detection algorithm 246 Lab: Real-time ECG processing algorithm 262 References 263 Study questions 263

Internal I/O device (RTD ADA2100) 318 External I/O device (Motorola 68HC11EVBU) 320 Virtual I/O device (data files) 324

317

vi

Contents

C.4 C.5 D

UW DIGISCOPE USER’S MANUAL D.1 D.2

E

G

INDEX

346

Quantization noise 346 Limit cycles 348 Scaling 351 Roundoff noise in IIR filters 352 Floating-point register filters 353 Summary 354 Lab: Finite-length register effects in digital filters 355 References 355

COMMERCIAL DSP SYSTEMS G.1 G.2 G.3 G.4

342

Signal generation methods 342 Signal generator program (GENWAVE) 343

FINITE-LENGTH REGISTER EFFECTS F.1 F.2 F.3 F.4 F.5 F.6 F.7 F.8

332

Getting around in UW DigiScope 332 Overview of functions 334

SIGNAL GENERATION E.1 E.2

F

Writing your own interface software 327 References 331

356

Data acquisition systems 356 DSP software 357 Vendors 359 References 360 361

List of Contributors

Valtino X. Afonso David J. Beebe Annie P. Foong Kok Fung Lai Danial J. Neebel Jesse D. Olson Dorin Panescu Jon D. Pfeffer Pradeep M. Tagare Steven J. Tang Thomas Y. Yen Ren Zhou

vii

Preface

There are many digital filtering and pattern recognition algorithms used in processing biomedical signals. In a medical instrument, a set of these algorithms typically must operate in real time. For example, an intensive care unit computer must acquire the electrocardiogram of a patient, recognize key features of the signal, determine if the signal is normal or abnormal, and report this information in a timely fashion. In a typical biomedical engineering course, students have limited real-world design opportunity. Here at the University of Wisconsin-Madison, for example, the laboratory setups were designed a number of years ago around single board computers. These setups run real-time digital signal processing algorithms, and the students can analyze the operation of these algorithms. However, the hardware can be programmed only in the assembly language of the embedded microprocessor and is not easily reprogrammed to implement new algorithms. Thus, a student has limited opportunity to design and program a processing algorithm. In general, students in electrical engineering have very limited opportunity to have hands-on access to the operation of digital filters. In our current digital filtering courses, the filters are designed noninteractively. Students typically do not have the opportunity to implement the filters in hardware and observe real-time performance. This approach certainly does not provide the student with significant understanding of the design constraints of such filters nor their actual performance characteristics. Thus, the concepts developed here are adaptable to other areas of electrical engineering in addition to the biomedical area, such as in signal processing courses. We developed this book with its set of laboratories and special software to provide a mechanism for anyone interested in biomedical signal processing to study the field without requiring any other instrument except an IBM PC or compatible. For those who have signal conversion hardware, we include procedures that will provide true hands-on laboratory experiences. We include in this book the basics of digital signal processing for biomedical applications and also C-language programs for designing and implementing simple digital filters. All examples are written in the Turbo C (Borland) programming language. We chose the C language because our previous approaches have had limited flexibility due to the required knowledge of assembly language programming. The relationship between a signal processing algorithm and its assembly language implementation is conceptually difficult. Use of the high-level C language permits viii

Preface

ix

students to better understand the relationship between the filter and the program that implements it. In this book, we provide a set of laboratory experiments that can be completed using either an actual analog-to-digital converter or a virtual (i.e., simulated with software) converter. In this way, the experiments may be done in either a fully instrumented laboratory or on almost any IBM PC or compatible. The only restrictions on the PC are that it must have at least 640 kbytes of RAM and VGA (or EGA or monochrome) graphics. This graphics requirement is to provide for a high resolution environment for visualizing the results of signal processing. For some applications, particularly frequency domain processing, a math coprocessor is useful to speed up the computations, but it is optional. The floppy disk provided with the book includes the special program called UW DigiScope which provides an environment in which the student can do the lab experiments, design digital filters of different types, and visualize the results of processing on the display. This program supports the virtual signal conversion device as well as two different physical signal conversion devices. The physical devices are the Real Time Devices ADA2100 signal conversion board which plugs into the internal PC bus and the Motorola 68HC11EVB board (chosen because students can obtain their own device for less than $100). This board sits outside the PC and connects through a serial port. The virtual device simulates signal conversion with software and reads data files for its input waveforms. Also on the floppy disk are some examples of sampled signals and a program that permits users to put their own data in a format that is readable by UW DigiScope. We hope that this program and the standard file format will stimulate the sharing of biomedical signal files by our readers. The book begins in Chapter 1 with an overview of the field of computers in medicine, including a historical review of the evolution of the technologies important to this field. Chapter 2 reviews the field of electrocardiography since the electrocardiogram (ECG) is the model biomedical signal used for demonstrating the digital signal processing techniques throughout the book. The laboratory in this chapter teaches the student about analog signal acquisition and preprocessing by building circuitry for amplifying his/her own ECG. Chapter 3 provides a traditional review of signal conversion techniques and provides a lab that gives insight into the techniques and potential pitfalls of digital signal acquisition. Chapters 4, 5, and 6 cover the principles of digital signal processing found in most texts on this subject but use a conceptual approach to the subject as opposed to the traditional equation-laden theoretical approach that is difficult for many students. The intent is to get the students involved in the design process as quickly as possible with minimal reliance on proving the theorems that form the foundation of the techniques. Two labs in these chapters give the students hands-on experience in designing and running digital filters using the UW DigiScope software platform. Chapter 7 covers a special class of integer coefficient filters that are particularly useful for real-time signal processing because these filters do not require floatingpoint operations. This topic is not included in most digital signal processing books. A lab helps to develop the student’s understanding of these filters through a design exercise.

x

Preface

Chapter 8 introduces adaptive filters that continuously learn the characteristics of their processing environment and change their filtering characteristics to optimally perform their intended functions. Chapter 9 reviews the technique and application of signal averaging. Chapter 10 covers data reduction techniques, which are important for reducing the amount of data that must be stored, processed, or transmitted. The ability to compress signals into smaller file sizes is becoming more important as more signals are being archived and handled digitally. A lab provides an experience in data reduction and reconstruction of signals using techniques provided in the book. Chapter 11 summarizes additional important techniques for signal processing with emphasis on frequency domain techniques and illustrates frequency analysis of the ECG with a special lab. Chapter 12 presents a diversity of techniques for detecting the principal features of the ECG with emphasis on real-time algorithms that are demonstrated with a lab. Then Chapter 13 shows how many of these techniques are used in actual medical monitoring systems. Chapter 14 concludes with a summary of the emerging integrated circuit technologies for digital signal processing with a look to the trends in this field for the future. Appendices A, B, and C provide details of interfacing and use of the two physical signal conversion devices supported as well as the virtual signal conversion device that can be used on any PC. Appendix D is the user’s manual for the special UW DigiScope program that is used for the lab experiments. Appendix E describes the signal generator function in UW DigiScope that lets the student create simulated signals with controlled noise and sampling rates and store them in disk files for processing by the virtual signal conversion device. Appendix F covers special problems that can occur due to the finite length of a computer’s internal registers when implementing digital signal processing algorithms. Appendix G reviews some of the commercial software in the market that facilitates digital signal acquisition and processing. I would especially like to thank the students who attended my class, Computers in Medicine (ECE 463), in Fall 1991 for helping to find many small (and some large problems) in the text material and in the software. I would also like to particularly thank Jesse Olson, author of Chapter 5, for going the extra mile to ensure that the UW DigiScope program is a reliable teaching tool. The interfaces and algorithms in the labs emphasize real-time digital signal processing techniques that are different from the off-line approaches to digital signal processing taught in most digital signal processing courses. We hope that the use of PC-based real-time signal processing workstations will greatly enhance the student’s hands-on design experience. Willis J. Tompkins Department of Electrical and Computer Engineering University of Wisconsin-Madison