# This file is sourced each time a Series is selected in the tree.
# print("hi from render_ser")
# project setup script ####################################################################
# the idea is to provide initial settings for project first start
# that may be modified interactively and not be overwritten by subsequent runs of the script
# typical setup script
setup_tree("VG_Blocker.dat", warn=F) # existing trees will not be overwritten. Maybe we can include a check for same filename!
init_cursor("NaIV", "min", curMin_, c(0.01,0.015)) # existing settings from previous sessions will not be overwritten
init_cursor("NaIV", "base", curMean_, c(0.005,0.009))
init_cursor("NaPharm", "base", curMean_, c(0.005,0.009))
init_cursor("NaPharm", "min", curMin_, c(0.01,0.015))
make_stimulus("NaIV", "voltage", -80, 10)
# the use of init_cursor above makes it save to define a resultmethods and plotting methods using the cursor
set_resultmethod("NaIV",name = "add_r1", function(x) {x$r1<-x$min*-1; x})
set_plotformula("NaIV", min-base~voltage)
set_plotformula("NaPharm", min~relTime)
set_plotformula("NaIV", min-base~voltage)
# bit of raw meat
attr(tree[[1]],'PLXLSfiles')<- list("VG_Blocker_1.xls") #vorherst nur 1 möglich
set_plotformula("NaPharm", Online1~relTime)
#############################################################################################
.render_ser <-
function(...) {
#plot(0, main="render_serx")
str(selection_)
}
# if this code is sourced automatically, use
# <<- to store in global CURSORS,
# <- to store only in this session
# modified from get_selected_names:
####################################################
# functions to be included in package
get_checked<-function (tree, ancestry = NULL, vec = list())
{
if (is.list(tree)) {
for (i in 1:length(tree)) {
anc <- c(ancestry, names(tree)[i])
vec <- get_checked(tree[[i]], anc, vec)
}
}
a <- attr(tree, "stchecked", TRUE)
if (!is.null(a) && a == TRUE) {
el <- tail(ancestry, n = 1)
vec[length(vec) + 1] <- el
attr(vec[[length(vec)]], "ancestry") <- head(ancestry,
n = length(ancestry) - 1)
}
return(vec)
}
plot2.default <<-function(tree,inp.tree,...) {
selection <- get_selected(inp.tree, format = "names")
sel <- c(attr(selection[[1]], "ancestry"), selection[[1]])
stimname<-attr(tree[[sel]], "StimulusName") #ephys2:::getStimname_from_node(tree[[sel]])
r<-calculate.results(tree,selection)
#print(r)
x=as.character(CURSORS[[stimname]]$plotformula[3])
y=as.character(CURSORS[[stimname]]$plotformula[2])
if(!is.null(r)){
require(ggplot2)
p<-(ggplot(r, aes_string(x, y))
+geom_line(aes(colour=factor(ser)))
+geom_point()
)
}
if(!is.null(r$Concentration)){
if(!all(is.na(r$Concentration))){ #COncentration is set if a PLXLS is found and matched
p<-p+ aes(colour=factor(Concentration))
}
}
print(p)
}
CURSORS$NaIV$plot2.fun <<- plot2.default
CURSORS$NaPharm$plot2.fun <<- plot2.default
CURSORS$'2PulseInact'$plot2.fun <<-NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.