Learn R Programming

mritc (version 0.5-3)

measureMRI: Compare the Predicted Classsification Results with the Truth

Description

Calculate and demonstrate different measures for classification results based on the truth.

Usage

measureMRI(intvec, actual, pre)

Value

mse

mean square error.

misclass

mis-classification rate.

rseVolume

root square error of volume with respect to reference tissue volume.

DSM

Dice Similary Measure of each tissue type. $$ DSM_{a,b}^{t}=\frac{2 \times N_{a \cap b}^t}{N_a^t+N_b^t} $$ where \(N_a^t\) and \(N_b^t\) are the number of voxels classified as tissue type \(t\) by method \(a\) and \(b\) respectively, and \(N_{a \cap b}^t\) is the number of voxels classified as tissue type \(t\) by both methods \(a\) and \(b\). The larger the DSM, the more similar the results from the two methods.

conTable

confusion table. Each column of the table represents the instances in an actual class, while each row represents the instances in a predicted class.

Arguments

intvec

a vector of intensity values. If it is not NULL, the density plots of each component corresponding to the actual and predicted classification results are shown. The default is NULL.

actual

matrix of the true classification result. Each row corresponds to one voxel. Column \(i\) represents the probabilities that all voxels are allocated to tissue type \(i\).

pre

matrix of the predicted classification result. Each row corresponds to one voxel. Column \(i\) represents the probabilities that all voxels are allocated to tissue type \(i\).

Examples

Run this code
  #Example 1
  prop <- c(.3, .4, .3)
  mu <- c(-4, 0, 4)
  sigma <- rep(1, 3)
  y <- rnormmix(n=1e4, prop, mu, sigma)
  intvec <- y[,1]
  actual <- y[,2]
  pre <- actual
  pre[sample(1:1e4, 100, replace=FALSE)]  <- sample(1:3, 100, replace=TRUE)
  actual <- do.call(cbind, lapply(1:3, function(i) ifelse(actual==i, 1, 0)))
  pre <- do.call(cbind, lapply(1:3, function(i) ifelse(pre==i, 1, 0)))
  measureMRI(intvec, actual, pre)

   # \donttest{
  #Example 2
  T1 <- readMRI(system.file("extdata/t1.rawb.gz", package="mritc"),
                c(91,109,91), format="rawb.gz")
  mask <-readMRI(system.file("extdata/mask.rawb.gz", package="mritc"),
                 c(91,109,91), format="rawb.gz")
  tc.icm <- mritc(T1, mask, method="ICM")

  csf <- readMRI(system.file("extdata/csf.rawb.gz", package="mritc"),
                c(91,109,91), format="rawb.gz")
  gm <- readMRI(system.file("extdata/gm.rawb.gz", package="mritc"),
                c(91,109,91), format="rawb.gz")
  wm <- readMRI(system.file("extdata/wm.rawb.gz", package="mritc"),
                c(91,109,91), format="rawb.gz")
  truth <- cbind(csf[mask==1], gm[mask==1], wm[mask==1])
  truth <- truth/255
  measureMRI(T1[mask==1], truth, tc.icm$prob)
  # }

Run the code above in your browser using DataLab