74
Panic Attack Monitor Engineering a device to automatically detect physical symptoms of panic attacks and contact help. Tamsin Edwards Lambourne 2-13-2017

Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

Embed Size (px)

Citation preview

Page 1: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

Panic Attack

Monitor Engineering a device to automatically detect physical symptoms of panic

attacks and contact help.

Tamsin Edwards Lambourne

2-13-2017

Page 2: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 1

TABLE OF CONTENTS

Acknowledgements ....................................................................................................................................................... 2

Abstract ......................................................................................................................................................................... 3

Literature Review .......................................................................................................................................................... 4

Introduction ............................................................................................................................................................... 4

Problems Within Current System .............................................................................................................................. 4

Symptoms .................................................................................................................................................................. 4

Wearable Technology ................................................................................................................................................ 5

Measurement ............................................................................................................................................................ 6

Engineering Plan ........................................................................................................................................................ 9

Methodology ............................................................................................................................................................... 11

Materials .................................................................................................................................................................. 11

Procedure ................................................................................................................................................................ 11

Results ......................................................................................................................................................................... 13

Pulse Sensor ............................................................................................................................................................. 13

Detection Accuracy .................................................................................................................................................. 15

Cost .......................................................................................................................................................................... 15

Scoring Matrix .......................................................................................................................................................... 15

Analysis ........................................................................................................................................................................ 17

Conclusions .................................................................................................................................................................. 18

References ................................................................................................................................................................... 19

Appendices .................................................................................................................................................................. 21

Appendix A. Pulse Sensor Unmodified Code ........................................................................................................... 21

Appendix B. Pulse Sensor Unmodified vs. Fitbit Full Data ....................................................................................... 23

Appendix C. Pulse Sensor Modified Code 1.0 .......................................................................................................... 24

Appendix D. Pulse Sensor Unmodified vs Modified 1.0 Full Data ........................................................................... 27

Appendix E. Pulse Sensor Modified Code 2.0 .......................................................................................................... 29

Appendix F. Pulse Sensor Unmodified vs. Modified 2.0 Full Data ........................................................................... 42

Appendix G. Detection Accuracy Full Data .............................................................................................................. 44

Appendix H. Application Code ................................................................................................................................. 45

Appendix I. Poster Information ............................................................................................................................... 55

Appendix J. Bakcground Information Notes ............................................................................................................ 63

Page 3: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 2

ACKNOWLEDGEMENTS

I would like to thank Professor Marc Tetel of Wellesley College for his assistance with

understanding the symptoms and sensors to use with this project, my parents for their patience

and assistance with the financial aspects of the project, and my advisor, Mrs. Wildfong, for her

weekly patience with my project.

Page 4: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 3

ABSTRACT

Although many Americans live with panic disorders, no devices automatically call for

assistance during a panic attack. Common symptoms of panic attacks include increased heart

rate and shaking in extremities, which are both measurable using commercially available

sensors. The goal of this project was to engineer a device to detect the physical symptoms of

panic attacks and automatically contact a trusted individual. To create this device, a base

version of a smartphone application was created and connected to a heart rate sensor. A device

containing this sensor was built and the sensor was tested again to ensure accuracy was

maintained. At this point, the app was updated to detect increased heart rates. The detection

accuracy of the device when slowly increasing, rapidly increasing, and resting heart rates were

tested was 88%. The device was able to detect and react to a typical symptom of a panic attack

and notify a trusted individual by a phone call. This device could help many of the six million

American adults currently living with panic disorders efficiently get the assistance they need.

Page 5: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 4

LITERATURE REVIEW

INTRODUCTION

Six million adults in America currently live with a panic disorder (“Facts & statistics”,

2016). Panic disorders are a subset of anxiety disorders, which affect 40 million adults in the

United States alone (“Facts & statistics”, 2016). These disorders can stem from a wide variety of

sources including genetics, personality, life events, and brain chemistry (“Facts & statistics”,

2016). In addition, panic disorders very often coexist with major depression, which can cause

other health issues (“Facts & Statistics”, 2016). The detection of one disease would help

minimize the negative physical effects the patient experiences overall.

The physical harm caused by panic disorders and their resultant attacks is something

that can be lessened with more accurate and efficient detection of panic attacks. A device

containing sensors that detect some of the various symptoms of panic attacks would increase

detection speed and allow people living with panic disorders to get the help that they need in

an efficient manner. Several common symptoms of panic attacks are measurable using heart

rate monitors, accelerometers, and other sensors. By linking these sensors to an app on a

smartphone and sending data directly from the device to the app, the device can instantly

connect a patient to the people responsible for their care and allow the patient to receive help

quickly.

PROBLEMS WITHIN CURRENT SYSTEM

Currently, doctors rely on patient self-reporting to diagnose panic disorders and detect

panic attacks (Fleet, 1997). This reliance on self-reporting means that people experiencing

these attacks must inform medical professionals or other people responsible for their care

themselves, which may not be possible in the midst of a panic attack. Waiting for help can be

detrimental to the patient’s health due to the symptoms associated with panic attacks.

Additionally, self-reporting is not the most accurate form of detection because people may

exaggerate or underestimate their symptoms, which could lead to misdiagnosis. Because much

of the current system for panic attack detection relies on patient self-reporting, it is slow, and

patients must call or get to someone who can help on their own.

SYMPTOMS

Panic disorders and attacks come with many physical and cognitive symptoms. These

symptoms can appear in various combinations and range in severity depending on the patient

(Fleet, 1997). For example, nausea is something that cannot be directly detected with current

technology; however, heart rate is something that is easily measurable with commercially

available sensors (Mio Global, n.d.). Panic disorder diagnosis and treatment continues to rely on

Page 6: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 5

self-report data because of the variety of symptoms and the challenges inherent in quantifying

the severity of those symptoms.

PHYSICAL

Many physical symptoms are associated with panic disorders and attacks, including a

sudden increase in heart rate and skin conductance (Hamm et al., 2015). These symptoms

alone are not enough to detect a panic attack because there are many other possible causes of

increased heart rate and skin conductance (B. Brown, personal communication, 2016). Other

symptoms such as trembling (Fleet, 1997) can be used to reduce the number of probable

causes; however, only four of thirteen possible symptoms are required at one time to conclude

that a patient is experiencing a panic attack (Hamm et al., 2015). Other possible physical

symptoms are chest pain, shortness of breath, choking, nausea, and flushes or chills (Fleet,

1997). Not all of these symptoms must appear at once, and presentation of symptoms may vary

from patient to patient (Fleet, 1997).

COGNITIVE

As for the cognitive side of panic attacks, patients often report experiencing fear of

death or losing touch with reality (Fleet, 1997). Additionally, there is a consistent fear of

subsequent panic attacks occurring (Hamm et al., 2015) which can interrupt daily life and

patient functionality depending on the severity of the disorder. Although cognitive symptoms

are not easily measurable using physical means, they are still an important part of the diagnosis

of a panic disorder.

MEASURABLE

Although many physical symptoms of panic attacks exist, not all are measurable. The

measurable physical symptoms of panic attacks include increased heart rate, respiration rate,

skin conductance, and trembling (Hamm et al., 2015). Heart rate and trembling are easily

measurable using commercially available sensors. Respiration rate and skin galvanization, or

the amount a person is sweating, are also measurable with more complex sensors (Dr. Tetel,

M., personal communication, November 15, 2016).

WEARABLE TECHNOLOGY

SAFETY

A common concern about wearable technology is that radiation is being released from

devices that are being placed close to important organs, such as the heart or brain. However,

this claim lacks scientific basis when made about modern devices. While it is true that older

Page 7: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 6

technology required a distance between the device and the body for health reasons, recently

developed technology no longer requires distance. (Mertz, 2016). This new technology has

allowed the wearable technology industry to take off and become a major part of life for many

people in America and the world.

MEASUREMENT

Wearable technology also allows for easy measurement of the wearer’s physical

reactions. Sensors can help diagnose and monitor medical problems to minimize doctor’s office

visits.

SENSORS

Several sensors are available to monitor and record data that can be used to detect

medical problems by responding to physical stimuli (Dictionary, n.d.). Sensors can measure a

wide variety of things, such as the body’s reaction to its environment or the amount of sunlight

in an area. The topic of sensors covers an immense amount of information.

HEART RATE MONITOR

Figure 1. A chest strap style heart rate monitor. Although more accurate than other heart rate monitor locations, users typically

complain about the comfort or restrictiveness of chest straps. The monitoring system is typically similar to other monitoring

locations, but it was more accurate prior to the development of algorithms to remove the “noise” generated by the wearer’s

movements and environment. (Mio Global).

Heart rate monitors come in many different types. The most accurate monitors are

typically chest-based because there is less interference from outside sources than on a wrist or

other body part. However, recent algorithms manage to cancel out much of that interference,

allowing for accurate readings from monitors worn on patients’ wrists or other body parts

(Rettner, 2014). Non-chest-based monitors tend to use light in order to detect heart rate. This

Page 8: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 7

method is called Infrared Heart Rate Monitoring, which uses the reflection of infrared light in

order to detect the patient’s pulse and track the patient’s heart rate. One application of

Infrared Heart Rate Monitoring is Pulse Sensor, an open source hardware heart rate sensor for

Arduino boards or other microcontrollers, which uses an LED to track fluctuation in the signal

created by blood pumping through tissue (Murphy & Gitman, 2016).

Figures 2 & 3. These pictures show the front side (left) and back side (right) of the Pulse Sensor. The LED component is attached

on the rear, allowing the LED itself to be the only thing on the front side and make the sensor as slim and compact as possible

while still managing to contain all the required components for accurate readings. (Murphy & Gitman, 2016).

ACCELEROMETER

Figure 4. A SunFounder brand digital accelerometer ADXL345 module. This accelerometer detects motion in three dimensions

along three axes, x, y, and z. It measures both the constant acceleration due to gravity and any sudden acceleration which

results from motion or shock to the sensor. (Amazon.com, n.d.).

Page 9: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 8

Accelerometers can be used in several ways to track the motion of various body parts.

For example, a team developed a watch which used accelerometers and gyroscopes in order to

measure heart rate and respiration rate (Hernandez, 2015). For detecting panic attacks, an

accelerometer would be useful for detecting shaking or trembling in the patient’s arms or

hands.

SKIN CONDUCTANCE

During a panic attack, a patient can experience sweating. This dampens fingers, which

allows the skin to conduct more electricity (Dr. M. Tetel, personal communication, November

15, 2016). Sensors to detect this change in skin conductance are large and can be difficult to

incorporate into a small device. For example, figure 5 shows a conductivity sensor for use in

labs, however this kind of sensor could not easily be incorporated into a wearable device due to

its size.

Figure 5. A conductivity sensor from Carolina Biological. The site recommends it for use with solutions to measure conductance.

(Carolina Biological, n.d.).

PULSE OXIMETRY

Traditional pulse oximetry uses a device which clamps over a fingertip to provide

readings. The process of obtaining blood oxygen levels, or SpO2 from a fingertip can be done in

two ways. The strategies are categorized by the style of light used. One style, transmissive pulse

oximetry, uses light which shines through the skin, hence the requirement of using a fingertip

Page 10: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 9

or other thin body part (Alza Corporation, 1995). The other style is transflective pulse oximetry,

which uses reflected light (Alza Corporation, 1995).

Although fingertips are typically used to measure a patient’s oxygen levels, the same

strategies of pulse oximetry can be used with an ear-mounted device. This placement allows for

the same accuracy of a fingertip-based sensor without the inconvenience of having a relatively

large device placed on one’s finger at all times (Da He, Winokur, Heldt, & Sodini, 2010). Blood

oxygen levels could be used to measure breathing rate and thus detect hyperventilation during

a panic attack, which is an important physical symptom of panic attacks.

ENGINEERING PLAN

ENGINEERING PROBLEM

Currently, people experiencing panic attacks often have to wait for the attack to subside

before reporting it to medical professionals or others in charge of their care. This delay is in part

due to the paralyzing fear associated with panic attacks. Waiting can be detrimental to the

patient emotionally and physically, due to the various physical symptoms associated with these

attacks and the worry that can arise from not having immediate access to help. Detection of the

physical manifestations of panic disorder (panic attacks) is currently slow and relies on the

patient to disclose much of the information.

ENGINEERING GOAL

The goal of this project was to engineer a device which detects physical symptoms of

panic attacks and alerts a trusted contact via a connected smartphone application. The device

measures the patient’s physical symptoms to determine whether or not the patient is

experiencing a panic attack. If the symptoms indicate that a panic attack is occurring, the

smartphone to which the device is connected calls for help.

PROCEDURAL OVERVIEW

DEVELOPMENT

The sensor to detect increased heart rate and a Bluetooth module were obtained. When

symptoms above the threshold are being experienced, the app associated with the device will

call someone. The app contains an emergency button capable of calling for help in the event

that the device does not detect a panic attack. When pressed, this button contacts the trusted

person that the patient designated upon setting up the device.

DESIGN CRITERIA

Page 11: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 10

The location of the device was chosen based on three criteria: low patient discomfort,

low visibility, and high accuracy of measurements taken at that point. These criteria were

chosen because they provide the most accurate readings for the device with the least

disruption of the patient’s normal life. The prototype is scored based on cost to the user, and

accuracy.

Table 1. Location design matrix. Three possible locations were scored: wrist, ear, and chest. Locations were scored out of 5

points for each weighted category. Although a chest based device would provide the most accurate readings due to proximity

to the heart and lungs, it could cause the patient discomfort.

Criteria (rated out of 5) Weight (out of 5) Wrist Ear Chest

Low patient discomfort 3 4 3 1

Low visibility 2 1 4 3

High accuracy of

measurements

4 2 4 5

Weighted Total 45 22 32 29

TESTING

The sensor was tested against an existing commercial sensor, a heart rate monitor on a

Fitbit Charge HR. The purpose of that testing was to determine the accuracy of the sensor

before placing it in the device. Once the device was built, the sensor was tested again to ensure

there was no significant loss of accuracy occurred from combining it with the device. Once the

sensor had been tested properly, symptom combinations were simulated to test the detection

algorithm.

Page 12: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 11

METHODOLOGY

MATERIALS

The materials used in this product are an Arduino Uno Rev3 board (obtained from RadioShack),

a Pulse Sensor Amped (obtained from the Pulse Sensor web store), an HC-06 Bluetooth module

(obtained from Amazon), and a SunFounder Project Super Starter Kit (obtained from Amazon).

Figure 6. The Arduino and sensor setup used.

PROCEDURE

The basic outline of the app was developed first using MIT App Inventor 2. This version

of the app saved a phone number entered by the user. When a button was pressed, the app

called the phone number and texted the user’s location to the number. Once this version of the

app was complete, the sensor and module were tested individually. The readings of the heart

rate sensor were tested against the heart rate readings of a Fitbit Charge HR. The readings were

recorded at rest at fifteen second intervals for a total of seven minutes. A t-test was performed

on these readings using Excel. The HC-06 module was then tested to ensure that a connection

could be formed between the device and the phone. A base code (“How to connect”, n.d.) was

downloaded for the Arduino. This code turned an LED on the Arduino board on and off using

entry into the Blueterm app on a Samsung Galaxy J3 smartphone.

Once it was ensured that both modules worked, the modules were connected to the

Arduino Uno board. The sensor was then tested again to ensure that the accuracy had not been

Page 13: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 12

affected. The sensor was tested in the same way as above. The Arduino-based code for this

stage was developed, using the open source code provided by the manufacturers of the Pulse

Sensor (Murphy & Gitman, 2016). This code was edited to include a signal sent via Bluetooth if

the heart rate suddenly increased by a certain amount. The app was remade in Android Studio

at this point to include a Bluetooth connection and an algorithm that would respond to the sent

data. When the signal was received indicating a sudden heart rate jump, the app called the

emergency contact.

Page 14: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 13

RESULTS

PULSE SENSOR

The sensor was tested for accuracy several times: against a commercial sensor before use and after each major modification to the code.

Figure 7. Recorded heart rate at each time interval during the original accuracy test of Pulse Sensor Amped against Fitbit Charge

HR.

Table 2. Summary of Pulse Sensor vs. Fitbit heart rate data. Resting heart rate was monitored at ten second intervals for five minutes with both sensors simultaneously. Two One-Sided Test for equivalence performed using XLSTAT add-on for Excel. Full data in Appendix B.

Variable Observations Minimum Maximum Mean Std. deviation

Fitbit Heart Rate 30 54.000 60.000 55.600 1.610

Pulse Sensor Heart Rate 30 53.000 58.000 54.667 0.884

Test Value

Lower bound (TOST) -5.000

Lower bound (90 %) 0.373

Upper bound (90 %) 1.494

Upper bound (TOST) 5.000

Test interpretation Equivalent

Table 2 shows the original test for accuracy using the Pulse Sensor used in the project

running the original code (see Appendix A for full code) and a commercially available heart rate

monitor on a Fitbit Charge HR. Resting heart rate was recorded every ten seconds over the

same five-minute interval on both sensors. Using an Excel add-on from XLSTAT, a TOST was

48

50

52

54

56

58

60

62

0:1

0

0:2

0

0:3

0

0:4

0

0:5

0

1:0

0

1:1

0

1:2

0

1:3

0

1:4

0

1:5

0

2:0

0

2:1

0

2:2

0

2:3

0

2:4

0

2:5

0

3:0

0

3:1

0

3:2

0

3:3

0

3:4

0

3:5

0

4:0

0

4:1

0

4:2

0

4:3

0

4:4

0

4:5

0

5:0

0

Hea

rt R

ate

(BP

M)

Elapsed Time (mm:ss)

Elapsed Time vs. Heart Rate

Fitbit Pulse Sensor

Page 15: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 14

performed to check for equivalency of the two data sets. The averages of the two sets of heart

rates were 55.6 beats per minute (BPM) and 54.7 BPM for the Pulse Sensor Amped and Fitbit

Charge HR respectively.

Table 3. Summary of Pulse Sensor original code vs. Pulse Sensor Modified Version 1.0. Resting heart rate was monitored at 15

second intervals for 15 minutes. Sensors were tested over consecutive intervals since both used the same device. TOST was

performed using XLSTAT add-on for Excel. Full data in Appendix D.

Variable Observations Minimum Maximum Mean Std. deviation

Pulse Sensor Unmodified 60 52.000 96.000 65.950 8.444

Pulse Sensor Modified V1.0 60 57.000 104.000 69.250 11.466

Test Value

Lower bound (TOST) -5.000

Lower bound (90 %) -6.348

Upper bound (90 %) -0.252

Upper bound (TOST) 5.000

Test interpretation Not equivalent

Table 3 shows the test for retained accuracy of the modified Pulse Sensor Code (see

Appendix C for full code). Resting heart rate was recorded every fifteen seconds over

consecutive fifteen minute intervals. Using an Excel add-on from XLSTAT, a TOST was

performed to check for equivalency of the two data sets. The average heart rates of the sensor

running the original and modified codes were 66.0 BPM and 69.3 BPM, respectively.

Table 4. Summary of Pulse Sensor original code vs. Pulse Sensor modified version 2.0. Resting heart rate was monitored at 15

second intervals for 10 minutes. Sensors were tested over consecutive intervals since both used the same device. TOST was

performed using XLSTAT add-on for Excel. Full data in Appendix F.

Variable Observations Minimum Maximum Mean Std. deviation

Pulse Sensor Unmodified 40 50.000 59.000 53.150 2.402

Pulse Sensor Modified V2.0 40 49.000 58.000 52.850 2.455

Test Value

Lower bound (TOST) -2.000

Lower bound (90 %) -0.604

Upper bound (90 %) 1.204

Upper bound (TOST) 2.000

Test interpretation Equivalent

Table 4 shows the test for retained accuracy of the modified Pulse Sensor Code (see

Appendix E for full code). Resting heart rate was recorded every fifteen seconds over

consecutive ten minute intervals. Using an Excel add-on from XLSTAT, a TOST was performed to

check for equivalency of the two data sets. The average heart rates of the sensor running the

original and modified codes were 53.15 BPM and 52.85 BPM, respectively.

Page 16: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 15

DETECTION ACCURACY

Figure 8. A visual representation of the number of accurate and inaccurate detections when sets of heart rates were sent to the

app. Accurate detection means that the data was supposed to indicate a panic attack and the device responded accordingly or

that the data was not meant to indicate a panic attack and thus the device did not react. Inaccurate detections mean that the

device did not respond in the correct manner. Of 24 sets of data sent to the app, 87.5% were accurate. Full data in Appendix G.

COST

Table 5. Component costs and total device cost.

Component Cost

Pulse Sensor Amped $24.99

Arduino Uno $24.99 (RadioShack)

HC-06 Bluetooth Module $17.00 (Amazon)

Total $67.98

Table 5 contains the parts used and the cost of each. The source of the part and price

are indicated in parentheses. The total cost of the device came out to just under $68, placing it

in the bracket between $50 and $75.

SCORING MATRIX

Table 6. Final scoring matrix for the prototype. It was scored out of 10 in 3 categories: heart rate accuracy, detection accuracy,

and cost. The score for heart rate accuracy was determined based on the confidence interval. Because the device was shown to

be accurate over a 90% confidence interval, it earned a score of 9 out of 10. The detection accuracy was based on the

percentage of accurate detection. Because the device appropriately reacted during 88% of the trials, it earned a score of 8 out

Detections

Accurate Inaccurate

Page 17: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 16

of 10. Cost was divided into predetermined brackets. A cost of $100 or greater would earn a score of 2, a cost between $90 and

$99.99 would earn a 4, between $75 and $89.99 would earn a 6, between $50 and $74.99 would earn an 8, and a cost less than

$50 would earn a 10. The total cost of the device components was $67.98, earning it an 8 out of 10.

Criteria Weight Score (out of 10)

Heart Rate Accuracy 2 9

Detection Accuracy 2 8

Cost 1 8

Total 50 42

Page 18: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 17

ANALYSIS

Through the use of TOSTs, it was shown that the original code of the Pulse Sensor

Amped was at least 90% accurate when compared to the commercially available Fitbit Charge

HR (Table 3). This accuracy shows that the heart rates measured by the Pulse Sensor Amped

before modification were accurate enough for use in the project. In addition, the second

modified version of the code was at least 90% accurate when compared to the unmodified

code (Table 4). This consistency means that the modifications made to send the data to the

application for use in the project did not significantly affect the detection accuracy of the Pulse

Sensor Amped.

Out of 24 total symptom tests, the device correctly responded 21 times, with 3 incorrect

responses. The full data can be found in Appendix G. The device had an 87.5% accuracy of

detection. This was above the benchmark of 85% accuracy. This accuracy means that the

device functioned well enough to be considered a success.

Page 19: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 18

CONCLUSIONS

The accurate detection rate of the device was 87.5% after running 24 symptom

simulations through the application’s detection algorithm. This success rate proved the concept

and device’s capability to be a starting point for future devices to detect more symptoms and

accurately detect panic attacks. The use of symptom monitoring devices for panic disorders and

other mental health issues is an area that should be looked into far more than it currently is, as

devices like this one can be beneficial to many people living with those issues.

Page 20: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 19

REFERENCES

Alza Corporation. (1995). Methods and devices for facilitated non-invasive oxygen monitoring. US.

Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more. SunFounder Digital Accelerometer ADXL345 Module for Arduino and Raspberry Pi: Electronics. Retrieved December 4, 2016, from http://www.amazon.com/SunFounder-Digital-Accelerometer-ADXL345-Raspberry/dp/B0151FIBZO/ref=sr_1_1?ie=UTF8&qid=1480891616&sr=8-1&keywords=ADXL345+sunfounder

Carolina Biological. NeuLog™ Conductivity Sensor. Retrieved December 4, 2016, from http://www.carolina.com/science-lab-sensors-probes/neulog-conductivity-sensor-probe/369644.pr?question=

Da He, D., Winokur, E., Heldt, T., & Sodini, C. (2010). The ear as a location for wearable vital signs monitoring. 2010 Annual International Conference Of The IEEE Engineering In Medicine And Biology. http://dx.doi.org/10.1109/iembs.2010.5627309

Dictionary and Thesaurus | Merriam-Webster. Sensor | Definition of Sensor by Merriam-Webster. Retrieved from http://www.merriam-webster.com/dictionary/sensor

Facts & statistics. (2016, August). Retrieved November 18, 2016, from Anxiety and Depression Association of America, https://www.adaa.org/about-adaa/press-room/facts-statistics

Fleet, R. P., Dupuis, G., Marchand, A., Burelle, D., & Beitman, B. D. (1997). Detecting panic disorder in emergency department chest pain patients: A validated model to improve recognition. Annals of Behavioral Medicine, 19(2), 124-131. doi:10.1007/bf02883329

Hamm, A. O., Richter, J., Pané-Farré, C., Westphal, D., Wittchen, H., Vossbeck-Elsebusch, A. N., . . . Deckert, J. (2016, August 1). Panic disorder with agoraphobia from a behavioral neuroscience perspective: Applying the research principles formulated by the Research Domain Criteria (RDoC) initiative. Psychophysiology, 53(3), 312-322. doi:10.1111/psyp.12553

Hernandez, McDuff, & Picard. (2015). Biowatch. Retrieved September 25, 2016, from http://ieeexplore.ieee.org.ezproxy.wpi.edu/stamp/stamp.jsp?arnumber=7349394&tag=1

Mertz, L. "Are Wearables Safe?" PubMed. (2016): Web. <https://www.ncbi.nlm.nih.gov/pubmed/26799727>.

Mio Global. Why You Should Never Wear a Heart Rate Monitor Chest Strap Again. Retrieved December 4, 2016, from http://blog.mioglobal.com/why-you-should-never-wear-a-heart-rate-monitor-chest-strap-again/

Page 21: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 20

Murphy, J., & Gitman, Y. (2016). Pulse Sensor. Open Hardware. Retrieved November 30, 2016, from http://pulsesensor.com/pages/open-hardware

Rettner, R. (2014, March 18). Live Science: The Most Interesting Articles, Mysteries & Discoveries. How Well Do Fitness Trackers Monitor Heart Rate? Retrieved November 30, 2016, from http://www.livescience.com/44170-fitness-tracker-heart-rate-monitors.html

Page 22: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 21

APPENDICES

APPENDIX A. PULSE SENSOR UNMODIFIED CODE

/* Pulse Sensor Amped 1.4 by Joel Murphy and Yury Gitman http://www.pulsesensor.com

---------------------- Notes ---------------------- ----------------------

This code:

1) Blinks an LED to User's Live Heartbeat PIN 13

2) Fades an LED to User's Live HeartBeat

3) Determines BPM

4) Prints All of the Above to Serial

Read Me:

https://github.com/WorldFamousElectronics/PulseSensor_Amped_Arduino/blob/master/README.md

---------------------- ---------------------- ----------------------

*/

// Variables

int pulsePin = 0; // Pulse Sensor purple wire connected to analog pin 0

int blinkPin = 13; // pin to blink led at each beat

int fadePin = 5; // pin to do fancy classy fading blink at each beat

int fadeRate = 0; // used to fade LED on with PWM on fadePin

// Volatile Variables, used in the interrupt service routine!

volatile int BPM; // int that holds raw Analog in 0. updated every 2mS

volatile int Signal; // holds the incoming raw data

volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!

volatile boolean Pulse = false; // "True" when User's live heartbeat is detected. "False" when not a "live beat".

volatile boolean QS = false; // becomes true when Arduino finds a beat.

// Regards Serial OutPut -- Set This Up to your needs

static boolean serialVisual = false; // Set to 'false' by Default. Re-set to 'true' to see Arduino Serial Monitor ASCII Visual Pulse

void setup(){

pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat!

Page 23: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 22

pinMode(fadePin,OUTPUT); // pin that will fade to your heartbeat!

Serial.begin(115200); // we agree to talk fast!

interruptSetup(); // sets up to read Pulse Sensor signal every 2mS

// IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,

// UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN

// analogReference(EXTERNAL);

}

// Where the Magic Happens

void loop(){

serialOutput() ;

if (QS == true){ // A Heartbeat Was Found

// BPM and IBI have been Determined

// Quantified Self "QS" true when Arduino finds a heartbeat

fadeRate = 255; // Makes the LED Fade Effect Happen

// Set 'fadeRate' Variable to 255 to fade LED with pulse

serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.

QS = false; // reset the Quantified Self flag for next time

}

ledFadeToBeat(); // Makes the LED Fade Effect Happen

delay(20); // take a break

}

void ledFadeToBeat(){

fadeRate -= 15; // set LED fade value

fadeRate = constrain(fadeRate,0,255); // keep LED fade value from going into negative numbers!

analogWrite(fadePin,fadeRate); // fade LED

}

Page 24: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 23

APPENDIX B. PULSE SENSOR UNMODIFIED VS. FITBIT FULL DATA

Sensor: Fitbit Pulse Sensor

Location: wrist fingertip

Time (BPM) (BPM)

0:10 56 58

0:20 60 54

0:30 60 54

0:40 59 53

0:50 57 54

1:00 56 54

1:10 55 54

1:20 55 54

1:30 55 55

1:40 55 54

1:50 55 54

2:00 54 54

2:10 55 55

2:20 55 55

2:30 55 55

2:40 55 55

2:50 55 55

3:00 55 55

3:10 55 55

3:20 58 55

3:30 56 55

3:40 55 55

3:50 55 55

4:00 54 55

4:10 54 55

4:20 55 53

4:30 55 55

4:40 55 55

4:50 54 55

5:00 55 55

Average 55.04 54.68

Standard Deviation

0.790 0.557

Page 25: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 24

APPENDIX C. PULSE SENSOR MODIF IED CODE 1.0

// Variables

int pulsePin = 0; // Pulse Sensor purple wire connected to analog pin 0

int blinkPin = 13; // pin to blink led at each beat

int fadePin = 5; // pin to do fancy classy fading blink at each beat

int fadeRate = 0; // used to fade LED on with PWM on fadePin

String inData;

// Volatile Variables, used in the interrupt service routine!

volatile int BPM; // int that holds raw Analog in 0. updated every 2mS

volatile int prevBPM;

volatile int Signal; // holds the incoming raw data

volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!

volatile boolean Pulse = false; // "True" when User's live heartbeat is detected. "False" when not a "live beat".

volatile boolean QS = false; // becomes true when Arduino finds a beat.

// Regards Serial OutPut -- Set This Up to your needs

static boolean serialVisual = false; // Set to 'false' by Default. Re-set to 'true' to see Arduino Serial Monitor ASCII Visual Pulse

#include <SoftwareSerial.h>

SoftwareSerial bt(3,2);

void setup(){

// pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat!

// pinMode(fadePin,OUTPUT); // pin that will fade to your heartbeat!

Serial.begin(115200); // we agree to talk fast!

interruptSetup(); // sets up to read Pulse Sensor signal every 2mS

// IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,

// UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN

// analogReference(EXTERNAL);

}

// Where the Magic Happens

void loop(){

serialOutput() ;

//pulse stuff

Page 26: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 25

if (QS == true){ // A Heartbeat Was Found

// BPM and IBI have been Determined

// Quantified Self "QS" true when Arduino finds a heartbeat

// fadeRate = 255; // Makes the LED Fade Effect Happen

// Set 'fadeRate' Variable to 255 to fade LED with pulse

serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.

QS = false; // reset the Quantified Self flag for next time

}

// ledFadeToBeat(); // Makes the LED Fade Effect Happen

delay(20); // take a break

prevBPM = BPM;

//hoping things work !!

// try{

/* String*/ inData = Serial.readStringUntil('\n');

inData.trim(); // cut off white space (carriage return)

if (inData.charAt(0) == 'S'){ // leading 'S' for sensor data

inData = inData.substring(1); // cut off the leading 'S'

int Sensor = inData.toInt(); // convert the string to usable int

}

if (inData.charAt(0) == 'B'){ // leading 'B' for BPM data

inData = inData.substring(1); // cut off the leading 'B'

BPM = inData.toInt(); // convert the string to usable int

boolean beat = true; // set beat flag to advance heart rate graph

// heart = 20; // begin heart image 'swell' timer

}

if (inData.charAt(0) == 'Q'){ // leading 'Q' means IBI data

inData = inData.substring(1); // cut off the leading 'Q'

IBI = inData.toInt(); // convert the string to usable int

}

//} // catch(Exception e) {

// // println(e.toString());

//}

// if(BPM-prevBPM>20){

// //do something ??? maybe add an led to test for now

// // bt.print(1);

// pinMode(blinkPin, HIGH);

// }

// else {

Page 27: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 26

// pinMode(blinkPin, LOW);

// }

}

void ledFadeToBeat(){

fadeRate -= 15; // set LED fade value

fadeRate = constrain(fadeRate,0,255); // keep LED fade value from going into negative numbers!

analogWrite(fadePin,fadeRate); // fade LED

}

Page 28: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 27

APPENDIX D. PULSE SENSOR UNMODIFIED VS MODIFIED 1.0 FULL DATA

Time Unmodified Code Modified Version 1

0:15 73 60

0:30 64 67

0:45 68 70

1:00 68 64

1:15 65 62

1:30 67 64

1:45 67 65

2:00 63 102

2:15 68 67

2:30 84 60

2:45 70 66

3:00 66 64

3:15 63 100

3:30 96 76

3:45 52 96

4:00 82 73

4:15 69 66

4:30 86 64

4:45 71 62

5:00 87 96

5:15 66 58

5:30 66 68

5:45 62 60

6:00 65 62

6:15 63 90

6:30 62 83

6:45 62 85

7:00 62 60

7:15 63 59

7:30 64 62

7:45 66 61

8:00 60 63

8:15 61 77

8:30 63 73

8:45 58 63

9:00 67 62

9:15 62 60

9:30 64 80

9:45 62 70

10:00 66 68

10:15 63 59

Page 29: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 28

10:30 62 104

10:45 61 73

11:00 65 64

11:15 61 73

11:30 69 63

11:45 62 64

12:00 57 66

12:15 61 69

12:30 62 66

12:45 62 68

13:00 58 71

13:15 60 70

13:30 61 71

13:45 65 60

14:00 61 69

14:15 94 59

14:30 59 61

14:45 58 57

15:00 63 60

Mean 65.95 69.25

Standard Deviation

8.444 11.46

Page 30: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 29

APPENDIX E. PULSE SENSOR MODIF IED CODE 2.0

PANICMONITOR2

/* Pulse Sensor Amped 1.4 by Joel Murphy and Yury Gitman http://www.pulsesensor.com

---------------------- Notes ---------------------- ----------------------

This code:

1) Blinks an LED to User's Live Heartbeat PIN 13

2) Fades an LED to User's Live HeartBeat

3) Determines BPM

4) Prints All of the Above to Serial

Read Me:

https://github.com/WorldFamousElectronics/PulseSensor_Amped_Arduino/blob/master/README.md

---------------------- ---------------------- ----------------------

*/

// Variables

int pulsePin = 0; // Pulse Sensor purple wire connected to analog pin 0

int blinkPin = 13; // pin to blink led at each beat

int fadePin = 5; // pin to do fancy classy fading blink at each beat

int fadeRate = 0; // used to fade LED on with PWM on fadePin

// Volatile Variables, used in the interrupt service routine!

volatile int BPM; // int that holds raw Analog in 0. updated every 2mS

volatile int Signal; // holds the incoming raw data

volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!

volatile boolean Pulse = false; // "True" when User's live heartbeat is detected. "False" when not a "live beat".

volatile boolean QS = false; // becomes true when Arduino finds a beat.

// Regards Serial OutPut -- Set This Up to your needs

static boolean serialVisual = true; // Set to 'false' by Default. Re-set to 'true' to see Arduino Serial Monitor ASCII Visual Pulse

void setup(){

pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat!

Page 31: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 30

pinMode(fadePin,OUTPUT); // pin that will fade to your heartbeat!

Serial.begin(9600); // we agree to talk fast!

interruptSetup(); // sets up to read Pulse Sensor signal every 2mS

// IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,

// UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN

// analogReference(EXTERNAL);

}

// Where the Magic Happens

void loop(){

serialOutput() ;

if (QS == true){ // A Heartbeat Was Found

// BPM and IBI have been Determined

// Quantified Self "QS" true when Arduino finds a heartbeat

fadeRate = 255; // Makes the LED Fade Effect Happen

// Set 'fadeRate' Variable to 255 to fade LED with pulse

serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.

QS = false; // reset the Quantified Self flag for next time

}

ledFadeToBeat(); // Makes the LED Fade Effect Happen

delay(20); // take a break

}

void ledFadeToBeat(){

fadeRate -= 15; // set LED fade value

fadeRate = constrain(fadeRate,0,255); // keep LED fade value from going into negative numbers!

analogWrite(fadePin,fadeRate); // fade LED

}

ALLSERIALHANDLING

//////////

///////// All Serial Handling Code,

///////// It's Changeable with the 'serialVisual' variable

///////// Set it to 'true' or 'false' when it's declared at start of code.

/////////

Page 32: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 31

void serialOutput(){ // Decide How To Output Serial.

if (serialVisual == true){

arduinoSerialMonitorVisual('-', Signal); // goes to function that makes Serial Monitor Visualizer

} else{

sendDataToSerial('S', Signal); // goes to sendDataToSerial function

}

}

// Decides How To OutPut BPM and IBI Data

void serialOutputWhenBeatHappens(){

if (serialVisual == true){ // Code to Make the Serial Monitor Visualizer Work

Serial.print("*** Heart-Beat Happened *** "); //ASCII Art Madness

Serial.print("BPM: ");

Serial.print(BPM);

Serial.print(" ");

} else{

sendDataToSerial('B',BPM); // send heart rate with a 'B' prefix

sendDataToSerial('Q',IBI); // send time between beats with a 'Q' prefix

}

}

// Sends Data to Pulse Sensor Processing App, Native Mac App, or Third-party Serial Readers.

void sendDataToSerial(char symbol, int data ){

Serial.print(symbol);

Serial.println(data);

}

// Code to Make the Serial Monitor Visualizer Work

void arduinoSerialMonitorVisual(char symbol, int data ){

const int sensorMin = 0; // sensor minimum, discovered through experiment

const int sensorMax = 1024; // sensor maximum, discovered through experiment

Page 33: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 32

int sensorReading = data;

// map the sensor range to a range of 12 options:

int range = map(sensorReading, sensorMin, sensorMax, 0, 11);

// do something different depending on the

// range value:

switch (range) {

case 0:

Serial.println(""); /////ASCII Art Madness

break;

case 1:

Serial.println("---");

break;

case 2:

Serial.println("------");

break;

case 3:

Serial.println("---------");

break;

case 4:

Serial.println("------------");

break;

case 5:

Serial.println("--------------|-");

break;

case 6:

Serial.println("--------------|---");

break;

case 7:

Serial.println("--------------|-------");

break;

case 8:

Serial.println("--------------|----------");

break;

case 9:

Serial.println("--------------|----------------");

Page 34: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 33

break;

case 10:

Serial.println("--------------|-------------------");

break;

case 11:

Serial.println("--------------|-----------------------");

break;

}

}

INTERRUPT

volatile int rate[10]; // array to hold last ten IBI values

volatile unsigned long sampleCounter = 0; // used to determine pulse timing

volatile unsigned long lastBeatTime = 0; // used to find IBI

volatile int P =512; // used to find peak in pulse wave, seeded

volatile int T = 512; // used to find trough in pulse wave, seeded

volatile int thresh = 525; // used to find instant moment of heart beat, seeded

volatile int amp = 100; // used to hold amplitude of pulse waveform, seeded

volatile boolean firstBeat = true; // used to seed rate array so we startup with reasonable BPM

volatile boolean secondBeat = false; // used to seed rate array so we startup with reasonable BPM

void interruptSetup(){

// Initializes Timer2 to throw an interrupt every 2mS.

TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE

TCCR2B = 0x06; // DON'T FORCE COMPARE, 256 PRESCALER

OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE

TIMSK2 = 0x02; // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A

sei(); // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED

}

// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE.

// Timer 2 makes sure that we take a reading every 2 milliseconds

ISR(TIMER2_COMPA_vect){ // triggered when Timer2 counts to 124

Page 35: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 34

cli(); // disable interrupts while we do this

Signal = analogRead(pulsePin); // read the Pulse Sensor

sampleCounter += 2; // keep track of the time in mS with this variable

int N = sampleCounter - lastBeatTime; // monitor the time since the last beat to avoid noise

// find the peak and trough of the pulse wave

if(Signal < thresh && N > (IBI/5)*3){ // avoid dicrotic noise by waiting 3/5 of last IBI

if (Signal < T){ // T is the trough

T = Signal; // keep track of lowest point in pulse wave

}

}

if(Signal > thresh && Signal > P){ // thresh condition helps avoid noise

P = Signal; // P is the peak

} // keep track of highest point in pulse wave

// NOW IT'S TIME TO LOOK FOR THE HEART BEAT

// signal surges up in value every time there is a pulse

if (N > 250){ // avoid high frequency noise

if ( (Signal > thresh) && (Pulse == false) && (N > (IBI/5)*3) ){

Pulse = true; // set the Pulse flag when we think there is a pulse

digitalWrite(blinkPin,HIGH); // turn on pin 13 LED

IBI = sampleCounter - lastBeatTime; // measure time between beats in mS

lastBeatTime = sampleCounter; // keep track of time for next pulse

if(secondBeat){ // if this is the second beat, if secondBeat == TRUE

secondBeat = false; // clear secondBeat flag

for(int i=0; i<=9; i++){ // seed the running total to get a realistic BPM at startup

rate[i] = IBI;

}

}

if(firstBeat){ // if it's the first time we found a beat, if firstBeat == TRUE

firstBeat = false; // clear firstBeat flag

secondBeat = true; // set the second beat flag

sei(); // enable interrupts again

return; // IBI value is unreliable so discard it

Page 36: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 35

}

// keep a running total of the last 10 IBI values

word runningTotal = 0; // clear the runningTotal variable

for(int i=0; i<=8; i++){ // shift data in the rate array

rate[i] = rate[i+1]; // and drop the oldest IBI value

runningTotal += rate[i]; // add up the 9 oldest IBI values

}

rate[9] = IBI; // add the latest IBI to the rate array

runningTotal += rate[9]; // add the latest IBI to runningTotal

runningTotal /= 10; // average the last 10 IBI values

BPM = 60000/runningTotal; // how many beats can fit into a minute? that's BPM!

QS = true; // set Quantified Self flag

// QS FLAG IS NOT CLEARED INSIDE THIS ISR

}

}

if (Signal < thresh && Pulse == true){ // when the values are going down, the beat is over

digitalWrite(blinkPin,LOW); // turn off pin 13 LED

Pulse = false; // reset the Pulse flag so we can do it again

amp = P - T; // get amplitude of the pulse wave

thresh = amp/2 + T; // set thresh at 50% of the amplitude

P = thresh; // reset these for next time

T = thresh;

}

if (N > 2500){ // if 2.5 seconds go by without a beat

thresh = 512; // set thresh default

P = 512; // set P default

T = 512; // set T default

lastBeatTime = sampleCounter; // bring the lastBeatTime up to date

firstBeat = true; // set these to avoid noise

secondBeat = false; // when we get the heartbeat back

}

Page 37: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 36

sei(); // enable interrupts when you’re done!

}// end isr

Timer_Interrupt_Notes

/*

These notes put together by Joel Murphy for Pulse Sensor Amped, 2015

The code that this section is attached to uses a timer interrupt

to sample the Pulse Sensor with consistent and regular timing.

The code is setup to read Pulse Sensor signal at 500Hz (every 2mS).

The reasoning for this can be found here:

http://pulsesensor.com/pages/pulse-sensor-amped-arduino-v1dot1

There are issues with using different timers to control the Pulse Sensor sample rate.

Sometimes, user will need to switch timers for access to other code libraries.

Also, some other hardware may have different timer setup requirements. This page

will cover those different needs and reveal the necessary settings. There are two

part of the code that will be discussed. The interruptSetup() routine, and

the interrupt function call. Depending on your needs, or the Arduino variant that you use,

check below for the correct settings.

******************************************************************************************

ARDUINO UNO, Pro 328-5V/16MHZ, Pro-Mini 328-5V/16MHz (or any board with ATmega328P running at 16MHz)

>> Timer2

Pulse Sensor Arduino UNO uses Timer2 by default.

Use of Timer2 interferes with PWM on pins 3 and 11.

There is also a conflict with the Tone library, so if you want tones, use Timer1 below.

void interruptSetup(){

// Initializes Timer2 to throw an interrupt every 2mS.

TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE

TCCR2B = 0x06; // DON'T FORCE COMPARE, 256 PRESCALER

Page 38: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 37

OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE

TIMSK2 = 0x02; // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A

sei(); // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED

}

use the following interrupt vector with Timer2

ISR(TIMER2_COMPA_vect)

>> Timer1

Use of Timer1 interferes with PWM on pins 9 and 10.

The Servo library also uses Timer1, so if you want servos, use Timer2 above.

void interruptSetup(){

// Initializes Timer1 to throw an interrupt every 2mS.

TCCR1A = 0x00; // DISABLE OUTPUTS AND PWM ON DIGITAL PINS 9 & 10

TCCR1B = 0x11; // GO INTO 'PHASE AND FREQUENCY CORRECT' MODE, NO PRESCALER

TCCR1C = 0x00; // DON'T FORCE COMPARE

TIMSK1 = 0x01; // ENABLE OVERFLOW INTERRUPT (TOIE1)

ICR1 = 16000; // TRIGGER TIMER INTERRUPT EVERY 2mS

sei(); // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED

}

Use the following ISR vector for the Timer1 setup above

ISR(TIMER1_OVF_vect)

>> Timer0

DON'T USE TIMER0! Timer0 is used for counting delay(), millis(), and micros().

Messing with Timer0 is highly unadvised!

******************************************************************************************

ARDUINO Fio, Lilypad, ProMini328-3V/8MHz (or any board with ATmega328P running at 8MHz)

>> Timer2

Page 39: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 38

Pulse Sensor Arduino UNO uses Timer2 by default.

Use of Timer2 interferes with PWM on pins 3 and 11.

There is also a conflict with the Tone library, so if you want tones, use Timer1 below.

void interruptSetup(){

// Initializes Timer2 to throw an interrupt every 2mS.

TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE

TCCR2B = 0x05; // DON'T FORCE COMPARE, 128 PRESCALER

OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE

TIMSK2 = 0x02; // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A

sei(); // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED

}

use the following interrupt vector with Timer2

ISR(TIMER2_COMPA_vect)

>> Timer1

Use of Timer1 interferes with PWM on pins 9 and 10.

The Servo library also uses Timer1, so if you want servos, use Timer2 above.

void interruptSetup(){

// Initializes Timer1 to throw an interrupt every 2mS.

TCCR1A = 0x00; // DISABLE OUTPUTS AND PWM ON DIGITAL PINS 9 & 10

TCCR1B = 0x11; // GO INTO 'PHASE AND FREQUENCY CORRECT' MODE, NO PRESCALER

TCCR1C = 0x00; // DON'T FORCE COMPARE

TIMSK1 = 0x01; // ENABLE OVERFLOW INTERRUPT (TOIE1)

ICR1 = 8000; // TRIGGER TIMER INTERRUPT EVERY 2mS

sei(); // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED

}

Use the following ISR vector for the Timer1 setup above

ISR(TIMER1_OVF_vect)

Page 40: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 39

>> Timer0

DON'T USE TIMER0! Timer0 is used for counting delay(), millis(), and micros().

Messing with Timer0 is highly unadvised!

******************************************************************************************

ARDUINO Leonardo (or any board with ATmega32u4 running at 16MHz)

>> Timer1

Use of Timer1 interferes with PWM on pins 9 and 10.

void interruptSetup(){

TCCR1A = 0x00;

TCCR1B = 0x0C; // prescaler = 256

OCR1A = 0x7C; // count to 124

TIMSK1 = 0x02;

sei();

}

The only other thing you will need is the correct ISR vector in the next step.

ISR(TIMER1_COMPA_vect)

******************************************************************************************

ADAFRUIT Flora, ARDUINO Fio v3 (or any other board with ATmega32u4 running at 8MHz)

>> Timer1

Use of Timer1 interferes with PWM on pins 9 and 10.

void interruptSetup(){

TCCR1A = 0x00;

TCCR1B = 0x0C; // prescaler = 256

OCR1A = 0x3E; // count to 62

Page 41: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 40

TIMSK1 = 0x02;

sei();

}

The only other thing you will need is the correct ISR vector in the next step.

ISR(TIMER1_COMPA_vect)

******************************************************************************************

ADAFRUIT Gemma (or any other board with ATtiny85 running at 8MHz)

NOTE: Gemma does not do serial communication!

Comment out or remove the Serial code in the Arduino sketch!

Timer1

Use of Timer1 breaks PWM output on pin D1

void interruptSetup(){

TCCR1 = 0x88; // Clear Timer on Compare, Set Prescaler to 128 TEST VALUE

GTCCR &= 0x81; // Disable PWM, don't connect pins to events

OCR1C = 0x7C; // Set the top of the count to 124 TEST VALUE

OCR1A = 0x7C; // Set the timer to interrupt after counting to TEST VALUE

bitSet(TIMSK,6); // Enable interrupt on match between TCNT1 and OCR1A

sei(); // Enable global interrupts

}

The only other thing you will need is the correct ISR vector in the next step.

ISR(TIMER1_COMPA_vect)

******************************************************************************************

******************************************************************************************

******************************************************************************************

******************************************************************************************

******************************************************************************************

******************************************************************************************

Page 42: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 41

******************************************************************************************

*/

Page 43: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 42

APPENDIX F. PULSE SENSOR UNMODIFIED VS. MODIFIED 2.0 FULL DATA

Time Unmodified Code Modified 2.0

0:00 (BPM) (BPM)

0:15 55 55

0:30 50 52

0:45 59 53

1:00 53 54

1:15 53 58

1:30 52 51

1:45 52 52

2:00 55 54

2:15 50 53

2:30 52 56

2:45 55 56

3:00 57 53

3:15 57 56

3:30 58 50

3:45 55 50

4:00 52 52

4:15 53 53

4:30 53 52

4:45 54 52

5:00 51 50

5:15 50 58

5:30 50 56

5:45 52 52

6:00 51 51

6:15 52 52

6:30 55 54

6:45 51 53

7:00 50 53

7:15 51 58

7:30 52 51

7:45 52 51

8:00 52 50

8:15 52 49

8:30 58 51

8:45 55 52

9:00 53 53

9:15 52 57

9:30 56 51

9:45 52 50

10:00 54 50

Page 44: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 43

Average 53.15 52.85

Standard Deviation

2.402 2.455

Page 45: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 44

APPENDIX G. DETECTION ACCURACY FULL DATA

Table G1. Each trial except for “Code Used in Project” was running code to update the heart rate by the specified increment

every 2 seconds. All trials were run for 60 seconds.

Trial Type expected actual

Increasing by 1 BPM from 40 0 0

0 0

0 0

Increasing by 5 BPM 0 0

0 0

0 0

Code Used in Project 0 0

0 0

0 0

Increasing by 10 BPM 1 1

1 1

1 2

Increasing by 15 BPM 1 1

1 1

1 2

Increasing by 20 BPM 1 1

1 1

1 2

Increasing by 25 BPM 1 1

1 1

1 1

Increasing by 30 BPM 2 2

2 2

2 2

Total Trials: 24 24

Case 0: no detection 9 9

Case 1: over max limit 12 9

Case 2: rapid increase 3 6

Page 46: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 45

APPENDIX H. APPLICATION CODE

MAINACTIVITY.JAVA

package com.tamsinedwards.panicmonitor2;

import android.Manifest;

import android.content.Context;

import android.content.Intent;

import android.content.pm.PackageManager;

import android.net.Uri;

import android.os.Bundle;

import android.support.v4.app.ActivityCompat;

import android.support.v7.app.AppCompatActivity;

import android.view.View;

import android.view.Menu;

import android.view.MenuItem;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

import java.io.IOException;

import java.io.InputStream;

import java.lang.reflect.Method;

import java.util.UUID;

import android.bluetooth.BluetoothAdapter;

import android.bluetooth.BluetoothDevice;

import android.bluetooth.BluetoothSocket;

import android.os.Build;

import android.os.Handler;

import android.util.Log;

import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

private static final String TAG = "bluetooth2";

TextView currentBPM;

public static Handler h;

public final int RECEIVE_MESSAGE = 1; // Status for Handler

private BluetoothAdapter btAdapter = null;

private BluetoothSocket btSocket = null;

private StringBuilder sb = new StringBuilder();

Page 47: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 46

// SPP UUID service

private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws IOException {

if (Build.VERSION.SDK_INT >= 10) {

try {

final Method m = device.getClass().getMethod("createInsecureRfcommSocketToServiceRecord",

UUID.class);

return (BluetoothSocket) m.invoke(device, MY_UUID);

} catch (Exception e) {

Log.e(TAG, "Could not create Insecure RFComm Connection", e);

}

}

return device.createRfcommSocketToServiceRecord(MY_UUID);

}

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

// Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

// setSupportActionBar(toolbar);

final Intent[] caller = {new Intent(Intent.ACTION_CALL, Uri.parse("tel:9783940804"))};

final Button save = (Button) findViewById(R.id.save);

final Button call = (Button) findViewById(R.id.call);

final EditText phoneEntry = (EditText) findViewById(R.id.phoneEntry);

final String number = phoneEntry.getText().toString();

final int[] count = {0};

save.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

if(count[0] ==0)

caller[0] = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneEntry.getText().toString()));

count[0] = count[0]++;

}

});

call.setOnClickListener(new View.OnClickListener() {

public void onClick(View view) {

// sendText(number);

makeCall(caller[0]);

}

});

Page 48: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 47

currentBPM = (TextView) findViewById(R.id.currentBPM); // for display the received data from the Arduino

final TextView prevBPM = (TextView) findViewById(R.id.prevBPM);

final int[] current = {60};

final int[] previous = {60};

h = new Handler() {

public void handleMessage(android.os.Message msg) {

switch (msg.what) {

case RECEIVE_MESSAGE: // if receive massage

byte[] readBuf = (byte[]) msg.obj;

String strIncom = new String(readBuf, 0, msg.arg1); // create string from bytes array

sb.append(strIncom); // append string

int endOfLineIndex = sb.indexOf("\r\n"); // determine the end-of-line

if (endOfLineIndex > 0) { // if end-of-line,

String sbprint = sb.substring(0, endOfLineIndex); // extract string

sb.delete(0, sb.length()); // and clear

currentBPM.setText(sbprint); // update TextView

previous[0] = current[0];

prevBPM.setText("" + previous[0]);

try {

current[0] = Integer.parseInt(sbprint);

} catch (NumberFormatException e) {

current[0] = 60;

}

}

//Log.d(TAG, "...String:"+ sb.toString() + "Byte:" + msg.arg1 + "...");

break;

}

if ((current[0] > 110 && Math.abs(current[0] - previous[0]) >= 30) || current[0] > 200) {

// sendText(number);

//if(count[0] ==0) {

//for testing purposes:

// currentBPM.setText("ALERT DETECTED");

makeCall(caller[0]);

// }

count[0] = count[0]++;

}

}

};

btAdapter = BluetoothAdapter.getDefaultAdapter(); // get Bluetooth adapter

checkBTState();

Page 49: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 48

}

public void makeCall(Intent callNum) {

startActivity(callNum);

}

// public void sendText(String num) {

// final Context cont = MainActivity.this;

// Criteria cri = new Criteria();

// cri.setAccuracy(ACCURACY_FINE);

// LocationManager locator = (LocationManager) cont.getSystemService(Context.LOCATION_SERVICE);

//// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + num));

//// if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=

PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,

Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

//// // TODO: Consider calling

//// // ActivityCompat#requestPermissions

//// // here to request the missing permissions, and then overriding

//// // public void onRequestPermissionsResult(int requestCode, String[] permissions,

//// // int[] grantResults)

//// // to handle the case where the user grants the permission. See the documentation

//// // for ActivityCompat#requestPermissions for more details.

//// return;

//// }

//// intent.putExtra("sms_body", locator.getLastKnownLocation(locator.getBestProvider(cri, true)));

//// startActivity(intent);

//

// SmsManager smsManager = SmsManager.getDefault();

// if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=

PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,

Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

// // TODO: Consider calling

// // ActivityCompat#requestPermissions

// // here to request the missing permissions, and then overriding

// // public void onRequestPermissionsResult(int requestCode, String[] permissions,

// // int[] grantResults)

// // to handle the case where the user grants the permission. See the documentation

// // for ActivityCompat#requestPermissions for more details.

// return;

// }

// smsManager.sendTextMessage("tel:"+num, null, locator.getLastKnownLocation(locator.getBestProvider(cri,

true)).toString(), null, null);

// }

Page 50: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 49

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.menu_main, menu);

return true;

}

@Override

public boolean onOptionsItemSelected(MenuItem item) {

// Handle action bar item clicks here. The action bar will

// automatically handle clicks on the Home/Up button, so long

// as you specify a parent activity in AndroidManifest.xml.

int id = item.getItemId();

//noinspection SimplifiableIfStatement

if (id == R.id.action_settings) {

return true;

}

return super.onOptionsItemSelected(item);

}

@Override

public void onResume() {

super.onResume();

Log.d(TAG, "...onResume - try connect...");

// Set up a pointer to the remote node using it's address.

String address = "20:16:09:18:75:41";

BluetoothDevice device = btAdapter.getRemoteDevice(address);

// Two things are needed to make a connection:

// A MAC address, which we got above.

// A Service ID or UUID. In this case we are using the

// UUID for SPP.

try {

btSocket = createBluetoothSocket(device);

} catch (IOException e) {

errorExit("Fatal Error", "In onResume() and socket create failed: " + e.getMessage() + ".");

}

// Discovery is resource intensive. Make sure it isn't going on

// when you attempt to connect and pass your message.

btAdapter.cancelDiscovery();

Page 51: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 50

// Establish the connection. This will block until it connects.

Log.d(TAG, "...Connecting...");

try {

btSocket.connect();

Log.d(TAG, "....Connection ok...");

} catch (IOException e) {

try {

btSocket.close();

} catch (IOException e2) {

errorExit("Fatal Error", "In onResume() and unable to close socket during connection failure" +

e2.getMessage() + ".");

}

}

// Create a data stream so we can talk to server.

Log.d(TAG, "...Create Socket...");

ConnectedThread mConnectedThread = new ConnectedThread(btSocket);

mConnectedThread.start();

}

@Override

public void onPause() {

super.onPause();

Log.d(TAG, "...In onPause()...");

try {

btSocket.close();

} catch (IOException e2) {

errorExit("Fatal Error", "In onPause() and failed to close socket." + e2.getMessage() + ".");

}

}

private void checkBTState() {

// Check for Bluetooth support and then check to make sure it is turned on

// Emulator doesn't support Bluetooth and will return null

if(btAdapter==null) {

errorExit("Fatal Error", "Bluetooth not support");

} else {

if (btAdapter.isEnabled()) {

Log.d(TAG, "...Bluetooth ON...");

} else {

//Prompt user to turn on Bluetooth

Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);

Page 52: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 51

startActivityForResult(enableBtIntent, 1);

}

}

}

private void errorExit(String title, String message){

Toast.makeText(getBaseContext(), title + " - " + message, Toast.LENGTH_LONG).show();

finish();

}

public class ConnectedThread extends Thread {

private final InputStream mmInStream;

ConnectedThread(BluetoothSocket socket) {

InputStream tmpIn = null;

// Get the input and output streams, using temp objects because

// member streams are final

try {

tmpIn = socket.getInputStream();

} catch (IOException e) { }

mmInStream = tmpIn;

}

public void run() {

byte[] buffer = new byte[256]; // buffer store for the stream

int bytes; // bytes returned from read()

// Keep listening to the InputStream until an exception occurs

while (true) {

try {

// Read from the InputStream

bytes = mmInStream.read(buffer); // Get number of bytes and message in "buffer"

h.obtainMessage(RECEIVE_MESSAGE, bytes, -1, buffer).sendToTarget(); // Send to message queue

Handler

} catch (IOException e) {

break;

}

}

}

}

}

Page 53: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 52

ANDROIDMANIFEST.XML

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.tamsinedwards.panicmonitor2" >

<uses-permission android:name="android.permission.BLUETOOTH"/>

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<uses-permission android:name="android.permission.CALL_PHONE"/>

<uses-permission android:name="android.permission.SEND_SMS"/>

<application

android:debuggable="true"

android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:supportsRtl="true"

android:theme="@style/AppTheme" >

<activity

android:name=".MainActivity"

android:label="@string/app_name"

android:theme="@style/AppTheme.NoActionBar" >

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity><!-- ATTENTION: This was auto-generated to add Google Play services to your project for

App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->

<meta-data

android:name="com.google.android.gms.version"

android:value="@integer/google_play_services_version" />

</application>

</manifest>

CONTENT_MAIN.XML

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/content_main"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingLeft="@dimen/activity_horizontal_margin"

Page 54: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 53

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

android:paddingBottom="@dimen/activity_vertical_margin"

app:layout_behavior="@string/appbar_scrolling_view_behavior"

tools:showIn="@layout/activity_main"

tools:context="com.tamsinedwards.panicmonitor2.MainActivity">

<Button

android:text="save"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/save"

android:layout_marginTop="14dp"

android:layout_below="@+id/phoneEntry"

android:layout_alignParentLeft="true"

android:layout_alignParentStart="true" />

<Button

android:text="call"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@+id/save"

android:layout_alignParentLeft="true"

android:layout_alignParentStart="true"

android:layout_marginTop="8dp"

android:id="@+id/call" />

<EditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:inputType="phone"

android:ems="10"

android:id="@+id/phoneEntry"

android:textColor="?attr/actionMenuTextColor"

android:layout_alignParentTop="true"

android:layout_alignParentLeft="true"

android:layout_alignParentStart="true"

tools:text="Enter a phone number..." />

<TextView

android:text="previous bpm"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_below="@+id/currentBPM"

android:layout_marginTop="15dp"

android:id="@+id/prevBPM" />

Page 55: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 54

<TextView

android:text="current bpm"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/currentBPM"

android:layout_marginTop="14dp"

android:layout_below="@+id/call"

android:layout_alignParentLeft="true"

android:layout_alignParentStart="true" />

</RelativeLayout>

Page 56: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 55

APPENDIX I. POSTER INFORMATION

Page 57: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 56

Page 58: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 57

Page 59: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 58

Page 60: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 59

Page 61: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 60

Page 62: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 61

Page 63: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 62

Page 64: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 63

APPENDIX J. BAKCGROUND INFORMATION NOTES

VENKATESH; ELECTRONIC PATCH WIRELESS REFLECTANCE PULSE OXIMETRY…

Original URL http://www.ijesrt.com/issues%20pdf%20file/Archives%202013/may-2013/56.pdf

File name of PDF 160915_venkatesh_oximtery

Date Written May 2013 Date Accessed September 15, 2016

Type of paper Original research

Goal of the paper Describe the development of a wireless patch to measure vitals

Major findings They were able to create their design

Notes on the paper Polymer based material Reflectance pulse oximetry heart rate + O2 levels from shining light into body Small thermometer

Biases of the authors They made it

My opinions on the paper

It’s probably good, I only read the abstract

Follow up questions and ideas

What was their actual process?

keywords Electronic patch, reflectance pulse oximetry, heart rate monitoring

Page 65: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 64

SCHULTZ; BIOSENSORS

Original URL http://www.nature.com/scientificamerican/journal/v265/n2/pdf/scientificamerican0891-64.pdf

File name of PDF 160915_schultz_biosensors

Date Written August 1991 (yikes) Date Accessed September 15, 2016

Type of paper Secondary Source

Goal of the paper

Present uses for bionsensors in medical monitoring

Major findings They were able to create their design

Notes on the paper

Based on molecular components of plants/animals Quick test results Continuous monitoring Article mostly used for in-hospital bedside analysis

Biases of the authors

Worked on some of the sensors described

My opinions on the paper

Focused on the glucose monitor a lot, but that’s expected. Also old.

Follow up questions and ideas

What has changed since this was written?

keywords Medical monitoring, biochemical, microcircuits, sensors

Page 66: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 65

HERNANDEZ, MCDUFF, AND PICARD; BIOWATCH

Original URL http://ieeexplore.ieee.org.ezproxy.wpi.edu/stamp/stamp.jsp?arnumber=7349394&tag=1

File name of PDF 160925_hernandez_biowatch

Date Written 2015 Date Accessed September 25, 2016

Type of paper Primary Source

Goal of the paper

Use accelerometers and gyroscopic sensors to measure heart rate and breathing rate

Major findings Useful and accurate, but seemingly only when wearer is completely still

Notes on the paper

Accelerometer & gyroscope good for measuring sleep patterns Accurate for three positions tested Empatica, MyBasis, Mio Alpha google? Battery life is very low with this kind of monitoring (9 hours at reduced frequency)

Biases of the authors

None?

My opinions on the paper

Good, interesting to see how the technology holds up to motion, can it tell the difference between breathing and moving in general

Follow up questions and ideas

What happens when the wearer is moving? Could I put my device on the ear instead of the wrist? closer to heart, easier to get SpO2 because ears are thin Is there a way I could incorporate this despite the apparent problems with motion?

keywords Accelerometer; gyroscope; smartwatch; wrist; ballistocardiography; photoplethysmography; sleep monitoring; respiration; heart rate; breathing rate

Page 67: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 66

SAFAR AND EL-DASH; PULSE OXIMETRY

Original URL http://cpj.sagepub.com.ezproxy.wpi.edu/content/54/14/1375.full.pdf+html

File name of PDF 160925_safar_oxygen

Date Written 2015 Date Accessed September 25, 2016

Type of paper Primary Source

Goal of the paper

Comparing accuracy of wrist/ankle measurements to those on hand and foot

Major findings Wrist and ankle work for babies

Notes on the paper

Focus on babies applications to teens/young adults as well? Pulse oximetry is accurate Fingers are most accurate, but less convenient than other placements

Biases of the authors

none

My opinions on the paper

Could have gone more in depth

Follow up questions and ideas

Can this be applied to teens or young adults or is it baby-specific? Are there more effective placements for older patients?

keywords Pulse oximetry, oxygen saturation, wrist, ankle

Page 68: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 67

DA HE, WINOKUR, HELDT, SODINI; THE EAR AS A LOCATION FOR WEARABLE VITAL SIGNS

MONITORING

Original URL http://ieeexplore.ieee.org/document/5627309/?part=1

File name of PDF 160929_dahe_ear

Date Written September 4, 2010 Date Accessed September 29, 2016

Type of paper Conference proceedings

Goal of the paper

To establish the accuracy an viability of the placing devices behind the ear to get readings on vital signs

Major findings Ears are good

Notes on the paper

Ears are stationary which increases accuracy Not as obvious as the wrist Getting oxygen from the ear is less cumbersome than on the wrist but it’s still accurate Ears don’t rotate which is good for measuring these things There’s also a way to get the breathing rate

Biases of the authors

n/a

My opinions on the paper

It didn’t do a great job of explaining what they did, but there was lots of information in it.

Follow up questions and ideas

What are ballistocardiography, photoplethysmograph, OPT101,common-mode feedback, intrathoracic strain, and the Valsalva maneuver?

keywords Ear, heart rate, oximetry

Page 69: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 68

LEBOEUF, AUMER, KRAUS, JOHNSON, & DUSCHA; EARBUD-BASED SENSOR FOR THE ASSESSMENT

OF ENERGY EXPENDITURE, HEART RATE, AND VO2MAX

Original URL https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3996514/pdf/nihms542366.pdf

File name of PDF 161003_leboeuf_earbud

Date Written May 2014 Date Accessed October 3, 2016

Type of paper Author Manuscript primary source

Goal of the paper

Determine the feasibility of a device to measure total energy expenditure and oxygen consumption in an earbud

Major findings Their sensor worked well

Notes on the paper

Mostly based on exercise, but similar principles for my project? Inside the ear is more discreet than on the ear, allows for speaker directly in the device, but is it still stable? Earbuds tend to fall out. Connected through Bluetooth (short range, low battery life) Their device also tracks your distance which is cool but not really helpful to me

Biases of the authors

N/A

My opinions on the paper

Could have explained things better, which is a common theme with all of my sources so far

Follow up questions and ideas

Maybe look into placing the device in an earbud since people are less likely to question headphones than a large thing on people’s ears (patient confidentiality)

keywords Ear, accelerometer, photoplethysmography, pulse

Page 70: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 69

LI; A WIRELESS TRACKING SYSTEM FOR AT-HOME MEDICAL EQUIPMENT DURING NATURAL

DISASTERS

Original URL http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=7160188

File name of PDF 161002_li_connection

Date Written 2015 Date Accessed October 2, 2016

Type of paper Primary Source

Goal of the paper

Describe the development of a system to keep up communication between medical equipment and hospitals during power outages

Major findings

Notes on the paper

“radio ad hoc network to automatically report the patient’s information and location” exactly what I need to do basically Doesn’t use cell towers or cost money every month which is good Algorithm seems reasonable (written in C) Works better with more users around not too good for me

Biases of the authors

n/a

My opinions on the paper

It is similar to mine and explains the process a lot better than the other papers

Follow up questions and ideas

Look into integrated reporting units

keywords Ad hoc network, DME, Durable Medical Equipment, GPS, Radio Tracking System, Wireless, Zigbee, Xbee

Page 71: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 70

WARRING ET AL.; METHODS AND DEVICES FOR FACILITATED NON-INVASIVE OXYGEN MONITORING

Original URL https://www.google.com/patents/US5402777

File name of PDF

161003_warring_patent

Date Written April 4, 1995 Date Accessed October 3, 2016

Type of paper

Patent

Goal of the paper

Patent the device the authors made

Major findings

n/a?

Notes on the paper

Transmissive = through the skin Transflective = on the same side Look into “Cyclops sensor” still around? Works for an “extended period of time”, up to a week this could work in a limited capacity for me

Biases of the authors

n/a?

My opinions on the paper

At least this one explained some things even if I didn’t understand said things

Follow up questions and ideas

Look into Cyclops sensors 3D print the device?

keywords Pulse oximetry, oxygen sensor, heart rate monitor, wearable technology

Page 72: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 71

RIGHTER & FALLIN; WRIST WORN HEART RATE MONITOR

Original URL https://patentimages.storage.googleapis.com/pdfs/8fbb18afeb5dadf19404/US4938228.pdf

File name of PDF 161003_righter_patent

Date Written Feb 15, 1989 Date Accessed October 3, 2016

Type of paper Patent

Goal of the paper

Patent a wrist-worn heart rate monitor

Major findings n/a

Notes on the paper

Can the sensor system be condensed (probably, this is old)? Measure ECG/EKG for heart rate Two sensor system – one on wrist, one on finger Designed for use during exercise, so probably applies well to daily life Accuracy factors – signal:noise ratio, level of exercise (not a problem for me?), contact quality (issue with ears?)

Biases of the authors

They made it

My opinions on the paper

It had explanation!

Follow up questions and ideas

What developments have been made since?

keywords Heart rate monitor, wearable technology

Page 73: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 72

MERTZ; ARE WEARABLES SAFE?

Original URL http://ieeexplore.ieee.org.ezproxy.wpi.edu/stamp/stamp.jsp?arnumber=7387859 Digital Object Identifier 10.1109/MPUL.2015.2498477

File name of PDF 161024_mertz_safety

Date Written 21 January 2016 Date Accessed 24 October 2016

Type of paper Journal Article

Goal of the paper

Establish the safety of emerging wearable technology

Major findings Nothing definitive

Notes on the paper

Old tech made it necessary to keep things away from body Wearable tech has accuracy problems, possibly distracting Electromagnetic fields – dangerous? Evidence for that is shady at best

Biases of the authors

n/a

My opinions on the paper

Didn’t really provide a lot of information, more just speculation about possible effects

Follow up questions and ideas

Should I be worried about putting the device so close to the brain?

keywords Wearable technology medical

Page 74: Panic Attack Monitor - Worcester Polytechnic Instituteusers.wpi.edu/~tredwardslambour/pdfs/stem.pdf · Panic Attack Monitor Engineering a device to automatically detect physical symptoms

E d w a r d s L a m b o u r n e | 73

HAMM ET AL.; PANIC DISORDER

Original URL http://onlinelibrary.wiley.com/doi/10.1111/psyp.12553/epdf

File name of PDF 161025_hamm_panic

Date Written 1 August 2015 Date Accessed 25 October 2016

Type of paper Journal Article

Goal of the paper

Analyze the symptoms and types of responses to panic attacks in people with Panic Disorder with and without Agoraphobia & their responses to therapy

Major findings Those with strong tendencies to avoid situations that caused panic respond better with a therapist guiding them through the situation

Notes on the paper

Panic attack = "abrupt and intense fear responses to acute threat arising from inside the body" Anxious apprehension = "anxiety responses to potential harm and more distant of uncertain threat" For diagnosis: 4+ of 13 physical & cognitive symptoms (according to patient)

Persistent worry about additional Rapid increase in heart rate and skin conductance Avoidance/escape tendencies Hyperventilation?? CO2 partial pressure being low?

Biases of the authors

n/a

My opinions on the paper

Helpful, even if it focused more on the behaviours than the symptoms that can be monitored.

Follow up questions and ideas

Is monitoring heart rate enough to accurately detect panic attacks? Can I easily use skin conductance somehow? Is there a general heart rate that is typically reached during a panic attack? Can I monitor hyperventilation?

keywords Panic attack physical symptoms