oasis_train_dataframe: OASIS Training Data Frame

Description Usage Arguments Value See Also Examples

View source: R/oasis_train_dataframe.R

Description

This function creates the training vectors from a single MRI study that has FLAIR, T1, T2, and PD volumes as well as binary masks of lesions. The function can create a brain mask for the data (or the user can supply a brain mask), can preprocess the data, and the user may supply already normalized data if they wish to use an alternative normalization method.

Usage

1
2
3
4
5
oasis_train_dataframe(flair, t1, t2, pd = NULL, gold_standard = NULL,
  brain_mask = NULL, preproc = FALSE, normalize = TRUE, slices = NULL,
  orientation = c("axial", "coronal", "sagittal"), return_preproc = FALSE,
  cores = 1, sigma = c(10, 20), verbose = TRUE, eroder = c("fsl",
  "oasis"))

Arguments

flair

FLAIR volume of class nifti

t1

T1 volume of class nifti

t2

T2 volume of class nifti

pd

PD volume of class nifti

gold_standard

gold standard lesion segmentation mask of class nifti

brain_mask

brain mask of class nifti, if NULL a brain mask will be created using fslbet

preproc

is a logical value that determines whether to call the oasis_preproc function and performs the necessary preprocessing steps for OASIS

normalize

is a logical value that determines whether to perform z-score normalization of the image over the brain mask, should be TRUE unless you train model using an alternative normalization

slices

vector of desired slices to train on, if NULL then train over the entire brain mask

orientation

string value telling which orientation the training slices are specified in, can take the values of "axial", "sagittal", or "coronal"

return_preproc

is a logical value that indicates whether the preprocessed images should be returned

cores

numeric indicating the number of cores to be used (no more than 4 is useful for this software implementation)

sigma

Sigmas used to smooth the data, default is 10,20

verbose

print diagnostic output

eroder

Should fslerode or oasis_erode be used

Value

If return_preproc = FALSE the function returns a data.frame for use with the oasis_training function. Otherwise, the function returns a list containing: a data.frame for use with the oasis_training function, the FLAIR volume, the T1 volume, the T2 volume, the PD volume, the brain mask for the subject, and the voxel selection mask.

See Also

oasis_training

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
library(neurobase)
dl_file = function(url) {
   tfile = tempfile(fileext = ".nii.gz")
   req <- httr::GET(url,
   httr::write_disk(path = tfile))
   httr::stop_for_status(req)
   tfile
}
in_ci <- function() {
 nzchar(Sys.getenv("CI"))
}
on_cran = function() {
 identical(Sys.getenv("NOT_CRAN"), "false")
} 
if (in_ci() || on_cran()) {
  if (fslr::have.fsl() && require(httr)) {
    mods = c("FLAIR", "T1W", "T2W", "consensus_gt", "brainmask")
    base_url = file.path(
      "https://raw.githubusercontent.com/muschellij2/open_ms_data", 
      "master/cross_sectional/coregistered/patient01/")
    files = paste0(base_url, mods, ".nii.gz")
    files = sapply(files, dl_file)
    names(files) = mods

    flair <- readnii(files["FLAIR"])
    t1 <- readnii(files["T1W"])
    t2 <- readnii(files["T2W"])
    brain_mask <- readnii(files["brainmask"])
    gold_standard = readnii(files["consensus_gt"])
    oasis_preprocessed_data <- oasis_train_dataframe(flair, t1, t2, 
      brain_mask = brain_mask, gold_standard = gold_standard)
  } 
}

Example output

Loading required package: oro.nifti
oro.nifti 0.9.1

oasis documentation built on May 2, 2019, 2:31 a.m.