LightLogR
LightLogR: Reproducible analysis of personal light exposure data - Published in JOSS (2025)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 6 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
✓Committers with academic emails
3 of 4 committers (75.0%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
dosimetry
light
rstats-package
time-series-analysis
wearable-devices
wearable-sensors
Scientific Fields
Artificial Intelligence and Machine Learning
Computer Science -
40% confidence
Last synced: 4 months ago
·
JSON representation
Repository
R package for processing and analysing light logger and optical radiation dosimeter data
Basic Info
- Host: GitHub
- Owner: tscnlab
- License: other
- Language: HTML
- Default Branch: main
- Homepage: https://tscnlab.github.io/LightLogR/
- Size: 174 MB
Statistics
- Stars: 14
- Watchers: 0
- Forks: 2
- Open Issues: 4
- Releases: 12
Topics
dosimetry
light
rstats-package
time-series-analysis
wearable-devices
wearable-sensors
Created over 2 years ago
· Last pushed 5 months ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# LightLogR
[](https://github.com/tscnlab/LightLogR/actions/workflows/R-CMD-check.yaml) [](https://doi.org/10.5281/zenodo.11562600) [](https://CRAN.R-project.org/package=LightLogR)
[](https://joss.theoj.org/papers/10.21105/joss.07601)
[](https://app.codecov.io/gh/tscnlab/LightLogR)
Personalized luminous exposure data is progressively gaining importance in various sectors, including research, occupational affairs, and fitness tracking. Data are collected through a proliferating selection of wearable loggers and dosimeters, varying in size, shape, functionality, and output format. Despite or maybe because of numerous use cases, the field lacks a unified framework for collecting, validating, and analyzing the accumulated data. This issue increases the time and expertise necessary to handle such data and also compromises the FAIRness (Findability, Accessibility, Interoperability, Reusability) of the results, especially in meta-analyses.
::: {style="text-align:center"}
{width="90%"}
:::
**LightLogR** is a package under development as part of the [*MeLiDos*](https://www.melidos.eu) project to address these issues. The package aims to provide tools for:
- Import from common measurement devices (see below for a list of [Supported devices])
- Cleaning and processing of light logging data
- Visualization of light exposure data, both exploratory and publication ready
- Calculation of common analysis parameters (see below for a list of [Metrics])
To come:
- Import, creation, and verification of crucial metadata
- Semi-automated analysis and visualization (both command-line and GUI-based)
- Integration of data into a unified database for cross-study analyses
##### Please note that LightLogR is work in progress! If you are interested in the project and want to know more, you can subscribe to the [LightLogR mailing list](https://www.tscnlab.org/software). If you find a bug or would like to see new or improved features, please open an issue on the [GitHub repository](https://github.com/tscnlab/LightLogR/issues).
Have a look at the [Example] section down below to get started, or dive into the [Articles](https://tscnlab.github.io/LightLogR/articles/index.html) to get more in depth information about how to work with the package and generate images such as the one above, import data, visualization, and metric calculation.
## Installation
You can install LightLogR from [CRAN](https://cran.r-project.org/package=LightLogR) with:
``` r
install.packages("LightLogR")
```
You can install the latest development version of LightLogR from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("tscnlab/LightLogR")
```
## Example
Here is a quick starter on how to use **LightLogR**.
```{r, message = FALSE}
library(LightLogR)
#the following packages are needed for the examples as shown below.
library(flextable)
library(dplyr)
library(ggplot2)
```
### Import
You can import a light logger dataset with ease. The import functions give quick, helpful feedback about the dataset.
```{r, out.width="60%", fig.align='center'}
filename <-
system.file("extdata/205_actlumus_Log_1020_20230904101707532.txt.zip",
package = "LightLogR")
dataset <- import$ActLumus(filename, "Europe/Berlin", manual.id = "P1")
```
For more complex data, there is the useful `gg_overview()` function to get an immediate grasp of your data. It was automatically called during import (set `auto.plot = FALSE` to suppress this), but really shines for datasets with multiple participants. It also indicates where data is missing, based on the measurement epochs found in the data.
::: {style="text-align:center"}
{width="60%"}
:::
*note:* the above example image requires a large dataset, not included in the package. It is available, however, in the article on [Import & cleaning](https://tscnlab.github.io/LightLogR/articles/Import.html).
```
#example code, on how to use gg_overview():
dataset %>% gg_overview()
```
### Visualize
Once imported, **LightLogR** has many convenient visualization options.
```{r, fig.width = 11, fig.height = 4}
dataset %>% gg_days()
```
There is a wide range of options to the `gg_days()` function to customize the output. Have a look at the reference page (`?gg_days`) to see all options. You can also override most of the defaults, e.g., for different `color`, `facetting`, `theme` options. Helper functions can prepare the data (e.g. to aggregate it to coarser intervals), or to add to the plot (e.g., to add conditions, such as nighttime)
```{r, fig.width = 11, fig.height = 4.5}
dataset |>
#change the interval from 10 seconds to 15 minutes:
aggregate_Datetime("15 min") |>
#create groups of 3-hour intervals:
cut_Datetime("3 hours") |>
#plot creation, with a boxplot:
gg_days(geom = "boxplot", group = Datetime.rounded) |>
#adding nighttime indicators:
gg_photoperiod(c(47.9,9)) +
# the output is a standard ggplot, and can be manipulated that way
geom_line(col = "red", linewidth = 0.25) +
labs(title = "Personal light exposure across a week",
subtitle = "Boxplot in 3-hour bins")
```
### More than one dataset
The built-in dataset `sample.data.environment` shows a combined dataset of light logger data and a second set of data - in this case unobstructed outdoor light measurements. Combined datasets can be easily visualized with `gg_day()`. The `col` parameter used on the `Id` column of the dataset allows for a color separation.
```{r, out.width= "70%", fig.align='center', fig.height = 6}
sample.data.environment %>%
gg_day(
start.date = "2023-09-01",
aes_col = Id,
geom = "line") +
theme(legend.position = "bottom")
```
`gg_day()` will show plots always facetted by day, whereas `gg_days()` shows a timeline of days for each group. Both functions are opinionated in terms of the scaling and linebreaks to only show whole days, all of which can be adjusted.
There are many ways to enhance the plots - if, e.g., we look for periods of at least 1 hour above 250 lx, we can add and then visualize these periods easily
```{r, fig.width = 11, fig.height = 5, warning=FALSE}
sample.data.environment %>%
#search for these conditions:
add_clusters(MEDI > 250, cluster.duration = "30 min") |>
#base plot + add the condition
gg_days() |>
gg_state(state, fill = "red") +
#standard ggplot:
geom_hline(yintercept = 250, col = "red", linetype = "dashed") +
labs(title = "Periods > 250 lx mel EDI for more than 30 minutes")
```
There are more visualizations to try - the article on [Visualizations](https://tscnlab.github.io/LightLogR/articles/Visualizations.html) dives into them in-depths.
```{r, fig.width = 12, fig.height = 3}
sample.data.environment |> gg_heatmap(doubleplot = "next")
```
### Metrics
There are many [Metrics] used in literature for condensing personalized light exposure time series to singular values. `LightLogR` has a rather comprehensive number of these metrics with a consistent, easy-to-use interface.
```{r}
sample.data.environment |> # two groups: participant and environment
filter_Date(length = "2 days") |> #filter to three days each for better overview
group_by(Day = lubridate::date(Datetime), .add = TRUE) |> #add grouping per day
summarize(
#time above 250 lx mel EDI:
duration_above_threshold(MEDI, Datetime, threshold = 250, as.df = TRUE),
#intradaily variability (IV):
intradaily_variability(MEDI, Datetime, as.df = TRUE),
#... as many more metrics as are desired
.groups = "drop"
)
```
Other types of metrics can be derived less formally by the `durations()`, `extract_state()` or `extract_cluster()` function.
```{r}
dataset |>
gap_handler(full.days = TRUE) |> #extend the viewed time until midnight of the first and last day
durations(MEDI, show.missing = TRUE)
dataset |>
group_by(TAT250 = MEDI >= 250, .add = TRUE) |> #creating a grouping column that checks for values above 250lx
durations(MEDI)
```
The second row indicates where this status is true. This will be identical to:
```{r}
dataset |>
summarize(
duration_above_threshold(MEDI, Datetime, threshold = 250, as.df = TRUE),
.groups = "drop"
)
```
What if we are interested in how often this threshold is crossed, and for how long?
```{r}
dataset |>
extract_states(TAT250, MEDI >= 250) |> #extract a list of states
summarize_numeric() |> #summarize the numeric values
select(Id, TAT250, mean_duration, episodes, total_duration) #collect a subset
```
We see that there are roughly one thousand instances across the week where 250 lx was reached, but it only lasted under two minutes on average. How many long periods are there, say above 30 minutes? As there might be short interruption, that we consider irrelevant, we are ignoring interruptions of 1 minute. This is the area of clusters.
```{r}
dataset |>
extract_clusters(MEDI >= 250, #base condition
cluster.duration = "30 mins", #search for at least 30 minute instances
interruption.duration = "1 min", #allow 1 minute interrupts
add.label = TRUE) |> #add a description of the conditions
group_by(label) |> #group by the label so it does not get removed next
summarize_numeric() |> #summarize the output
select(-mean_epoch) #collect a subset
```
We see there are only 17 instances across the week, lasting, on average, a bit above an hour (and sitting aroung 14:00 - 15:00). Directly relating the total duration to the 1.29 days time above 250 lx from above would be misleading, however. This is because here, there are interruptions present. How prominent are these interruptions?
```{r}
dataset |>
extract_clusters(MEDI >= 250, #base condition
cluster.duration = "30 mins", #search for at least 30 minute instances
interruption.duration = "1 min", #allow 1 minute interrupts
add.label = TRUE) |>
#extract the metric:
extract_metric(dataset, rel_interrupt = sum(MEDI < 250)/n()) |>
summarize_numeric(prefix = "") |> #summarize the output
select(episodes, total_duration, rel_interrupt) |> #collect a subset
mutate(interrupt_duration = (total_duration*rel_interrupt) |> round(), #calculate interrupt
rel_interrupt = rel_interrupt |> scales::percent_format(1)())
```
Thus we find that only about 4% of the long exposure periods are made up of interruptions, or just shy of 50 minutes out of over 20 hours.
### Gaps and cleaning
**LightLogR** provides a range of functions to get insight into your light logger data. Most importantly, you can search for and eliminate implicit gaps.
```{r}
sample.data.irregular |> has_irregulars()
sample.data.irregular |> has_gaps()
```
At import, we already get a sense for intervals, but can always show them with `count_difftime()`.
```{r}
sample.data.irregular %>% count_difftime()
```
We can eliminate this through the `gap_handler()` function. This function will automatically fill in the gaps with NA values. **The function will not impute or interpolate data**. As the most dominant interval in the dataset is now not 15 seconds anymore (because intermediate datapoints have been added), we need to specify the epoch for `gap_finder()`.
```{r}
sample.data.irregular |> gap_handler() |> has_gaps(epoch = "15 secs")
```
If we want to force the data to be regular, we can use the `aggregate_Datetime()` function. This will aggregate the data to the specified epoch. There are sensible defaults on how to aggregate numeric, categorical, and logical data. You can also specify your own aggregation functions.
```{r}
sample.data.irregular |>
aggregate_Datetime(unit = "20 sec") |>
has_gaps()
```
There are also convenient functions to extract (`extract_gaps()`), summarize (`gap_table()`) or visualize (`gg_gaps()`) gaps.
```{r, fig.width = 11, fig.height = 3}
dataset |> gg_gaps()
```
Finally, the `remove_partial_data()` easily gets rid of groups or days that do not provide enough data.
```{r, fig.width = 11, fig.height = 3}
dataset |>
remove_partial_data(MEDI, #variable for which to check missingness
threshold.missing = "2 hours", #remove when more than 2 hours are missing
by.date = TRUE, #check the condition per day, not the whole participant
handle.gaps = TRUE) |> #go beyond the available data to midnight of the first and last day
gg_days()
```
## Supported devices
At present, these are the devices we support in LightLogR:
`r library(LightLogR); paste("- ", supported_devices() %>% paste(collapse = "\n\n- "))`
More Information on these devices can be found in the reference for `import_Dataset()`. If you want to know how to import data from these devices, have a look at our article on [Import & Cleaning](https://tscnlab.github.io/LightLogR/articles/Import.html).
If you are using a device that is currently not supported, please contact the developers. We are always looking to expand the range of supported devices. The easiest and most trackable way to get in contact is by opening a new issue on our [Github repository](https://github.com/tscnlab/LightLogR/issues). Please also provide a sample file of your data, so we can test the import function.
## Metrics
LightLogR supports a wide range of metrics across different metric families. You can find the full documentation of metrics functions in the [reference section](https://tscnlab.github.io/LightLogR/reference/index.html#metrics). There is also an overview article on how to use [Metrics](https://tscnlab.github.io/LightLogR/articles/Metrics.html).
| Metric Family | Submetrics | Note | Documentation |
|------------------|----------------|-----------------|---------------------|
| Barroso | 7 | | `barroso_lighting_metrics()` |
| Bright-dark period | 4x2 | bright / dark | `bright_dark_period()` |
| Centroid of light exposure | 1 | | `centroidLE()` |
| Dose | 1 | | `dose()` |
| Disparity index | 1 | | `disparity_index()` |
| Duration above threshold | 3 | above, below, within | `duration_above_threshold()` |
| Exponential moving average (EMA) | 1 | | `exponential_moving_average()` |
| Frequency crossing threshold | 1 | | `frequency_crossing_threshold()` |
| Intradaily Variance (IV) | 1 | | `intradaily_variability()` |
| Interdaily Stability (IS) | 1 | | `interdaily_stability()` |
| Midpoint CE (Cumulative Exposure) | 1 | | `midpointCE()` |
| nvRC (Non-visual circadian response) | 4 | | `nvRC()`, `nvRC_circadianDisturbance()`, `nvRC_circadianBias()`, `nvRC_relativeAmplitudeError()` |
| nvRD (Non-visual direct response) | 2 | | `nvRD()`, `nvRD_cumulative_response()` |
| Period above threshold | 3 | above, below, within | `period_above_threshold()` |
| Pulses above threshold | 7x3 | above, below, within | `pulses_above_threshold()` |
| Threshold for duration | 2 | above, below | `threshold_for_duration()` |
| Timing above threshold | 3 | above, below, within | `timing_above_threshold()` |
| **Total:** | | | |
| **17 families** | **61 metrics** | | |
If you would like to use a metric you don't find represented in LightLogR, please contact the developers. The easiest and most trackable way to get in contact is by opening a new issue on our [Github repository](https://github.com/tscnlab/LightLogR/issues).
## About the creation and funding of LightLogR
**LightLogR** is developed by the [*Translational Sensory & Circadian Neuroscience*](https://www.tscnlab.org) lab, a joint group from the [Technical University of Munich](https://www.tum.de/en/) and the [Max Planck Institute for Biological Neuroscience Unit (MPS/TUM/TUMCREATE)\*](https://www.tscnlab.org), a joint group based at the [Technical University of Munich](https://www.tum.de/en/), [TUMCREATE](https://www.tum-create.edu.sg/), the [Max Planck Institute for Biological Cybernetics](https://www.mpg.de/152075/biological-cybernetics).
[*MeLiDos*](https://www.melidos.eu) is a joint, [EURAMET](https://www.euramet.org)-funded project involving sixteen partners across Europe, aimed at developing a metrology and a standard workflow for wearable light logger data and optical radiation dosimeters. Its primary contributions towards fostering FAIR data include the development of a common file format, robust metadata descriptors, and an accompanying open-source software ecosystem.
[{width="282"}](https://www.euramet.org) {width="288"}
The project (22NRM05 MeLiDos) has received funding from the European Partnership on Metrology, co-financed from the European Union's Horizon Europe Research and Innovation Programme and by the Participating States. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or EURAMET. Neither the European Union nor the granting authority can be held responsible for them.
# I Want To Contribute
All types of contributions are encouraged and valued. See the [CONTRIBUTING](https://tscnlab.github.io/LightLogR/CONTRIBUTING.html) section for different ways to help and details about how this project handles them.
This project and everyone participating in it is governed by the
[LightLogR Code of Conduct](https://tscnlab.github.io/LightLogR/CODE_OF_CONDUCT.html).
Owner
- Name: MPI-BC Translational Sensory & Circadian Neuroscience Lab & TUM Chronobiology & Health
- Login: tscnlab
- Kind: organization
- Location: Germany
- Website: https://www.tscnlab.org/
- Repositories: 1
- Profile: https://github.com/tscnlab
JOSS Publication
LightLogR: Reproducible analysis of personal light exposure data
Published
March 13, 2025
Volume 10, Issue 107, Page 7601
Authors
Johannes Zauner
Technical University of Munich, TUM School of Medicine and Health, Department Health and Sport Sciences, Chronobiology & Health, Munich, Germany, Max Planck Institute for Biological Cybernetics, Max Planck Research Group Translational Sensory & Circadian Neuroscience, Tübingen, Germany
Technical University of Munich, TUM School of Medicine and Health, Department Health and Sport Sciences, Chronobiology & Health, Munich, Germany, Max Planck Institute for Biological Cybernetics, Max Planck Research Group Translational Sensory & Circadian Neuroscience, Tübingen, Germany
Steffen Hartmeyer
École Polytechnique Fédérale de Lausanne (EPFL), School of Architecture, Civil and Environmental Engineering (ENAC), Laboratory of Integrated Performance in Design (LIPID), Lausanne, Switzerland
École Polytechnique Fédérale de Lausanne (EPFL), School of Architecture, Civil and Environmental Engineering (ENAC), Laboratory of Integrated Performance in Design (LIPID), Lausanne, Switzerland
Manuel Spitschan
Technical University of Munich, TUM School of Medicine and Health, Department Health and Sport Sciences, Chronobiology & Health, Munich, Germany, Max Planck Institute for Biological Cybernetics, Max Planck Research Group Translational Sensory & Circadian Neuroscience, Tübingen, Germany, TUM Institute for Advanced Study (TUM-IAS), Technical University of Munich, Garching, Germany, TUMCREATE Ltd., Singapore, Singapore
Technical University of Munich, TUM School of Medicine and Health, Department Health and Sport Sciences, Chronobiology & Health, Munich, Germany, Max Planck Institute for Biological Cybernetics, Max Planck Research Group Translational Sensory & Circadian Neuroscience, Tübingen, Germany, TUM Institute for Advanced Study (TUM-IAS), Technical University of Munich, Garching, Germany, TUMCREATE Ltd., Singapore, Singapore
Tags
light light exposure luminous exposure personal light exposure melanopsin ipRGCs (intrinsic photosensitive retinal ganglion cells) circadian rhythm chronobiology photoperiod occupational exposure time series analysis wearable devices wearable sensors wearables rstats-packageGitHub Events
Total
- Create event: 7
- Release event: 5
- Issues event: 13
- Watch event: 4
- Delete event: 1
- Issue comment event: 3
- Push event: 101
- Pull request review event: 13
- Pull request event: 32
Last Year
- Create event: 7
- Release event: 5
- Issues event: 13
- Watch event: 4
- Delete event: 1
- Issue comment event: 3
- Push event: 101
- Pull request review event: 13
- Pull request event: 32
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Johannes Zauner | 1****r | 352 |
| steffenhartmeyer | s****r@e****h | 27 |
| Manuel Spitschan | m****n@t****e | 27 |
| JZauner | j****r@t****e | 4 |
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 13
- Total pull requests: 67
- Average time to close issues: 28 days
- Average time to close pull requests: about 21 hours
- Total issue authors: 6
- Total pull request authors: 3
- Average comments per issue: 0.85
- Average comments per pull request: 0.03
- Merged pull requests: 57
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 11
- Pull requests: 43
- Average time to close issues: 22 days
- Average time to close pull requests: 1 day
- Issue authors: 5
- Pull request authors: 3
- Average comments per issue: 0.73
- Average comments per pull request: 0.02
- Merged pull requests: 34
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- JZauner (7)
- ThomasKraft (2)
- andrectonon (1)
- dsherman11 (1)
- coxrc522 (1)
- joanna-j99 (1)
Pull Request Authors
- JZauner (69)
- steffenhartmeyer (15)
- spitschan (7)
Top Labels
Issue Labels
enhancement (3)
bug (2)
Pull Request Labels
enhancement (1)
Packages
- Total packages: 1
-
Total downloads:
- cran 218 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
cran.r-project.org: LightLogR
Process Data from Wearable Light Loggers and Optical Radiation Dosimeters
- Homepage: https://github.com/tscnlab/LightLogR
- Documentation: http://cran.r-project.org/web/packages/LightLogR/LightLogR.pdf
- License: MIT + file LICENSE
-
Latest release: 0.9.2
published 7 months ago
Rankings
Dependent packages count: 28.6%
Dependent repos count: 35.2%
Average: 50.1%
Downloads: 86.6%
Maintainers (1)
Last synced:
4 months ago
Dependencies
DESCRIPTION
cran
- magrittr * imports
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.4.1 composite
- actions/checkout v3 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite