Biosignal and Biomedical Image Processing -...

18
Biosignal and Biomedical Image Processing MATLA B-Based Applications JOHN L. SEMMLOW Robert Wood Johnson Medical School New Brunswick, New Jersey, U.S.A. Rutgers University Piscataway, New Jersey, U.S.A. Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

Transcript of Biosignal and Biomedical Image Processing -...

  • Biosignal and Biomedical Image Processing MATLA B-Based Applications

    JOHN L. SEMMLOW Robert Wood Johnson Medical School New Brunswick, New Jersey, U.S.A.

    Rutgers University Piscataway, New Jersey, U.S.A.

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • Although great care has been taken to provide accurate and current information, neitherthe author(s) nor the publisher, nor anyone else associated with this publication, shall beliable for any loss, damage, or liability directly or indirectly caused or alleged to becaused by this book. The material contained herein is not intended to provide specificadvice or recommendations for any specific situation.

    Trademark notice: Product or corporate names may be trademarks or registered trade-marks and are used only for identification and explanation without intent to infringe.

    Library of Congress Cataloging-in-Publication DataA catalog record for this book is available from the Library of Congress.

    ISBN: 08247-48034

    This book is printed on acid-free paper.

    HeadquartersMarcel Dekker, Inc., 270 Madison Avenue, New York, NY 10016, U.S.A.tel: 212-696-9000; fax: 212-685-4540

    Distribution and Customer ServiceMarcel Dekker, Inc., Cimarron Road, Monticello, New York 12701, U.S.A.tel: 800-228-1160; fax: 845-796-1772

    Eastern Hemisphere DistributionMarcel Dekker AG, Hutgasse 4, Postfach 812, CH-4001 Basel, Switzerlandtel: 41-61-260-6300; fax: 41-61-260-6333

    World Wide Webhttp://www.dekker.com

    The publisher offers discounts on this book when ordered in bulk quantities. For moreinformation, write to Special Sales/Professional Marketing at the headquarters addressabove.

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

    Neither this book nor any part may be reproduced or transmitted in any form or by anymeans, electronic or mechanical, including photocopying, microfilming, and recording,or by any information storage and retrieval system, without permission in writing fromthe publisher.

    Current printing (last digit):

    10 9 8 7 6 5 4 3 2 1

    PRINTED IN THE UNITED STATES OF AMERICA

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

    http:/ /www.dekker.com

  • Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • To Lawrence Stark, M.D., who has shown me the many possibilities . . .

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • Series Introduction

    Over the past 50 years, digital signal processing has evolved as a major engi-neering discipline. The fields of signal processing have grown from the originof fast Fourier transform and digital filter design to statistical spectral analysisand array processing, image, audio, and multimedia processing, and shaped de-velopments in high-performance VLSI signal processor design. Indeed, thereare few fields that enjoy so many applicationssignal processing is everywherein our lives.

    When one uses a cellular phone, the voice is compressed, coded, andmodulated using signal processing techniques. As a cruise missile winds alonghillsides searching for the target, the signal processor is busy processing theimages taken along the way. When we are watching a movie in HDTV, millionsof audio and video data are being sent to our homes and received with unbeliev-able fidelity. When scientists compare DNA samples, fast pattern recognitiontechniques are being used. On and on, one can see the impact of signal process-ing in almost every engineering and scientific discipline.

    Because of the immense importance of signal processing and the fast-growing demands of business and industry, this series on signal processingserves to report up-to-date developments and advances in the field. The topicsof interest include but are not limited to the following:

    Signal theory and analysis Statistical signal processing Speech and audio processing

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • Image and video processing Multimedia signal processing and technology Signal processing for communications Signal processing architectures and VLSI design

    We hope this series will provide the interested audience with high-quality,state-of-the-art signal processing literature through research monographs, editedbooks, and rigorously written textbooks by experts in their fields.

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • Preface

    Signal processing can be broadly defined as the application of analog or digitaltechniques to improve the utility of a data stream. In biomedical engineeringapplications, improved utility usually means the data provide better diagnosticinformation. Analog techniques are applied to a data stream embodied as a time-varying electrical signal while in the digital domain the data are represented asan array of numbers. This array could be the digital representation of a time-varying signal, or an image. This text deals exclusively with signal processingof digital data, although Chapter 1 briefly describes analog processes commonlyfound in medical devices.

    This text should be of interest to a broad spectrum of engineers, but itis written specifically for biomedical engineers (also known as bioengineers).Although the applications are different, the signal processing methodology usedby biomedical engineers is identical to that used by other engineers such electri-cal and communications engineers. The major difference for biomedical engi-neers is in the level of understanding required for appropriate use of this technol-ogy. An electrical engineer may be required to expand or modify signalprocessing tools, while for biomedical engineers, signal processing techniquesare tools to be used. For the biomedical engineer, a detailed understanding ofthe underlying theory, while always of value, may not be essential. Moreover,considering the broad range of knowledge required to be effective in this field,encompassing both medical and engineering domains, an in-depth understandingof all of the useful technology is not realistic. It is important is to know what

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • tools are available, have a good understanding of what they do (if not how theydo it), be aware of the most likely pitfalls and misapplications, and know howto implement these tools given available software packages. The basic conceptof this text is that, just as the cardiologist can benefit from an oscilloscope-typedisplay of the ECG without a deep understanding of electronics, so a biomedicalengineer can benefit from advanced signal processing tools without always un-derstanding the details of the underlying mathematics.

    As a reflection of this philosophy, most of the concepts covered in thistext are presented in two sections. The first part provides a broad, general under-standing of the approach sufficient to allow intelligent application of the con-cepts. The second part describes how these tools can be implemented and reliesprimarily on the MATLAB software package and several of its toolboxes.

    This text is written for a single-semester course combining signal andimage processing. Classroom experience using notes from this text indicatesthat this ambitious objective is possible for most graduate formats, althougheliminating a few topics may be desirable. For example, some of the introduc-tory or basic material covered in Chapters 1 and 2 could be skipped or treatedlightly for students with the appropriate prerequisites. In addition, topics suchas advanced spectral methods (Chapter 5), time-frequency analysis (Chapter 6),wavelets (Chapter 7), advanced filters (Chapter 8), and multivariate analysis(Chapter 9) are pedagogically independent and can be covered as desired with-out affecting the other material.

    Although much of the material covered here will be new to most students,the book is not intended as an introductory text since the goal is to provide aworking knowledge of the topics presented without the need for additionalcourse work. The challenge of covering a broad range of topics at a useful,working depth is motivated by current trends in biomedical engineering educa-tion, particularly at the graduate level where a comprehensive education mustbe attained with a minimum number of courses. This has led to the developmentof core courses to be taken by all students. This text was written for just sucha core course in the Graduate Program of Biomedical Engineering at RutgersUniversity. It is also quite suitable for an upper-level undergraduate course andwould be of value for students in other disciplines who would benefit from aworking knowledge of signal and image processing.

    It would not be possible to cover such a broad spectrum of material to adepth that enables productive application without heavy reliance on MATLAB-based examples and problems. In this regard, the text assumes the studenthas some knowledge of MATLAB programming and has available the basicMATLAB software package including the Signal Processing and Image Process-ing Toolboxes. (MATLAB also produces a Wavelet Toolbox, but the section onwavelets is written so as not to require this toolbox, primarily to keep the num-ber of required toolboxes to a minimum.) The problems are an essential part of

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • this text and often provide a discovery-like experience regarding the associatedtopic. A few peripheral topics are introduced only though the problems. Thecode used for all examples is provided in the CD accompanying this text. Sincemany of the problems are extensions or modifications of examples given in thechapter, some of the coding time can be reduced by starting with the code of arelated example. The CD also includes support routines and data files used inthe examples and problems. Finally, the CD contains the code used to generatemany of the figures. For instructors, there is a CD available that contains theproblem solutions and Powerpoint presentations from each of the chapters.These presentations include figures, equations, and text slides related to chapter.Presentations can be modified by the instructor as desired.

    In addition to heavy reliance on MATLAB problems and examples, thistext makes extensive use of simulated data. Except for the section on imageprocessing, examples involving biological signals are rarely used. In my view,examples using biological signals provide motivation, but they are not generallyvery instructive. Given the wide range of material to be presented at a workingdepth, emphasis is placed on learning the tools of signal processing; motivationis left to the reader (or the instructor).

    Organization of the text is straightforward. Chapters 1 through 4 are fairlybasic. Chapter 1 covers topics related to analog signal processing and data acqui-sition while Chapter 2 includes topics that are basic to all aspects of signal andimage processing. Chapters 3 and 4 cover classical spectral analysis and basicdigital filtering, topics fundamental to any signal processing course. Advancedspectral methods, covered in Chapter 5, are important due to their widespreaduse in biomedical engineering. Chapter 6 and the first part of Chapter 7 covertopics related to spectral analysis when the signals spectrum is varying in time,a condition often found in biological signals. Chapter 7 also covers both contin-uous and discrete wavelets, another popular technique used in the analysis ofbiomedical signals. Chapters 8 and 9 feature advanced topics. In Chapter 8,optimal and adaptive filters are covered, the latters inclusion is also motivatedby the time-varying nature of many biological signals. Chapter 9 introducesmultivariate techniques, specifically principal component analysis and indepen-dent component analysis, two analysis approaches that are experiencing rapidgrowth with regard to biomedical applications. The last four chapters coverimage processing, with the first of these, Chapter 10, covering the conventionsused by MATLABs Imaging Processing Toolbox. Image processing is a vastarea and the material covered here is limited primarily to areas associated withmedical imaging: image acquisition (Chapter 13); image filtering, enhancement,and transformation (Chapter 11); and segmentation, and registration (Chapter 12).

    Many of the chapters cover topics that can be adequately covered only ina book dedicated solely to these topics. In this sense, every chapter representsa serious compromise with respect to comprehensive coverage of the associated

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • topics. My only excuse for any omissions is that classroom experience with thisapproach seems to work: students end up with a working knowledge of a vastarray of signal and image processing tools. A few of the classic or major bookson these topics are cited in an Annotated bibliography at the end of the book.No effort has been made to construct an extensive bibliography or reference listsince more current lists would be readily available on the Web.

    TEXTBOOK PROTOCOLS

    In most early examples that feature MATLAB code, the code is presented infull, while in the later examples some of the routine code (such as for plotting,display, and labeling operation) is omitted. Nevertheless, I recommend that stu-dents carefully label (and scale when appropriate) all graphs done in the prob-lems. Some effort has been made to use consistent notation as described inTable 1. In general, lower-case letters n and k are used as data subscripts, andcapital letters, N and K are used to indicate the length (or maximum subscriptvalue) of a data set. In two-dimensional data sets, lower-case letters m and nare used to indicate the row and column subscripts of an array, while capitalletters M and N are used to indicate vertical and horizontal dimensions, respec-tively. The letter m is also used as the index of a variable produced by a transfor-mation, or as an index indicating a particular member of a family of relatedfunctions.* While it is common to use brackets to enclose subscripts of discretevariables (i.e., x[n]), ordinary parentheses are used here. Brackets are reservedto indicate vectors (i.e., [x1, x2, x3 , . . . ]) following MATLAB convention.Other notation follows standard conventions.

    Italics () are used to introduce important new terms that should be incor-porated into the readers vocabulary. If the meaning of these terms is not obvi-ous from their use, they are explained where they are introduced. All MATLABcommands, routines, variables, and code are shown in the Courier typeface.Single quotes are used to highlight MATLAB filenames or string variables.Textbook protocols are summarized in Table 1.

    I wish to thank Susanne Oldham who managed to edit this book, andprovided strong, continuing encouragement and support. I would also like toacknowledge the patience and support of Peggy Christ and Lynn Hutchings.Professor Shankar Muthu Krishnan of Singapore provided a very thoughtfulcritique of the manuscript which led to significant improvements. Finally, Ithank my students who provided suggestions and whose enthusiasm for thematerial provided much needed motivation.

    *For example, m would be used to indicate the harmonic number of a family of harmonically relatedsine functions; i.e., fm(t) = sin (2 m t).

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • TABLE 1 Textbook Conventions

    Symbol Description/General usage

    x(t), y(t) General functions of time, usually a waveform or signalk, n Data indices, particularly for digitized time dataK, N Maximum index or size of a data setx(n), y(n) Waveform variable, usually digitized time variables (i.e., a dis-

    creet variable)m Index of variable produced by transformation, or the index of

    specifying the member number of a family of functions (i.e.,fm(t))

    X(f), Y(f) Frequency representation (complex) of a time functionX(m), Y(m) Frequency representation (complex) of a discreet variableh(t) Impulse response of a linear systemh(n) Discrete impulse response of a linear systemb(n) Digital filter coefficients representing the numerator of the dis-

    creet Transfer Function; hence the same as the impulse re-sponse

    a(n) Digital filter coefficients representing the denominator of the dis-creet Transfer Function

    Courier font MATLAB command, variable, routine, or program.Courier font MATLAB filename or string variable

    John L. Semmlow

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • Contents

    Preface

    1 Introduction

    Typical Measurement SystemsTransducers

    Further Study: The TransducerAnalog Signal ProcessingSources of Variability: Noise

    Electronic NoiseSignal-to-Noise Ratio

    Analog Filters: Filter BasicsFilter TypesFilter BandwidthFilter OrderFilter Initial Sharpness

    Analog-to-Digital Conversion: Basic ConceptsAnalog-to-Digital Conversion Techniques

    Quantization ErrorFurther Study: Successive Approximation

    Time Sampling: BasicsFurther Study: Buffering and Real-Time Data Processing

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • Data BanksProblems

    2 Basic Concepts

    NoiseEnsemble AveragingMATLAB Implementation

    Data Functions and TransformsConvolution, Correlation, and Covariance

    Convolution and the Impulse ResponseCovariance and CorrelationMATLAB Implementation

    Sampling Theory and Finite Data ConsiderationsEdge Effects

    Problems

    3 Spectral Analysis: Classical Methods

    IntroductionThe Fourier Transform: Fourier Series Analysis

    Periodic FunctionsSymmetry

    Discrete Time Fourier AnalysisAperiodic Functions

    Frequency ResolutionTruncated Fourier Analysis: Data WindowingPower Spectrum

    MATLAB ImplementationDirect FFT and WindowingThe Welch Method for Power Spectral Density DeterminationWidow Functions

    Problems

    4 Digital Filters

    The Z-TransformDigital Transfer FunctionMATLAB Implementation

    Finite Impulse Response (FIR) FiltersFIR Filter Design

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • Derivative Operation: The Two-Point Central DifferenceAlgorithm

    MATLAB ImplementationInfinite Impulse Response (IIR) FiltersFilter Design and Application Using the MATLAB Signal

    Processing ToolboxFIR Filters

    Two-Stage FIR Filter DesignThree-Stage Filter Design

    IIR FiltersTwo-Stage IIR Filter DesignThree-Stage IIR Filter Design: Analog Style Filters

    Problems

    5 Spectral Analysis: Modern Techniques

    Parametric Model-Based MethodsMATLAB Implementation

    Non-Parametric Eigenanalysis Frequency EstimationMATLAB Implementation

    Problems

    6 TimeFrequency Methods

    Basic ApproachesShort-Term Fourier Transform: The SpectrogramWigner-Ville Distribution: A Special Case of Cohens ClassChoi-Williams and Other Distributions

    Analytic SignalMATLAB Implementation

    The Short-Term Fourier TransformWigner-Ville DistributionChoi-Williams and Other Distributions

    Problems

    7 The Wavelet Transform

    IntroductionThe Continuous Wavelet Transform

    Wavelet TimeFrequency CharacteristicsMATLAB Implementation

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • The Discrete Wavelet TransformFilter Banks

    The Relationship Between Analytical Expressions andFilter Banks

    MATLAB ImplementationDenoisingDiscontinuity DetectionFeature Detection: Wavelet Packets

    Problems

    8 Advanced Signal Processing Techniques:Optimal and Adaptive Filters

    Optimal Signal Processing: Wiener FiltersMATLAB Implementation

    Adaptive Signal ProcessingAdaptive Noise CancellationMATLAB Implementation

    Phase Sensitive DetectionAM ModulationPhase Sensitive DetectorsMATLAB Implementation

    Problems

    9 Multivariate Analyses: Principal Component Analysisand Independent Component Analysis

    IntroductionPrincipal Component Analysis

    Order SelectionMATLAB Implementation

    Data RotationPrincipal Component Analysis Evaluation

    Independent Component AnalysisMATLAB Implementation

    Problems

    10 Fundamentals of Image Processing: MATLAB ImageProcessing Toolbox

    Image Processing Basics: MATLAB Image FormatsGeneral Image Formats: Image Array Indexing

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • Data Classes: Intensity Coding SchemesData FormatsData ConversionsImage DisplayImage Storage and RetrievalBasic Arithmetic Operations

    Advanced Protocols: Block ProcessingSliding Neighborhood OperationsDistinct Block Operations

    Problems

    11 Image Processing: Filters, Transformations,and Registration

    Spectral Analysis: The Fourier TransformMATLAB Implementation

    Linear FilteringMATLAB Implementation

    Filter DesignSpatial Transformations

    MATLAB ImplementationAffine TransformationsGeneral Affine TransformationsProjective Transformations

    Image RegistrationUnaided Image RegistrationInteractive Image Registration

    Problems

    12 Image Segmentation

    Pixel-Based MethodsThreshold Level AdjustmentMATLAB Implementation

    Continuity-Based MethodsMATLAB Implementation

    Multi-ThresholdingMorphological Operations

    MATLAB ImplementationEdge-Based Segmentation

    MATLAB ImplementationProblems

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

  • 13 Image Reconstruction

    CT, PET, and SPECTFan Beam GeometryMATLAB Implementation

    Radon TransformInverse Radon Transform: Parallel Beam GeometryRadon and Inverse Radon Transform: Fan Beam Geometry

    Magnetic Resonance ImagingBasic PrinciplesData Acquisition: Pulse SequencesFunctional MRIMATLAB ImplementationPrincipal Component and Independent Component Analysis

    Problems

    Annotated Bibliography

    Copyright 2004 by Marcel Dekker, Inc. All Rights Reserved.

    BIOSIGNAL AND BIOMEDICAL IMAGE PROCESSINGSERIES INTRODUCTIONPREFACECONTENTSCHAPTER 1: INTRODUCTIONCHAPTER 2: BASIC CONCEPTSCHAPTER 3: SPECTRAL ANALYSIS: CLASSICAL METHODSCHAPTER 4: DIGITAL FILTERSCHAPTER 5: SPECTRAL ANALYSIS: MODERN TECHNIQUESCHAPTER 6: TIMEFREQUENCY METHODSCHAPTER 7: THE WAVELET TRANSFORMCHAPTER 8: ADVANCED SIGNAL PROCESSING TECHNIQUES: OPTIMAL AND ADAPTIVE FILTERSCHAPTER 9: MULTIVARIATE ANALYSES: PRINCIPAL COMPONENT ANALYSIS AND INDEPENDENT COMPONENT ANALYSISCHAPTER 10: FUNDAMENTALS OF IMAGE PROCESSING: MATLAB IMAGE PROCESSING TOOLBOXCHAPTER 11: IMAGE PROCESSING: FILTERS, TRANSFORMATIONS, AND REGISTRATIONCHAPTER 12: IMAGE SEGMENTATIONCHAPTER 13: IMAGE RECONSTRUCTIONANNOTATED BIBLIOGRAPHY