get_patches: Get Patches from T1 and FLAIR image

Description Usage Arguments Value Note Examples

View source: R/get_patches.R

Description

Get Patches from T1 and FLAIR image

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
get_patches(
  t1,
  flair = NULL,
  t2 = NULL,
  mask = NULL,
  patchsize,
  pad = TRUE,
  normalize = TRUE,
  verbose = TRUE,
  only_patches = FALSE,
  seed = NULL,
  ...
)

Arguments

t1

3D array or nifti image

flair

3D array or nifti image

t2

3D array or nifti image

mask

binary 3D array or nifti image

patchsize

Vector of length 2 (or more)

pad

Run pad_image on the image before getting patches (pads then normalizes if normalize = TRUE)

normalize

Run normalize_image on the image before getting patches

verbose

print diagnostic messages

only_patches

Only return the patches, not additional information.

seed

Seed for random sampling of indices. If NULL, no sampling is done, passed to mask_indices

...

additional arguments to pass to get_patch_from_volume

Value

A list of T1, FLAIR, and Mask Patches

Note

If mask = NULL, a mask will be created based on voxels greater than the 75th percentile of the FLAIR image.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
user = Sys.getenv("USER")
if (user %in% c("johnmuschelli", "travis") &
Sys.info()["sysname"] == "Darwin"){
reticulate::use_python(paste0(
"/Library/Frameworks/Python.framework/Versions/3.5/bin/python3"))
} else {
python = system("which python", intern = TRUE)
print(python)
reticulate::use_python(python)
}
library(neurobase)
fname = system.file("extdata", "MPRAGE.nii.gz", package = "flexconn")
t1 = readnii(fname)
fname = system.file("extdata", "FLAIR.nii.gz", package = "flexconn")
flair = readnii(fname)
patchsize = c(3, 3)
verbose = TRUE
patch = get_patches(t1, flair, mask = NULL, patchsize = patchsize)

rm(patch)

neuroconductor/flexconn documentation built on Sept. 25, 2020, 10:51 a.m.