library(rpyANTs)
if(interactive() && ants_available("antspynet")) {
image_path <- ants$get_ants_data('r30')
preprocessed <- antspynet_preprocess_brain_image(
image_path, verbose = FALSE
)
# Compare
orig_img <- as_ANTsImage(image_path)
new_img <- preprocessed$preprocessed_image
pal <- grDevices::gray.colors(256, start = 0, end = 1)
par(mfrow = c(1, 2), mar = c(0.1, 0.1, 0.1, 0.1),
bg = "black", fg = "white")
image(orig_img[], asp = 1, axes = FALSE,
col = pal, ylim = c(1, 0))
image(new_img[], asp = 1, axes = FALSE,
col = pal, ylim = c(1, 0))
}
Run the code above in your browser using DataLab