Actogram from browsers history, to screen sleep-wake patterns and sleep disorders.
This repository and tool will be renamed.
Forked from Barrett F. Davis excellent online_actogram script.
Script to generate an 'online actogram' from web browser history files.
The graphical presentation was inspired by this UCSD tutorial and this scientific paper.
Currently configured to import history from ALL browsers available on the system, from the default user profiles for each:
- Windows:
- Chrome
Historyfile - Edge
Historyfile
- Chrome
- MacOS:
- Chrome
Historyfile - Safari
History.db
- Chrome
Currently, this script may not function as intended if you use multiple profiles within one browser, or the browser's default installation profile has changed.
History files are copied from their home directories to a temporary location in the working directory. These copies are then deleted after the script has executed. Only the last_visit_time is read.
Plots are easily generated from the command line:
python actogram.py
Plots will be saved in a new sub-folder called "actograms" with appropriate timestamp and description.
Script 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)
[Feature] Added support for the Default profile of Microsoft Edge for Windows
[Bug fix] Previously there was an artificially low minimum window for all generated plots. Plots can now be shown with minutes resolution
[Feature] Added "activity CDF" subplot to gauge periods of minimum and maximum activity
[Feature] Added cumulative "offline hours" subplot to estimate sleep per 24h period (NB: this yields artificially high results with high freq values)
This tool originated from an idea and script by Barrett F. Davis, initially released in July 2020.
MIT Public License.
Another project, inspired by this one, was written in Javascript using D3, but it cannot fetch 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..