41
IN DEGREE PROJECT MEDICAL ENGINEERING, SECOND CYCLE, 30 CREDITS , STOCKHOLM SWEDEN 2017 Pulse Oximetry Signal Processing in real time on Raspberry Pi MALIN THUNHOLM KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF TECHNOLOGY AND HEALTH

Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

IN DEGREE PROJECT MEDICAL ENGINEERING,SECOND CYCLE, 30 CREDITS

, STOCKHOLM SWEDEN 2017

Pulse OximetrySignal Processing in real time on Raspberry Pi

MALIN THUNHOLM

KTH ROYAL INSTITUTE OF TECHNOLOGYSCHOOL OF TECHNOLOGY AND HEALTH

Page 2: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Acknowledgements

I would like to express my special thanks of gratitude to my reviewer Kaj Lindecrantz,my group supervisor Dmitry Grishenkov and my group members at The Royal Instituteof Technology for the help with my thesis report from start to end. I really appreciateall the feedback and suggestions that I got from all of you.

I would also like to thank Bengt Ragnemalm from Linkopings University (LiU) andRegion Ostergotland, and Lars-Goran Lindberg from Linkoping University (LiU) andRespiHeart AB who introduced and helped me with RespiHeart and its technique.

I wish to express my sincere thanks to Eva Broman and Erik Sundvall at the depart-ment of Test and Innovation at Region Ostergotland, who introduced and followed methroughout the project with suggestions and assistance. I would also like to thank myfather Peter Thunholm, who introduced, assisted and helped me with Python, but alsoencouraged me throughout the project.

At last but not least, I would like to thank my family and friends for all the supportthroughout the whole project and that you all believed in me.

Page 3: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Abstract

This thesis introduces the reader into RespiHeart, which is a product under development.RespiHeart is an complement/alternative to the regular Pulse Oximeter and is intendedto be used within the health care sector for combined measurements and communicationon open inexpensive platforms.

This thesis evaluates interaction between RespiHeart and a Raspberry Pi 3 Model Bto evaluate if the computer is capable of handling the data from RespiHeart and makesignal processing.

Python is used throughout the whole project and is a suitable language for interactionand signal processing in real time.

Page 4: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Sammanfattning

Detta examensarbete introducerar lasaren till RespiHeart, en ny tradlos produkt somar under utveckling. RespiHeart ar ett komplement/alternativ till den nuvarande Pul-soximetern och ar tankt att anvandas inom sjukvarden for analys, kommuniakation ochkombinerade matningar pa oppna billiga plattformar.

Detta project utvarderar interaktionen mellan RespiHeart och en Raspberry Pi 3Model B for att undersoka om datorn ar kapabel till att hantera datan fran RespiHeartsamt gora signal processing i real tid.

Programmeringsspraket Python anvandes under hela projektet och ar ett lampligtsprak att anvanda for interation och signal processing i real tid.

Page 5: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Contents

1 Introduction 11.1 Aim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Background 22.1 Python vs Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2.1.1 Signal processing with Python vs Matlab . . . . . . . . . . . . . . 22.2 Computer workload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

3 Methods 43.1 Connection between Raspberry Pi and RespiHeart . . . . . . . . . . . . . 43.2 Data Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.3 Signal Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3.3.1 Criteria for choice of filter . . . . . . . . . . . . . . . . . . . . . . 63.3.2 Oxygen saturation and SNR . . . . . . . . . . . . . . . . . . . . . 6

3.4 The process load on the CPU . . . . . . . . . . . . . . . . . . . . . . . . 7

4 Result 84.1 Signal processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.2 Process time for different order and filter . . . . . . . . . . . . . . . . . . 104.3 Changes in SNR and oxygen saturation . . . . . . . . . . . . . . . . . . . 10

5 Discussion 115.1 Alternatives to Raspberry Pi 3 Model B . . . . . . . . . . . . . . . . . . 115.2 Alternatives to Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

5.2.1 Real time plotting . . . . . . . . . . . . . . . . . . . . . . . . . . 125.3 Signal Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135.4 Other potential errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

6 Conclusions 156.1 Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Bibliography 16

Appendix A Flow Chart A1

Appendix B Example of a guideline to choose filter B1

Appendix C The State of the Art Report C1

Page 6: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

1 Introduction

Two important organs in our body are the heart and the lungs. These organs workstogether almost without our notice and have a primary function to exchange oxygen andcarbon dioxide (1), (2). Two primary goals for the lungs are to extract the oxygen fromthe air and deliver it to the blood stream but also eliminate the rest product: carbondioxide (1). If this system does not work properly one may need health care. At thehospital a medical doctor investigates the health status by the use of modified earlywarning score (MEWS-score) to warn about deterioration (3).

Various aspects of individuals health can be obtained from the heart rate togetherwith other biomedical signals (4) that need to be evaluated for the MEWS-score (3). Forexample, a healthy person has 60-100 beats per minute (BPM)(5) and around 97 % ofoxygen saturation, while values below 70 % are life threatening (6).

Nowadays most records are electronic, but paper records are still in use to write downvalues and information about the patient (7). To reduce paper documentation, differentprojects evaluate if devices can be connected to the Electronic Health Record (EHR) viaNode-RED and store measured values from the device.

RespiHeart is a wireless Bluetooth device that is a product under development, whichwould be a complement/alternative to the traditional Pulse Oximeter. The device isplaced on sternum and measures oxygen saturation, heart rate, respiratory rate andtemperature. RespiHeart does not handle signal processing by its own yet and thereforeRaspberry Pi needs to take care of this. In this case the execution time is critical for thesystem to process the data from RespiHeart in real time.

1.1 Aim

This project will examine the feasibility of using a Raspberry Pi 3 Model B as an interface(bridge) between Raspberry Pi and RespiHeart and other systems e.g. EHR. The goal isto evaluate if Raspberry Pi 3 Model B can interact well with RespiHeart. A secondarygoal is to evaluate some aspects of the signal processing involved. A filter will be evaluatedin Matlab and then implemented in Python and executed and tested on the RaspberryPi 3.

The advantages and disadvantages of the use of Raspberry Pi 3 Model B are discussedas well as some alternatives to the computer. The cost of the system are discussed andincludes which program language that could be appropriate for both signal processingand connection between Raspberry Pi and RespiHeart.

1.2 Limitations

This project does not include real time plotting. Implementation is only done usingPython, both for interaction and signal processing. Three filters were implemented inPython, to discuss the time difference between two different filters.

A complementary device was not available for the project, therefore the accuracy ofoxygen saturation and heart rate are not compared with any traditional Pulse Oximeter.Oxygen saturation is calculated in Matlab and Python, but not included due to lack ofreliable data for the Molar Extinction Coefficients.

1

Page 7: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

2 Background

RespiHeart is a reflection-based Pulse Oximeter (8) and the output signals are in formof alternating current (AC) and direct current (DC). The DC component represents thelight absorption of the tissue, venous blood and non-pulsatile arterial blood. The ACcomponent represents the pulsatile arterial blood (9), (4).

RespiHeart’s systems handles the sampling when it is started and sends output in adigital form of bytes. Data is stored in a specific way by RespiHeart: first a three bytelong header and then two bytes each (most significant byte and least significant byte)of DC infrared, AC infrared, DC red and AC red. The DC signals are unfiltered, whilethe AC signals are inverted and filtered with a first order of FIR filter to remove the DCcomponent.

In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This projectis based on the operating system (OS) Linux/Unix.

2.1 Python vs Matlab

In this project Python is used as program language to make the interaction betweenRespiHeart and Raspberry Pi and the signal processing possible. Matlab is used to eval-uate a suitable filter that can be implemented in Python and used for signal processing.

Both Matlab and Python have large scientific communities, in Matlab everything isbuilt-in into the program, however in Python you have to learn which packages to usefor what. Matlab also has better documentation and visualizing interface. At Matlab’shomepage a test between different programs in both Matlab and Python are shown, toshow which of these programs that is the fastest one. Python is faster when it comes tocomputing and plot Fast Fourier Transform (FFT) and plot it. However, Matlab is fasterin computing Root Mean Square (RMS) and plot it. The results of Python depends onwhich library that is used (10).

A speed test between the two programs has been made by Hanly where the differentinterfaces were examined and gave different results (11).

2.1.1 Signal processing with Python vs Matlab

Python has a package for signal processing called SciPy. It contains a limited set of filterdesign tools including some filtering functions (12). The SciPy Stack contains a plottingpackage called Matplotlib and NumPy (13). Numpy and SciPy have similarities withMatlab but also a lot of differences, while Numpy and SciPy are packages created fornumerical and scientific computing (14), (15).

Matplotlib is a plotting package (13). The plots can be visualized using matplotlib,which makes the functions work like the ones in Matlab (16), (17).

Matlab has built in functions for different filters but also a program (Filter Designer)where different filter can be designed (18). Both techniques were evaluated.

2.2 Computer workload

To be able to see how Raspberry Pi works and handles the processes, ”top” can be called inthe terminal. The top-command shows information including time, load average, numberof users, tasks, CPU (central processing unit) usage, memory and total swap (19). The

2

Page 8: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

CPU load average is divided into three parts: the average over one minute, five minutesand 15 minutes (20).

3

Page 9: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

3 Methods

In this project RespiHeart is connected to Raspberry Pi via Bluetooth. This was issuedvia the program language Python. An overview can be seen in Figure 1 where the greypart is out of scope.

Figure 1: Interaction between RespiHeart and Raspberry Pi and future plan (Grey colored)

The code and processes was written and driven over SSH (Secure Shell), where Rasp-berry Pi was connected to Mac OS. To be able to interact with RespiHeart some re-quirements were needed to be fulfilled. RespiHeart can be described as a slave and theRaspberry Pi as a master. An interaction between the master and the slave, a handshakeneeds to be performed. A handshake between the devices was made by that certaincommands was sent to the slave. The slave (RespiHeart) uses the IMSE RToS, a realtime operating system, which contains information about how the commands should besubmitted.

3.1 Connection between Raspberry Pi and RespiHeart

To be able to start the measurement, commands needed to be sent to the device withcorrect settings. The commands were sent in Hexadecimal code, Table 1 shows the usedcommands.

Table 1: Command descriptions

Command Description Hexadecimal codeIMSE ACK CMD Header (3 bytes) + CRC + Cmd + status 010003000100

IMSE READY CMD Header (3 bytes) + CRC + Cmd 0100020002IMSE START CMD Header (3 bytes) + CRC + Cmd 0100020006

IMSE POWER OFF CMD Header (3 bytes) + CRC + Cmd 0100020009

IMSE SYSTEM SETTINGS CMDHeader (3 bytes) + CRC + Cmd

+ fundamentalRateMSB (not used)+ fundamentalRateLSB + SRTPrescaler

010005000B004705

IMSE SENSOR SETTING CMD*

Header (3 bytes) + Cmd+ SensorID + Dcamp + Acamp

+ Stim.Curr + Spare 0+ Spare 1 + Spare 2

010009000D00640503000000

IMSE SENSOR SETTING CMD*

Header (3 bytes) + Cmd+ SensorID + Dcamp + Acamp

+ Stim.Curr + Spare 0+ Spare 1 + Spare 2

010009000D01640503000000

* There are two sensor settings due to both infrared and red channels, where the difference is

the SensorID.

A handshaking included sending a command with a header of three bytes, where thefirst byte indicated a command sent in the command direction. The next two bytes in-dicated the size of the data. The size of the data changed due to the different settings.

4

Page 10: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

When a command was received by RespiHeart, an ”Acknowledge” and a ”Ready” re-sponse was sent back. The response indicates that there were no errors and the systemwas ready for next command. When the master received the message an acknowledge wassent to the slave to indicate that the message was understood and no errors occurred. Anexample can be seen in Figure 2. The time for the connection was evaluated and includesfive seconds delay as total, due to the fact that RespiHeart can not handle the settingsthat fast.

Figure 2: Explanation of Master and Slave interaction

3.2 Data Measurement

The user starts the measurement by starting the device and then staring a script fromthe terminal in Raspberry Pi. Later the script will be implemented as a Graphical UserInterface (GUI). The script first makes a connection between the devices via Bluetooth.Thereafter the start command was sent, followed by the general and sensor settings. Thecommands was sent byte by byte with a delay of five milliseconds, between the bytes.When all settings were sent, the script listened to RespiHeart and receives data. Theoutput was stored in a .bin file and then processed to remove the header and retain onlythe values from the detectors. After removal of the header, the data was stored in a new.bin file in the Raspberry Pi. To be able to manage the signal processing the file wascopied from Raspberry Pi to the computer that uses Matlab to find a filter. When asuitable filter was found, signal processing utilized in Python.

3.3 Signal Processing

The file was rearranged to get a matrix of four columns where the DC and AC, infraredand red values are stored. The filters examined were:

• Lowpass filter

– FIR filter– IIR filter

∗ Butterworth filter∗ Chebyshev type I filter∗ Chebyshev type II filter∗ Elliptical filter

5

Page 11: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

• Bandpass filter

– FIR filter– IIR filter

∗ Butterworth filter∗ Chebyshev type I filter∗ Chebyshev type II filter∗ Elliptical filter

• Sawitzky Golay filter

Different input values for cut-off, passband and stopband frequency, passband andstopband attenuation were evaluated in Matlab. Changes in signal-to-noise ration (SNR)and oxygen saturation were also evaluated. All filters were made by filterDesigner andthe built in functions. The Fast Fourier Transform (FFT) was investigated, in orderto retain as much information as possible after the signal processing. In Python, thenumerical toolbox SciPy includes Numpy and Matplotlib. Numpy reshaped the outputto a matrix and later plotted it with the use of Matplotlib. The scipy.signal was used toimport suitable filters.

3.3.1 Criteria for choice of filter

Filters need specific characteristics to preserve information from the signal, contributeto high SNR but also remove noise and avoid aliasing. To be able to choose filters thatare sufficient, criteria needs to be defined. A guideline how to choose filter can be foundin Appendix B (21). As in all projects there are criteria that needs to be considered.This project includes three important criteria, apart form the underlying ones in signalprocessing. The first criterion is that the system needs to be fast. The second criterion tobe fulfilled is the total cost of the system. It is important to make a device to a low cost.Also the memory uptake is a criteria that needs to be fulfilled. Since there are always newdata that should be measured and sent further to the EHR, the memory uptake needs tobe low. The filter should also be fast, have a minimum impact on the oxygen saturationand a high SNR should be provided. Hence, it should be a low pass filter or bandpassfilter, since the frequency of beats per minutes are BPM/60 Hz, where BPM lies between60-100 BPM for a healthy person (5).

3.3.2 Oxygen saturation and SNR

In Matlab a .bin file was loaded with one sample at a certain time. The sample wasplotted. A specific part of the curve was chosen due to noise, disturbance or errors asa result of unsuitable settings. That part of the curve was evaluated through differentkind of filters with different kind of cut off frequency, stopband frequency, passband rippleand stopband attenuation. The oxygen saturation was calculated as in Equation 1, whereεr,d = 4345, 2cm−1/M , εr,o = 442cm−1/M , εir,d = 733, 58cm−1/M and εir,o = 840cm−1/M(22), (23).

SpO2 =εr,d −R ∗ εir,d

R(εir,o − εir,d)− (εr,o − εr,d)(1)

The AC values was calculated by the Root Mean Square (RMS) while the DC valueswas calculated as mean (24), (9), (25). R was calculated from Equation 2.

6

Page 12: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

R =

(AC660

DC660

/AC805

DC805

)(2)

The SNR was calculated through Matlab’s own built-in function and was calculatedas Equation 3.

SNR = 20 · log10(ACIR

DCIR

/ACIRnoise

DCIRnoise

)(3)

3.4 The process load on the CPU

To study the computers CPU load average (20) and if necessary CPU usage as a percent-age by idle processes (19), ”top” was called in the terminal. Ten samples in two minuteswas performed to notice changes in the average load. The load average over one minutewas collected for 10 samples after Bluetooth connection was accomplished, after filteringas well as after shut down of RespiHeart. The load average was noted in a text-file duringsampling and studied later.

7

Page 13: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

4 Result

An flow chart of the code can be found in Appendix A.Information about the use of the computer was checked with the command ”top”

(19). For different filters the CPU load average over one minute for ten samples, wherethe sampling took two minutes, are shown in Figures 3 - 5.

(a) CPU load average over one minute (b) CPU load average over time

Figure 3: CPU load average for second order Butterworth filter followed by Savitzky Golayfilter

(a) CPU load average over one minute (b) CPU load average over time

Figure 4: CPU load average for fourth order Butterworth filter followed by Savitzky Golayfilter

(a) CPU load average over one minute (b) CPU load average over time

Figure 5: CPU load average for second order Elliptical filter followed by Savitzky Golay filter

8

Page 14: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

4.1 Signal processing

The second aim was to evaluate a suitable filter for the output signal from RespiHeart.The span of the frequency spectrum of the signal was 0.5-4Hz, which represents 30-240BPM. In this project a second order lowpass Butterworth filter, with a cutoff frequencyat 4 Hz and a sampling frequency at 100 Hz, followed by a first order Savitzky Golayfilter with a framelength of 41, was used.

The average time for the connection after 10 samples was 11,895 seconds with built-indelays of 5 seconds as total. The load average is found in Table 2.

Table 2: CPU load average after 10 samples in two minutes after connection between RaspberryPi and RespiHeart, after the settings were set and after total sampling

CPU Load Average over one minute, %Connection 11,4Settings 10,1Total 30,4

The order was raised from two to four, thus no significant change in load average,see Figures 3a, 3b, 4a and 4b. The total load average over one minute after everythingwas notices was 29 % with a fourth order Butterworth filter, slightly lower than a secondorder.

The first filter was changed from lowpass Butterworth filter, to lowpass Elliptical filterwith an order of two. The total load average over one minute was 37.3 %, which is slightlylarger than the Butterworth filters with different order. The Figures 5a and 5b showsthat Elliptical filter uses more load in the end of the sampling, unlike Butterworth filter.The average is over one minute, thus we can conclude that Elliptical filter may use moreload than Butterworth filter. The different filters implemented in Matlab are shown inFigure 6 and 7.

(a) Butterworth filtered signal vs original signal (b) Butterworth filtered signal vs Butterworth +Savitzky Golay filtered signal

Figure 6: Second order Butterworth filter

9

Page 15: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

(a) Elliptical filtered signal vs Original signal (b) Elliptical filtered signal vs Elliptical +Savitzky Golay filtered signal

Figure 7: Second order Elliptical filter

4.2 Process time for different order and filter

The average time over each filter iteration, every two seconds, was measured during fivesamples. The average time can be found in Table 3.

Table 3: Average time for different filters

Filter Type Average TimeButterworth 2th order 10,6 msButterworth 4th order 11,1 msElliptical 2th order 30,3 ms

4.3 Changes in SNR and oxygen saturation

Measurements in Matlab show that SNR is affected by changes in the passband and cut-off frequency. Raising the passband raises the SNR, but only up to 3 Hz, then the SNRlowers again. Lowering the cut-off frequency lowers the SNR. Lowering the stoppbandattenuation raises the SNR.

10

Page 16: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

5 Discussion

The first aim of the project was to see how a Raspberry Pi 3 Model B interacts withRespiHeart in real time. The load average never raises to an unmanageable level andthe process time for the different filters is low. Raspberry pi 3 Model B is a quad corecomputer and therefore the load average is four times lower than the obtained results. Theload average is over one minute and therefore the first 48 seconds of the load average forethe filters includes the connection and setting part, since this interaction took almost 12seconds. As can be seen in Figures 3b, 4b and 5b peaks are defined in that region, whichmay depend on the connection and setting interaction. These peaks may also depend onthat Raspberry Pi handles its own buffer. An alternative is to study load average withthe tool pidstat, which show information about specific processes (26). In this project,Python was used as language to interact with RespiHeart and perform signal processing.Due to the obtained results, Python is a language that works for this purpose.

5.1 Alternatives to Raspberry Pi 3 Model B

Since Raspberry Pi is a large community, new updates and computers are available con-tinuously. A new model of Raspberry Pi Zero was released during February 2017, withwireless LAN and Bluetooth 4.0 to a price of 90 Swedish crowns. The size and weight isjust 65mm x 30mm x 5mm and 9g, unlike the Raspberry Pi 3 Model B which has thesize of a credit card and hence almost twice as big. Since this new product uses an equalchip as Raspberry Pi 3 Model B, Bluetooth 4.0 is available, which is why this smallerand cheaper Raspberry Pi Zero W can be a competitor. But an important feature forthis project was the speed of the computer and the Raspberry Pi 3 Model B is the fastestone (27), (28).

Another competitor can be the C.H.I.P computer, which is available for 80 Swedishcrowns and has the same important features for this project as the Raspberry Pi ZeroW, but on the other hand utilized a 4GB of built-in storage. A drawback for the C.H.I.Pcomputer is the lack of community support, which is an important feature in today’ssociety (28), (29). Arduino is another board that has similar functions as the RaspberryPi, but its a micro-controller instead of a complete computer. The main purpose of theArduino is to interfere with sensors and devices, so this computer is good for hardwareprojects. The computer that the user should choose, depend heavily on the project, whatthe computer will do and what it will interact with (30).

All these computers have different advantages, but the Raspberryy Pi 3 Model B hasall important features needed for this project and also have a faster processor, which wasone of the main features in this project.

Raspberry Pi 3 Model B was determined from the beginning because the societyaround it is large, the cost is small and the processor is fast. Bluetooth connection andWi-Fi is available. Also other accessories can be connected to it, such as a screen andHDMI cables, whole project kits, but it has also a SD-card reader so the user can adjustthe memory space for the intended project (31), (32).

5.2 Alternatives to Python

In this project Java, C and C++ can be competitors to Python, to interact with Respi-Heart. It is good to remember that Java is a portable web oriented language, C++ is an

11

Page 17: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

efficient language used in operating systems drivers. However, on the other hand Pythonis usable. The load average and the memory usage may be affected depending on whichprogram you use. Java is faster but uses more space than Python and C++ (33). Javahas advantages when programming applications for Android and many web applicationsare based on Java (34).

Since the programming occurred in the Terminal on the student’s Mac OS via SSH,one issue using Python was to declare the variables. Java can therefore be a better option,since the variables must be explicitly declared, which makes it easier to keep tracks ofthe variables (33), (35).

C++ and Java are low level languages compared to Python and have a longer history.C++ is more complex, so a lot of things need to be handled, e.g. memory management.In C++ and Java a lot of code needs to be written, which can induce secondary faultsin the code (36).

5.2.1 Real time plotting

For future project, Raspberry Pi should be able to handle both interaction, signal process-ing and real time plotting. Python has plotting utilities similar to Matlab and Octave.Note that Matlab itself can not run on Raspberry Pi, it can only communicate via asupport package for Raspberry Pi (37).

Matlab is a platform that is optimized for solving scientific and engineering problems(38). A big difference between Matlab and Python as program languages is the cost.Python is a freeware program, while Matlab have different prices for different licensesand toolboxes. The toolboxes and other products needs to be added to the cost, whilemost of Pythons libraries are free.

The reasons to use Matlab over Python are that the matrix math is fast, the debuggeris good and it has special syntax to facilitate numerical analysis. The Simulink, a blockdiagram environment for multidomain simulation and Model-Based Design (39), has noreal alternatives and is a well-respected software. There are graphical user interface (GUI)tools like signal processing tool (SPTool) and filter design and analysis tool (FDATool).The language is good when making high-quality professional-grade signal processing andcontrol system design. Matlab can be easier to start with, since it includes all the pack-ages, while both packages and an integrated development environment (IDE) needs to beinstalled in Python (40).

Python is a free, versatile and powerful language (40), (11). Since its free, you canprogram everywhere, and it works on Windows, Linux and OS X. There can exist as manyfunction and classes as needed and they can be designed anywhere. There are also greatGUI toolkits available for Python (40). It has a similar plotting utility like Matlab, butis easier to use and improved. The environment can be Matlab-like by using interactivePython (IPython) shell. The libraries in Python are similar to the ones in Matlab butcan be supplemented with a lot of toolboxes (41).

Octave is a free software similar to Matlab with its powerful mathematics-orientedsyntax, build-in plots and visualization tools (42). Since its free it can be a good com-plement to Matlab to handle graphs in Raspberry Pi. Python have a faster executionspeed and larger community, but the data analytic capabilities are equal (43). A compar-ison between the systems mathematical computation time shows that Python/Numpy isfaster than Matlab in the majority of calculations of matrix mathematics (44), (45). Thegraphical capabilities compaired to Matlab are not equal in neither Python nor Octave,

12

Page 18: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

however Matlab has more tools than both Python and Octave. Since its free it is a betteralternative than Matlab, but Python have some core features that are better than Octave(43).

5.3 Signal Processing

The second aim was to find a suitable filter for the output signal. It is difficult toimplement a perfect filter, due to the different parameters that need to be set. The filterorder gives shorter transition bands but longer impulse response and larger group delays.It has to be a trade off between these to find a optimal filter (46).

In this project, Matlab was first used to find an appropriate filter that later wasimplemented in Python. The signal processing worked in a fast and good way and theresults form Section 4.2 showed that a slightly raised order did not impact in a negativeway on the time. The Elliptical filter was slightly slower and had a total load averageslightly higher than the Butterworth filters. Elliptical filters change the appearance ofthe curve, which Butterworth filters does not, see Figures 6 and 7. The Savitzky-Golayfilter was used to smooth the signal and decrease the amount of peaks when calculatingthe heart rate.

Other filters such as FIR filters, take longer time to execute than IIR filters and IIRfilter requires less memory space. If the goal is to study the curve, FIR filters preservesthe curve better than an IIR filter but have a small delay.

In this project a lowpass filter was used, but a bandpass filter from 0.5-4 Hz mayhave shown better results, since noise and disturbance can occur at lower frequencies aswell. However, the SNR showed low values and therefore a Butterworth lowpass filterwas chosen instead.

In this project the RespiHeart have been treated as a Pulse Oximeter. However,RespiHeart will in a final solution use only the DC values of 660 nm and 805 nm. Thisfact may give rise to even less space for data storage and data calculation. For example,DC values may be sampled at a lower frequency in general compared to DC signals. Samedemand on filters discussed in this thesis may however still be relevant.

5.4 Other potential errors

The table of extinction coefficient for Hemoglobin was updated 1998 (22), and thereforethe values may have been changed. Unfortunately small changes in the extinction coef-ficients can cause significant errors in calculating oxygen saturation (47). This resultedin to unreliable values for oxygen saturation and SNR, which may cause incorrect infor-mation for filter selection. Also the filters were chosen from certain parts of a stored .binfile, with specific settings, which can cause error in real time filtering.

Since an complementary device was not used, it was difficult to know if the values arewithin a reasonable range and thus exclude right amount of noise and disturbance.

In this project a specific value for SNR was not set. Since the settings was changedmanually, it was difficult to find the perfect settings for each and every person. Thus,noise and disturbances made it difficult to find the peaks in the signal and thereforedifficult to set specific SNR value.

Due to faulty information about the calculation of oxygen saturation the method usedin this report differs from the most accurate one. The wavelengths for the infrared light

13

Page 19: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

(805 nm) is different from pulse oximetry and the most accurate calculation do not includethe AC signal, which may contribute to errors in the result of the oxygen saturation.

14

Page 20: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

6 Conclusions

The results show that the computer does not work on full load or take too long to process,thus we can conclude that Raspberry Pi and Python can handle the analysis of data andinteraction with RespiHeart in real time.

Raspberry Pi 3 Model B is a computer suitable for this handling. It has a high speed,low cost and is simple to learn how to use. The speed of the whole process depends onwhich language that are used to do the interaction via Bluetooth and signal processing.Matlab is not a good alternative for signal processing or plotting since it has a highcost, but can be exchanged for Octave or Python. Python is capable of both interaction,signal processing and plotting the signal similar to what Matlab is capable of, which iswhy Python is a working program language for these tasks.

The process time for the different filters depends on the filter used, but from theresults the process time is within milliseconds. The time will be different depending onfilter and its order. The load average can be further studied but will also depend on thefilter and its order.

6.1 Future work

For future work the signal processing could be improved and more different filters canbe examined with different data. Examples are the walvet transformations and psuedoWigner-Ville distribution, while these have showed significant improvements (48). AlsoFIR filter with different windows and order could be investigated (24). The filters can beinvestigated with a specific value of R and known noise at different levels to examine howSNR and oxygen saturation occur. This will increase the reliability of the filter, fromwhere it is now. Also a complementary device could be used to investigate if the valuesare in a reasonable interval after signal processing.

The load average could be examined in real time instead of over one minute and alsofor a certain process to exclude other potential influences.

Java, C and C++ can be examined to be the main language to connect to RespiHeartand to do signal processing. Also different computers such as Arduino and Raspberry PiZero W can be tested and see if they can handle the output. This may then lower thecost of the whole project.

The code can be rewritten to obtain faster speed and lower the delay in real time, butalso see how it affects the load average. Real time values for oxygen saturation, heartrate and respiratory rate could be visualized via Node-RED and later on be implementedin a EHR.

All medical devices needs to undergo CE-marking to be used within health care. Inthis case both Raspberry Pi and RespiHeart needs to be CE-marked, but in future thesignal processing could be implemented in RespiHeart to avoid two CE-marking processes.

The project around RespiHeart is still under development and therefore the finalproduct will have a lot of improvements and a more efficient way to process the signals.

15

Page 21: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Bibliography

[1] J. R. Goodman, “Importance of oxygen: The heart lung connection,” My PrimeTime News, Jun. 2015. [Online]. Available: http://www.myprimetimenews.com/importance-of-oxygen-the-heart-lung-connection-2/

[2] N. Lechtzin, “Exchanging oxygen and carbon dioxide,” MSD Manuals, 2017. [On-line]. Available: http://www.msdmanuals.com/home/lung-and-airway-disorders/biology-of-the-lungs-and-airways/exchanging-oxygen-and-carbon-dioxide

[3] M. Magnusson, “Mews – modified early warning score,”Vardgivarwebb for Region Ostergotland, Aug. 2014. [Online]. Available:http://vardgivarwebb.regionostergotland.se/Startsida/PM-medicinska-o-vardadm/PM-dokument/Ledningsstab/MEWS---Modified-Early-Warning-Score/

[4] S. Jaafari, “Adaptive Filtering for Heart Rate Signals,” Ph.D. dissertation, SanJose State University, 2014. [Online]. Available: http://scholarworks.sjsu.edu/cgi/viewcontent.cgi?article=7967&context=etd theses

[5] E. R. Laskowski, “What’s a normal resting heart rate?” Mayo Clinic, Aug.2015. [Online]. Available: http://www.mayoclinic.org/healthy-lifestyle/fitness/expert-answers/heart-rate/faq-20057979

[6] B. Midgren, “Oxygenbehandling,” Vardhandboken, May 2016. [Online]. Available:http://www.vardhandboken.se/Texter/Oxygenbehandling/Oversikt/

[7] J. Asante and J. Olsson, “Using Node-Red to Connect Patient, Staff and MedicalEquipment ,” Ph.D. dissertation, Department of Electrical Engineering, LinkopingUniversity, 2016. [Online]. Available: http://www.diva-portal.org/smash/get/diva2:949264/FULLTEXT01.pdf

[8] S. S. Chreiteh, B. Belhage, K. Hoppe, J. Branebjerg, and E. V. Thomsen, “ReflectivePulse Oximetry on Sternum,” Ph.D. dissertation, Department of Micro- andNanotechnology, Technical University of Denmark, Department of Anesthesiology,Bispebjerg University Hospital, DELTA Danish Electronics, Light Acoustics.[Online]. Available: http://www.biop.dk/biophotonics13/poster/chreiteh p.pdf

[9] S. Lopez, “Pulse oximeter fundamentals and design,” vol. 2, Nov.2012. [Online]. Available: http://www.nxp.com/assets/documents/data/en/application-notes/AN4327.pdf

[10] “MATLAB vs. Python: Top Reasons to Choose MATLAB,” Mathworks. [Online].Available: https://se.mathworks.com/products/matlab/matlab-vs-python.html#comparison table

[11] S. Hanly, “MATLAB vs Python: Speed Test for Vibration Analysis [FreeDownload],” Mide, Aug. 2016. [Online]. Available: http://blog.mide.com/matlab-vs-python-speed-for-vibration-analysis-free-download

[12] “Signal Processing (scipy.signal),” SciPy, Mar. [Online]. Available: https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#

16

Page 22: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

[13] “Scientific Computing Tools for Python,” SciPy. [Online]. Available: https://www.scipy.org/about.html

[14] “Numpy,” NumPy. [Online]. Available: http://www.numpy.org/

[15] “NumPy for Matlab users,” SciPy. [Online]. Available: https://docs.scipy.org/doc/numpy-dev/user/numpy-for-matlab-users.html

[16] “Pyplot tutorial,” matplotlib. [Online]. Available: https://matplotlib.org/users/pyplot tutorial.html

[17] “Introduction,” Matplotlib. [Online]. Available: https://matplotlib.org/

[18] “Introduction to Filter Designer.” [Online]. Available: https://se.mathworks.com/help/signal/examples/introduction-to-filter-designer.html

[19] G. Newell, “How To Use The Linux Top Command To Show RunningProcesses,” Lifewire, Feb. 2017. [Online]. Available: https://www.lifewire.com/linux-top-command-2201163

[20] C. Hoffman, “Understanding the Load Average on Linux and Other Unix-like Sys-tems,” How-To Geek, Aug. 2014. [Online]. Available: https://www.howtogeek.com/194642/understanding-the-load-average-on-linux-and-other-unix-like-systems/

[21] D.-M. Dobrea, “How to choose a filter ?” Feb. 2002. [Online]. Available:http://www.etc.tuiasi.ro/cin/Downloads/Filters/Filters.htm

[22] S. Prahl, “Tabulated Molar Extinction Coefficient for Hemoglobin in Water,” Mar.1998. [Online]. Available: http://omlc.org/spectra/hemoglobin/summary.html

[23] J. G. Kim, M. Xia, and H. Liu, “Extinction coefficients of hemoglobinfor near-infrared spectroscopy of tissue,” IEEE Engineering in Medicine andBiology Magazine, vol. 24, no. 2, p. 118, Mar. 2005. [Online]. Available:https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4504215/

[24] V. Markandey, “Pulse oximeter implementation on the tms320c5515 dsp medicaldevelopment kit (mdk),” 2010. [Online]. Available: http://www.ti.com/lit/an/sprab37a/sprab37a.pdf

[25] R. Stojanovic and D. Karadaglic, “Design of an Oximeter Based on LED-LEDConfiguration and FPGA Technology ,” Sensors, vol. 13, p. 574, Jan. 2013.[Online]. Available: http://images.biomedsearch.com/23291575/sensors-13-00574.pdf?AWSAccessKeyId=AKIAIBOKHYOLP4MBMRGQ&Expires=1495756800&Signature=yQWcPLBA2ve%2F5vKmULg66%2F06nOc%3D

[26] S. Godard, “pidstat(1) - Linux man page.” [Online]. Available: https://linux.die.net/man/1/pidstat

[27] “New product! raspberry pi zero w joins the family,” Rasp-berry Pi, Feb. 2017. [Online]. Available: https://www.raspberrypi.org/blog/raspberry-pi-zero-w-joins-family/

17

Page 23: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

[28] N. Heath, “Raspberry pi zero w: The smart person’s guide,” Tech-Public, Feb. 2017. [Online]. Available: http://www.techrepublic.com/article/raspberry-pi-zero-wireless-the-smart-persons-guide/

[29] “Welcome to the chip operating system,” Get Chip. [Online]. Available:https://docs.getchip.com/chip.html#introduction

[30] B. Bourque, “Arduino vs. raspberry pi: Mortal enemies, or best friends?” DigitalTrends, Mar. 2015. [Online]. Available: http://www.digitaltrends.com/computing/arduino-vs-raspberry-pi/

[31] O. A. Paiva and R. d. O. Moreira, “Raspberry pi: a 35-dollar device forviewing dicom images,” vol. 47, no. 2, pp. 99–100, Mar. 2014. [Online]. Available:RaspberryPi:a35-dollardeviceforviewingDICOMimages

[32] “Raspberry pi,” Adafruit. [Online]. Available: https://www.adafruit.com/categories/105

[33] S. Ferg, “Python java: a side-by-side comparison,” Python Conquers the Universe,Oct. 2009. [Online]. Available: https://pythonconquerstheuniverse.wordpress.com/2009/10/03/python-java-a-side-by-side-comparison/

[34] J. Paul, “Where is java used in real world?” Javarevisited, 2014. [Online]. Available:http://javarevisited.blogspot.se/2014/12/where-does-java-used-in-real-world.html

[35] M. Fourment and M. R. Gillings, “A comparison of common programminglanguages used in bioinformatics,” BioMEd Central, Feb. 2008. [Online]. Available:https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2267699/

[36] “Why learn c++?” Best Programming Language For, Jan. 2016. [Online].Available: http://www.bestprogramminglanguagefor.me/why-learn-c-plus-plus

[37] “Raspberry Pi Programming with MATLAB and Simulink,”MathWorks. [Online]. Available: https://se.mathworks.com/discovery/raspberry-pi-programming-matlab-simulink.html

[38] “The language of technical computing,” MathWorks. [Online]. Available:https://se.mathworks.com/products/matlab.html

[39] “Simulation and Model-Based Design,” MathWorks, 2017. [Online]. Available:https://se.mathworks.com/products/simulink.html

[40] “Python vs Matlab,” Pyzo, 2016. [Online]. Available: http://www.pyzo.org/python vs matlab.html

[41] J. M. Sachs, “Adventures in Signal Processing with Python,” Embedded Related,2013. [Online]. Available: https://www.embeddedrelated.com/showarticle/197.php

[42] “GNU Octave, Scientific Programming Language,” GNU. [Online]. Available:https://www.gnu.org/software/octave/

[43] S. P. Katru, “R vs Python vs MATLAB vs Octave vs Julia: Who is theWinner?” LinkedIn, Jul. [Online]. Available: https://www.linkedin.com/pulse/r-vs-python-matlab-octave-julia-who-winner-siva-prasad-katru

18

Page 24: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

[44] J. Kouatchou, “Comparing Python, NumPy, Matlab, Fortran, etc.” NASA, Oct.[Online]. Available: https://modelingguru.nasa.gov/docs/DOC-1762

[45] “Part II: Comparing the Speed of Matlab versus Python/Numpy,”Rob Hicks, Apr. [Online]. Available: http://rlhick.people.wm.edu/posts/comparing-the-speed-of-matlab-versus-pythonnumpy-partii.html

[46] F. Gustafsson, L. Ljung, and M. Milnert, Signal Processing. Studentlitteratur, 2010.

[47] J. G. Kim and H. Liu, “Variation of haemoglobin extinction coefficients cancause errors in the determination of haemoglobin concentration measured bynear-infrared spectroscopy,” Physics In Medicine and Biology, vol. 52, p.6295, Aug. 2007. [Online]. Available: http://biophotonics.gist.ac.kr/Publications/2007%20Physics%20Med%20Biol Variation%20of%20haemoglobin%20extinction%20coefficients%20can%20cause%20errors%20in%20the%20determination%20of%20haemoglobin%20concentration%20measured%20by%20NIRS.pdf

[48] R. M. Ram, V. K. Madhav, H. E. KRishna, R. N. Komalla, and A. K. Reddy, “ANovel Approach for Motion Artifact Reduction in PPG Signals Based on AS-LMSAdaptive Filter,” IEEE Transactions on Instrumentation and Measurement, vol. 61,no. 5, Dec. 2011. [Online]. Available: http://ieeexplore.ieee.org/document/6111474/

[49] “Heart,” Nov. [Online]. Available: https://www.nhlbi.nih.gov/health/health-topics/topics/hhw

[50] “The Respiratory System,” Jul. [Online]. Available: https://www.nhlbi.nih.gov/health/health-topics/topics/hlw/system

[51] A. Guz, Brain, breathing and breathlessness. Elsevier, Oct. 1998, vol. 119. [Online].Available: http://www.sciencedirect.com/science/article/pii/S1050641103000804

[52] T. P. in Human Biology Stanford University, “Human biology - breath-ing,” CK12, Feb. 2012. [Online]. Available: http://www.ck12.org/book/Human-Biology-Breathing/section/4.1/

[53] B. Orlenius, “Strategi for varddokumentation i region Ostergotland,”Vardgivarwebb for Region Ostergotland, Nov. 2016. [Online]. Available:http://vardgivarwebb.regionostergotland.se/Startsida/PM-medicinska-o-vardadm/PM-dokument/Ledningsstab/Strategi-for-varddokumentation-i-RO/

[54] L. Eriksson, “Las din journal via natet,” Dec. [Online]. Available: https://www.1177.se/Ostergotland/Tema/E-tjanster/Artiklar/Las-din-journal-via-natet3/?ar=True

[55] F. Ekelof and H. Engstrom, “Elektroniska journalsystem i varden. Varforkvarstar problemen?” Ph.D. dissertation, Lunds universitet, 2016. [Online].Available: http://lup.lub.lu.se/luur/download?func=downloadFile&recordOId=8879465&fileOId=8879469

[56] J. Petersen Stark, “Informationshantering inom halso- och sjukvard avseendepatientuppgifter - sarskilt om den elektroniska patientjournalen,” Ph.D.dissertation, Lunds universitet, Oct. 2016. [Online]. Available: https://www.jur.lu.se/WEB.nsf/(MenuItemByDocId)/ID94B7A189A737FCC4C1257D860028D82B/$FILE/Uppsats%20-%20Johanna%20Peterse%CC%81n%20Stark%202.pdf

19

Page 25: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

[57] “CE mark certification for Medical Devices in Europe,” LNE/G-MED, Jul. 2016. [Online]. Available: https://lne-america.com/certification/ce-marking-gain-market-access-to-europe

[58] “What is the EU/EC Declaration of Conformity for CE Marking (CE mark)? CEMarking (CE mark) EU/EC Declaration of Conformity: definition and requiredcontent (template),” CE-marking.com. [Online]. Available: http://www.ce-marking.com/required-content-for-CE-marking-EC-declaration-of-conformity.html

[59] S. M. Kennedy, “An Introduction to Pulse Oximeters: Equationsand Theory,” Ph.D. dissertation, University of Wisconsin-Madison, Apr.2015. [Online]. Available: http://www.imt.liu.se/FoUtb/kurser/oxikurs/restricted/pulseoximetersequationsandtheory-stephenkennedy.pdf

[60] S.-S. Oak and P. Aroul, “How to Design Peripheral Oxygen Saturation (SpO2) andOptical Heart Rate Monitoring (OHRM) Systems Using the AFE4403,” Mar. 2015.[Online]. Available: http://www.ti.com/lit/an/slaa655/slaa655.pdf

[61] M. Nitzan and et al., “Pulse oximetry: fundamentals and technology update,” Dove-press, pp. 231–239, Jul. 2014. [Online]. Available: http://www.imt.liu.se/FoUtb/kurser/oxikurs/restricted/pulseoximetersequationsandtheory-stephenkennedy.pdf

[62] A. Fontaine and et al., “Reflectance-based pulse oximeter for thechest and wrist,” Worcester Polytechnic Institute. [Online]. Avail-able: https://web.wpi.edu/Pubs/E-project/Available/E-project-042413-160152/unrestricted/Final MQP Report.pdf

[63] J. G. Webster, Design of Pulse Oximeters. New York: Taylor and Francis Group,1997. [Online]. Available: https://books.google.se/books?id=eQh1DQtvowUC&pg=PA98&lpg=PA98&dq=remove+dc+component+from+signal+pulse+oximeter&source=bl&ots=zuFgwnCkHF&sig=OH2sFjB5re2c4jp5IJmXk5oxUEE&hl=sv&sa=X&ved=0ahUKEwjz5qfxjdPSAhUBmBQKHf9cCMsQ6AEILjAC#v=onepage&q=remove%20dc%20component%20from%20signal%20pulse%20oximeter&f=false

[64] C. D. Mottram, Ruppel’s Manual of Pulomonary Function Testing, 10th ed.Rochester, Minnesota: Elsevier Mosby, 2013. [Online]. Available: http://www.madehow.com/Volume-6/Angioplasty-Balloon.html

[65] D. N. Townsend, “Pulse Oximetry,” 2001. [Online]. Available: https://www.robots.ox.ac.uk/∼neil/teaching/lectures/med elec/notes6.pdf

[66] A. Jubran, “Pulse oximetry,” Critical Care, vol. 19, no. 1, Jul. 2015. [Online].Available: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4504215/

[67] “Raspberry pi 3 model b,” Raspberry Pi, Feb. 2017. [Online]. Available:https://www.raspberrypi.org/products/raspberry-pi-3-model-b/

[68] N. Stuban and M. Niwayama, “Optimal filter bandwidth for pulse oximetry,”Review of Scientific Instruments, vol. 83, Oct. 2012. [Online]. Available:http://aip.scitation.org/doi/full/10.1063/1.4759491

20

Page 26: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

[69] J. Bailey, M. Fecteau, and N. L. Pendleton, “Wireless pulse oximeter,”Apr. 2008. [Online]. Available: https://web.wpi.edu/Pubs/E-project/Available/E-project-042408-101301/unrestricted/WPO MQP-Final 04242008.pdf

[70] S. J. Orfanidis, “Introduction to Signal Processing,” Ph.D. dissertation, RutgersUniversity, 2010. [Online]. Available: http://www.ece.rutgers.edu/∼orfanidi/intro2sp/orfanidis-i2sp.pdf

[71] G. Clarke, “Signal Quality Analysis in Pulse Oximetry: Modelling andDetection of Motion Artifact,” Ph.D. dissertation, Carleton Univeristy, May 2015.[Online]. Available: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.717.8516&rep=rep1&type=pdf

[72] H. Zumbahlen, Basic Linear Design. Analog Devices, Inc., 2007. [Online].Available: http://www.foxcomputer.se/Basic%20Linear%20Design.pdf

[73] S. W. Smith, The Scientist and Engineer’s Guide to Digital Sig-nal Processing. California Technical Publishing, 1997. [Online]. Avail-able: http://ft-sipil.unila.ac.id/dbooks/The%20Scientist%20and%20Engineer’s%20Guide%20to%20Digital%20Signal%20Process.pdf

[74] A. N. Rimell, N. J. Mansfield, and G. S. Paddan, “Design of digital filters forfrequency weightings (A and C) required for risk assessments of workers exposedto noise,” Industrial Health, no. 1, pp. 21–27, Jan. 2015. [Online]. Available:https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4331191/

[75] “Iir filters and fir filters,” National Instruments, Jun. 2012. [Online]. Avail-able: http://zone.ni.com/reference/en-XX/help/370858K-01/genmaths/genmaths/calc filterfir iir/

[76] S. W. Smith, The Scientist and Engineer’s Guide to Digital Signal Processing.California Technical Publishing, 1997. [Online]. Available: http://www.analog.com/media/en/technical-documentation/dsp-book/dsp book Ch19.pdf

[77] D. Robertson and J. J. Dowling, “Design and responses of Butterworth andcritically damped digital filters,” Journal of Electromyography and Kinesiology,vol. 13, Aug. 2003. [Online]. Available: http://www.sciencedirect.com/science/article/pii/S1050641103000804

[78] A. V. Oppenheim, “Resource: Signals and Sys-tems,” MIT OpenCourseWare, 2011. [Online]. Avail-able: https://ocw.mit.edu/resources/res-6-007-signals-and-systems-spring-2011/lecture-notes/MITRES 6 007S11 lec24.pdf

[79] “Plethysmographic Waveform Shapes Displayed by Pulse Oximeters,” MasimoCorporation, 2008. [Online]. Available: http://www.masimo.co.uk/pdf/whitepaper/LAB3618B.pdf

[80] W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery,Numerical Recipes in Fortran 77. Press Syndicate of the University of Cambridge,1992. [Online]. Available: http://perso.ens-lyon.fr/christophe.winisdoerffer/INTRONUM/NumericalRecipesinF77.pdf

21

Page 27: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

[81] W. Gander, U. von Matt, and J. Hrebicek, Solving Problems in ScientificComputing Using Maple and Matlab. Springer-Verlag, 1997. [Online]. Avail-able: http://www.springer.com/cda/content/document/cda downloaddocument/9783540617938-c1.pdf?SGWID=0-0-45-79520-p175272572

[82] “Python introduction,” Developers Google, Aug. 2016, this work is licensed underthe Creative Commons Attribution 3.0 Unported License. To view a copy ofthis license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter toCreative Commons, PO Box 1866, Mountain View, CA 94042, USA. [Online].Available: https://developers.google.com/edu/python/introduction

[83] M. Huenerfauth and et al., “Introduction to python,” Harvard University, Oct.2009. [Online]. Available: http://tdc-www.harvard.edu/Python.pdf

[84] S. McManus, “Top 10 programming languages ported to the raspberry pi,”Dummies. [Online]. Available: http://www.dummies.com/computers/raspberry-pi/top-10-programming-languages-ported-to-the-raspberry-pi/

22

Page 28: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

A Flow Chart

A1

Page 29: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

B Example of a guideline to choose filter

B1

Page 30: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

C The State of the Art Report

Heart and lungs

Heart and lungs work together almost without our notice and have the primary function toexchange oxygen and carbon dioxide (1), (2), (49). Deoxygenated blood travels throughthe pulmonary arteries to the lung, where the arteries release the carbon dioxide. Thepulmonary veins carry the oxygenated blood from the lungs to the heart and further outin the body (50).

The breathing is controlled by the brain under most conditions and is normally ef-fortless (51). There are inputs in other areas in the heart lung connection and one ofthem is to maintain the normalcy of our blood chemistry (1). Even though the lungshave several metabolic functions there are two primary goals. Goal one is to extract theoxygen and deliver it to the bloodstream. When we breathe the air, the lungs transferthe oxygen in the air to the blood stream and then the circulatory system transfers theoxygenated blood to each and every cell in our body (1). The oxygen can then be usedto produce energy by cellular respiration (52). Goal two is to eliminate a rest product,because when we utilize the oxygen to produce energy, the waste gas carbon dioxide willresult from our metabolic pathways and must be eliminated. Carbon dioxide is acting asa buffer, which is one of the key mechanisms to keep the blood chemistry within normallimits (1).

Health care

When a patient arrives to a health care unit, it is important to identify the patient’shealth status. This is done by using a scale that is called Modified Early WarningScore (MEWS-scale), where vital parameters such as respiratory rate, body temperature,heart rate, blood pressure and a neurological assessment (CNS, central nerve system) aremeasured and controlled (3).

MEWS - scale

The MEWS-scale gives score from 0-14 where a higher number represents a higher stateof emergency for the patient. It is important to know that a high value do not alwaysmean urgent problems of the patient, and a low value not always indicate urgent problem.If the patient went through a surgery, the assessment is done three times a day, and inother cases tentatively one to two times a day (3). Table 4 shows a scale of the scoresystem in MEWS. The different vital parameters and their normal to critical values thatare measured are also shown in table 4 (3).

C1

Page 31: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

ModifiedEarlyWarningScoreMEWSScore 3 2 1 0 1 2 3

Resp <9 9-14 15-20 21-29 ≥30

Pulse/min ≤40 41-50 51-100 101-110 111-129 ≥130

Sys.Bloodpre. ≤70 71-80 81-100 101-199 ≥200

Temp(degrees) ≤35 35.1-36 36.1-38 38.1-38.5 ≥38.5

CNS Newlyconfused

Alert Reactwhenspokento

Reactonpain

Don'treact

Table 4: MEWS-scale and score system (3)

In health care, there are not an abundance of devices that measures these vital pa-rameters that are necessary for measuring MEWS. The health professionals use a PulseOximeter, blood pressure cuff, thermometer and their own senses such as feeling, seeingand hearing to measure these parameters. Health professionals uses the MEWS-scale ormake another health assessment, but the way of documenting the score in OstergotlandsCounty is different depending on where the work is located and which journal systemthat is used (53).

Nowadays it is easier to get access to your own journal via Internet. The availableinformation in the patient journal summarizes the patient’s visit and can also containmeasurement results (54), such as MEWS. One of the main reasons for electronic journalsystems was the safety, while the paper journals was easily accessible to unauthorizedpeople. Other reasons was that referrals was send by mail, which was time consuming,measurement results was delayed and a lot of paper journals was created (55), (56).

RespiHeart

RespiHeart, see figures 8, 9 and 10, is a non-invasive, small, flexible and fully mobilemedical device that will be an alternative/complement to the traditional Pulse Oximeter.RespiHeart is under development, due to updates in software that need to be confirmedand the product still needs updates in the hardware. The device also needs to satisfy therequirements for CE marking to be able to offer the medical device within the EuropeanUnion (EU) and the European Free Trade Association (57), (58). The module is arectangular box that contains two cards: one that contains e.g. battery charger, voltageconverter and PPG amplifier and one card that contains driver to the LEDs and pre-amplifiers to the sensors.

C2

Page 32: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Figure 8: The front of RespiHeart

Figure 9: The back of RespiHeart

C3

Page 33: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Figure 10: The inside of RespiHeartPhoto by: Bengt Ragnemalm, 2006

Technique behind RespiHeart

The technique behind RespiHeart is similar to a Pulse Oximeter, but the RespiHearthas four Light Emitting Diods (LEDs), two infrared and two red, instead of two (59),(60) and four detectors instead of one as in a traditional Pulse Oximeter (59), (60), seefigure 8 and 9. The pulse oximetry technique and the RespiHeart technique uses lightto measure differences in the absorption, while oxygenated haemoglobin and not fullysaturated haemoglobin absorb different wavelengths of the lights and the reflected light,will be different (59), (61).

RespiHeart uses a technique that is called reflection-based technique. The signalsthat are obtained by the detectors are the reflected light. The light is then transformedinto alternating current (AC) and direct current (DC) (62). The AC signals will varydue to the pulsation of blood and the DC signal represents the light that is absorbedby the tissue and venous blood (63). The different lights have different wavelengths:red - 660 nm and infrared - 805 nm. The difference are due to red light passes throughHbO2 (Oxyhaemoglobin), but is absorbed by Hb (Haemoglobin) and infra red light passesthrough Hb, but is absorbed by HbO2 (62), (64).

IMSE RToS

RespiHeart uses a Real Time operating System (RToS) that is called IMSE and is designedat the department of Biomedical Engineering (IMT) at Linkoping’s University by BengtRagnemalm. IMSE is not a full-featured RToS and can therefore not be compared toother such systems. IMSE has the purpose of collecting physiological data from wirelesswearable devices and also include a protocol which have 100% control of data losses.IMSE is coded in a more basic way, which makes it easier to understand for programmerswithout any advanced knowledge. Even though IMSE is easier, this does not affect theperformance and uses also a low amount of power.

C4

Page 34: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

A Round Robin Cooperative Scheduler drives the IMSE RToS, which means that tasksare placed in a specific order and each task needs to by itself make sure that it don’texceed the maximum task time for the system. The tasks are controlled by a scheduler,which controls the type of tasks and the order they should be executed in. The scheduleris the most important part of the Kernel and the Kernel can be considered as the systemcontroller. The tasks need to be hard coded in the firmware in advance, but they arepre-defined so that the tasks are selected and programmed by the host on line.

All functions except Data Sampling, including the Kernel, which are much slower dueto that they execute asynchronously. Therefore all such functions need to be designedfor being slow and not for being Real Time.

RespiHeart vs. Pulse Oximeter

A Pulse Oximeter is a non-invasive device that measures the oxygen level in the blood(65). The technique of pulse oximetry has advanced and in critical care setting it isone of the most commonly employed monitoring modalities (66). The device consists ofLEDs, which uses different wavelengths of light: red and infrared (660-940 nm). Thelight signals have a certain frequency and are received either on the opposite side or onthe same side as the LEDs, depending on if the Pulse Oximeter is transmittance-basedor reflectance-based (62). The blood saturation value and the heart rate are shown on ascreen, either on the Pulse Oximeter or on another equipment that the Pulse Oximeteris connected to. Some Pulse Oximeters are wired, which can both be an advantage anda disadvantage. The main advantage of the wireless devices is that they are mobile antherefore can be used everywhere. The wired devices are often stored in a room or on acarriage and take up place in the patient room with its cables. The wires can thereforelead to accidents if it is not handled in correct way. Since the device always needs to beconnected to something, they are easier to find and have less risk to be lost or stolen.The wired devices can include errors that are due to the cable connections, while thewireless devices can include problems due to e.g. connecting to the device, other wirelessdevices or magnetic field that disturbs. The wired devices do also not have any batteriesto change or charge, which wireless devices have.

RespiHeart is a wireless device which uses infrared and red light to measure respirationrate, heart rate, temperature and also oxygen saturation.The difference from the usualPulse Oximeter is that the RespiHeart is placed on sternum where it registers the centralblood flow data, instead of at the finger where there is a delay of up to 45 seconds (59)from the actual heart function to the device registration. The RespiHeart also uses adifferent wavelength for the infrared light, 805 nm instead of 940 nm, as the majorityof Pulse Oximeters use. Other drawbacks with the Pulse Oximeter is that it cannotregister any data if the patient have disturbed blood flow in the fingers, e.g. low bodytemperature, shock or diseases, but also nail polish or altered skin can cause problemswith the technique. RespiHeart is better in a way that it still sends data even thoughthe patient is cooled, which the Pulse Oximeter doesn’t.

RespiHeart uses Bluetooth and WiFi connection to monitor, communicate and storedata in relation to different platforms and information systems. The data from the Respi-Heart is able to be shown on a RespiHeart sensor display, in an app on a tablet/smartphoneand in a Hospital Information System (HIS).

C5

Page 35: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Developement and goals for RespiHeart

Since the health records nowadays are developing to be more and more electronic, thisproject will examine the use of Rasberry Pi 3 Model B so data later can be stored in acloud and further send to the Electronic Health Record (EHR). To be able to do this aRaspberry Pi computer will be tested to connect to the device via Bluetooth and gatherthe data that is measured by the RespiHeart. Node-RED will be used to connect thecomputer to the EHR to be able to transfer the values in a safe and correct way, but thispart is not included in this project. The program language that will be used is primaryPython, since a Raspberry Pi works well with it and it is a simple language.

Node-RED

Node-RED is a visual tool for wiring the Internet of Things. This means that the toolis able to wire hardware devices, applications programming interface (APIs) and onlineservices together in different and new interesting ways. The editor is browser-based withseveral different nodes in a palette and therefore it is easy to wire together the flows,which then can be deployed to the runtime in a single click. Function templates andflows can be re-used due to a built-in library where it can be saved and within the texteditor a JavaScript can be created with use of a rich text editor.

Node-RED is ideal to run on a Raspberry Pi due to that the lightweight runtime isbuilt on Node.js, so it takes full advantages of its event-driven, non-blocking model. Therange of palette nodes are easy to extend so new capabilities can be added, due to thatit exists over 225,000 modules in Node’s package repository. At Node-RED’s webpage allrelevant information about the tool can be found.

Raspberry Pi 3 Model B

A Raspberry Pi is credit-card size, low-cost, high-performance computer that is createdfor educational purposes. The computer uses Linux as operating system but also freewareapplications. The developer of the computer had the purpose of stimulating the studyof computer science. Even though the computer got components, which were selectedin a way to optimize the cost, the computer is capable of accomplishing several specifictasks. The computer do not have any hard disk, instead it uses a SD card to store all thefiles and the operating system in (31). Different Operating Systems, such as Raspbianor Noobs, can be downloaded and loaded into the SD card, which is placed into thecomputer.

There are different generations of Raspberry Pi. The one that is used in this projectis the Raspberry Pi 3 Model B, which is the third generation of Raspberry Pi and it con-sists of an Operating System called Raspbian. The third generation replaces the secondgeneration and have some differences from the earlier computer. It consists of a 1.2GHz64-bit quad-core ARMv8 CPU, 802.11n Wireless LAN, Bluetooth 4.1 and Bluetooth LowEnergy (BLE). Like generation two, the third generation do also have: 1GB RAM, 4USB ports, 40 GPIO pins, full HDMI port, Ethernet port, combined 3.5mm audio jackand composite video, camera interface (CSI), display interface (DSI) micro SD card slotand VideoCore IV 3D graphics core (67). Figure 11 shows a Raspberry Pi 3 Model Bwith some of its components.

C6

Page 36: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Figure 11: A Raspberry Pi 3 Model B with some components listed

Filters

To obtain a readable signal, the measured data from RespiHeart needs to be filtered.Filters removes the noise but should retain the useful frequency components of the signal.In this way the signal-to-noise ratio is improved (68). The data that is obtained fromRespiHeart are DC and AC signals. The DC signal is untreated and the AC signal istreated in a way so the signal is inverted and the DC component is removed. The filterthat removes the DC component has similar characteristics as a first order of FIR-filter(Finite Impulse Response) (9). There are several different ways to filter data and thisproject will include evaluating different filters to filter the measured data. Two examplesof filters are: a low-pass filter which eliminates the high frequency noise (9), a high-pass filter which removes the DC component of the signal so the ADC (analog-to-digitalconverter) resolution can be taken advantage of (68), (69).

The filtering process

In signal processing the filtering is referred to change the relative amplitudes and fre-quency contents of a signal. The Fourier transform of the output is a product of inputFourier transform and frequency response of the system, therefore a appropriate frequencyresponse needs to be used for the filtering (70). It is important to retain meaningful in-formation from the signals, e.g. the ratio, even after filtration to be able to get a correctoxygen saturation value and a high signal-to-noise ratio (SNR). The oxygen saturation ismeasured by the absorption ratio, which can be calculated from Equation 4 (9).

R =

(AC660

DC660

/AC805

DC805

)(4)

The oxygen saturation can be calculated from equation 5, where εr,d = 4345, 2cm−1/M ,εr,o = 442cm−1/M , εir,d = 733, 58cm−1/M and εir,o = 840cm−1/M (22), (23).

C7

Page 37: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

SpO2 =εr,d −R ∗ εir,d

R(εir,o − εir,d)− (εr,o − εr,d)(5)

The signal-to-noise ratio (SNR) is a ratio that is important to keep high. Equation 6shows the formula to calculate SNR (71).

SNR = 20 · log10(ACIR

DCIR

/ACIRnoise

DCIRnoise

)(6)

To design a filter some parameters are important to know, see figure 12. Depending onwhich filter that will be designed, different limits needs to be set. The cut off frequencyFc is the frequency where the response changes from the pass band to the stop band.In a bandpass filter, there are two cut off frequencies to get a specific frequency range.A notch or band reject filter is the opposite of a bandpass where there are two cut offfrequencies to reject a specific frequency range (72).

Figure 12: Different filters and their characteristics

It is not easy to built the idealized filters mentioned above. Instead of an instantaneoustransition, it will be a transition region from the pass band to stop band. In figure 13more necessary parameters are introduced to be able to understand the filter design (72).

C8

Page 38: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Figure 13: Key Filter Parameters

A pass band are the frequencies of interest, where the stop band are the frequenciesthat will be set to zero everywhere. The stop band frequency Fs will be either the cut offfrequency (Fc) (73), the 3dB point or the Nyquist frequency FN , which is calculated byequation 7 (72). Pass band ripple (Amax) and minimum pass band attenuation (Amin)are the variation in pass band and the minimum signal attenuation within the stop band.All these features will not be included in all filters (72).

FNyquist =FSamplingFrequency

2(7)

FIR filter

A finite impulse response (FIR) filter have an output where the current and previous datasamples is multiplied by a set of coefficients and summing the result. In a finite period oftime the impulse response decays to zero, due to that the output values do not dependon the past output values. Equation 8 shows the value of the current output sample (74).

y[n] =M∑k=0

bk · x[n− k] (8)

The advantages with FIR filters are that they are easier to implement than a IIRfilter, they are always stable and can be designed to have a linear phase. The FIR filterssuits applications that requires a linear phase response (75), (74).

IIR filter

A infinite impulse response (IIR) filter, also called recursive filters (76), calculates thecurrent output sample value by previous output values in addition to previous inputvalues. Equation 9 shows the value of the current output sample (74).

y[n] =1

a0

[M∑j=0

bj · x[n− j]−M∑k=1

ak · y[n− k]

](9)

C9

Page 39: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

In comparison to the FIR filter, the IIR filters bypass a longer convolution. They alsorequires fewer coefficients to execute similar filtering operations as FIR, works faster andrequires less memory space. The disadvantages are that the IIR filters have a nonlinearphase response, so they suits applications where no phase information is required (75),(74).

*Butterworth filter Biomechanical data has since many years being smoothed by But-terworth low pass filter (77) . A Butterworth filter is a analog IIR filter (73) which has noripple in the pass band or stop band (72) and is therefore sometimes called a maximallyflat filter (72). There are two parameters that specified in this class, the cut off frequencyand the filter order (78). The Butterworth filter do not allow ripple in the pass band,but is optimized to provide the sharpest roll-off (drop in amplitude) without this ripple.

*Chebyshev filter The Chebyshev filter is also a analog IIR filter (73), but the tran-sition range is smaller in a Chebyshev filter than in a same order Butterworth filter. Ithave ripples in the pass band and the name comes from that the filter minimizes theheight of the maximum ripple, which is the Chebyshev criteria (72).

Both Chebyshev and Butterworth filter are designed to optimize a different perfor-mance parameter (73). By selecting the number of poles and zeros, the filter’s complexitycan be adjusted. The filter performs better with more poles in the filter, but it also re-quires more electronics (73). The Chebyshev filters are designed with a ripple in the passband of about 6%, which corresponds to 0.5 dB (73). This filter allows the pass bandripple and therefore gets and excellent roll-off (73).

*Elliptical filter An Elliptical filter, also and IIR filter is created when finite frequencytransfer function zeros are added to the poles. The Butterworth and Chebyshev filter areboth all-pole designs, so the zeros of the transfer function are at one of the two extremesof the frequency range, f = 0 or ∞ and for a low pass filter, the zeros are at f = ∞.The time response of the filter resembles the Chebyshev filter’s time response, since thepoles of the Elliptical filter are on an ellipse (72).

IIR vs FIR filtering

When a measurements between the different filter is done, there are some parameters thatcan be pointed out from both FIR and IIR filters that affects the signal. If the signal isa Notch input, the IIR filter causes a distortion in the waveform, where the notch fallsbelow the midline. The descending limb above the notch is elongated and the descendinglimb below the notch is curved (79). If the curve is a ramp input, the IIR filter also causesa distortion of the input curve. It also makes the sharp, straight descending limb as acurvilinear descending limb, which the FIR filter does not (79). When the input curveis a low heart rate input both FIR and IIR makes a distortion of the curve. The FIRfilter almost preserves the waveform integrity, but have a delay. The IIR filter changesthe notch below the midline, the descending limb above the notch is elongated and thedescending limb below the notch is shortened and curved (79). If the input curve is aasystole input, the FIR filter preserved the waveform but have a delay in the waveformappearance. The IIR filter distorts the waveform, but there is no significant delay (79).

These curves shows that the FIR filter maintains the integrity of the input curve, butdue to the increased computational requirements of the FIR filter, a delay occurs. TheIIR filter causes distortion of the curve, but no delay occur, which can be a importantfactor due to that the curves that the RespiHeart will show are curves of the heart rate(79).

C10

Page 40: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

Savitzky-Golay filter

The Savitzky-Golay filter is a low pass filter that is adapted for smoothing data (80).The average of the neighboring data is taken to obtain gi in a certain point, see equation10 (81).

gi =

nR∑n=−nL

cn · fi+n (10)

The nL is the earlier numbers to the left and and nR are the later numbers numbers tothe right (81). The speed of the Savitzky-Golay filter is one of its main advantages, dueto that the filter parameters c needs only to be evaluated once. Another main advantageis that the filter also provide smoothing without any loss of resolution (80), which is onegreat feature compared to other smoothing features. One disadvantage is how to choosethe filter parameters nL, nR and the degree M , which is not denoted in this equation (81).

Python

Python is a program language, which is dynamic and byte code-compiled (82). It is aprogram that easily interface with other language such as C, C++, Java and Fortran(83). Nowadays, many computers do already have Python installed, but otherwise theinstallation is generally easy.

The language is simple and easy to learn for beginners, while any type declarationsof variables, parameters, functions or methods in source code do not exist. Therefore thecode becomes short, flexible, but also there is no time needed to spend on checking thecode for compilation (82).

Other open source alternatives

There are several other program languages that can be used within Raspberry Pi toconnect wireless devices. Some examples are JavaScript, C++, but the name “Pi” comesfrom the Python programming language, which is therefore Python is one of the examinedlanguage in this project (84).

When the RespiHeart will arise on the market, the Raspberry Pi will need a programto start the measurement, gather the results and send the results to the correct electronichealth record via Node-RED. The program should be easily understood, efficient andsafe, while Raspberry Pi will contain and send filtered and measured patient data. Theprogram language will be evaluated in this project to fulfill the main criterion: it shouldbe fast, cheap and have low memory uptake. Node-RED will be used to send the measuredpatient data to the electronic health record, to decrease the paper documentation.

C11

Page 41: Pulse Oximetry - Divakth.diva-portal.org/smash/get/diva2:1117776/FULLTEXT01.pdf · In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is based on

TRITA 2017:68

www.kth.se