ortho_diff: Plot differences for Prediction and Gold Standard

Description Usage Arguments See Also Examples

View source: R/ortho_diff.R

Description

Uses ortho2 to plot differences between a predicted binary image and the assumed ground truth (roi).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
ortho_diff(
  img,
  pred,
  roi,
  xyz = NULL,
  cols = c("#56B4E9", "#D55E00", "#009E73"),
  levels = c("False Negative", "False Positive", "True Positive"),
  addlegend = TRUE,
  center = TRUE,
  leg.cex = 1.5,
  ...
)

multi_overlay_diff(
  x,
  pred,
  roi,
  z = NULL,
  cols = c("#56B4E9", "#D55E00", "#009E73"),
  ...
)

Arguments

img

image to be underlaid

pred

binary segmentation (prediction)

roi

binary manual segmentation (ground truth)

xyz

coordinate for the center of the crosshairs.

cols

colors for false negatives/positives

levels

labels for false negatives/positives

addlegend

add legend, passed to ortho2

center

run xyz on roi. Disregarded if xyz is not NULL

leg.cex

multiplier for legend size

...

arguments to be passed to ortho2 or multi_overlay

x

List of images of class nifti or character vector of filenames

z

slice to display

See Also

ortho2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
set.seed(5)
dims = rep(10, 3)
arr = array(rpois(prod(dims), lambda = 2), dim = dims)
nim = oro.nifti::nifti(arr)
roi = nim > 2
pred = nim > 1.5
ortho_diff(nim, pred, roi)
set.seed(5)
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
nim = oro.nifti::nifti(arr)
mask = nim > 2
pred = nim > 1.5
multi_overlay_diff(nim, roi = mask, pred = pred)



 if (requireNamespace("brainR", quietly = TRUE)) {
   visits = 1:3
   y = paste0("Visit_", visits, ".nii.gz")
   y = system.file(y, package = "brainR")
   y = lapply(y, readnii)

   y = lapply(y, function(r){
     pixdim(r) = c(0, rep(1, 3), rep(0, 4))
     dropImageDimension(r)
   })

   x = system.file("MNI152_T1_1mm_brain.nii.gz", 
                 package = "brainR")
   x = readnii(x)
   mask = x > 0
   alpha = function(col, alpha = 1) {
       cols = t(col2rgb(col, alpha = FALSE)/255)
       rgb(cols, alpha = alpha)
   }
   roi = y[[2]]
   pred = y
   multi_overlay_diff(x, roi = roi, pred = pred)
   multi_overlay_diff(x, roi = roi, pred = pred, 
         mask = mask, 
         main = paste0("\n", "Visit ", visits),
         text = LETTERS[visits],
         text.x = 0.9,
         text.y = 0.1,
         text.cex = 3)
 }

neuroconductor-devel/neurobase documentation built on May 6, 2021, 1:48 p.m.