pad_vol {fMRItools}R Documentation

Pad 3D Array

Description

Pad a 3D array by a certain amount in each direction, along each dimension. This operation is like the opposite of cropping.

Usage

pad_vol(x, padding, fill = NA)

uncrop_vol(x, padding, fill = NA)

Arguments

x

A 3D array, e.g. unvec_vol(xifti$data$subcort, xifti$meta$subcort$mask).

padding

A 3 \times 2 matrix indicating the number of slices to add at the beginning (first column) and end (second column) of each of dimension, e.g. xifti$meta$subcort$mask_padding.

fill

Value to pad with. Default: NA.

Value

The padded array

Examples

x <- array(seq(24), dim=c(2,3,4))
y <- pad_vol(x, array(1, dim=c(3,2)), 0)
stopifnot(all(dim(y) == dim(x)+2))
stopifnot(sum(y) == sum(x))
z <- crop_vol(y)$data
stopifnot(identical(dim(x), dim(z)))
stopifnot(max(abs(z - x))==0)

[Package fMRItools version 0.4.7 Index]