Shift a 3D Array in One Dimension

Share:

Description

One axis of the three-dimensional array is translated by an integer amount. This is useful when applying convolution operators in the Fourier domain.

Usage

1
shift3D(A, s, type, fill = 0)

Arguments

A

is a three-dimensional array.

s

is the integer number of translation steps.

type

is a character string using anatomical coordinates assuming a transverse acquisition scheme (“LR” = left-right = x-axis, “AP” = anterior-posterior = y-axis, “SI” = superior-inferior = z-axis).

fill

is the quantity used to fill gaps induced by the translations (circular boundary conditions are NOT used).

Value

A three-dimensional array is returned, the same dimension as the original array, with one dimension translated.

Author(s)

Brandon Whitcher bwhitcher@gmail.com

See Also

convFFT

Examples

1
2
3
4
5
6
cube <- array(0, rep(20,3))
cube[9:12,9:12,9:12] <- 1
cube.shift <- shift3D(cube, 5, type="AP")
par(mfrow=c(1,2), mar=rep(0.5,4))
image(cube[,,10], xlab="", ylab="", axes=FALSE)
image(cube.shift[,,10], xlab="", ylab="", axes=FALSE)