#' @title
#' Calculate a scaling factor to allow inter-patient comparisons
#'
#' @description
#' Calculates a scaling factor which normalizes the
#' biparietal distance to 1
#'
#' @param img brainImage instance
#'
#' @return list containg the factor and a version
#'
#' @export
#'
#' @examples
#' options("BITSIZE"=10)
#' data <- data.frame(x=1:10, y=1:10,
#' z=c(rep(2,5), rep(3,5)), val=rnorm(100))
#' img <- new("brainImage", data, "test", 10)
#' calcXScalingFactor(img)
calcXScalingFactor <- function(img) {
if (class(img) != "brainImage") {
stop("Invalid parameter! Not a brainImage instance!")
}
## calculate x scaling factor
xvals <- imageanalysisBrain::getXRange(img@values)
xfactor <- 1/(xvals$xMax - xvals$xMin)
## and store in brainImage slots
img@xfactor <- xfactor
## keep track of the used version
img@xfactorVersion <- xvals$version
return(img)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.