non_package_files/new_ideas/tracecollection.R

# function to plot an arbitrary subset of traces from a tree
# question is do we really want to have the intermediate result

devtools::load_all()
t1<-get_treeinfo("non_package_files/2014-07-22_CHO hERG.dat")
t2<-get_treeinfo("non_package_files/VG_Blocker.dat")
t<-c(t1,t2)


get_traceCollection <-
  function(tree, selection) {
    list_of_series <- lapply(selection, function(sel_element){
      getSeries_from_node(tree[[sel_element[1:3]]],sweeps = sel_element[4], trace = sel_element[5] )
    })
    list_of_series
  }



plot_tracecollection<-function(tc){
  xrange<-range(lapply(tc, function(trace){range(trace$x)}))
  yrange<-range(lapply(tc, function(trace){range(trace$y)}))
  plot(NULL, xlim=xrange, ylim=yrange, ylab="", xlab="")
  lapply(tc, function(trace){
    lines(trace$x,trace$y)
  })
  invisible(NULL)
}

tc<-get_traceCollection(t, list(c(1,1,1,1,1), c(2,1,7,1,2)))
plot_tracecollection(tc)

tc<-get_traceCollection(t, list(c(2,1,7,1,4), c(2,1,7,1,2)))
plot_tracecollection(tc)
tdanker/ephys2 documentation built on Aug. 11, 2019, 12:12 p.m.