Description Usage Arguments Value See Also Examples
View source: R/oasis_train_dataframe.R
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.
1 2 3 4 5 |
flair |
FLAIR volume of class |
t1 |
T1 volume of class |
t2 |
T2 volume of class |
pd |
PD volume of class |
gold_standard |
gold standard lesion segmentation mask of class
|
brain_mask |
brain mask of class |
preproc |
is a logical value that determines whether to call the
|
normalize |
is a logical value that determines whether
to perform z-score normalization of the image over the brain mask,
should be |
slices |
vector of desired slices to train on, if |
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 |
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.
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)
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.