Learn R Programming

neuroim2 (version 0.8.5)

resample: Resample an Image to Match the Space of Another Image

Description

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).

This method preserves discrete cluster labels and label mappings when resampling clustered volumes to a new space.

Usage

resample(source, target, ...)

# S4 method for NeuroVol,NeuroVol resample(source, target, interpolation = 3L)

# S4 method for NeuroVol,NeuroSpace resample(source, target, interpolation = 3L)

# S4 method for ClusteredNeuroVol,NeuroSpace resample(source, target, interpolation = 0L)

# S4 method for ClusteredNeuroVol,NeuroVol resample(source, target, interpolation = 0L)

Value

An object representing the resampled source image, with the same spatial properties as target.

Arguments

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.

See Also

NeuroVol for the base volume class

Examples

Run this code

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))
# \donttest{
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)


Run the code above in your browser using DataLab