• No results found

Pulse Oximetry

N/A
N/A
Protected

Academic year: 2021

Share "Pulse Oximetry"

Copied!
41
0
0

Loading.... (view fulltext now)

Full text

(1)

IN

DEGREE PROJECT MEDICAL ENGINEERING, SECOND CYCLE, 30 CREDITS

,

STOCKHOLM SWEDEN 2017

Pulse Oximetry

Signal Processing in real time on Raspberry Pi

MALIN THUNHOLM

(2)

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 Institute of Technology for the help with my thesis report from start to end. I really appreciate all the feedback and suggestions that I got from all of you.

I would also like to thank Bengt Ragnemalm from Link¨opings University (LiU) and Region ¨Osterg¨otland, and Lars-G¨oran Lindberg from Link¨oping University (LiU) and RespiHeart 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 ¨Osterg¨otland, who introduced and followed me throughout the project with suggestions and assistance. I would also like to thank my father Peter Thunholm, who introduced, assisted and helped me with Python, but also encouraged me throughout the project.

(3)

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 intended to be used within the health care sector for combined measurements and communication on open inexpensive platforms.

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

(4)

Sammanfattning

Detta examensarbete introducerar l¨asaren till RespiHeart, en ny tr˚adl¨os produkt som ¨

ar under utveckling. RespiHeart ¨ar ett komplement/alternativ till den nuvarande Pul-soximetern och ¨ar t¨ankt att anv¨andas inom sjukv˚arden f¨or analys, kommuniakation och kombinerade m¨atningar p˚a ¨oppna billiga plattformar.

Detta project utv¨arderar interaktionen mellan RespiHeart och en Raspberry Pi 3 Model B f¨or att unders¨oka om datorn ¨ar kapabel till att hantera datan fr˚an RespiHeart samt g¨ora signal processing i real tid.

(5)

Contents

1 Introduction 1 1.1 Aim . . . 1 1.2 Limitations . . . 1 2 Background 2 2.1 Python vs Matlab . . . 2

2.1.1 Signal processing with Python vs Matlab . . . 2

2.2 Computer workload . . . 2

3 Methods 4 3.1 Connection between Raspberry Pi and RespiHeart . . . 4

3.2 Data Measurement . . . 5

3.3 Signal Processing . . . 5

3.3.1 Criteria for choice of filter . . . 6

3.3.2 Oxygen saturation and SNR . . . 6

3.4 The process load on the CPU . . . 7

4 Result 8 4.1 Signal processing . . . 9

4.2 Process time for different order and filter . . . 10

4.3 Changes in SNR and oxygen saturation . . . 10

5 Discussion 11 5.1 Alternatives to Raspberry Pi 3 Model B . . . 11

5.2 Alternatives to Python . . . 11

5.2.1 Real time plotting . . . 12

5.3 Signal Processing . . . 13

5.4 Other potential errors . . . 13

6 Conclusions 15 6.1 Future work . . . 15

Bibliography 16

Appendix A Flow Chart A1

Appendix B Example of a guideline to choose filter B1

(6)

1

Introduction

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

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

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

RespiHeart is a wireless Bluetooth device that is a product under development, which would be a complement/alternative to the traditional Pulse Oximeter. The device is placed on sternum and measures oxygen saturation, heart rate, respiratory rate and temperature. RespiHeart does not handle signal processing by its own yet and therefore Raspberry Pi needs to take care of this. In this case the execution time is critical for the system 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 is to evaluate if Raspberry Pi 3 Model B can interact well with RespiHeart. A secondary goal is to evaluate some aspects of the signal processing involved. A filter will be evaluated in Matlab and then implemented in Python and executed and tested on the Raspberry Pi 3.

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

1.2

Limitations

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

(7)

2

Background

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

RespiHeart’s systems handles the sampling when it is started and sends output in a digital form of bytes. Data is stored in a specific way by RespiHeart: first a three byte long 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, while the AC signals are inverted and filtered with a first order of FIR filter to remove the DC component.

In this project a Raspberry Pi with Raspbian Jessie with Pixel was used. This project is 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 between RespiHeart 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 is built-in into the program, however in Python you have to learn which packages to use for what. Matlab also has better documentation and visualizing interface. At Matlab’s homepage a test between different programs in both Matlab and Python are shown, to show which of these programs that is the fastest one. Python is faster when it comes to computing and plot Fast Fourier Transform (FFT) and plot it. However, Matlab is faster in computing Root Mean Square (RMS) and plot it. The results of Python depends on which library that is used (10).

A speed test between the two programs has been made by Hanly where the different interfaces 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 filter design tools including some filtering functions (12). The SciPy Stack contains a plotting package called Matplotlib and NumPy (13). Numpy and SciPy have similarities with Matlab but also a lot of differences, while Numpy and SciPy are packages created for numerical 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

(8)
(9)

3

Methods

In this project RespiHeart is connected to Raspberry Pi via Bluetooth. This was issued via the program language Python. An overview can be seen in Figure 1 where the grey part 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 the Raspberry Pi as a master. An interaction between the master and the slave, a handshake needs to be performed. A handshake between the devices was made by that certain commands was sent to the slave. The slave (RespiHeart) uses the IMSE RToS, a real time operating system, which contains information about how the commands should be submitted.

3.1

Connection between Raspberry Pi and RespiHeart

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

Table 1: Command descriptions

Command Description Hexadecimal code

IMSE ACK CMD Header (3 bytes) + CRC + Cmd + status 010003000100

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

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

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

IMSE SYSTEM SETTINGS CMD

Header (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.

(10)

When a command was received by RespiHeart, an ”Acknowledge” and a ”Ready” re-sponse was sent back. The rere-sponse indicates that there were no errors and the system was ready for next command. When the master received the message an acknowledge was sent to the slave to indicate that the message was understood and no errors occurred. An example can be seen in Figure 2. The time for the connection was evaluated and includes five seconds delay as total, due to the fact that RespiHeart can not handle the settings that 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 from the terminal in Raspberry Pi. Later the script will be implemented as a Graphical User Interface (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. The commands 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. The output was stored in a .bin file and then processed to remove the header and retain only the 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 was copied from Raspberry Pi to the computer that uses Matlab to find a filter. When a suitable 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, infrared and red values are stored. The filters examined were:

• Lowpass filter – FIR filter – IIR filter

(11)

• 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 and stopband attenuation were evaluated in Matlab. Changes in signal-to-noise ration (SNR) and oxygen saturation were also evaluated. All filters were made by filterDesigner and the built in functions. The Fast Fourier Transform (FFT) was investigated, in order to retain as much information as possible after the signal processing. In Python, the numerical toolbox SciPy includes Numpy and Matplotlib. Numpy reshaped the output to a matrix and later plotted it with the use of Matplotlib. The scipy.signal was used to import suitable filters.

3.3.1 Criteria for choice of filter

Filters need specific characteristics to preserve information from the signal, contribute to high SNR but also remove noise and avoid aliasing. To be able to choose filters that are sufficient, criteria needs to be defined. A guideline how to choose filter can be found in 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 signal processing. The first criterion is that the system needs to be fast. The second criterion to be 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 new data that should be measured and sent further to the EHR, the memory uptake needs to be low. The filter should also be fast, have a minimum impact on the oxygen saturation and a high SNR should be provided. Hence, it should be a low pass filter or bandpass filter, since the frequency of beats per minutes are BPM/60 Hz, where BPM lies between 60-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 was plotted. A specific part of the curve was chosen due to noise, disturbance or errors as a result of unsuitable settings. That part of the curve was evaluated through different kind of filters with different kind of cut off frequency, stopband frequency, passband ripple and 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

(12)

R = AC660 DC660  AC805 DC805  (2) The SNR was calculated through Matlab’s own built-in function and was calculated as Equation 3. SN R = 20 · log10 ACIR DCIR  ACIRnoise DCIRnoise  (3)

3.4

The process load on the CPU

(13)

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, where the 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 Golay filter

(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 Golay filter

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

(14)

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-240 BPM. In this project a second order lowpass Butterworth filter, with a cutoff frequency at 4 Hz and a sampling frequency at 100 Hz, followed by a first order Savitzky Golay filter with a framelength of 41, was used.

The average time for the connection after 10 samples was 11,895 seconds with built-in delays 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 Raspberry Pi and RespiHeart, after the settings were set and after total sampling

CPU Load Average over one minute, %

Connection 11,4

Settings 10,1

Total 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 everything was notices was 29 % with a fourth order Butterworth filter, slightly lower than a second order.

The first filter was changed from lowpass Butterworth filter, to lowpass Elliptical filter with an order of two. The total load average over one minute was 37.3 %, which is slightly larger than the Butterworth filters with different order. The Figures 5a and 5b shows that 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 more load than Butterworth filter. The different filters implemented in Matlab are shown in Figure 6 and 7.

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

(15)

(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 five samples. The average time can be found in Table 3.

Table 3: Average time for different filters

Filter Type Average Time Butterworth 2th order 10,6 ms

Butterworth 4th order 11,1 ms Elliptical 2th order 30,3 ms

4.3

Changes in SNR and oxygen saturation

(16)

5

Discussion

The first aim of the project was to see how a Raspberry Pi 3 Model B interacts with RespiHeart in real time. The load average never raises to an unmanageable level and the process time for the different filters is low. Raspberry pi 3 Model B is a quad core computer and therefore the load average is four times lower than the obtained results. The load average is over one minute and therefore the first 48 seconds of the load average fore the filters includes the connection and setting part, since this interaction took almost 12 seconds. As can be seen in Figures 3b, 4b and 5b peaks are defined in that region, which may depend on the connection and setting interaction. These peaks may also depend on that Raspberry Pi handles its own buffer. An alternative is to study load average with the 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, with wireless LAN and Bluetooth 4.0 to a price of 90 Swedish crowns. The size and weight is just 65mm x 30mm x 5mm and 9g, unlike the Raspberry Pi 3 Model B which has the size of a credit card and hence almost twice as big. Since this new product uses an equal chip as Raspberry Pi 3 Model B, Bluetooth 4.0 is available, which is why this smaller and cheaper Raspberry Pi Zero W can be a competitor. But an important feature for this project was the speed of the computer and the Raspberry Pi 3 Model B is the fastest one (27), (28).

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

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

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

5.2

Alternatives to Python

(17)

efficient language used in operating systems drivers. However, on the other hand Python is usable. The load average and the memory usage may be affected depending on which program you use. Java is faster but uses more space than Python and C++ (33). Java has advantages when programming applications for Android and many web applications are 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 of the 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 faults in 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 plottprocess-ing. Python has plottprocess-ing utilities similar to Matlab and Octave. Note that Matlab itself can not run on Raspberry Pi, it can only communicate via a support 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 licenses and toolboxes. The toolboxes and other products needs to be added to the cost, while most of Pythons libraries are free.

The reasons to use Matlab over Python are that the matrix math is fast, the debugger is good and it has special syntax to facilitate numerical analysis. The Simulink, a block diagram environment for multidomain simulation and Model-Based Design (39), has no real 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 and control 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 be installed in Python (40).

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

(18)

however Matlab has more tools than both Python and Octave. Since its free it is a better alternative 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 to implement a perfect filter, due to the different parameters that need to be set. The filter order 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 was implemented in Python. The signal processing worked in a fast and good way and the results form Section 4.2 showed that a slightly raised order did not impact in a negative way on the time. The Elliptical filter was slightly slower and had a total load average slightly higher than the Butterworth filters. Elliptical filters change the appearance of the curve, which Butterworth filters does not, see Figures 6 and 7. The Savitzky-Golay filter was used to smooth the signal and decrease the amount of peaks when calculating the heart rate.

Other filters such as FIR filters, take longer time to execute than IIR filters and IIR filter requires less memory space. If the goal is to study the curve, FIR filters preserves the 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 may have shown better results, since noise and disturbance can occur at lower frequencies as well. However, the SNR showed low values and therefore a Butterworth lowpass filter was 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. This fact 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. Same demand 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 therefore the values may have been changed. Unfortunately small changes in the extinction coef-ficients can cause significant errors in calculating oxygen saturation (47). This resulted in 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 .bin file, 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 are within 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 changed manually, 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 therefore difficult to set specific SNR value.

(19)
(20)

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 and interaction 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 on which 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 high cost, 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 is why Python is a working program language for these tasks.

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

6.1

Future work

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

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

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

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

(21)

Bibliography

[1] J. R. Goodman, “Importance of oxygen: The heart lung connection,” My Prime Time 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,” V˚ardgivarwebb f¨or Region Osterg¨¨ otland, 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, San Jose 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,” V˚ardhandboken, 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 Medical Equipment ,” Ph.D. dissertation, Department of Electrical Engineering, Link¨oping University, 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, “Reflective Pulse Oximetry on Sternum,” Ph.D. dissertation, Department of Micro- and Nanotechnology, 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 [Free Download],” Mid´e, Aug. 2016. [Online]. Available: http://blog.mide.com/ matlab-vs-python-speed-for-vibration-analysis-free-download

(22)

[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 Running Processes,” 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 hemoglobin

for near-infrared spectroscopy of tissue,” IEEE Engineering in Medicine and Biology 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 medical development 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-LED Configuration 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

(23)

[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?” Digital Trends, 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 for viewing 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 programming

languages 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/

(24)

[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 can cause errors in the determination of haemoglobin concentration measured by near-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, “A Novel Approach for Motion Artifact Reduction in PPG Signals Based on AS-LMS Adaptive 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 f¨or v˚arddokumentation i region Osterg¨¨ otland,” V˚ardgivarwebb f¨or Region Osterg¨¨ otland, Nov. 2016. [Online]. Available: http://vardgivarwebb.regionostergotland.se/Startsida/PM-medicinska-o-vardadm/ PM-dokument/Ledningsstab/Strategi-for-varddokumentation-i-RO/

[54] L. Eriksson, “L¨as din journal via n¨atet,” Dec. [Online]. Available: https://www.1177. se/Ostergotland/Tema/E-tjanster/Artiklar/Las-din-journal-via-natet3/?ar=True [55] F. Ekel¨of and H. Engstr¨om, “Elektroniska journalsystem i v˚arden. Varf¨or

kvarst˚ar problemen?” Ph.D. dissertation, Lunds universitet, 2016. [Online]. Available: http://lup.lub.lu.se/luur/download?func=downloadFile&recordOId= 8879465&fileOId=8879469

(25)

[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)? CE Marking (CE mark) EU/EC Declaration of Conformity: definition and required content (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: Equations and 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) and Optical 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 the

chest 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/

(26)

[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, Rutgers University, 2010. [Online]. Available: http://www.ece.rutgers.edu/∼orfanidi/ intro2sp/orfanidis-i2sp.pdf

[71] G. Clarke, “Signal Quality Analysis in Pulse Oximetry: Modelling and Detection 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 for frequency weightings (A and C) required for risk assessments of workers exposed to 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 and critically 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,” Masimo Corporation, 2008. [Online]. Available: http://www.masimo.co.uk/pdf/whitepaper/ LAB3618B.pdf

(27)

[81] W. Gander, U. von Matt, and J. Hrebicek, Solving Problems in Scientific Computing 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 under the Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative 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

(28)
(29)
(30)

C

The State of the Art Report

Heart and lungs

Heart and lungs work together almost without our notice and have the primary function to exchange oxygen and carbon dioxide (1), (2), (49). Deoxygenated blood travels through the pulmonary arteries to the lung, where the arteries release the carbon dioxide. The pulmonary veins carry the oxygenated blood from the lungs to the heart and further out in 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 of them is to maintain the normalcy of our blood chemistry (1). Even though the lungs have several metabolic functions there are two primary goals. Goal one is to extract the oxygen and deliver it to the bloodstream. When we breathe the air, the lungs transfer the oxygen in the air to the blood stream and then the circulatory system transfers the oxygenated blood to each and every cell in our body (1). The oxygen can then be used to 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 will result from our metabolic pathways and must be eliminated. Carbon dioxide is acting as a buffer, which is one of the key mechanisms to keep the blood chemistry within normal limits (1).

Health care

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

MEWS - scale

(31)

Modified Early Warning Score MEWS Score 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. Blood pre. ≤ 70 71-80 81-100 101-199 ≥ 200 Temp (degrees) ≤ 35 35.1-36 36.1-38 38.1-38.5 ≥ 38.5 CNS Newly confused Alert React when spoken to React on pain Don't react

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 Pulse Oximeter, blood pressure cuff, thermometer and their own senses such as feeling, seeing and hearing to measure these parameters. Health professionals uses the MEWS-scale or make another health assessment, but the way of documenting the score in ¨Osterg¨otlands County is different depending on where the work is located and which journal system that is used (53).

Nowadays it is easier to get access to your own journal via Internet. The available information in the patient journal summarizes the patient’s visit and can also contain measurement results (54), such as MEWS. One of the main reasons for electronic journal systems was the safety, while the paper journals was easily accessible to unauthorized people. 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

(32)

Figure 8: The front of RespiHeart

(33)

Figure 10: The inside of RespiHeart Photo by: Bengt Ragnemalm, 2006

Technique behind RespiHeart

The technique behind RespiHeart is similar to a Pulse Oximeter, but the RespiHeart has 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), see figure 8 and 9. The pulse oximetry technique and the RespiHeart technique uses light to measure differences in the absorption, while oxygenated haemoglobin and not fully saturated 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 signals that are obtained by the detectors are the reflected light. The light is then transformed into alternating current (AC) and direct current (DC) (62). The AC signals will vary due to the pulsation of blood and the DC signal represents the light that is absorbed by 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 through HbO2(Oxyhaemoglobin), but is absorbed by Hb (Haemoglobin) and infra red light passes through Hb, but is absorbed by HbO2 (62), (64).

IMSE RToS

(34)

A Round Robin Cooperative Scheduler drives the IMSE RToS, which means that tasks are placed in a specific order and each task needs to by itself make sure that it don’t exceed 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 scheduler is the most important part of the Kernel and the Kernel can be considered as the system controller. The tasks need to be hard coded in the firmware in advance, but they are pre-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 due to that they execute asynchronously. Therefore all such functions need to be designed for 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 is one of the most commonly employed monitoring modalities (66). The device consists of LEDs, which uses different wavelengths of light: red and infrared (660-940 nm). The light signals have a certain frequency and are received either on the opposite side or on the same side as the LEDs, depending on if the Pulse Oximeter is transmittance-based or reflectance-based (62). The blood saturation value and the heart rate are shown on a screen, either on the Pulse Oximeter or on another equipment that the Pulse Oximeter is connected to. Some Pulse Oximeters are wired, which can both be an advantage and a disadvantage. The main advantage of the wireless devices is that they are mobile an therefore can be used everywhere. The wired devices are often stored in a room or on a carriage and take up place in the patient room with its cables. The wires can therefore lead to accidents if it is not handled in correct way. Since the device always needs to be connected 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 the wireless devices can include problems due to e.g. connecting to the device, other wireless devices or magnetic field that disturbs. The wired devices do also not have any batteries to change or charge, which wireless devices have.

RespiHeart is a wireless device which uses infrared and red light to measure respiration rate, heart rate, temperature and also oxygen saturation.The difference from the usual Pulse Oximeter is that the RespiHeart is placed on sternum where it registers the central blood 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 a different wavelength for the infrared light, 805 nm instead of 940 nm, as the majority of Pulse Oximeters use. Other drawbacks with the Pulse Oximeter is that it cannot register any data if the patient have disturbed blood flow in the fingers, e.g. low body temperature, shock or diseases, but also nail polish or altered skin can cause problems with the technique. RespiHeart is better in a way that it still sends data even though the patient is cooled, which the Pulse Oximeter doesn’t.

(35)

Developement and goals for RespiHeart

Since the health records nowadays are developing to be more and more electronic, this project will examine the use of Rasberry Pi 3 Model B so data later can be stored in a cloud and further send to the Electronic Health Record (EHR). To be able to do this a Raspberry Pi computer will be tested to connect to the device via Bluetooth and gather the data that is measured by the RespiHeart. Node-RED will be used to connect the computer to the EHR to be able to transfer the values in a safe and correct way, but this part is not included in this project. The program language that will be used is primary Python, 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 tool is able to wire hardware devices, applications programming interface (APIs) and online services together in different and new interesting ways. The editor is browser-based with several 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 and flows can be re-used due to a built-in library where it can be saved and within the text editor 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 is built on Node.js, so it takes full advantages of its event-driven, non-blocking model. The range of palette nodes are easy to extend so new capabilities can be added, due to that it exists over 225,000 modules in Node’s package repository. At Node-RED’s webpage all relevant 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 created for educational purposes. The computer uses Linux as operating system but also freeware applications. The developer of the computer had the purpose of stimulating the study of computer science. Even though the computer got components, which were selected in a way to optimize the cost, the computer is capable of accomplishing several specific tasks. The computer do not have any hard disk, instead it uses a SD card to store all the files and the operating system in (31). Different Operating Systems, such as Raspbian or Noobs, can be downloaded and loaded into the SD card, which is placed into the computer.

(36)

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 from RespiHeart are DC and AC signals. The DC signal is untreated and the AC signal is treated in a way so the signal is inverted and the DC component is removed. The filter that 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 this project will include evaluating different filters to filter the measured data. Two examples of 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-digital converter) 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 input Fourier transform and frequency response of the system, therefore a appropriate frequency response 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 correct oxygen saturation value and a high signal-to-noise ratio (SNR). The oxygen saturation is measured by the absorption ratio, which can be calculated from Equation 4 (9).

(37)

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 6 shows the formula to calculate SNR (71).

SN R = 20 · log10  ACIR DCIR  ACIRnoise DCIRnoise  (6) To design a filter some parameters are important to know, see figure 12. Depending on which filter that will be designed, different limits needs to be set. The cut off frequency Fc 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 off frequencies to reject a specific frequency range (72).

Figure 12: Different filters and their characteristics

(38)

Figure 13: Key Filter Parameters

A pass band are the frequencies of interest, where the stop band are the frequencies that will be set to zero everywhere. The stop band frequency Fs will be either the cut off frequency (Fc) (73), the 3dB point or the Nyquist frequency FN, which is calculated by equation 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).

FN yquist =

FSamplingF requency

2 (7)

FIR filter

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

y[n] = M X

k=0

bk· x[n − k] (8)

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

IIR filter

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

(39)

In comparison to the FIR filter, the IIR filters bypass a longer convolution. They also requires fewer coefficients to execute similar filtering operations as FIR, works faster and requires less memory space. The disadvantages are that the IIR filters have a nonlinear phase 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 ButBut-terworth filter is a analog IIR filter (73) which has no ripple in the pass band or stop band (72) and is therefore sometimes called a maximally flat filter (72). There are two parameters that specified in this class, the cut off frequency and 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. It have ripples in the pass band and the name comes from that the filter minimizes the height 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 complexity can 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 pass band of about 6%, which corresponds to 0.5 dB (73). This filter allows the pass band ripple and therefore gets and excellent roll-off (73).

*Elliptical filter An Elliptical filter, also and IIR filter is created when finite frequency transfer function zeros are added to the poles. The Butterworth and Chebyshev filter are both all-pole designs, so the zeros of the transfer function are at one of the two extremes of 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 the poles 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 that can be pointed out from both FIR and IIR filters that affects the signal. If the signal is a Notch input, the IIR filter causes a distortion in the waveform, where the notch falls below the midline. The descending limb above the notch is elongated and the descending limb below the notch is curved (79). If the curve is a ramp input, the IIR filter also causes a distortion of the input curve. It also makes the sharp, straight descending limb as a curvilinear descending limb, which the FIR filter does not (79). When the input curve is a low heart rate input both FIR and IIR makes a distortion of the curve. The FIR filter almost preserves the waveform integrity, but have a delay. The IIR filter changes the notch below the midline, the descending limb above the notch is elongated and the descending limb below the notch is shortened and curved (79). If the input curve is a asystole input, the FIR filter preserved the waveform but have a delay in the waveform appearance. The IIR filter distorts the waveform, but there is no significant delay (79).

(40)

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 equation 10 (81). gi = nR X n=−nL cn· fi+n (10)

The nLis the earlier numbers to the left and and nRare the later numbers numbers to the right (81). The speed of the Savitzky-Golay filter is one of its main advantages, due to that the filter parameters c needs only to be evaluated once. Another main advantage is that the filter also provide smoothing without any loss of resolution (80), which is one great feature compared to other smoothing features. One disadvantage is how to choose the filter parameters nL, nRand 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 a program that easily interface with other language such as C, C++, Java and Fortran (83). Nowadays, many computers do already have Python installed, but otherwise the installation is generally easy.

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

Other open source alternatives

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

(41)

TRITA 2017:68

References

Related documents

​ 2 ​ In this text I present my current ideas on how applying Intersectional Feminist methods to work in Socially Engaged Art is a radical opening towards new, cooperative ​ 3 ​

The thesis includes a study assessing how to optimise screening performance (I), establishing normal values of peripheral perfusion index in 10 000 newborns with a comparison with

In cells containing both the plasmid and the small antisense RNA (Fig. 8 middle and bottom), the results revealed a significant decrease in the fused lacZ- P450 expression in

On the other hand, variation provides an opportunity to experience this distinction in language, as it becomes apparent to the child that not all string instruments

This project explores game development using procedural flocking behaviour through the creation of a sheep herding game based on existing theory on flocking behaviour algorithms,

While trying to keep the domestic groups satisfied by being an ally with Israel, they also have to try and satisfy their foreign agenda in the Middle East, where Israel is seen as

This study aimed to validate the use of a new digital interaction version of a common memory test, the Rey Auditory Verbal Learning Test (RAVLT), compared with norm from

We could develop ranking maps for any urban environment that can help us see the bigger picture of instant highlights and disadvantages of a certain space and see how can we improve