if(interactive() && ants_available()) {
ants <- load_ants()
fixed <- as_ANTsImage( ants$get_ants_data('r16') )
moving <- as_ANTsImage( ants$get_ants_data('r64') )
fixed <- ants_resample_image(fixed, c(64, 64), TRUE, "linear")
moving <- ants_resample_image(moving, c(64,64), TRUE, "linear")
mytx <- ants_registration(fixed = fixed,
moving = moving,
type_of_transform = 'SyN')
mywarpedimage <- ants_apply_transforms(
fixed = fixed,
moving = moving,
transformlist = mytx$fwdtransforms
)
par(mfrow = c(1,3), mar = c(0,0,3,0))
pal <- gray.colors(256)
image(fixed[], asp = 1, axes = FALSE, col = pal,
ylim = c(1, 0), main = "Reference")
image(moving[], asp = 1, axes = FALSE, col = pal,
ylim = c(1, 0), main = "Moving")
image(mywarpedimage[], asp = 1, axes = FALSE, col = pal,
ylim = c(1, 0), main = "Moving reg+resamp into Reference")
}
Run the code above in your browser using DataLab