Convenience function that combines split.gds() and as_neurovol_list()
to extract neuroimaging volumes for subjects in a specific group.
Arguments
- x
A GDS object.
- group_var
Column name in
col_data(x)containing group labels.- group_level
The specific group level to extract.
- assay
Name of the assay to extract (default:
"beta").- ...
Additional arguments passed to
as_neurovol_list().
Value
A named list of neuroim2::NeuroVol objects for subjects in the
specified group.
Examples
if (requireNamespace("neuroim2", quietly = TRUE)) {
sp4 <- neuroim2::NeuroSpace(c(4, 4, 2, 4), spacing = c(2, 2, 2))
vec4d <- neuroim2::NeuroVec(array(rnorm(128), c(4, 4, 2, 4)), sp4)
gds <- as_gds(vec4d, along = "subject", subjects = paste0("sub0", 1:4))
gds <- with_col_data(gds, data.frame(
diagnosis = c("patient", "control", "patient", "control"),
row.names = subjects(gds)
))
# Get beta maps for all patients
patient_vols <- extract_group(gds, "diagnosis", "patient", assay = "beta")
print(names(patient_vols))
# Get beta maps for controls
control_vols <- extract_group(gds, "diagnosis", "control", assay = "beta")
print(names(control_vols))
}
#> [1] "sub01" "sub03"
#> [1] "sub02" "sub04"