get_patch_from_volume: Get Patches from 3D Volume

Description Usage Arguments Value Examples

View source: R/get_patches.R

Description

Get Patches from 3D Volume

Usage

 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
get_patch_from_volume(
  vol,
  mask = NULL,
  patchsize,
  verbose = TRUE,
  pad = TRUE,
  normalize = TRUE,
  contrast,
  seed = NULL,
  run_mask_patches = TRUE,
  peak_estimator = c("Python", "R"),
  ...
)

get_num_patches(mask)

norm_pad(
  vol,
  mask = NULL,
  patchsize,
  verbose = TRUE,
  pad = TRUE,
  normalize = TRUE,
  peak_estimator = c("Python", "R"),
  contrast
)

get_mask_patches(mask, patchsize, pad = TRUE, seed = NULL, verbose = TRUE)

Arguments

vol

3D array or nifti image

mask

binary 3D array or nifti image, for the brain usually

patchsize

Vector of length 2 (or more)

verbose

print diagnostic messages

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

contrast

What imaging sequence of MRI is this volume, passed to normalize_image

seed

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

run_mask_patches

Should the patches for the mask be made as well?

peak_estimator

Which functions to use to estimate peak, either wrapper Python code or native R code.

...

not used

Value

A list of image and mask Patches

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
user = Sys.getenv("USER")
if (user == "johnmuschelli") {
reticulate::use_python(paste0(
"/Library/Frameworks/Python.framework/Versions/3.5/bin/python3"))
mpl = reticulate::import("matplotlib")
mpl$use('TkAgg')
}
library(neurobase)
fname = system.file("extdata", "MPRAGE.nii.gz", package = "flexconn")
vol = readnii(fname)
mask = vol > 0
patchsize = c(5, 5)
verbose = TRUE
patch = get_patch_from_volume(vol, mask, patchsize = patchsize,
contrast = "T1")

rm(patch)

patch = get_patch_from_volume(vol, mask, patchsize = c(1,1,1),
contrast = "T1")
rm(patch)

neuroconductor-devel-releases/flexconn documentation built on May 6, 2020, 4:21 p.m.