|
a |
|
b/R/ct_template.R |
|
|
1 |
#' @title Read in CT Template |
|
|
2 |
#' @description Wrapper for returning a \code{nifti} object of the CT Template |
|
|
3 |
#' @param ... Arguments passed to \code{\link{ct_template_fname}} |
|
|
4 |
#' |
|
|
5 |
#' @return Object of class \code{\link{nifti}} |
|
|
6 |
#' @export |
|
|
7 |
ct_template = function(...){ |
|
|
8 |
fname = ct_template_fname(...) |
|
|
9 |
res = readnii(fname) |
|
|
10 |
return(res) |
|
|
11 |
} |
|
|
12 |
|
|
|
13 |
#' @title Get CT Template Filename |
|
|
14 |
#' @description Wrapper for returning the filename of the CT Template |
|
|
15 |
#' @param type Type of image. \code{image} is the original image, |
|
|
16 |
#' \code{brain} is the skull stripped image, |
|
|
17 |
#' \code{mask} is brain mask. Values with \code{cormack} or \code{stripped} |
|
|
18 |
#' are in 2 millimeter resolution, and smoothed. |
|
|
19 |
#' @return Character filename |
|
|
20 |
#' @export |
|
|
21 |
#' @examples |
|
|
22 |
#' types = c("brain", "mask", "image", |
|
|
23 |
#' "cormack", |
|
|
24 |
#' "stripped_cormack", |
|
|
25 |
#' "stripped_hu", |
|
|
26 |
#' "stripped_hu8") |
|
|
27 |
#' sapply(types, ct_template_fname) |
|
|
28 |
ct_template_fname = function(type = c("brain", "mask", "image", |
|
|
29 |
"cormack", |
|
|
30 |
"stripped_cormack", |
|
|
31 |
"stripped_hu", |
|
|
32 |
"stripped_hu8")){ |
|
|
33 |
type = match.arg(type) |
|
|
34 |
if (type %in% c("cormack", |
|
|
35 |
"stripped_cormack", |
|
|
36 |
"stripped_hu", |
|
|
37 |
"stripped_hu8")) { |
|
|
38 |
stub = paste0("scct_", type) |
|
|
39 |
} else { |
|
|
40 |
stub = "scct_unsmooth" |
|
|
41 |
brain = type %in% "brain" |
|
|
42 |
mask = type %in% "mask" |
|
|
43 |
if (brain | mask) { |
|
|
44 |
stub = paste0(stub, "_SS_0.01") |
|
|
45 |
} |
|
|
46 |
if (mask) { |
|
|
47 |
stub = paste0(stub, "_Mask") |
|
|
48 |
} |
|
|
49 |
} |
|
|
50 |
stub = paste0(stub, ".nii.gz") |
|
|
51 |
res = system.file(stub, |
|
|
52 |
package = "ichseg") |
|
|
53 |
if (!file.exists(res)) { |
|
|
54 |
stop("Template File not found!") |
|
|
55 |
} |
|
|
56 |
return(res) |
|
|
57 |
} |