resample | R Documentation |
This function resamples a source image to match the spatial properties (dimensions, resolution, and orientation) of a target image.
This method resamples a NeuroVol object (source
) to match the dimensions and orientation of a NeuroSpace object (target
).
resample(source, target, ...)
## S4 method for signature 'NeuroVol,NeuroVol'
resample(source, target, interpolation = 3L)
## S4 method for signature 'NeuroVol,NeuroSpace'
resample(source, target, interpolation = 3L)
source |
A NeuroVol object representing the source volume to be resampled. |
target |
A NeuroSpace object representing the target space to match the dimensions and orientation of the source volume. |
... |
Additional arguments passed to the resampling function, such as interpolation method, boundary handling, or other resampling options. |
interpolation |
A single integer specifying the type of interpolation to be applied to the final resampled image. May be 0 (nearest neighbor), 1 (trilinear), or 3 (cubic spline). No other values are valid. |
An object representing the resampled source
image, with the same spatial properties as target
.
NeuroVol
for the base volume class
img <- read_vol(system.file("extdata", "global_mask_v4.nii", package = "neuroim2"))
rspace <- space(img)
newtrans4X3 <- trans(img)[1:4, 1:3]
newtrans4X3 <- newtrans4X3 * c(.5,.5,.5,1)
newtrans <- cbind(newtrans4X3, c(space(img)@origin,1))
rspace <- NeuroSpace(rspace@dim*2, rspace@spacing/2, origin=rspace@origin, trans=trans(img))
rvol <- resample(img, rspace)
# Create source and target volumes
src_vol <- read_vol(system.file("extdata", "global_mask_v4.nii", package="neuroim2"))
targ_vol <- read_vol(system.file("extdata", "global_mask_v4.nii", package="neuroim2"))
# Resample source to match target
resampled <- resample(src_vol, targ_vol, interpolation=1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.