• Nenhum resultado encontrado

Smartphone Noise Supression

N/A
N/A
Protected

Academic year: 2021

Share "Smartphone Noise Supression"

Copied!
86
0
0

Texto

(1)

F

ACULDADE DE

E

NGENHARIA DA

U

NIVERSIDADE DO

P

ORTO

SmartNS

Gabriel Guedes Pereira Damaso

Mestrado Integrado em Engenharia Informática e Computação Supervisor: Aníbal João de Sousa Ferreira (Ph.D)

(2)
(3)

SmartNS

Gabriel Guedes Pereira Damaso

Mestrado Integrado em Engenharia Informática e Computação

Approved in oral examination by the committee:

Chair: José Manuel De Magalhães Cruz, PhD

External Examiner: António Guilherme Rocha Campos, PhD Supervisor: Aníbal João de Sousa Ferreira, PhD

(4)
(5)

Abstract

The decrease of the birth rate and the rise of life expectancy has brought an uncommon ageing phenomenon to our world. On the other hand, mobile technologies have become an everyday essential good, having an outstanding evolution in the last years when it comes to its features. As a result, they have become a tool also to health care services.

Chronic heart failure is a medical condition mostly observed in the elderly, and it is responsible for millions of deaths every year. One of the main physiopathologic mechanisms of chronic heart failure symptoms is pulmonary congestion, characterized by the accumulation of fluid in the lungs, often detected on physical examination by pulmonary auscultation. Crackles are characteristic noises that may be present in one or both lungs, frequently heard during inspiration.

This medical condition can be attenuated when diagnosed in an early process, and that is where this project fits in. It intends to make an improvement on an existing solution, that is a part of an health care remote monitoring application. An Android smartphone and a low cost electronic stethoscope is all that is needed.

Two issues are faced when this challenge is addressed. First, the respiratory sounds collected with this method show a significant amount of noise, which directly influences the second issue: the automatic method for crackles detection, because in order to have a maximized efficiency in this second part, the first must be as efficient as possible.

In order to solve these problems, noise suppression is mandatory in a preprocessing stage before submitting the samples to the crackles detection algorithm. The first approach turned out to be unsuccessful, which consisted in applying a differentiator filter followed by the convolution method. A new solution was necessary, which arose from the possibility to connect a second microphone, using the first smartphone that allows stereo recording from jack input. It became possible to apply adaptive filtering in order to perform a more effective noise cancellation in the described context.

Regarding automatic methods for crackles detection, one algorithm was successfully imple-mented and validated, as well as an alternative version created in order to have a more solid base for testing the solution presented.

A simulation was performed to test the efficiency of the solution proposed. For the first al-gorithm, the noisy respiratory sounds revealed a Sensitivity of 36.6%, Precision of 34.5% and Harmonic Mean of 33.6%, while the filtered signals with maximum performance presented a Sen-sitivity of 63.2%, Precision of 70.5% and Harmonic Mean of 64.9%. For the second algorithm, the noisy respiratory sounds revealed a Sensitivity of 21.0%, Precision of 33.2% and Harmonic Mean of 23.5%, while the filtered signal with maximum performance presented a Sensitivity of 62.5%, Precision of 81.2% and Harmonic Mean of 68.4%.

(6)
(7)

Resumo

A diminuição da natalidade e o aumento da esperança média de vida, fizeram surgir um fenómeno único de envelhecimento no nosso mundo. Por outro lado, as tecnologias móveis tornaram-se um bem essencial do dia a dia, sofrendo uma evolução tremenda nos últimos anos no que diz respeito às suas funcionalidades e consequentes aplicabilidades. Como resultado disso, estes tomaram também um importante papel no que diz respeito aos serviços de saúde.

A insuficiência cardíaca é uma condição médica obervada principalmente nos mais idosos, e é responsável por milhões de mortes todos os anos. Um dos principais sintomas da insufi-ciência cardíaca é a congestão pulmonar, caracterizada pela acumulação de fluidos nos pulmões, frequentemente detetada em examinação física por auscultação pulmonar. Crepitações são ruí-dos característicos desse mesmo sintoma, que podem estar presentes em ambos ou em apenas um pulmão, mais perceptíveis durante a inspiração.

Esta condição médica pode ser atenuada quando diagnosticada numa fase inicial, e é aí que este projeto se concentra. Este, pretende ser uma evolução de uma solução existente, que faz parte de uma aplicação de monitorização remota de saúde. Um smartphone Android e um estoscópio electrónico de custo reduzido é o necessário.

Dois problemas são encontrados ao lidar com a solução anterior. Em primeiro lugar, as aus-cultações recolhidas com este método, mostraram uma quantidade significativa de ruído, o qual influencia diretamente o segundo problema: o método automático para deteção de crepitações, pois para maximizar a eficiência desta segunda parte, a primeira deve ser o mais eficiente possível. De forma a resolver estes problemas, o cancelamento de ruído é então uma necessidade numa fase de pré-processamento das auscultações, antes de submeter estas ao algoritmo de deteção de crepitações. A primeira abordagem ao problema revelou-se infrutífera, e consistia na aplicação de um filtro diferenciador seguido do método de convolução. Uma nova solução era necessária, e surgiu através da possibilidade de conectar um segundo microfone, usando o primeiro smart-phone que permite gravação estéreo a partir da entrada jack. Tornou-se então possível a aplicação de filtragem adaptativa de forma a efetuar um cancelamento de ruído mais eficiente no contexto descrito.

No que diz respeito aos métodos para deteção de crepitação, um algoritmo foi implementado e validado com sucesso, assim como uma versão alternativa criada de forma a ter uma base mais sólida de teste para a solução apresentada.

Uma simulação foi efetuada de forma a verificar a eficiência da solução proposta. Para o primeiro algoritmo, as auscultações "ruidosas" apresentaram uma Sensibilidade de 36.6%, Pre-cisão de 34.5% e Média Harmónica de 33.6%, enquanto que os sinais filtrados que revelaram melhor desempenho apresentaram uma Sensibilidade de 63.2%, Precisão de 70.5% e Média Har-mónica de 64.9%. Quanto ao segundo algoritmo, as auscultações "ruidosas" apresentaram uma Sensibilidade de 21.0%, Precisão de 33.2% e Média Harmónica de 23.5%, enquanto que os sinais filtrados que revelaram melhor desempenho apresentaram uma Sensibilidade de 62.5%, Precisão de 81.2% e Média Harmónica de 68.4%.

(8)
(9)

Acknowledgements

My special thanks to both my supervisors Aníbal Ferreira and Ricardo Lagido for giving me crucial guidance and their time. I want also to thank Fraunhofer Portugal AICOS for giving me the opportunity and conditions to work in this noble project. And finally, I want to thank everyone that was around me through these last years, specially my family, friends and girlfriend.

(10)
(11)

“Science and technology multiply around us. To an increasing extent they dictate the languages in which we speak and think. Either we use those languages, or we remain mute”

(12)
(13)

Contents

1 Introduction 1 1.1 Context . . . 2 1.2 Motivation . . . 2 1.3 Goals . . . 3 1.4 Document Structure . . . 3

2 State of the Art 5 2.1 Crackles Detection . . . 5

2.1.1 Phone-based Heart and Lung Functions Monitor . . . 5

2.1.2 Automatic Methods for crackles detection . . . 6

2.1.3 Crackles Detection Using a Time-Variant Autoregressive Model . . . 7

2.2 Signal processing . . . 7

2.2.1 ThinkLabs One . . . 8

2.2.2 StethoCloud . . . 8

2.2.3 A New Digital Stethoscope with Environmental Noise Cancellation . . . 9

2.2.4 A New Method of Lung Sounds Filtering using Modulated Least Mean Square - Adaptive Noise Cancellation . . . 10

2.3 Technologies . . . 11

2.3.1 MATLAB . . . 11

2.3.2 Python . . . 11

2.3.3 Android . . . 12

2.4 Conclusions . . . 13

3 Crackles and Noise Analysis 15 3.1 Respiratory sounds . . . 15 3.1.1 Crackles Characterization . . . 15 3.2 Signal Analysis . . . 18 3.2.1 Crackles . . . 18 3.2.2 Noise . . . 19 3.3 Conclusions . . . 20 4 Crackles Detection 21 4.1 Repository . . . 21

4.1.1 Samples Collection with electronic stethoscope . . . 21

4.1.2 Data samples - repository . . . 22

4.1.3 Annotations . . . 22

4.1.4 Performance Evaluation . . . 23

(14)

CONTENTS

4.2.1 Vannuccini et al. . . 24

4.2.2 Vannuccini et al. Alternative Version . . . 32

4.2.3 Fractal Dimension Algorithm . . . 36

4.3 Conclusions . . . 40 5 Preprocessing Techniques 41 5.1 Differentiator Filter . . . 41 5.2 Convolution Method . . . 44 5.3 Preliminary Tests . . . 46 5.3.1 Vannuccini et al. . . 47

5.3.2 Vannuccini et al. Alternative Version . . . 47

5.4 Conclusions . . . 48

6 Adaptive Noise Cancellation 49 6.1 Proposed Solution . . . 49

6.2 Android DoubleMic Application . . . 52

6.3 Adaptive Filtering - Least Mean Squares . . . 53

6.4 Tests . . . 56

6.4.1 Testing Procedure . . . 56

6.4.2 Vannuccini et al. . . 58

6.4.3 Vannuccini et al. Alternative Version . . . 60

6.5 Conclusions . . . 62

7 Conclusions and Future work 63 7.1 State of the project . . . 63

7.2 Future work . . . 64

(15)

List of Figures

1.1 Aged 60 or over. . . 2

2.1 Electronic Stethoscope. . . 6

2.2 One Digital Stethoscope . . . 8

2.3 StethoCloud . . . 9

2.4 Stethoscope head equipped with two microphones . . . 10

2.5 Comparison between inner microphone and filtered signals . . . 10

2.6 Android Architecture . . . 13

3.1 Fine and Coarse Crackles . . . 17

3.2 Time and frequency analysis . . . 18

3.3 Crackle example (starting approximately at 0.865s) . . . 18

3.4 Example of crackles which are characterized by abrupt changes in the signal . . . 19

4.1 Eletronic stethoscope connected to the Samsung Galaxy Nexus . . . 21

4.2 Annotations of the first group of respiratory sounds ([Qui11]) . . . 22

4.3 Annotations of the second group of respiratory sounds . . . 23

4.4 Block diagram of the algorithm implemented by Vannuccini et al. . . 25

4.5 Representation of the FDAV and signal of a sample, the intervals involved in the method and the T and Tw thresholds ([LVP98]) . . . 26

4.6 Sensitivity performance for thresholds in the range [1.5 ; 5.5] . . . 28

4.7 Precision performance for thresholds in the range [1.5 ; 5.5] . . . 29

4.8 Harmonic Mean performance for thresholds in the range [1.5 ; 5.5] . . . 29

4.9 Sensitivity performance for thresholds in the range [2 ; 4.5] . . . 30

4.10 Precision performance for thresholds in the range [2 ; 4.5] . . . 30

4.11 Harmonic Mean performance for thresholds in the range [2 ; 4.5] . . . 31

4.12 Sensitivity performance for thresholds in the range [1.5 ; 5] . . . 33

4.13 Precision performance for thresholds in the range [1.5 ; 5] . . . 33

4.14 Harmonic Mean performance for thresholds in the range [1.5 ; 5] . . . 34

4.15 Sensitivity performance for thresholds in the range [1.25 ; 3.5] . . . 34

4.16 Precision performance for thresholds in the range [1.25 ; 3.5] . . . 35

4.17 Harmonic Mean performance for thresholds in the range [1.25 ; 3.5] . . . 35

4.18 Block diagram of the Fractal Dimension algorithm. . . 37

4.19 Peak Peeling Algorithm (FD-PPA) flow diagram [Had05]. . . 39

5.1 The relationship between the f and a vectors in defining a desired frequency re-sponse13 . . . 42

(16)

LIST OF FIGURES

5.3 Spectrogram of a region of the signal containing crackles, before and after

apply-ing filterapply-ing. . . 44

5.4 Time waveform of a region of the signal containing crackles, before and after applying filtering (arrows pointing to regions where crackles begin). . . 44

5.5 Crackle prototype. . . 45

5.6 Sample before convolution (arrows pointing to regions where crackles begin). . . 46

5.7 Sample after convolution (arrows pointing to regions where crackles begin). . . . 46

6.1 Audio Jack Conventions . . . 50

6.2 Sony Xperia Z2 5 pole connector . . . 50

6.3 Adapter schematics . . . 51

6.4 Adapter built. . . 52

6.5 Android application prints. . . 52

6.6 Adapted stethoscope connected to the Sony Xperia Z2 . . . 53

6.7 Adaptive Noise Cancellation . . . 53

6.8 Convergence for a filter length of 512. . . 55

6.9 Convergence for a filter length of 128. . . 55

6.10 Case 1. . . 56

6.11 Case 2. . . 57

6.12 Case 3, first phase. . . 57

6.13 Case 3, second phase. . . 57

6.14 Case 4. . . 58

6.15 Case 5. . . 58

6.16 Vannuccini et al. - Performance evaluation for a filter length of 512. . . 59

6.17 Vannuccini et al. - Performance evaluation for a filter length of 128. . . 60

6.18 Vannuccini et al. Alternative Version - Performance evaluation for a filter length of 512. . . 61

6.19 Vannuccini et al. Alternative Version - Performance evaluation for a filter length of 128. . . 61

(17)

List of Tables

3.1 Clinical Characteristics and Correlations of Respiratory Sounds ([ABSSK14]) . . 16

4.1 Respiratory Sounds for the preliminary test . . . 28

4.2 Results for optimal threshold . . . 31

4.3 Results for optimal threshold . . . 32

4.4 Results for optimal threshold . . . 36

4.5 Results for optimal threshold . . . 36

5.1 Raw respiratory Sounds . . . 47

5.2 Respiratory Sounds after applying the differentiator filter . . . 47

5.3 Respiratory Sounds after applying the differentiator filter and the convolution method 47 5.4 Raw respiratory Sounds . . . 48

5.5 Respiratory Sounds after applying the differentiator filter . . . 48

5.6 Respiratory Sounds after applying the differentiator filter and the convolution method 48 6.1 Respiratory sounds chosen for the simulation. . . 56

(18)
(19)

Acronyms

F Harmonic Mean

FD Fractal Dimension

FDPPA Fractal Dimension Peak Peeling Algorithm FDAV First Derivative Absolute Value

FhP AICOS Fraunhofer Portugal Research Center for Assistive Information and Commu-nication Solutions

FIR Finite Impulse Response FP False Positives

HCP Health Care Professional

HS Heart Sounds

LS Lung Sounds

PPV Precision or Positive Predictive Value PSD Power Spectral Density

SE Sensitivity SG Savitsky-Golay SP Specificity

RS Respiratory Sound TP True Positives

TVAR Time-Variant Autoregressive Model VM Virtual Machine

(20)
(21)

Chapter 1

Introduction

Population ageing is a demographic revolution affecting the entire world, mostly due to the de-crease of the birth rate. According to a United Nations study1, the population has decreased world-wide from 37.2 in 1950-1955 to 20.3 in 2005-2010 (births per 1,000 total population). Nowadays, millions of people in the world suffer from respiratory diseases, being the elderly, the most affected ( [RD10]). Figure1.1shows the number of people aged over 60 in the world, and considering de-veloped and developing countries, 1950-2050. This figure predicts an increase of over one and a half million people in this age group within 100 years2.

At the same time, mobile phones have gain extreme importance day after day in people’s lives, with no group age limit3, and are in a constant and incredible technological advance.

Those developments in the smartphones features started to raise interest from the health per-spective.

“The progresses in the technologies provided by mobile devices, its portability and ease of use along with the falling of prices, make these devices an appropriate tool for health care purposes. More and more, m-technology is being used in the health care field.” [GL07]

Also, as these devices get more and more accurate, it is possible to think they can be an effective assistant tool for health professionals.

In short, it is believed that mobile phones can play a crucial part in health care, by monitoring people’s medical status with due consistency, anywhere, anytime, with the use of features built in the device, which are increasing in quantity and quality. This dissertation project is included in this line of thinking.

1United Nations data: Historical and predicted crude birth rates, <http://data.un.org/Data.aspx?q= world+population&d=PopDiv&f=variableID%3A53%3BcrID%3A900> (accessed on Sep 4th, 2014)

2United Nations Population Fund: Population Ageing: A Celebration and a Challenge, <http://www.unfpa. org/pds/ageing.html> (accessed on Jun 20th, 2014)

3PewResearch Internet Project: Mobile technology Fact Sheet, <http://www.pewinternet.org/ fact-sheets/mobile-technology-fact-sheet/> (accessed on Sep 4th, 2014)

(22)

Introduction

Figure 1.1: Aged 60 or over.

1.1

Context

This dissertation project was developed in association with Fraunhofer Portugal Research Center for Assistive Information and Communication Solutions (FhP AICOS). This research center, aims to create scientific knowledge in order to build practical utilities to its customers and partners, from the exploration of technological innovations oriented to economic growth, social well-being and improving the quality of life of its end-users.

These end-users are mostly elderly, which makes user-friendly solutions, a crucial issue for those who create products for this population, and FhP is one of them. FhP promotes and co-ordinates the cooperation between its research centers, other research institutions and industrial partners, with the aim to apply their research with direct use to private and public companies, yielding benefits for society as a whole.

1.2

Motivation

The stethoscope is a medical tool that has been used for almost two centuries now, and can be used to listen to heart and lung sounds. This project focuses on crackles detection, an adventitious lung sound, which is a symptom that indicates the presence of fluid in the lungs. An electronic stethoscope connected to the smartphone is used to perform the lung auscultation. This method suffers from distortions due to external noise, which has to be cancelled before running the crackles detection method. With that being said, the reasons that motivated me to the development of this work are:

(23)

Introduction

• The possibility to give a new usage to a tool that has been used for almost two centuries, and that is fundamental to medicine, which is the stethoscope, by connecting it to the smartphone to perform lung auscultation;

• Applying noise cancellation, which is a technique that has been used for years now in the most diverse areas (headphones4, microphones5, car interior6);

• Prevent serious illnesses by early diagnosis. The frequent auscultation (either by the pa-tient or by any caregiver) allows the physicians to easily monitor the papa-tients, without much effort. In this particular case, if the crackles appear, they may be revealed in these ausculta-tions, which may allow a quick intervention to prevent health problems;

• Be an efficient assistant tool for health care professionals.

All of these reasons unite for a common purpose: improve the quality of life for the elderly.

1.3

Goals

This work may be divided in three parts: firstly, noise cancellation in the described context, where noise suppression techniques are applied in order to prepare the signal corresponding to the aus-cultation for the second part: the automatic crackles detection. The end goal of this project is to develop an Android application that processes the signal of an auscultation with techniques based on the knowledge acquired, giving the patient’s doctor an estimation of the presence of crackles. This application could be applied in the context of a remote monitoring system, where a certain patient can easily be auscultated, anywhere, and where this data becomes automatically available to his physician.

1.4

Document Structure

In addition to the introduction, this document contains 6 more chapters. Chapter2describes the state of the art, that involves the theoretical background and technologies related to this dissertation project. In chapter3, pulmonary sounds are described, as well as signal analysis regarding crackles and noise. In chapter4, the algorithms for automatic crackles detection are presented, as well as the repository of samples collected.

Chapter5describes the first approach to the problem, using preprocessing techniques with the corresponding preliminary results. Chapter6, approaches the final solution to the problem: adap-tive noise cancellation by the means of two microphones, also presenting the Android application implemented and the final results.

4Sony: Digital Noise Cancelling Headset, <http://www.sonymobile.com/global-en/products/ accessories/digital-noise-cancelling-headset-mdr-nc31em/> (accessed on Sep 4th, 2014)

5Sony: Stereo Microphone, <www.sonymobile.com/microphone-stm10> (accessed on Sep 4th, 2014) 6Bose: Active Sound Management Technology, <http://www.bose.com/controller?url= /automotive/innovations/asm.jsp> (accessed on Sep 3th, 2014)

(24)

Introduction

(25)

Chapter 2

State of the Art

In 1816, Rané Laennec [RTH19] invented the instrument that revolutionized auscultation, the stethoscope. Almost two centuries later, and after technological advances like magnetic resonance and ultrasonography, which can detect lung disease with accuracy, modern computer-assisted tech-niques have also allowed precise recording and analysis of lung sounds, prompting the correlation of acoustic indexes with measures of lung mechanics.

In this chapter, information will be given about the investigation and a few already commer-cialized solutions related with this project goals. The technologies used in the dissertation project are also presented, as well as some brief conclusions at the end of the chapter.

2.1

Crackles Detection

As an introduction to this project, some context is needed about the project with the purpose to explain the emergence of the idea associated with it, and give some background on the automatic crackles detection investigations.

2.1.1 Phone-based Heart and Lung Functions Monitor

The SmartNS dissertation project came in as a response to a problem faced in a previous thesis developed in FhP AICOS, by João Silva [Sil11]: "Phone-based Heart and Lung Functions Mon-itor", whose main target was to build an Android application that would provide people a way of monitoring their heart and lung functions everyday, taking greater care on their health status. It would allow people to perform daily tests and build a history of results which would then be shared with health care professionals.

This application used an electronic stethoscope that is connected to the smartphone, that was used to help recording heart and lung sounds from the patient, for further analysis. The problem is that early results with this approach revealed a large amount of noise in the audio files obtained through auscultation. This issue motivated the need for applying noise suppression techniques in

(26)

State of the Art

order to obtain a clearer signal of the auscultation, which is exactly one of the two purposes of the SmartNS project.

To collect the lung sounds (auscultations), an electronic stethoscope was used which is illus-trated in Figure2.1. This particular instrument was built using a conventional stethoscope, which was cut in the pipe, and then a microphone was plugged in that same area.

The stethoscope is an MDF MD One Stainless Steel Dual-Head Stethoscope7, and is dis-tinguished by its chestpiece, acoustic tubing, Acoustic Pyramid Chamber R and ErgonoMax R

Headset.

As for the microphone, its main characteristic are: • MicW i436 professional microphone;

• Type: Electret Condenser;

• Frequency Response: 20Hz-20kHz; • Signal to Noise Ratio: 62dB; • Sensitivity: 5.8 mV/Pa

Figure 2.1: Electronic Stethoscope.

2.1.2 Automatic Methods for crackles detection

The dissertation project developed by João Quintas ( [Qui11]) explores automatic methods for crackle detection. It describes and discusses the MatLab implementation of four algorithms that were proposed. The first, by Vannuccini et al. ([LVP98]), involves the application of Savitzky Golay filters. The second, by Hadjileontiadis and Rekanos ([HR03]), is based on the Fractal Dimension (FD) function. The third is an alternative version of the previous one, replacing the Katz algorithm by the Sevcik algorithm ([Sev10]) for calculating the FD corresponding to the

7MDF: MDF MD One, <http://mdfinstruments.com/index.php/

mdf-md-one-stainless-steel-premium-dual-head-stethoscope.html?___store=english_ demo> (accessed on May 21th, 2014)

(27)

State of the Art

waveform. The last one proposed, by Bahoura and Lu, is based on Wavelet packet-based stationary and non stationary filters ([LB08]) (implemented with a few adaptations).

Performance evaluation was based on a repository of 10 respiratory sounds (5 from patients with cystic fibrosis and 5 from patients with pneumonia) duly annotated by three health care pro-fessionals. By agreement among their annotations, references were generated to calculate the values of sensitivity, accuracy as well as the harmonic mean for the various algorithms

The useful threshold ranges of the four algorithms were empirically established and a set of 10 evenly spaced thresholds were defined for each. The top performance thresholds yielded a maximum value of sensitivity of 87.5% for the first algorithm, 91.4% for the second, 91.5% for the third and 89.6% for the fourth algorithm.

At the point of optimal performance, a sensitivity of 91.4% and accuracy of 83.7% were ob-tained. The harmonic mean reached 86.7%, surpassing by 7% the top performance achieved with individual algorithms.

2.1.3 Crackles Detection Using a Time-Variant Autoregressive Model

The purpose of the work carried out by Dorantes-Méndez et al. ([GDM08]) was to explore the ability of the time-variant autoregressive (TVAR) model to detect and to provide an estimate num-ber of fine and coarse crackles in lung sounds. Thus, simulated crackles inserted in normal lung sounds and real lung sounds containing adventitious sounds were processed with TVAR and by an expert that based crackles detection on time-expanded waveform-analysis. The coefficients of the TVAR were obtained by an adaptive filtering prediction scheme. The adaptive filter used the recursive least squares algorithm with a forgetting factor of 0.97 and the model order was four.

The TVAR model presented an efficiency to detect crackles over 90% even with crackles overlapping and amplitudes as low as 1.5 of the standard deviation of background lung sounds, where expert presented an efficiency around 30%.

The author states that the TVAR model is a proper alternative to detect and to provide an esti-mate number of fine and coarse crackles, even in the presence of overlapping crackles and crackles with low amplitude, which are conditions where crackles detection based on time-expanded wave-form analysis reveals evident limitations.

2.2

Signal processing

In the last years, several research was made in the field of auscultation that is considered rele-vant for this dissertation project, from already commercialized digital stethoscopes to researches focusing on noise cancellation. In the next subsections the most important ones are highlighted.

(28)

State of the Art

2.2.1 ThinkLabs One

One1is a powerful digital stethoscope that performs both cardiac and pulmonary auscultation. It has multiple filter choices, to cover all the range of sounds, from low to high pitched. The user may also change the frequency response by applying more or less pressure on the diaphragm.

The constructors claim that the system is capable of efficient ambient noise cancellation and signal amplification. It’s a small device with easy usability (Figure2.2), and that needs appropriate headphones to take full advantage of the system.

Figure 2.2: One Digital Stethoscope

2.2.2 StethoCloud

Dr. Andrew Lin and Dr. Hon Weng Chong, founders of StethoCloud8, have designed and built a low cost electronic stethoscope that can be used by parents of child patients and doctors alike. The device is easy enough for a parent to use at home and cheap enough so that a doctor can use it in the developing world to diagnose diseases like pneumonia. The Company started from a winning entry into the 2012 Microsoft Australian Imagine Cup – a student technology competition.

The system comprises an app and a stethoscope embedded with a microphone that connects to a cell phone (Figure 2.3), allowing users to record breath sounds and upload them to a cloud service for remote diagnosis.

Currently, the app runs through a quick checklist, including how long the child has exhibited symptoms. The user is then instructed to check for two types of abnormal breathing, which are demonstrated by video, and the user records the child’s breathing for five seconds at each of six different points on the back.

(29)

State of the Art

According to the official website, the project’s developers are currently working on building new solutions, and no update is given since 2012.

Figure 2.3: StethoCloud

2.2.3 A New Digital Stethoscope with Environmental Noise Cancellation

Belloni et al. describe in their paper [FB11] a medical instrument for acquisition and analysis of phono-cardiac signals. The proposed system is based on an electronic stethoscope with enhanced performances in environmental noise cancellation, achieved by means of two microphones whose signals are combined by an adaptive algorithm.

A software tool able to reproduce, visualize and analyze cardiac sounds completes the system. The approach proposed in the paper uses a stethoscope head equipped with two small pipes. While the first pipe is directly connected to the stethoscope head, the latter is put just beside, as shown in Figure2.4. A microphone is placed inside of each pipe. The inner microphone captures the sound from the inside of the head, i.e., both the heart beat and the noise. On the other hand, the outer microphone detects the noise only, due to the very low level of the cardiac signal. The pipes have the same length and are placed close enough so that the spatial dependencies of the sound waves are negligible in the frequency range of interest.

The filtered signal could not be easily yielded through a direct subtraction because the two transducers do not sense the noise in the same way, so, an adaptive approach was adopted (Least Mean Square algorithm). Figure2.5shows the difference between the inner microphone and the filtered signals.

8StethoCloud: StethoCloud Official WebSite, <http://www.stethocloud.com/> (accessed on Jun 19th,

(30)

State of the Art

Figure 2.4: Stethoscope head equipped with two microphones

Figure 2.5: Comparison between inner microphone and filtered signals

2.2.4 A New Method of Lung Sounds Filtering using Modulated Least Mean Square - Adaptive Noise Cancellation

This paper [AN13] proposes a new method of lung sounds (LS) filtering which separates heart sounds (HS) and low frequency noise from instruments (NI) simultaneously. It focuses on the ap-plication of least mean squares (LMS) algorithm with adaptive noise cancelling (ANC) technique. The second step of this method is to modulate the reference input of LMS-ANC to combine HS

(31)

State of the Art

and NI signals. The obtained signal is removed from primary signal (original LS recording). The original signal is recorded from subjects and the HS signal is derived from it and it is modified by a band pass filter. NI is simulated by generating approximately periodic white gaussian noise (WGN) signal. The LMS-ANC designed algorithm is controlled in order to determine the opti-mum values of the order L and the coefficient convergence µ.

An effective technique for simultaneous heart sound and noise reduction from lung sounds recordings, while preserving LS characteristics is claimed by the author, by showing and analyzing the performance through the Power Spectral Density (PSD). The authors show that the PSD of LS before filtering contains more frequencies which can not be differentiated. The PSD after filtering demonstrates different components of frequency. This explains that the HS frequency and NI have been removed successfully from LS.

Several other related works were found regarding adaptive noise cancellation ([Gni03] [HL97] [PUK11]), and to understand its behaviour more precisely, the project developed by Aarti Singh [Sin97] was an important reference.

2.3

Technologies

In this section, the tools required for the research and development of this project are described.

2.3.1 MATLAB

MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment and fourth-generation programming language. Developed by MathWorks, MATLAB allows matrix manipu-lations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages, including C, C++ and Java.

MathWorks signal processing products provide extensive tools and algorithm libraries allow-ing to analyze, design, and simulate Digital Signal Processallow-ing systems in a fraction of the time it takes with traditional programming languages.

2.3.2 Python

Python is a high-level programming language conceived in the late 1980s, and its implementation was started in 1989. Van Rossum is Python’s principal author.

It is a multi-paradigm programming language, where object-oriented programming and struc-tured programming are fully supported. Python uses dynamic typing and a combination of ref-erence counting and a cycle-detecting garbage collector for memory management. An important feature of Python is dynamic name resolution, which binds method and variable names during program execution.

Some of the distinguishing features are: • Very clear, readable syntax;

(32)

State of the Art

• Strong introspection capabilities; • Intuitive object orientation;

• Natural expression of procedural code;

• Full modularity, supporting hierarchical packages; • Exception-based error handling;

• Very high level dynamic data types;

• Extensive standard libraries and third party modules for virtually every task; • Extensions and modules easily written in C, C++, Java;

• Embeddable within applications as a scripting interface.

2.3.3 Android

Android is an open-source, Linux-based operating system built for smartphones, that was initially developed by Android Inc., a company later purchased by Google (2005). Then, in 2007, a group of industry leaders, including HTC, Dell, Intel, Motorola, Samsung and others, formed the Open Handset Alliance in order to create open patterns for the Android platform.

The Android operating system is structured in several layers, as shown in Figure2.6. It relies on the Linux kernel, acting as an abstraction layer between the hardware and the software. The core system services like security, network stack, driver model, memory and process management, are provided by this layer.

In the Android Runtime layer, there is the virtual machine, Dalvik VM, and a set of libraries providing most of the features of the Java programming language. A single process is executed by each Android application, each of them on top of Dalvik VM. This one, runs on top of the Linux Kernel and was designed so that it is able to run several virtual machines at the same time. The libraries section represents a set of C/C++ features used by components of the Android system.

The Application Framework layer simplifies the use and reuse of components, by giving the developer full access to the same framework APIs used by the core applications. This layer is the basis for building the rich applications available to the end-use, from every installable application to the browser or the contacts.

The core set of applications that include an e-mail client, calendar, maps, browser and contact manager, are part of the top layer, the Applications layer. This operating system is in constant technological evolution and, therefore, many versions have been released since the beginning of this project. When it comes to develop an Android application these aspects must be taken to account, because creating it for the most recent platform could restrict it to devices owned by just a small share of the market. The latest version is the Android 4.4 KitKat.

(33)

State of the Art

Figure 2.6: Android Architecture

2.4

Conclusions

Regarding automatic crackles detection methods, and considering specifically the project pre-sented in section 2.1.2, although this project presents great results of sensitivity (91.4%) and accuracy (83.7%), there is one important fact: the samples from the repository used to test the algorithms are almost perfect when it comes to absence of noise, which makes the crackles detec-tion less prone to errors. Despite that, this work was extremely important to validate our methods, by implementing some of the algorithms discussed by the author, that would serve as a way to validate the noise cancellation techniques.

As for noise reduction techniques, it was concluded that there are static filtering techniques that may reduce a significant amount of the noise ([Qui11]), and that adaptive filtering is an ef-fective method when the possibility exists to obtain two input signals simultaneously, as seen in sections2.2.3and2.2.4.

(34)
(35)

Chapter 3

Crackles and Noise Analysis

This chapter will start with a brief characterization of different kinds of respiratory sounds: nor-mal and adventitious breath sounds, according to the paper "Fundamentals of Lung Ausculta-tion" [ABSSK14], followed by a more detailed characterization of crackles.

In section 3.2, a behaviour analysis of noise and crackles are presented, based on the first samples collected by physicians using a smartphone and the electronic stethoscope.

3.1

Respiratory sounds

Respiratory sounds refer to the specific sounds generated by the movement of air through the respiratory system, and may be identified through pulmonary auscultation, using a stethoscope. They are subdivided in two groups, the normal breath sounds, which includes normal tracheal sounds, normal lung sounds and bronchial breathing. The second group involves breath sounds, which include stridors, wheezes, rhonchus, crackles, pleural friction rubs and squawks. Table3.1

summarizes the clinical characteristics of all these respiratory sounds. 3.1.1 Crackles Characterization

Crackles are short, explosive, non musical sounds heard on inspiration and sometimes during ex-piration. There are two types of crackles: fine and coarse crackles (Figure3.1). On auscultation, fine crackles are usually heard during mid-to-late inspiration, are well perceived in dependent lung regions, and are not transmitted to the mouth. Uninfluenced by cough, fine crackles are altered by gravity, changing or disappearing with changes in body position (e.g., bending forward). On the other hand, coarse crackles tend to appear early during inspiration and throughout expiration and have a "popping" quality. They may be heard over any lung region, are usually transmitted to the mouth, can change or disappear with coughing, and are not influenced by changes in body position. In a superficial sound analysis, crackles appear as rapidly dampened wave deflections

(36)

Crackles and Noise Analysis

Table 3.1: Clinical Characteristics and Correlations of Respiratory Sounds ([ABSSK14]) Respiratory

Sound

Clinical Characteristics Clinical Correlation Normal

tra-cheal sound

Hollow and nonmusical, clearly heard in both phases of respira-tory cycle

Transports intrapulmonary sounds, indicating upperairway pa-tency; can be disturbed (e.g., become more noisy or even musical) if upper-airway patency is altered; used to monitor sleep apnea; serves as a good model of bronchial breathing

Normal lung sound

Soft, nonmusical, heard only on inspiration and on early expira-tion

Is diminished by factors affecting sound generation (e.g., hy-poventilation, airway narrowing) or sound transmission (e.g., lung destruction, pleural effusion, pneumothorax); assessed as an aggregate score with normal breath sound; rules out clinically sig-nificant airway obstruction

Bronchial breathing

Soft, nonmusical, heard on both phases of respiratory cycle (mimics tracheal sound)

Indicates patent airway surrounded by consolidated lung tissue (e.g., pneumonia) or fibrosis

Stridor Musical, high-pitched, may be heard over the upper airways or at a distance without a stetho-scope

Indicates upper-airway obstruction; associated with extrathoracic lesions when heard on inspiration; associated with intrathoracic lesions when heard on expiration; associated with fixed lesions (e.g., croup, paralysis of both vocal cords, laryngeal mass or web) when biphasic

Wheeze Musical, high-pitched; heard on inspiration, expiration, or both

Suggests airway narrowing or blockage when localized (e.g., for-eign body, tumor); associated with generalized airway narrowing and airflow limitation when widespread; degree of airflow limita-tion proporlimita-tional to number of airways generating wheezes; may be absent if airflow is too low

Rhonchus Musical, low-pitched, similar to snoring; lower in pitch than wheeze; may be heard on inspi-ration, expiinspi-ration, or both

Associated with rupture of fluid films and abnormal airway col-lapsibility; often clears with coughing, suggesting a role for se-cretions in larger airways; is nonspecific; is common with airway narrowing caused by mucosal thickening or edema or by bron-chospasm

Fine crackle Nonmusical, short, explosive; heard on mid-to-late inspiration and occasionally on expiration; unaffected by cough, gravity-dependent, not transmitted to mouth

Unrelated to secretions; associated with various diseases (e.g., interstitial lung fibrosis, congestive heart failure, pneumonia); can be earliest sign of disease; may be present before detection of changes on radiology

Coarse crackle

Nonmusical, short, explosive sounds; heard on early inspira-tion and throughout expirainspira-tion; affected by cough; transmitted to mouth

Indicates intermittent airway opening, may be related to secre-tions (e.g., in chronic bronchitis)

Pleural fric-tion rub

Nonmusical, explosive, usually biphasic sounds; typically heard over basal regions

Associated with pleural inflammation or pleural tumors

Squawk Mixed sound with short musi-cal component (short wheeze) accompanied or preceded by crackles

Associated with conditions affecting distal airways; may suggest hypersensitivity pneumonia or other types of interstitial lung dis-ease in patients who are not acutely ill; may indicate pneumonia in patients who are acutely ill

(37)

Crackles and Noise Analysis

with a repetitive pattern. As compared with coarse crackles, fine crackles have a shorter dura-tion and higher frequency. The most likely mechanism for the generadura-tion of fine crackles is the sudden inspiratory opening of small airways held closed by surface forces during the previous expiration [VA09].

The search for crackles is important because it can help with the differential diagnosis. Typ-ically, fine crackles are prominent in idiopathic pulmonary fibrosis, appearing first in the basal areas of the lungs and progressing to the upper zones with disease progression [CV12]. Fine crackles are also associated to other interstitial diseases, such as asbestosis, nonspecific interstitial pneumonitis, and interstitial fibrosis associated with connective-tissue disorders.

Coarse crackles are commonly heard in patients with obstructive lung diseases, including Chronic Obstructive Pulmonary Diseases, bronchiectasis, and asthma, usually in association with wheezes. They are also often heard in patients with pneumonia and those with congestive heart failure.

Sometimes crackles can be heard in healthy persons, but those tend to disappear after a few deep breaths. The presence of persistent crackles in both lungs in older persons with dyspnea should prompt an investigation for interstitial lung disease. [ABSSK14]

Regarding the crackles frequency range, there is no agreement in the papers of the literature review. In [ABSSK14], a typical frequency of fine crackles is defined as 650 Hz, and 350 Hz for coarse crackles. In [SR08] it is stated that the frequency range of crackles is between 100 and 200 Hz. In the dissertation project [Qui11] it is said that the crackles frequency range varies from 100 to 2000 Hz, and according to [ARASE00] the frequency may reach higher values.

(38)

Crackles and Noise Analysis

3.2

Signal Analysis

An important phase of this dissertation project consisted in a thorough signal analysis of the aus-cultations that were collected by the physicians, some of them with minimum noise and no pres-ence of crackles, and others containing noise and crackles.

These signals were analyzed in time and frequency domain (Figure3.2).

Figure 3.2: Time and frequency analysis

3.2.1 Crackles

Figure 3.1 shows the signal behavior of "perfect" crackles, but in practice, it is not as simple as it looks like. Due to the way the auscultations are captured and recorded (electronic Stetho-scope connected to an Android smartphone), the signal suffers undesirable distortions that make its processing harder. These distortions make it impossible for a common algorithm of crackles detection to have good results, because they accuse lots of false positives and exclude real crack-les. Figure3.3shows the behavior in time domain of a crackle with low distortion, from one of the auscultations analyzed.

(39)

Crackles and Noise Analysis

From the observation of those signals, when it comes to the behavior of crackles, the following conclusions were reached:

• Crackles appear more often in the inspiratory than the expiratory phase. In the inspiratory phase it is easily recognizable because crackles appear in group, on the other hand, in the expiratory phase, crackles appear isolated from each other.

• Crackles have a particular characteristic that is common to all of them, and that is the abrupt initial change in the signal, as it is possible to confirm in Figure3.4that shows that same behavior in several crackles.

• Through power spectrum analysis, it is possible to conclude that each crackle corresponds to an impulse that is easily observed. (Figure3.2).

• A detailed noise analysis was required as well as a suitable signal pre-processing strategy preventing the crackles detection algorithm from performing poorly, e.g. avoiding false positives.

Figure 3.4: Example of crackles which are characterized by abrupt changes in the signal

3.2.2 Noise

Regarding noise analysis, there were some questions that required an answer so that it would be possible to build the most appropriate solution.

What are the causes of the noise? Does it all come from the same source? If it’s just ambient noise (e.g., people talking)? is it viable to adapt the stethoscope? Add an extra microphone to capture just the ambient noise, and use an adaptive noise cancellation algorithm (e.g. Least Mean Square) to remove it from the original signal?

(40)

Crackles and Noise Analysis

• A large amount of the noise came from ambient causes, for example, objects moving and people talking.

• Also, some noise came from the friction between the stethoscope membrane and the skin. That phenomenon can be explained in a simple manner: during inspiration, the area of skin that is in direct contact with the membrane is larger than it is during expiration, and the noise comes exactly from that transition.

• No organ or muscle sounds were considered significant.

• The quality of the hardware built in the smartphones responsible for the signal processing until it reaches the digital format influences the quality of the collected sample.

• Once the major cause for signal distortion is an ambient factor, the possibility to adapt the stethoscope with an extra microphone was not excluded.

In order to validate the assumptions defined previously, some tests were made with the elec-tronic stethoscope. After all, no noise was coming from the friction between the stethoscope membrane and the skin. As a matter of fact, that noise was actually coming from the friction between the fingers that hold the stethoscope’s head. The minimum slip of a finger, creates a significant distortion in the signal.

3.3

Conclusions

The noise analysis led to the following conclusions: adapting the stethoscope with another mi-crophone in order to perform noise cancellation seemed the most appropriate solution, but, one problem appeared. The smartphones standard jack only admits one input. So, the option of adapt-ing the stethoscope was set aside, leavadapt-ing just one possible approach to solvadapt-ing the problem: the use of preprocessing techniques to perform noise cancellation.

(41)

Chapter 4

Crackles Detection

This chapter is divided in two sections. The first one addresses the repository characterization and presentation of the statistical measures used to assess the crackles detection algorithms. The second section addresses automatic methods for crackles detection, where implementation details and corresponding performance results are presented.

4.1

Repository

Samples collection method, repository and corresponding annotations methods, and performance measures are the topics approached in this section.

4.1.1 Samples Collection with electronic stethoscope

The electronic Stethoscope was connected to a Samsung Galaxy Nexus9and the Android applica-tion Smart Voice Recorder10was used to record the respiratory sounds (Figure4.1).

(42)

Crackles Detection

4.1.2 Data samples - repository

The repository is composed by two groups of respiratory sounds.

The first group consists in a set of 10 samples, which are the same used in the dissertation project: "Automatic Methods for Crackles Detection" ([Qui11]), in which half belong to patients with cystic fibrosis, and the other half to patients with pneumonia.

The second group consists of 5 samples collected by physicians in a hospital (Centro Hospi-talar São João11). These respiratory sounds were collected by the means of the method presented previously (4.1.1).

More than 20 samples were gathered by the physicians, but only 5 had presence of crackles.

4.1.3 Annotations

Crackles annotations are different for the two sets of respiratory sounds presented.

The annotations corresponding to the respiratory sounds used in "Automatic Methods for Crackles Detection" ([Qui11]), were the result of an agreement between three different health care professionals’ (HCP) annotations. A platform ([JDM12]) was used to assist the HCP in this process. After having the annotations corresponding to each HCP, an algorithm was used to get an agreement, considering the maximum absolute value of the interval as the comparison condition as seen in Figure4.2.

Figure 4.2: Annotations of the first group of respiratory sounds ([Qui11])

9Samsung: Samsung Galaxy Nexus, <http://www.samsung.com/pt/consumer/mobile-phone/ smartphones/android/GT-I9250TSATPH> (accessed on Sep 13th, 2014)

10Google Play: Smart Voice Recorder, <https://play.google.com/store/apps/details?id=com. andrwq.recorder&hl=pt_PT> (accessed on Sep 13th, 2014)

(43)

Crackles Detection

As for the second group of respiratory sounds, which were collected using the electronic stethoscope connected to the smartphone, the annotations were done by a single HCP (using a platform named Audacity12) and with different precision comparing to the first group of annota-tions. In fact, these have larger intervals, which correspond to more than one crackle, as seen in Figure4.3.

Figure 4.3: Annotations of the second group of respiratory sounds

4.1.4 Performance Evaluation

Validating algorithms by performance assessment is mandatory. For the performance evaluation of the algorithms implemented, three measures were used.

Sensitivity (Equation4.1) which corresponds to the division between the True Positives (TP, crackles detected by the algorithm and annotated by the professionals) and Positives (P, which are the total number of crackles annotated).

The second measure is the Precision or Positive Predictive Value (PPV, Equation4.2), corre-sponding to the division between the TP and the total number of crackles detected by the algorithm (TP + FP, being FP - False Positives).

And the last measure, the Harmonic Mean (F) is a performance measure based on SE and PPV as seen in Equation4.3. SE=T P P (4.1) PPV = T P T P+ FP (4.2) F= 2 ×PPV× SE PPV+ SE (4.3)

12Audacity: Free Audio Editor and Recorder, <http://audacity.sourceforge.net/?lang=en> (accessed

(44)

Crackles Detection

4.2

Algorithms for Crackles Detection

The methods chosen to test and incorporate our solution are: the algorithm created by Vannuccini et al. ([LVP98]) and the algorithm created by Hadjileontiadis and Rekanos ([HR03]). This choice took into account the target platform capabilities, the algorithms complexity and memory space required.

This section presents detailed information about the algorithms implemented, and the corre-sponding performance evaluation for the ones that were successfully developed.

4.2.1 Vannuccini et al.

The Vannuccini et al. algorithm ([LVP98]) was used as a baseline to test the collected sound samples. This choice is also explained because this is one of the algorithms that was implemented in the "Automatic Methods for Crackles Detection" dissertation project as seen in2.1.2.

The most relevant steps of this algorithm are presented in Figure4.4, involving the following steps:

• In the first block, the respiratory sound is smoothed by filtering it using Savitsky-Golay (SG) filters.

• In the second block the first derivative of the smoothed signal is calculated, as well as its absolute value.

• In the third block, the T threshold, whose value is associated with the amplitude, is compared to the First Derivative Absolute Value (FDAV) of the respiratory sound (obtained in the second block) to select the regions considered with a high probability of containing crackles. The interesting regions having duration above Tw are discarded.

• In the last block, the crackles that verify certain conditions in those regions are identified as seen in Figure4.5

(45)

Crackles Detection

Figure 4.4: Block diagram of the algorithm implemented by Vannuccini et al.

There is no automatic method to obtain T and Tw. The T threshold, associated to the respira-tory sound amplitude is critical for the algorithm performance, but it can only be defined empiri-cally. When it comes to the Tw threshold, it is associated to the crackle duration, and it is not as critical as T. It should be noted that if T is too small, the algorithm may not detect all crackles, and if it is too high, it may only detect one crackle where there are many more. Assuming that a crackle duration is usually below 20ms, the authors considered that a good value would be 5ms.

(46)

Crackles Detection

Figure 4.5: Representation of the FDAV and signal of a sample, the intervals involved in the method and the T and Tw thresholds ([LVP98])

4.2.1.1 Locating Interesting regions

The FDAV of the respiratory sound is analyzed from beginning to end. An interesting region initiates the FDAV is above the T threshold, and so begins the assessment of the ton and to f f intervals. tonis the period where FDAV is above T, and to f f is the period where FDAV is below T.

Figure4.5shows those intervals and its correspondence to the signal’s FDAV.

The accumulation of those intervals goes on while ton> to f f and ton+ to f f < Tw. The point where this last condition is no longer satisfied, defines the end of the interesting region.

ton=

i toni (4.4) to f f =

i to f fi (4.5)

(47)

Crackles Detection

4.2.1.2 Crackles detection in Interesting regions

The set of interesting regions selected in the third block of the diagram are finally tested to check if they contain crackles. The conditions of this test are:

• Existence of at least three peaks in the FDAV on the interval Tw. The positions of these peaks correspond to the points of maximum slope of the respiratory sound in the interval (te, t2 and t3 in Figure4.5).

• Slope in t2 superior to the slope of t1 and t3, which means that the maximum peak of the FDAV must be in t2.

• Progressively higher intervals between peaks: t1-ts < t2-t1 < t3-t2

If all of the above conditions are satisfied, than a crackle is in that interesting region.

The respiratory sounds the authors submitted to this algorithm had 16 bits of resolution and frequency of 8000 Hz and were collected from patients with idiopathic pulmonary fibrosis.

The respiratory sounds were annotated by a single health care professional, based on hearing and on Murphy’s criterion ([RLHMK77]), where the author modeled a crackle as having the fol-lowing characteristics: 3 to 16 zero crossings, maximum amplitude greater than twice the signal base, abrupt initial deflection, and peaks successively more distant in time.

Two statistical measures were presented, Sensitivity and Specificity, with different definitions when comparing to the conventional equations for its calculation:

T OT = T P + FN (4.6)

SP= 1 − FP

FN+ T P (4.7)

The results were: sensitivity of 84% and specificity of 89%. 4.2.1.3 Algorithm Validation

The algorithm was implemented in Java according to the steps presented in the previous section (4.2.1). The respiratory sounds used to validate the algorithm, were the same from the "Automatic Methods for Crackles Detection" dissertation project seen in2.1.2, with a sampling frequency of 8000 Hz. One step of the algorithm suffered a change: the high pass filter had a cutoff frequency of 95 Hz, in order to cancel the noise coming from the heart and the respiratory muscles.

As mentioned previously, the only way to find the value for the threshold T is empirically, so, an initial range was tested [1.5 ; 5.5] with a 0.5 interval, in 5 of the 10 samples from the first group of the repository (chosen randomly):

(48)

Crackles Detection

Table 4.1: Respiratory Sounds for the preliminary test Respiratory Sound rs_6 rs_7 rs_2 rs_1 rs_9

Three statistical measures were calculated following the equations presented in the section Performance Evaluation ( 4.1.4): Sensitivity (SE), Precision (PPV) and Harmonic Mean (F) in order to locate the best value for the threshold in a first scenario, and then, to evaluate the efficiency of the implemented algorithm.

Figures 4.6, 4.7 and 4.8 represent the variation of the statistical measure according to the threshold range defined.

(49)

Crackles Detection

Figure 4.7: Precision performance for thresholds in the range [1.5 ; 5.5]

Figure 4.8: Harmonic Mean performance for thresholds in the range [1.5 ; 5.5]

After this preliminary evaluation, the threshold range [2, 4.5] (now with an interval of 0.25) was chosen to the final evaluation with the 10 respiratory sounds.

Figures 4.9, 4.10 and 4.11, show the values of Sensitivity, Precision and Harmonic Mean respectively for all the respiratory sounds and also the mean for each measure.

(50)

Crackles Detection

Figure 4.9: Sensitivity performance for thresholds in the range [2 ; 4.5]

(51)

Crackles Detection

Figure 4.11: Harmonic Mean performance for thresholds in the range [2 ; 4.5]

The threshold that revealed the maximum value of harmonic mean was 3. This was considered the optimal threshold of the algorithm.

Table 4.2 presents the values of Sensitivity, Precision and Harmonic mean for the optimal threshold. The mean values for this measures are, respectively, 78,1%, 68,6% and 71,3%. The specificity was also calculated according to the equation4.7, resulting in the value 69,4%.

Table 4.2: Results for optimal threshold

RS Annotated Threshold Detected TP FP FN SE(%) PPV(%) F(%)

rs_1 46 3 54 40 14 6 86,96 74,04 80,00 rs_2 38 3 53 28 25 10 73,68 52,83 61,54 rs_3 48 3 54 31 23 17 64,58 57,41 60,78 rs_4 15 3 26 11 15 4 73,33 42,31 53,66 rs_5 23 3 37 21 16 2 91,30 56,76 70,00 rs_6 51 3 51 48 3 3 94,12 94,12 94,12 rs_7 81 3 97 73 24 8 90,12 75,26 82,02 rs_8 75 3 98 65 33 10 86,67 66,33 75,14 rs_9 132 3 57 43 14 89 32,58 75,44 45,50 rs_10 50 3 48 44 4 6 88,00 91,67 89,80

On the other hand, Table4.3shows the results for the threshold with maximum performance corresponding to each respiratory sound. The mean values for the performance measures are: SE of 81,0%, PPV of 73,2% and F of 76,4%. Is important to see that the mean value for the harmonic mean (F) is 5% higher when comparing with the optimal threshold results.

(52)

Crackles Detection

Table 4.3: Results for optimal threshold

RS Annotated Threshold Detected TP FP FN SE(%) PPV(%) F(%)

rs_1 46 2,5 42 37 5 9 80,43 88,10 84,09 rs_2 38 2,75 52 28 24 10 73,68 53,85 62,22 rs_3 48 3 54 31 23 17 64,58 57,41 60,78 rs_4 15 2,75 23 11 12 4 73,33 47,83 57,89 rs_5 23 2 29 21 8 2 91,30 72,41 80,77 rs_6 51 3 51 48 3 3 94,12 94,12 94,12 rs_7 81 2,25 97 74 23 7 91,36 76,29 83,15 rs_8 75 2 86 64 22 11 85,33 74,42 79,50 rs_9 132 5,5 124 89 35 43 67,42 71,77 69,53 rs_10 50 2 46 44 2 6 88,00 95,65 89,80 Performance comparison:

The authors of this method ([LVP98]) claim for a Sensitivity of 84% (5,9% more) and speci-ficity of 89% (19,6% more) according to equations 4.6and4.7, while the author of "Automatic Methods for Crackles Detection" ([Qui11]) claims for a Sensitivity of 71,6% (6,5% less), a speci-ficity of 62% (7,4% less), a precision of 68,9% (0,3% more) and a harmonic mean of 69,1% (2,2% less), using the same respiratory sounds and corresponding annotations.

4.2.2 Vannuccini et al. Alternative Version

In order to increase the test scenarios of automatic crackles detection and having the knowledge that came from signal analysis discussed on section3.2, more precisely, regarding the difference of crackles behaviour between theory and practice, a variation of the previous algorithm was expe-rienced. The conditions that tested intervals between peaks and slopes comparison, were removed. As was done to the first version of the algorithm, a preliminary test with a threshold range of [1.5, 5] with 0.5 interval was also taken. Figures4.12,4.13and4.14present the relation between thresholds and Sensitivity, Precision and Harmonic Mean, of the same 5 respiratory sounds used to carry out the preliminary test of the first version.

(53)

Crackles Detection

Figure 4.12: Sensitivity performance for thresholds in the range [1.5 ; 5]

(54)

Crackles Detection

Figure 4.14: Harmonic Mean performance for thresholds in the range [1.5 ; 5]

After this preliminary evaluation, the range [1.25, 3.5] was chosen to the final evaluation with the 10 respiratory sounds, using a step of 0.25. Figures 4.15,4.16and4.17, show the values of Sensitivity, Precision and Harmonic Mean respectively for all the respiratory sounds, and also the mean for each measure.

(55)

Crackles Detection

Figure 4.16: Precision performance for thresholds in the range [1.25 ; 3.5]

Figure 4.17: Harmonic Mean performance for thresholds in the range [1.25 ; 3.5]

The threshold that revealed the maximum value of harmonic mean was 1.75. This was consid-ered the optimal threshold.

Table 4.4 presents the values of Sensitivity, Precision and Harmonic mean for the optimal threshold. The mean values for this measures are, respectively, 84,8%, 72,9% and 76,7%. The specificity was also calculated according to the equation4.7, resulting in the value 71,4%.

(56)

Crackles Detection

Table 4.4: Results for optimal threshold

RS Annotated Threshold Detected TP FP FN SE(%) PPV(%) F(%)

rs_1 46 1,75 40 37 3 9 80,43 92,50 86,05 rs_2 38 1,75 63 31 32 7 81,58 49,21 61,39 rs_3 48 1,75 61 36 25 12 75,00 59,02 66,06 rs_4 15 1,75 26 13 13 2 86,67 50,00 63,41 rs_5 23 1,75 36 22 14 1 95,65 61,11 74,58 rs_6 51 1,75 51 50 6 1 98,04 89,29 93,46 rs_7 81 1,75 104 78 26 3 96,3 75,00 84,32 rs_8 75 1,75 89 68 21 6 90,67 76,40 82,93 rs_9 132 1,75 75 66 9 66 50,00 88,00 63,77 rs_10 50 1,75 53 47 6 3 94,00 88,68 91,67

Table4.5 shows the results for the threshold with maximum performance corresponding to each respiratory sound. The mean values for the performance measures are: SE of 87,7%, PPV of 74,0% and F of 79,8%. It is worth noting that the mean value for the harmonic mean (F) is only 3,1% higher when comparing with the optimal threshold results.

Table 4.5: Results for optimal threshold

RS Annotated Threshold Detected TP FP FN SE(%) PPV(%) F(%)

rs_1 46 1,75 40 37 3 9 80,43 92,50 86,05 rs_2 38 1,50 53 28 25 10 63,58 52,83 61,54 rs_3 48 2 72 40 32 8 83,33 55,56 66,67 rs_4 15 1,5 24 13 11 2 86,67 54,17 66,67 rs_5 23 1,5 30 21 9 2 91,30 70,00 79,25 rs_6 51 1,75 51 50 6 1 98,04 89,29 93,46 rs_7 81 1,5 99 76 23 5 93,83 76,77 84,44 rs_8 75 1,75 89 68 21 6 90,67 76,40 82,93 rs_9 132 4 167 128 49 4 96,97 76,65 85,62 rs_10 50 1,25 48 46 2 4 92,00 95,83 91,26 Performance comparison:

This adapted algorithm presents 0.8% more in Sensitivity and 17,6% less in specificity in comparison with the results obtained by the authors of the original method.

On the other hand, this version presents 3.4% less in Sensitivity, 6% more in specificity, 1.3% more in precision and 0.7% less in harmonic mean in comparison with the results obtained with this same alternative version by the author of "Automatic Methods for Crackles Detection" ([Qui11]).

4.2.3 Fractal Dimension Algorithm

Hadjileontiadis and Rekanos ([HR03]) presented an algorithm named Fractal Dimension (FD) for crackles detection, and claimed for an efficiency of 100%. This algorithm was also implemented

(57)

Crackles Detection

in Java, according to the authors specification. The following diagram (Figure4.18), shows the flow of the algorithm:

Figure 4.18: Block diagram of the Fractal Dimension algorithm.

Each block corresponds to:

• First, the estimation of the respiratory sound’s FD by the application of the Katz algorithm ([Kat88]).

• Second, the FD’s automatic peak identifier (FD-Peak Peeling Algorithm, FD-PPA) of the respiratory sound. Through the identification of peaks, the crackles location and duration are obtained. The Sensitivity of the identifier is set by the threshold that is empirically adjusted in order to get the best performance of the algorithm. The authors used the value 0.006.

• Third, the identification of crackles is carried out using the intervals of FD’s Peak Peeling (FDPP) that are above 1.

4.2.3.1 Fractal Dimension Calculus

For calculating the respiratory sound’s FD, the first step it to define a window of M = (int) (0.006*fs) samples (fs is the sampling frequency). Then, the window of M samples runs the respiratory sound of N samples with over 95% of overlap. And finally, for each window position, the FD value is computed and is assigned to the window’s middle point.

As stated before, the FD calculus is done by the Katz algorithm, in which a curve’s FD is estimated by the following equation:

Ds= log(n)

(58)

Crackles Detection

where L is the curve’s length, expressed by the sum of the Euclidean distances between suc-cessive points: L= N−1

i=1 dist(i, i + 1) (4.9)

d from equation 4.8 corresponds to the curve’s diameter, which is given by the following equation:

d= max[dist(i, j)]; i 6= j; i, j ∈ [1, N] (4.10) Finally, n is the total number of intervals in the curve:

n= N − 1 (4.11)

4.2.3.2 FD’s Peaks Automatic Identification

The respiratory sound’s FD calculated previously, is now submitted to the automatic peaks de-tection (FD-PPA), in order to identify crackles location and duration. It consists in a self-tuning iterative procedure that gradually finds signal components responsible for peaks.

The FDPP signal obtained is equal to 1, except in the regions where peaks exist. Figure4.19

(59)

Crackles Detection

Figure 4.19: Peak Peeling Algorithm (FD-PPA) flow diagram [Had05].

This algorithm was not successfully implemented, due to a problem faced during its devel-opment, which was related to the memory space of Java. After some code refactoring and after

(60)

Crackles Detection

increasing the platform’s heap size, the end was not achieved. The problem wasn’t solved

4.3

Conclusions

Despite the unsuccessful implementation of the Fractal Dimension algorithm, the results achieved in the algorithms validation were stimulating, mainly due to the greater efficiency obtained in comparison with João Quintas thesis ([Qui11]), which used the same repository and corresponding annotations.

Once the phase regarding automatic crackles detection was completed, the next step was to approach the noise cancellation issue.

Referências

Documentos relacionados

social assistance. The protection of jobs within some enterprises, cooperatives, forms of economical associations, constitute an efficient social policy, totally different from

Ousasse apontar algumas hipóteses para a solução desse problema público a partir do exposto dos autores usados como base para fundamentação teórica, da análise dos dados

The probability of attending school four our group of interest in this region increased by 6.5 percentage points after the expansion of the Bolsa Família program in 2007 and

i) A condutividade da matriz vítrea diminui com o aumento do tempo de tratamento térmico (Fig.. 241 pequena quantidade de cristais existentes na amostra já provoca um efeito

didático e resolva as ​listas de exercícios (disponíveis no ​Classroom​) referentes às obras de Carlos Drummond de Andrade, João Guimarães Rosa, Machado de Assis,

The values of the harmonic mean of the genotypic values (MHVG) to evaluate stability, the relative performance of the genotypic values (PRVG) for adaptability and the harmonic

Despercebido: não visto, não notado, não observado, ignorado.. Não me passou despercebido

Foram aprovadas, por unanimidade de votos, as autorizações para cursar disciplinas -