Skip to content

Commit

Permalink
preparation for CRAN submission
Browse files Browse the repository at this point in the history
  • Loading branch information
JZauner committed Jul 3, 2024
1 parent c18525f commit d29b24f
Show file tree
Hide file tree
Showing 33 changed files with 80 additions and 303 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
^vignettes/articles$
^\.gitlab-ci\.yml$
^cran-comments\.md$
^LightLogR-manual\.tex$
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Authors@R: c(
person("EURAMET", role = "fnd", comment = "European Association of National Metrology Institutes. Website: www.euramet.org. Grant Number: 22NRM05 MeLiDos. Grant Statement: 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."),
person("European Union", role = "fnd", comment = "Co-funded by the European Union. 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."),
person("TSCN-Lab", comment = c(URL = "www.tscnlab.org"), role = "cph"))
Description: LightLogR facilitates easy import, processing, validation, and visualization of personal light exposure measurement data from wearable devices. The package implements features such as the import of data and metadata files, conversion of common file formats, validation of light logging data, verification of crucial metadata, calculation of common parameters, and semi-automated analysis and visualization.
Description: Import, processing, validation, and visualization of personal light exposure measurement data from wearable devices. The package implements features such as the import of data and metadata files, conversion of common file formats, validation of light logging data, verification of crucial metadata, calculation of common parameters, and semi-automated analysis and visualization.
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
URL: https://github.com/tscnlab/LightLogR,
https://tscnlab.github.io/LightLogR/,
https://zenodo.org/doi/10.5281/zenodo.11562600
Expand Down Expand Up @@ -61,4 +61,3 @@ Suggests:
testthat (>= 3.0.0),
tidyverse
Config/testthat/edition: 3
VignetteBuilder: knitr
4 changes: 2 additions & 2 deletions R/metric_EMA.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
#' @references
#' Price, L. L. A. (2014). On the Role of Exponential Smoothing in Circadian
#' Dosimetry. \emph{Photochemistry and Photobiology}, 90(5), 1184-1192.
#' \url{https://doi.org/10.1111/php.12282}
#' \doi{10.1111/php.12282}
#'
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @examples
#' sample.data.environment.EMA = sample.data.environment %>%
Expand Down
4 changes: 2 additions & 2 deletions R/metric_barroso.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
#' @references
#' Barroso, A., Simons, K., & Jager, P. de. (2014). Metrics of circadian
#' lighting for clinical investigations. \emph{Lighting Research & Technology},
#' 46(6), 637–649. \url{https://doi.org/10.1177/1477153513502664}
#' 46(6), 637–649. \doi{10.1177/1477153513502664}
#'
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @examples
#'
Expand Down
2 changes: 1 addition & 1 deletion R/metric_bright_dark_period.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#' @references
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @export
#'
Expand Down
4 changes: 2 additions & 2 deletions R/metric_centroidLE.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
#' L. K., Picard, R. W., Lockley, S. W., Klerman, E. B., & Czeisler, C. A. (2017).
#' Irregular sleep/wake patterns are associated with poorer academic performance
#' and delayed circadian and sleep/wake timing. \emph{Scientific Reports},
#' 7(1), 3216. \url{https://doi.org/10.1038/s41598-017-03171-4}
#' 7(1), 3216. \doi{10.1038/s41598-017-03171-4}
#'
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @examples
#' # Dataset with POSIXct time vector
Expand Down
4 changes: 2 additions & 2 deletions R/metric_disparity_index.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#' Martín-Vide, J., & Peñuelas, J. (2018).
#' The consecutive disparity index, D: A measure of temporal variability in
#' ecological studies. \emph{Ecosphere}, 9(12), e02527.
#' \url{https://doi.org/10.1002/ecs2.2527}
#' \doi{10.1002/ecs2.2527}
#'
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @examples
#' dataset1 <-
Expand Down
2 changes: 1 addition & 1 deletion R/metric_duration_above_threshold.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#' @references
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @export
#'
Expand Down
4 changes: 2 additions & 2 deletions R/metric_frequency_crossing_threshold.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#' @references
#' Alvarez, A. A., & Wildsoet, C. F. (2013). Quantifying light
#' exposure patterns in young adult students. \emph{Journal of Modern Optics},
#' 60(14), 1200–1208. \url{https://doi.org/10.1080/09500340.2013.845700}
#' 60(14), 1200–1208. \doi{10.1080/09500340.2013.845700}
#'
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @examples
#
Expand Down
4 changes: 2 additions & 2 deletions R/metric_interdaily_stability.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
#' McCall, W. V., & Rosenquist, P. B. (1999). Bright Light Therapy: Improved
#' Sensitivity to Its Effects on Rest-Activity Rhythms in Alzheimer Patients
#' by Application of Nonparametric Methods. \emph{Chronobiology International},
#' 16(4), 505–518. \url{https://doi.org/10.3109/07420529908998724}
#' 16(4), 505–518. \doi{10.3109/07420529908998724}
#'
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @examples
#'
Expand Down
4 changes: 2 additions & 2 deletions R/metric_intradaily_variability.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#' McCall, W. V., & Rosenquist, P. B. (1999). Bright Light Therapy: Improved
#' Sensitivity to Its Effects on Rest-Activity Rhythms in Alzheimer Patients
#' by Application of Nonparametric Methods. \emph{Chronobiology International},
#' 16(4), 505–518. \url{https://doi.org/10.3109/07420529908998724}
#' 16(4), 505–518. \doi{10.3109/07420529908998724}
#'
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @examples
#'
Expand Down
4 changes: 2 additions & 2 deletions R/metric_midpointCE.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#' Shochat, T., Santhi, N., Herer, P., Flavell, S. A., Skeldon, A. C.,
#' & Dijk, D.-J. (2019). Sleep Timing in Late Autumn and Late Spring Associates
#' With Light Exposure Rather Than Sun Time in College Students.
#' \emph{Frontiers in Neuroscience}, 13. \url{https://doi.org/10.3389/fnins.2019.00882}
#' \emph{Frontiers in Neuroscience}, 13. \doi{10.3389/fnins.2019.00882}
#'
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @examples
# Dataset with POSIXct time vector
Expand Down
138 changes: 10 additions & 128 deletions R/metric_nvR.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#'
#' @param MEDI.vector Numeric vector containing the melanopic EDI data.
#' @param Illuminance.vector Numeric vector containing the Illuminance data.
#' @param Time.vector Vector containing the time data. Can be \link[base]{POSIXct}, \link[hms]{hms},
#' \link[lubridate]{duration}, or \link[base]{difftime}.
#' @param Time.vector Vector containing the time data. Can be [POSIXct()],[hms::hms()],
#' [lubridate::duration()], [difftime()].
#' @param epoch The epoch at which the data was sampled. Can be either a
#' \link[lubridate]{duration} or a string. If it is a string, it needs to be
#' [lubridate::duration()] or a string. If it is a string, it needs to be
#' either `"dominant.epoch"` (the default) for a guess based on the data, or a valid
#' \link[lubridate]{duration} string, e.g., `"1 day"` or `"10 sec"`.
#' [lubridate::duration()] string, e.g., `"1 day"` or `"10 sec"`.
#'
#' @return A numeric vector containing the nvRD data. The output has the same
#' length as `Time.vector`.
Expand All @@ -25,62 +25,11 @@
#'
#' @details The timeseries is assumed to be regular. Missing values in the
#' light data will be replaced by 0.
#'
#' The inputs to the model are discrete time samples of melanopic equivalent
#' daylight (D65) illuminance (mEDI) \eqn{E_{v,mel}^{D65}(t)}, transformed into
#' the effective light stimulus \eqn{I(t)}.
#'
#' \deqn{I(t) = E_{v,mel}^{D65} * K_{mel,v}^{D65}/A_{mel},}
#'
#' where \eqn{K_{mel,v}^{D65} = 1.3262 / 1000} is the melanopic normalization factor
#' to convert melanopic EDI to melanopic Irradiance and \eqn{A_{mel} = 97.07} is the
#' area of the melanopic sensitivity curve.
#'
#' The light stimulus \eqn{I(t)} is then passed through a linear filter \eqn{L1},
#' which is associated with the temporal integration of the retina, to determine the
#' output \eqn{u(t)}.
#'
#' \deqn{u(t) = \frac{1}{d_{1}}\sum_{i=0}^{d_{1}/\Delta t} I(t-1)\Delta t,}
#'
#' where \eqn{d_{1}} is the length of filter \eqn{L1}. The time step size
#' \eqn{\Delta t} is the epoch at which the data was sampled.
#' Then \eqn{u(t)} is transformed by a nonlinear function \eqn{N(u)}, describing the
#' intensity-response relationship to the light stimulus, to determine the
#' output \eqn{v(t)}.
#'
#' \deqn{v(t) = N(u(t)) = \frac{1}{1+(\sigma(t)/u(t))^n}.}
#'
#' The half-maximum constant \eqn{\sigma} adapts to prior light history
#' \deqn{
#' \begin{array}{ll}
#' \sigma(t)=\sigma_{0}/2, & \qquad & \forall u_{H}(t)<0,\\
#' \sigma(t)=\sigma_{0}\times2^{u_{H}(t)-1}, & \qquad & \forall u_{H}(t)\geq 0.
#' \end{array}
#' }
#'
#' The prior history of light exposure is calculated using a moving window,
#' filter \eqn{LH}, to average the input
#'
#' \deqn{u_{H}(t) = \frac{1}{d_{H}}\sum_{i=0}^{d_{H}/\Delta t}
#' \log_{10}(E_{v}(t-i))\Delta t,}
#'
#' where \eqn{dH} is the width of the filter \eqn{LH} in hours and \eqn{E_{v}}
#' is the photopic illuminance.
#'
#' The signal \eqn{v(t)} is finally passed through a second filter \eqn{L2},
#' which reflects the adaptation of the non-visual system to continuous light
#' exposure, to determine the final output \eqn{r_{D}(t)}.
#'
#' \deqn{r_{D}(t)=\alpha \times v(t−1)+(1−\alpha) \times r_{D}(t−1),}
#'
#' where \eqn{\alpha=2/(d2/\Delta t+1)} and \eqn{d2} is the length of filter
#' \eqn{L2} in hours. The model outputs are time-sampled relative non-visual
#' responses.
#'
#' @references Amundadottir, M.L. (2016). Light-driven model for identifying
#' indicators of non-visual health potential in the built environment
#' \[Doctoral dissertation, EPFL\]. EPFL infoscience.
#' \url{http://dx.doi.org/10.5075/epfl-thesis-7146}
#' \doi{10.5075/epfl-thesis-7146}
#'
#' @examples
#'
Expand Down Expand Up @@ -201,7 +150,7 @@ nvRD <- function(MEDI.vector,
#' @references Amundadottir, M.L. (2016). Light-driven model for identifying
#' indicators of non-visual health potential in the built environment
#' \[Doctoral dissertation, EPFL\]. EPFL infoscience.
#' \url{http://dx.doi.org/10.5075/epfl-thesis-7146}
#' \doi{10.5075/epfl-thesis-7146}
#'
#' @examples
#' dataset1 <-
Expand Down Expand Up @@ -288,78 +237,11 @@ nvRD_cumulative_response <- function(nvRD,
#' @details The timeseries is assumed to be regular. Missing values in the
#' light data will be replaced by 0.
#'
#' The inputs to the model are discrete time samples of melanopic equivalent
#' daylight (D65) illuminance (mEDI) \eqn{E_{v,mel}^{D65}(t)}, transformed into
#' the effective light stimulus \eqn{I(t)}.
#'
#' \deqn{I(t) = E_{v,mel}^{D65} * K_{mel,v}^{D65}/A_{mel},}
#'
#' where \eqn{K_{mel,v}^{D65} = 1.3262 / 1000} is the melanopic normalization factor
#' to convert melanopic EDI to melanopic Irradiance and \eqn{A_{mel} = 97.07} is the
#' area of the melanopic sensitivity curve.
#'
#' The light stimulus \eqn{I(t)} is then passed through a linear filter \eqn{L1},
#' which is associated with the temporal integration of the retina, to determine the
#' output \eqn{u(t)}.
#'
#' \deqn{u(t) = \frac{1}{d_{1}} \sum_{i=0}^{d_{1}/\Delta t} I(t-1)\Delta t,}
#'
#' where \eqn{d_{1}} is the length of filter \eqn{L1}. The time step size
#' \eqn{\Delta t} is the epoch at which the data was sampled.
#' Then \eqn{u(t)} is transformed by a nonlinear function \eqn{N(u)}, describing the
#' intensity-response relationship to the light stimulus, to determine the
#' output \eqn{v(t)}.
#'
#' \deqn{v(t) = N(u(t)) \times N_{C}(t) = \frac{N_{C}(t)}{1+(\sigma(t)/u(t))^n}.}
#'
#' The saturation intensity is controlled by the circadian sensitivity modulator
#'
#' \deqn{N_{C}(t)=(1−0.4C_{1}(t))(1−0.4C_{2}(t)),}
#'
#' acting as a simple harmonic oscillator
#'
#' \deqn{
#' \begin{array}{l}
#' C_{1} = \cos(\pi(t/12+1)+\phi_{xcx}/2),\\
#' C_{2} = -\sin(\pi(t/12+1)+\phi_{xcx}/2),
#' \end{array}
#' }
#'
#' where the phase angle to CBT min \eqn{\phi_{xcx}} is equal to \eqn{-2.98} rad,
#' assuming that sleep onset is at \eqn{t_{0}}.
#'
#' The half-maximum constant \eqn{\sigma} adapts to prior light history
#'
#' \deqn{
#' \begin{array}{ll}
#' \sigma(t)=\sigma_{0}/2, & \qquad & \forall u_{H}(t)<0,\\
#' \sigma(t)=\sigma_{0}\times2^{u_{H}(t)-1}, & \qquad & \forall u_{H}(t)\geq 0.
#' \end{array}
#' }
#'
#' The prior history of light exposure is calculated using a moving window,
#' filter \eqn{LH}, to average the input
#'
#' \deqn{u_{H}(t) = \frac{1}{d_{H}}\sum_{i=0}^{d_{H}/\Delta t}
#' \log_{10}(E_{v}(t-i))\Delta t,}
#'
#' where \eqn{dH} is the width of the filter \eqn{LH} in hours and \eqn{E_{v}}
#' is the photopic illuminance.
#'
#' The signal \eqn{v(t)} is finally passed through a second filter \eqn{L2},
#' which reflects the adaptation of the non-visual system to continuous light
#' exposure, to determine the final output \eqn{r_{C}(t)}.
#'
#' \deqn{r_{C}(t)=\alpha \times v(t−1)+(1−\alpha) \times r_{C}(t−1),}
#'
#' where \eqn{\alpha=2/(d2/\Delta t+1)} and \eqn{d2} is the length of filter
#' \eqn{L2} in hours. The model outputs are time-sampled relative non-visual
#' responses.
#'
#' @references Amundadottir, M.L. (2016). Light-driven model for identifying
#' indicators of non-visual health potential in the built environment
#' \[Doctoral dissertation, EPFL\]. EPFL infoscience.
#' \url{http://dx.doi.org/10.5075/epfl-thesis-7146}
#' \doi{10.5075/epfl-thesis-7146}
#'
#' @examples
#'
Expand Down Expand Up @@ -504,7 +386,7 @@ nvRC <- function(MEDI.vector,
#' @references Amundadottir, M.L. (2016). Light-driven model for identifying
#' indicators of non-visual health potential in the built environment
#' \[Doctoral dissertation, EPFL\]. EPFL infoscience.
#' \url{http://dx.doi.org/10.5075/epfl-thesis-7146}
#' \doi{10.5075/epfl-thesis-7146}
#'
#' @name nvRC_metrics
#' @examples
Expand Down Expand Up @@ -540,7 +422,7 @@ nvRC <- function(MEDI.vector,
#' # Relative amplitude error
#' nvRC_relativeAmplitudeError(dataset1$nvRC, dataset.reference$nvRC)

NULL


#' @rdname nvRC_metrics
#'
Expand Down Expand Up @@ -623,7 +505,7 @@ nvRC_circadianBias <- function(nvRC,
#' `nvRC_relativeAmplitudeError()` calculates the relative amplitude error (RAE).
#' It is expressed as
#'
#' \deqn{RAE(i,T)=r_{C,max}r_{C,max}^{ref},}
#' \deqn{RAE(i,T)=r_{C,max}-r_{C,max}^{ref},}
#'
#' and quantifies the difference between the maximum response achieved in a period
#' to the reference signal.
Expand Down
2 changes: 1 addition & 1 deletion R/metric_pulses_above_threshold.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#' @references Wilson, J., Reid, K. J., Braun, R. I., Abbott, S. M., & Zee, P. C.
#' (2018). Habitual light exposure relative to circadian timing in delayed
#' sleep-wake phase disorder. \emph{Sleep}, 41(11).
#' \url{https://doi.org/10.1093/sleep/zsy166}
#' \doi{10.1093/sleep/zsy166}
#'
#' @examples
#' # Sample data
Expand Down
4 changes: 2 additions & 2 deletions R/metric_timing_above_threshold.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
#' Reid, K. J., Santostasi, G., Baron, K. G., Wilson, J., Kang, J.,
#' & Zee, P. C. (2014). Timing and Intensity of Light Correlate with Body Weight
#' in Adults. \emph{PLOS ONE}, 9(4), e92251.
#' \url{https://doi.org/10.1371/journal.pone.0092251}
#' \doi{10.1371/journal.pone.0092251}
#'
#' Hartmeyer, S.L., Andersen, M. (2023). Towards a framework for light-dosimetry studies:
#' Quantification metrics. \emph{Lighting Research & Technology}.
#' \url{https://doi.org/10.1177/14771535231170500}
#' \doi{10.1177/14771535231170500}
#'
#' @examples
#' # Dataset with light > 250lx between 06:00 and 18:00
Expand Down
14 changes: 14 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,17 @@
0 errors | 0 warnings | 1 note

* This is a new release.

## Windevel results

Maintainer: 'Johannes Zauner <[email protected]>'

* New submission

* Found the following (possibly) invalid URLs:
URL: https://lists.lrz.de/mailman/listinfo/lightlogr-users
From: README.md
Status: 403
Message: Forbidden

This URL is valid, but the server does not allow the Windevel server to access it. The URL leads to the mailing list for the package.
Loading

0 comments on commit d29b24f

Please sign in to comment.