Skip to content

Commit

Permalink
Merge pull request #110 from shawntz/89-preprocessing-parameters-in-o…
Browse files Browse the repository at this point in the history
…utput-report

feature #89: preprocessing parameters in output report
  • Loading branch information
shawntz authored Nov 24, 2024
2 parents 459784c + 155a8fd commit b91ec9f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions R/handlers.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ error_handler <- function(e, e_class) {

# generic handler/wrapper for eyeris pupil pipeline funcs
pipeline_handler <- function(eyeris, operation, new_suffix, ...) {
call_stack <- sys.calls()[[1]]

if (!is.list(eyeris$params)) {
eyeris$params <- list()
}

eyeris$params[[new_suffix]] <- call_stack

tryCatch(
{
check_data(eyeris, new_suffix)
Expand Down
22 changes: 22 additions & 0 deletions R/parsers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
parse_call_stack <- function(call_str) {
func <- sub("\\(.*", "", call_str)
return(list(Function = func, Arguments = call_str))
}

format_call_stack <- function(callstack) {
params_parsed <- do.call(rbind, lapply(names(callstack), function(step) {
parsed <- parse_call_stack(callstack[[step]])
args <- deparse(parsed$Arguments)
args <- paste(args, collapse = "")

data.frame(
step = step,
callstack = args,
stringsAsFactors = FALSE
)
}))

rownames(params_parsed) <- NULL

return(params_parsed)
}
3 changes: 3 additions & 0 deletions R/report.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ make_report <- function(eyeris, out, plots, ...) {
"\n\n---\n\n## EyeLink Header Metadata\n\n",
make_md_table(eyeris$info), "\n",

"\n\n---\n\n## eyeris call stack\n\n",
make_md_table(format_call_stack(eyeris$params)), "\n",

"\n\n---\n\n### Citation\n\n",
"```{r citation, echo=FALSE, comment=NA}\n",
"citation('eyeris')\n",
Expand Down

0 comments on commit b91ec9f

Please sign in to comment.