Editing Tracking smoking habits

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 4: Line 4:
  
 
== Background ==
 
== Background ==
I've been trying to quit smoking on and off, with temporary but ultimately limited success. I thought having some more qualitative data on how much smoke might help me to a) identify the extend of my smoking habit and potentially also find some triggers/situations in which I smoke and b) ultimately figure out a way to deliver feedback to help me stop. This project was partially inspired by a reddit post regarding using [[Flic button|Flic buttons]] as a [[One Button Tracker|one-button tracker]]<ref>https://www.reddit.com/r/QuantifiedSelf/comments/vu74jo/comment/ifc9eul/?utm_source=share&utm_medium=web2x&context=3</ref>.  
+
I've been trying to quit smoking on and off, with temporary but ultimately limited success. I thought having some more qualitative data on how much smoke might help me to a) identify the extend of my smoking habit and potentially also find some triggers/situations in which I smoke and b) ultimately figure out a way to deliver feedback to help me stop. This project was partially inspired by a reddit post regarding using [[Flic button|Flic buttons]] as a [[One Button Tracker|one-button tracker]].  
  
 
== Initial setup, protocol and baseline collection ==
 
== Initial setup, protocol and baseline collection ==
 
[[File:Flic-spreadsheet-setup.png|thumb|The Google Sheet into which data is written automatically. Geolocation for the first data points is empty as location permissions weren't set correctly.]]
 
[[File:Flic-spreadsheet-setup.png|thumb|The Google Sheet into which data is written automatically. Geolocation for the first data points is empty as location permissions weren't set correctly.]]
Before starting on any interventions or even providing feedback, I wanted to collect some baseline data on how much I smoke and when. For this I connected my Flic button to my phone and set it up to trigger an IFTTT<ref>https://ifttt.com/</ref> trigger every time the button was pressed. IFTTT in turn would write the button presses into a Google Sheet to collect the data. In total I decided to collect 3 types of data:  
+
Before starting on any interventions or even providing feedback, I wanted to collect some baseline data on how much I smoke and when. For this I connected my Flic button to my phone and set it up to trigger an IFTTT trigger every time the button was pressed. IFTTT in turn would write the button presses into a Google Sheet to collect the data. In total I decided to collect 3 types of data:  
  
 
# Type of click, the Flic supports regular clicks, double clicks as well as recording holding the button
 
# Type of click, the Flic supports regular clicks, double clicks as well as recording holding the button
Line 17: Line 17:
 
I then used a little clip to attach the Flic button to my pack of cigarettes, which made for an easy protocol: Every time I'd take out a cigarette and smoke, I'd press the Flic button to record the location and timestamp data.  
 
I then used a little clip to attach the Flic button to my pack of cigarettes, which made for an easy protocol: Every time I'd take out a cigarette and smoke, I'd press the Flic button to record the location and timestamp data.  
  
=== Refining the protocol ===
 
 
Within the first two days it became clear that relying on regular presses of the button would result in recording false-positives: As the button spends a lot of time within the pockets of my trousers, it is prone to accidental short presses or long presses because of other stuff that bumps around in the pocket. Luckily, doing a double press requires a more deliberate action and seemed unlikely to be generated by accident, so I adapted my protocol to only record actual data by doing double clicks.  
 
Within the first two days it became clear that relying on regular presses of the button would result in recording false-positives: As the button spends a lot of time within the pockets of my trousers, it is prone to accidental short presses or long presses because of other stuff that bumps around in the pocket. Luckily, doing a double press requires a more deliberate action and seemed unlikely to be generated by accident, so I adapted my protocol to only record actual data by doing double clicks.  
  
=== Getting the baseline data ===
+
I started the data collection on July 13th, 2022 and continued to do the recording protocol until August 16, 2022, giving me a good month worth of baseline data. During this time I did not look at the data beyond spot-checks to make sure the data collection still worked (i.e. no plotting/reasoning about the data during this period).  
I started the data collection on July 13th, 2022 and continued to do the recording protocol until August 16, 2022, giving me a good month worth of baseline data. During this time I did not look at the data beyond spot-checks to make sure the data collection still worked (i.e. no plotting/reasoning about the data during this period). After that time period I downloaded the data from the spreadsheet and loaded into [[R]] to explore the data I had gathered so far by making some basic plots of the data, starting with a simple time series before looking at the overall distribution.  
 
  
=== Learning from the baseline ===
+
The baseline more or less confirmed my initial gut feeling regarding my smoking frequency: I had expected it to be an average of around 10 cigarettes a day, and over the baseline it came out at 8.6 which is slightly lower than guess was.
The baseline more or less confirmed my initial gut feeling regarding my smoking frequency: I had expected it to be an average of around 10 cigarettes a day. My baseline data came out at a median number of 9 which is slightly lower than guess was. I also decided to break down the data between regular working days and weekends to see if there's a strong effect there. While the violin plots show a slightly shifted distribution, the actual differences aren't too big, with the median remaining at 9 for weekdays and lowering to 8 for weekends.
 
 
 
==Implementing a feedback method==
 
With a solid baseline data collection in hand I now decided to start implementing a more immediate feedback mechanism: So far all collected data went into a Google Sheet but would remain there unseen until the moment I decided to view the data as a spreadsheet or export it to make plots by hand. As a simple small intervention I decided I would like to start by giving more immediate feedback when pressing the button, which I hope would help me reflect on my smoking habit and ideally motivate me into keeping those daily numbers down as they are now properly counted and highlighted to me. 
 
[[File:Flic-smoking-notification-setup.png|thumb|500x500px|The spreadsheet after adding some columns for processing]]
 
The simplest way would be to automatically send back a notification to my phone/smart watch regarding how many cigarettes I had so far smoked throughout the day. It turns out this is also (somewhat) easy through IFTTT, as it not only allows writing data to a spreadsheet, but also monitor specific cells for changes. Effectively, I would have to count the number of records in a spreadsheet that were done on the current day. Implementing this was not as easy as I had hoped though, given that the timestamps that IFTTT writes are rather ugly (see top image).
 
 
 
To solve this issue I took the following steps:
 
 
 
#Split the dates in column D into its components through the formula <code>=ArrayFormula(SPLIT(D2:D," ,"))</code>, resulting columns E to I.
 
#This splitting would then allow me to construct a more "normal" date format in column J using <code>=ARRAYFORMULA(F2:F&" "&E2:E&" "&G2:G)</code>
 
#I then convert the data into the <code>date_value</code> in column K through the formula <code>=ArrayFormula(DATEVALUE(J2:J))</code>, as I could not figure out how to otherwise compare the dates correctly.
 
[[File:Smoke-counter.jpg|thumb|A notification that was triggered by recording a new data point.  ]]
 
Through the use of <code>ArrayFormula</code> all columns would automatically populate until the end of the spreadsheet, which includes all new data that is added by future button presses. With a continuously growing column K, I could now compare that value to the date value of whatever the current date is:
 
 
 
#In cell N2 I get today's datevalue using <code>=DATEVALUE(TODAY())</code>
 
#In cell N3 I could then do a conditional counting to see how many data points were collected both today and through the double click, <code>=COUNTIFS(A2:A,"double_click",K2:K,N2)</code>
 
 
 
As a result, every time I double click the Flic button, the value in cell N3 automatically increments upwards for a given day, before jumping back to zero at midnight. With this automated counting in the Google Sheet in place I then added a monitoring of this particular cell (N3) to IFTTT, and every change in the cell's value will trigger a notification on my phone/watch through the IFTTT app that informs me about today's counter status. IFTTT does not monitor the data in real-time, but rather every 5 minutes, which seems timely enough for now.
 
 
 
In a few weeks it will then be time to check the the data and compare it to the baseline to see if the intervention made any difference.
 
 
 
=== Fixing the feedback mechanism ===
 
'''Update 2022-08-17''': Unfortunately the regular monitoring that IFTTT provides for Google Sheets seems not to work reliably, leading to notifications rarely being sent. My workaround for this was to slightly change my IFTTT setup using the "webhooks" integration: 
 
 
 
# I expanded the IFTTT action that is taken when clicking the Flic button is pressed. After writing the data to the Google Sheet it now also uses the webhook integration to send a web-request to IFTTT itself. This webhook can than be used to trigger a second action
 
# The second IFTTT action listens for activity on the webhook that fired in step 1. When triggered it manually requests the current value of the cell in the Google Sheet as outlined above and then delivers the value as a rich notification to my phone/watch. 
 
 
 
This approach is pretty rigged together, but so far seems to work reliable and didn't require any programming.
 
 
 
== Project update - July 2023 ==
 
[[File:Respiratory rate time.png|thumb|Respiratory rate change while smoking and after stopping to smoke.]]
 
This project has stopped because of an amazing reason, as I stopped smoking: After switching to vaping for a few months in November 2022, I totally stopped smoking/vaping in February 2023. But there's some alternative, interesting data following this change: Looking at my respiratory rate as measured by the [[Oura Ring|Oura ring]], it seems that post-smoking my respiratory rate dropped an average of 2 breaths/min, which is super encouraging!
 
 
 
== References ==
 
<references />
 
 
 
[[Category:Projects]][[Category:Habits projects]]
 

Please note that all contributions to Personal Science Wiki are considered to be released under the Creative Commons Attribution-ShareAlike 3.0 Unported (see PersonalScienceWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page: