Population study using simple_voxel_based_analysis.R¶
This example shows how to run a basic linear regression study across a population of image measurements.
Load libraries.
library(knitr)
library(ANTsR)
Define the normalized image cohort and image mask.
controlFileNames <- list.files(path = "../../", pattern = glob2rx("phantomtemplate_CONTROL*"),
full.names = TRUE, recursive = TRUE)
experimentalFileNames <- list.files(path = "../../", pattern = glob2rx("phantomtemplate_EXP*"),
full.names = TRUE, recursive = TRUE)
images <- c(controlFileNames, experimentalFileNames)
mask <- "../../demo/example_images/phantomtemplate_mask.nii.gz"
Assign cohort (diagnosis) predictor and assign a random age to simulated images.
diagnosis <- c(rep(1, length(controlFileNames)), rep(0, length(experimentalFileNames)))
age <- runif(length(diagnosis), 25, 30)
Specify output path for statistical maps.
outputPath <- "../../test_output/"
Perform a simple voxelwise t-test.
prefix <- "ANTsR_t.test_"
simple_voxel_based_analysis(dimensionality = 2, imageFileNames = images, predictors = data.frame(diagnosis),
maskFileName = mask, outputPrefix = paste0(outputPath, prefix), testType = "student.t")
Plot the results.
timg <- antsImageRead(paste0(outputPath, prefix, "tValues.nii.gz"), 2)
plotANTsImage(myantsimage = antsImageRead(mask, 2), functional = list(timg),
threshold = "0x1", color = "red", axis = 1)