R/radiomics_all.R

Defines functions radiomics_all

Documented in radiomics_all

#' @title Calculates all radiomic statistics on supplied RIA_image
#' @export
#'
#' @description Calculates specified radiomic statistics on \emph{RIA_image}. Parameters of
#' radiomic functions may be set. By default the the images are discretized to 2, 8, 32 and 128 bins
#' using equally sized binning. First-order statistics are calculated on the
#' original image and if asked then on all discretizations. Symmetric GLCMs are calculated for all directions
#' at a distance of 1, 2 and 3 for all discretizations. GLRLMs are also calculated for all
#' discretizations. Geometry-based statistics are calculated for the original image as well as all
#' discretizations is requested. 
#' 
#' @param RIA_data_in \emph{RIA_image}.
#' 
#' @param bins_in integer vector, number of bins specified.
#' 
#' @param equal_prob logical, indicating to cut data into bins with equal relative frequencies.
#' If FALSE, then equal interval bins will be used.
#' 
#' @param fo_discretized logical, indicating whether to calculate first-order statistics on 
#' discretized images.
#' 
#' @param distance integer, distance between the voxels being compared.
#' 
#' @param statistic string, defining the statistic to be calculated on the array of GLCM statistics.
#' By default, statistic is set to \emph{"mean"}, however any function may be provided. The proper
#' syntax is: function(X, attributes). The supplied string must contain a "X", which will be replaced
#' with the array of the GLCM statistics value. Further attributes of the function may also be given.
#' For example, if you wish to calculate the median of all GLCMs calculated in different directions,
#' then it must be supplied as: \emph{median(X, na.rm = TRUE)}.
#' 
#' @param geometry_discretized logical, indicating whether to calculate geometry-based statistics on 
#' discretized images.
#'
#' @param verbose_in logical, indicating whether to print detailed information.
#' Most prints can also be suppressed using the \code{\link{suppressMessages}} function.
#'
#' @return \emph{RIA_image} containing the statistical information.
#'
#' @examples \dontrun{
#' #Discretize loaded image and then calculate all radiomic statistics
#' RIA_image <- radiomics_all(RIA_image, equal_prob = FALSE, bins_in= c(2,8,32,128), distance = c(1:3))
#' RIA_image <- radiomics_all(RIA_image, equal_prob = TRUE, bins_in= c(2,8,32,128), distance = c(1:3))
#' }
#' 
#' @references Márton KOLOSSVÁRY et al.
#' Radiomic Features Are Superior to Conventional Quantitative Computed Tomographic
#' Metrics to Identify Coronary Plaques With Napkin-Ring Sign
#' Circulation: Cardiovascular Imaging (2017).
#' DOI: 10.1161/circimaging.117.006843
#' \url{https://www.ncbi.nlm.nih.gov/pubmed/29233836}
#' 
#' Márton KOLOSSVÁRY et al.
#' Cardiac Computed Tomography Radiomics: A Comprehensive Review on Radiomic Techniques.
#' Journal of Thoracic Imaging (2018).
#' DOI: 10.1097/RTI.0000000000000268
#' \url{https://www.ncbi.nlm.nih.gov/pubmed/28346329}
#' @encoding UTF-8

radiomics_all <- function(RIA_data_in, bins_in=c(2,8,32,128), equal_prob = FALSE,
                          fo_discretized = FALSE,
                          distance = c(1,2, 3), statistic = "mean(X, na.rm = TRUE)",
                          geometry_discretized = FALSE,
                          verbose_in = TRUE) {
  
  RIA_data_in <- discretize(RIA_data_in, bins_in=bins_in, equal_prob = equal_prob, verbose_in = verbose_in)
  
  RIA_data_in <- first_order(RIA_data_in, use_type = "single", use_orig = TRUE, verbose_in = verbose_in)
  if(fo_discretized) {RIA_data_in <- first_order(RIA_data_in, use_type = "discretized", verbose_in = verbose_in)}
  
  for (i in 1: length(distance)) {
  RIA_data_in <- glcm_all(RIA_data_in, use_type = "discretized", distance = distance[i], verbose_in = verbose_in)
  }
  RIA_data_in <- glcm_stat(RIA_data_in, use_type = "glcm", verbose_in = verbose_in)
  RIA_data_in <- glcm_stat_all(RIA_data_in, statistic = statistic, verbose_in = verbose_in)
  
  RIA_data_in <- glrlm_all(RIA_data_in, use_type = "discretized", verbose_in = verbose_in)
  RIA_data_in <- glrlm_stat(RIA_data_in, use_type = "glrlm", verbose_in = verbose_in)
  RIA_data_in <- glrlm_stat_all(RIA_data_in, statistic = statistic, verbose_in = verbose_in)
  
  RIA_data_in <- geometry(RIA_data_in, use_orig = TRUE, calc_sub = FALSE, verbose_in = verbose_in)
  if(geometry_discretized) {RIA_data_in <- geometry(RIA_data_in, use_type = "discretized", calc_sub = TRUE, verbose_in = verbose_in)}
  RIA_data_in
}

Try the RIA package in your browser

Any scripts or data that you put into this service are public.

RIA documentation built on July 2, 2018, 1:04 a.m.