Circadiaware / webactogram

🌐🏃Use your browser's history as a novel instantaneous mass screening tool for 🌙🛌sleep patterns & maybe disorders!
MIT License
8 stars 2 forks source link

WebActogram

PyPI-Status PyPI-Versions PyPi-License PyPI-Downloads

🌐🏃Use your browser's history as a novel instantaneous mass screening tool for 🌙🛌sleep patterns & maybe disorders!

image

Install & Quickstart

Install with a precompiled binary

This is the easiest way to install if you don't use Python.

Precompiled binaries are available for Windows 64-bits (MacOS and Linux in the future too).

To download, just get the .exe file of the latest release.

Note: if you cannot find the .exe download on your computer, make sure that you explicitly accepted the download in your browser (eg, Chrome), as it may block it for safety and require you to go to the browser's downloads tab and accept manually the download (there is absolutely no risk, but if you are paranoid you can use the Python module instead, it's the exact same software).

Then just double-click on webactogram_vX.Y.Z.exe, it will autogenerate the actogram and then show it in a pop-up window.

On Windows, you may need to manually pass the Windows Defender SmartScreen like this:

Install using Python

First you need a modern Python 3 interpreter (Python > 3.7), such as Miniconda3.

Then, install WebActogram with:

pip install webactogram

To generate an actogram and display it, type the following command in a terminal (or cmd or PowerShell on Windows):

webactogram

Note: First, you need to cd in a folder with write permission (so that the actogram image can be saved in a subfolder).

This will create a folder actograms in the current folder, and add inside a picture with the latest actogram and a csv file with all the browsers activities recorded.

More options, such as the sampling frequency (and hence granularity of the actogram and its patterns) can be shown with:

webactogram --help

Description

WebActogram is a tool that generates an activity graph, called an online actogram, from web browsers history files. It supports various browsers including Google Chrome, Mozilla Firefox and Safari history files (full list of supported browsers here).

To screen sleep-wake patterns and disorders, all sleep screening tools require that the user either manually record a sleep diary or wears an actigraphic device or participate in an even more cumbersome constant routine study with melatonin sampling under always dark conditions.

The main limitations of these approaches are:

  1. the upfront cost (in money and/or time), as there needs to be a suspicion of a sleep disorder to request such data from a subject or medical tests (especially melatonin sampling),
  2. there is a big latency between the time the user first suspects they may have a sleep disorder and the time they have enough data to get diagnosed, as it takes weeks or even months of rigorously acquired data by a very compliant subject for the sleep clinician to then be able to interpret if there is any potential sleep disorder.

Both of these issues make current sleep disorders diagnostic procedures very poor screening procedures, as the hurdles to get enough data to assess whether there is any sleep disorder at all is just too high for most people and is likely causing a big dropout rate. Behavioral scales are also unfit for circadian rhythm disorders diagnosis.

The web actogram is the first tool that can provide an instantaneous estimation of the user’s sleep-wake pattern, aka actogram, by being a pseudo-actigraphic tool that infers an actogram from the browser’s history. This could allow for mass screening of sleep-wake patterns and disorders via the simple and fast installation of an app.

Multiple web browsers are supported, and the histories of all supported browsers will be merged automatically, and include all profiles installed in all browsers.

Example plots: horizontal (landscape) mode:

Vertical (portrait) mode:

The limitations are however as follows:

How the actogram is plotted was inspired by this UCSD tutorial and this scientific paper.

Usage

Plots are easily generated from the command line by typing the following command:

webactogram

Plots will be saved in a new sub-folder called "actograms" with appropriate timestamp and description.

The software now supports command line arguments for additional customizability. For example:

python actogram.py --freq '15T' --daily_blur 3 --start '2020-01-01'

python actogram.py --freq '30T' --printer_friendly True

python actogram.py --dims (8,8)

Where:

--freq determines the granularity of binned online/offline periods (default is 15 minutes increments, ex.  --freq '15T')

--start_date sets initial date to plot from, default is 180 days ago (ex. --start_date '2022-01-01')

--daily_blur applies median filtering between days (off by default, ex. --daily_blur 3)  

--period_blur applies median filtering between binned time periods (off by default, ex. --period_blur 5)

--normalize normalizes search frequency against max, then applies binary mask (plot shows periods of some search history vs. none, on by default)

--dims sets the relative dimensions of generated actogram plot (ex. --dims (4, 6))

--printer_friendly sets whether activity is shown in black on white (friendly) or vice versa (False by default, ex. --printer_friendly True)

Privacy statement

The only data that is extracted from your browsers usage is the datetime of visited pages from the browsers histories. The URLs are not extracted, nor any other information than datetimes. No data is ever leaving your computer.

Authors

This tool is a fork from the excellent online_actogram script by Barrett F. Davis who conceived both the idea and the first implementation initially released in July 2020.

Since then, it is maintained by Stephen Karl Larroque and the Circadiaware Collective.

Lots of awesome contributors made awesome contributions to further improve this software, we cannot thank them enough!

Contributors

For a list of all contributors, please see the GitHub Contributors graph and the commits history.

License

MIT Public License.

Similar projects

Another project, inspired by this one, was written in Javascript using D3, but it cannot fetch browser's history, it can only plot from an already extracted browser’s history: Tylian's D3 Browser's History. How to generate the history.txt file (source): It's a dump of the timestamp column with some manual processing to divide every entry by 1000, since Firefox stores them as a nanosecond epoch for some reason..