Skip to content

Commit

Permalink
update for travis
Browse files Browse the repository at this point in the history
  • Loading branch information
FredHasselman committed Mar 28, 2018
1 parent fc11af5 commit c3967f2
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 141 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Expand Up @@ -50,7 +50,6 @@ Imports:
infotheo,
methods,
RColorBrewer,
patchwork,
tibble
Suggests: knitr,
rmarkdown,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Expand Up @@ -45,7 +45,6 @@ export(plotNET_SW)
export(plotNET_groupColour)
export(plotNET_groupWeight)
export(plotNET_prep)
export(plotRP_crqa)
export(plotSUR_hist)
export(recmat)
export(recmat_plot)
Expand Down
7 changes: 5 additions & 2 deletions R/CasNET_Merlijn.R
Expand Up @@ -33,6 +33,7 @@
#' @references Schiepek, G. (2003). A Dynamic Systems Approach to Clinical Case Formulation. European Journal of Psychological Assessment, 19, 175-184.
#' @references Haken, H. & Schiepek, G. (2006, 2. Aufl. 2010). Synergetik in der Psychologie. Selbstorganisation verstehen und gestalten. G?ttingen: Hogrefe.
#' @references Schiepek, G. K., St?ger-Schmidinger, B., Aichhorn, W., Sch?ller, H., & Aas, B. (2016). Systemic case formulation, individualized process monitoring, and state dynamics in a case of dissociative identity disorder. Frontiers in psychology, 7, 1545.
#'
dyn_comp = function(df, col_first, col_last, scale_min, scale_max, win=NROW(df), doPlot = FALSE){


Expand Down Expand Up @@ -229,9 +230,11 @@ DC_D = function (df, win, xmin, xmax, col_first, col_last){
#' @description Computes significant peaks in the dynamic complexity time series. Example: Schiepek, Tominschek & Heinzel, 2014.
#'
#' @param df A dataframe of dynamic complexity values, e.g. output data from dyn_comp
#' @param win Window size over which dynamic complexity was calculated (nescesary for plot)
#' @param win Window size over which dynamic complexity was calculated (neccesary for plot)
#' @param doPlot If \code{TRUE} shows a plot and returns a \code{\link[ggplot2]{ggplot}} object in a list. If \code{FALSE}, no plot will be drawn and no object will be returned (default = \code{FALSE})
#'
#' @return A list with a dataframe of binary critical instability indices and a summed critical intability index, a ggplot object containing a critical instability diagram.
#'
#' @export
#'
#' @author Merlijn Olthof
Expand All @@ -241,7 +244,7 @@ DC_D = function (df, win, xmin, xmax, col_first, col_last){
#' @references Haken, H. & Schiepek, G. (2006, 2. Aufl. 2010). Synergetik in der Psychologie. Selbstorganisation verstehen und gestalten. G?ttingen: Hogrefe.
#' @references Schiepek, G. K., Tominschek, I., & Heinzel, S. (2014). Self-organization in psychotherapy: testing the synergetic model of change processes. Frontiers in psychology, 5, 1089.
#'
crit_in = function(df, win){
crit_in = function(df, win, doPlot = TRUE){

df.ci <- matrix(data=NA, nrow=nrow(df), ncol=ncol(df))
df.ci <- data.frame(df.ci)
Expand Down
87 changes: 1 addition & 86 deletions R/nlRtsa_SOURCE.R
Expand Up @@ -250,7 +250,7 @@ crqa_cl_main <- function(data,
#' @param silent Do not display any messages (default = \code{TRUE})
#' @param surrogateTest Perform surrogate tests. If \code{TRUE}, will run surrogate tests using default settings for a two-sided test of \eqn{H_0: The data generating process is a rescaled linear Gaussian process} at \eqn{\alpha = .05} (arguments \code{ns = 39, fft = TRUE, amplitude = TRUE})
#' @param targetValue A value passed to \code{crqa_radius(...,type="fixed", targetMeasure="RR")} if \code{is.na(emRad)==TRUE}. This is useful for windowed analysis, it will estimate a new radius for each window.
#' @param useParallel Speed up calculations by using the parallel processing options provided by \code{\link[multidplyr]{partition}} to assign a seperate process/core for each window in windowed (C)RQA analysis using \code{\link[purrr]{map2}} to assign data and \code{\link[parallel]{detectCores}} with \code{logical = TRUE} to decide on the available cores (default = \code{FALSE})
#' @param useParallel Speed up calculations by using the parallel processing options provided by `parallel` to assign a seperate process/core for each window in windowed (C)RQA analysis using \code{\link[purrr]{map2}} to assign data and \code{\link[parallel]{detectCores}} with \code{logical = TRUE} to decide on the available cores (default = \code{FALSE})
#' @param ... Additional parameters (currently not used)
#'
#' @details The \code{rp} executable is installed when the function is called for the first time and is renamed to \code{rp}, from a platform specific filename downloaded from \url{http://tocsy.pik-potsdam.de/commandline-rp.php} or extracted from an archive located in the directory: \code{...\\casnet\\commandline_rp\\}.
Expand Down Expand Up @@ -4372,8 +4372,6 @@ plotSUR_hist <- function(surrogateValues,





#' Add transparency to a colour
#'
#' @param col A colour name, hexadecimal string or positive integer \code{i}, such that palette()[i]
Expand All @@ -4388,89 +4386,6 @@ add_alpha <- function(col, alpha=1){
}


#' plotRP
#'
#' @param crqaOutput List output from \code{\link[crqa]{crqa}}
#'
#' @return A list
#' @export
#' @author Fred Hasselman
#' @description Creates a recurrence plot from the sparse matrix output generated by \code{\link[crqa]{crqa}}.
plotRP_crqa <- function(crqaOutput){

AUTO <- FALSE

# Is is crqa output?
if(all(names(crqaOutput)%in%c("RR","DET","NRLINE","maxL","L","ENTR","rENTR","LAM","TT","RP"))){

# RP dimensions
nr <- dim(crqaOutput$RP)[1]
nc <- dim(crqaOutput$RP)[2]

RP <- crqaOutput$RP

# AUTO or CROSS?
if(class(RP)=="dtCMatrix"){
message("\nRP in crqa output is a Triangular Sparse Matrix, this implies auto-recurrence...\n")
AUTO <- TRUE
}
if(isSymmetric(RP)){
message("\nRP in crqa output is a Symmetric Sparse Matrix, this implies auto-recurrence: \n >> RP Measures will include the Line of Identity, unless:\n >> crqa() with side = 'upper' or 'lower' was used.\n >> crqa() with Theiler window (tw) of 1 was used.")
AUTO <- TRUE}

if(nc*nr>10^6){
message(paste("\nLarge RP with",nc*nr,"elements... \n >> This could take some time to plot!\n"))
}

ifelse(AUTO,
Titles <- list(main="Auto Recurrence Plot", X = expression(Y[t]), Y = expression(Y[t])),
Titles <- list(main="Cross Recurrence Plot", X = expression(X[t]), Y = expression(Y[t]))
)


# Thresholded or Distance matrix?
ifelse(is.logical(as.array(RP)),
distPallette <- grDevices::colorRampPalette(c("white", "black"))(2),
distPallette <- grDevices::colorRampPalette(c("red", "white", "blue")) #( length(unique(as.vector(RP))))
)

#distPallette <- grDevices::colorRampPalette(c("white", "black"))(2)

lp <- levelplot(Matrix::as.matrix(RP),
#colorkey = TRUE,
region = TRUE, col.regions = distPallette, useRaster = TRUE, aspect = nc/nr,
main = Titles$main,
xlab = Titles$X,
ylab = Titles$Y)

txt <- grid.text(paste0("\n RR: ", round(crqaOutput$RR, digits = 1),
"\n DET: ", round(crqaOutput$DET, digits = 1),
"\nmeanL: ", round(crqaOutput$maxL, digits = 1),
"\n maxL: ", round(crqaOutput$NRLINE, digits = 1),
"\n LAM: ", round(crqaOutput$LAM, digits = 1),
"\n TT: ", round(crqaOutput$TT, digits = 1),
"\n ENT: ", round(crqaOutput$ENT, digits = 1),
"\n rENT: ", round(crqaOutput$rENTR, digits = 1)),
.02,.7, just = "left", draw = FALSE, gp = gpar(fontfamily = "mono", cex = .7))
# ,)

grid.arrange(lp, txt, ncol=2, nrow=1, widths=c(4, 1), heights=c(4))

} else {
warning("\nInput is not list output from function crqa().\n")
}

}

plotRP_fnn <- function(FNNoutput){
graphics::plot(FNNoutput["combined",],type="b",pch=16, cex=2, col="grey80", ylim=c(0,100), xaxt="n",
xlab = "Embedding Dimension", ylab = "False Nearest Neighbours")
graphics::lines(FNNoutput["atol",],type="b",pch="a",col="grey30", lty=2)
graphics::lines(FNNoutput["rtol",],type="b",pch="r", col="grey30",lty=2)
graphics::Axis(side=1,at=seq_along(FNNoutput[1,]),labels = dimnames(FNNoutput)[[2]])
graphics::legend("topright",c("Combined","atol","rtol"), pch = c(16,97,114), lty = c(1,2,2), col = c("grey80","grey30","grey30"), pt.cex=c(2,1,1))
}

# Complex Networks# graph2svg <- function(TDM,pname){
#
# # Create weighted Term-Term matrix
Expand Down
4 changes: 2 additions & 2 deletions inst/doc/cl_RQA.html
Expand Up @@ -12,7 +12,7 @@

<meta name="author" content="Fred Hasselman" />

<meta name="date" content="2018-03-28" />
<meta name="date" content="2018-03-29" />

<title>Using the CRQA command line interface (crqa_cl)</title>

Expand Down Expand Up @@ -70,7 +70,7 @@

<h1 class="title toc-ignore">Using the CRQA command line interface (crqa_cl)</h1>
<h4 class="author"><em>Fred Hasselman</em></h4>
<h4 class="date"><em>2018-03-28</em></h4>
<h4 class="date"><em>2018-03-29</em></h4>



Expand Down
6 changes: 4 additions & 2 deletions man/crit_in.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/crqa_cl.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions man/plotRP_crqa.Rd

This file was deleted.

26 changes: 0 additions & 26 deletions vignettes/cl_RQA.R

This file was deleted.

0 comments on commit c3967f2

Please sign in to comment.