Description Usage Arguments Value Examples
View source: R/patches_to_volume.R
Convert Patches to a Volume
1 2 3 4 5 6 7 8 9 10 | patches_to_volume(patches, indices, patchsize, verbose = TRUE, orig_dim = NULL)
get_volume_from_patches(
patches,
indices,
patchsize,
verbose = TRUE,
invert_pad = TRUE,
orig_dim = NULL
)
|
patches |
A matrix of patches, generally from
|
indices |
A matrix of 3 by |
patchsize |
Vector of length 2 (or more) |
verbose |
print diagnostic messages |
orig_dim |
Original dimensions of volume |
invert_pad |
Run |
A 3D volume
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 | 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,
only_patches = FALSE, normalize = FALSE)
out_mask = patch$mask
masked_t1 = mask_img(t1, out_mask)
t1_remade = get_volume_from_patches(patch$t1_patches,
indices = patch$indices,
patchsize = patchsize,
invert_pad = patch$pad)
stopifnot(all(dim(t1) == dim(t1_remade)))
t1vals = mask_vals(t1, out_mask)
t1_remade_vals = mask_vals(t1_remade, out_mask)
testthat::expect_equal(t1vals, t1_remade_vals)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.