This function resamples a source image to match the spatial properties (dimensions, resolution, and orientation) of a target image.
Arguments
- source
An object representing the source image to be resampled. This could be a 3D or 4D image object, depending on the use case.
- target
An object representing the target image, whose spatial properties will be used as the reference for resampling the source image.
- ...
Additional arguments passed to the resampling function, such as interpolation method, boundary handling, or other resampling options.
Value
An object representing the resampled source image, with the same spatial properties as the target image.
Examples
img <- read_vol(system.file("extdata", "global_mask.nii", package = "neuroim2"))
rspace <- space(img)
### normally, one would resample from two existing soource and target spaces.
### But here we manually create the target space, which is a bit ugly.
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)