#' Make a cursor with a fixed result, i.e. a stimulus
#' @param stimname the name of the stimulus for which a result shall be defined, or a "series" object
#' @param resultname the name of the result to define
#' @param base start value
#' @param inc increment
#'
#' @export
#'
#' @examples
#' data(series_NaIV)
#' set_cursor("NaIV", "peak", curMin_,c(0.01,0.013))
#' make_stimulus("NaIV", "voltage", -80, 10)
#' plot(peak~voltage, data=series_NaIV$results(), type="o", main="IVplot")
#' series_NaIV$plotresults(peak~voltage, type="o", main="IVplot") #the same
make_stimulus <- function(stimname, resultname, base, inc = 0) {
method = function(cut, s) {
base + (s - 1) * inc
}
methods = list(method)
names(methods) <- resultname
cursor <- makecursor(resultname, c(0, 0), methods, plot.fun.first = NULL, plot.fun.last = NULL)
add_cursor(stimname, cursor)
}
add_cursor <- function(sweeps, cursor) {
stimname<-get_stimname(sweeps)
if (!exists("CURSORS", .GlobalEnv))
CURSORS <<- list()
CURSORS[[stimname]]$cursors[[cursor$name]]<<-cursor
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.