R/plotIt.R

Defines functions annotate_IT plotIt plotresults_

annotate_IT<-function(annot){
  with(annot, {
    arrows(relTime.start,res,relTime.end,res, len=0, col="red", lwd=3)
    abline(v=relTime.end, col="grey80")
  })
}


#' I/t plots from series objects
#'
#' @param sweeps a series object
#' @param cursor a defined cursor
#' @param rdfun  a \link{rundowncorrection} method
#' @param ...    further arguments passed to plot()
#'
#' @return a data frame containing the results at the end of given liquid periods
#' @export
plotIt <- function(sweeps, cursor, rdfun=NULL, ...) {
    res<-sweeps$results()
    
    if(is.null(rdfun)){
    plot(res[, 2], res[, cursor], type = "o", ylab = cursor, xlab = "seconds", 
        ...)
    }
    
    # rundown correction (does its own plotting)
    if(!is.null(rdfun)){
      res[, cursor]<-rdfun(res[, "relTime"], res[, cursor], ...) 
    }
    
    if(!is.null(res$Concentration)){
      lpresults<-get_lpresults2(res,cursor,3)
      annotate_IT(lpresults)
      return(invisible(lpresults))
    }
    NULL
}

plotresults_ <- function(sweeps, formula, ...) {
    #anaDef = getAnadef(sweeps)
    #sweep_data2 <- calculate.cursors(sweeps, anaDef)
    res<-sweeps$results()
    plot(formula, data = res, ...)
}
tdanker/ephys2 documentation built on Aug. 11, 2019, 12:12 p.m.