Creates a structured confound strategy object that specifies which variables
to reduce via PCA and which to keep as-is. Pass the result directly to
read_confounds(..., cvars = confound_strategy(...)).
Arguments
- name
Character. Name of a predefined strategy (see above), or
NULLfor a custom strategy.- pca_vars
Character vector of confound names/wildcards to include in PCA reduction. Ignored when
nameis specified.- raw_vars
Character vector of confound names/wildcards to keep without reduction. Ignored when
nameis specified.- perc_var
Numeric. Percentage of variance to retain from PCA (default -1, meaning use
npcsinstead).- npcs
Integer. Number of PCs to retain (default -1, meaning use
perc_varinstead).
Value
A confound_strategy object (S3 class) that can be passed as
the cvars argument to read_confounds().
Details
When a strategy is passed to read_confounds, the function:
Selects the
pca_varscolumns and reduces them via PCA (retainingperc_var\Selects the
raw_varscolumns and keeps them unchanged.Column-binds the PCA scores with the raw columns.
Available named strategies:
"pcabasic80"PCA over motion24 + aCompCor + tCompCor + CSF + white matter, retaining 80\ Discrete cosine regressors are appended un-reduced.
Examples
# Named strategy
confound_strategy("pcabasic80")
#> $name
#> [1] "pcabasic80"
#>
#> $pca_vars
#> [1] "trans_x" "trans_y"
#> [3] "trans_z" "rot_x"
#> [5] "rot_y" "rot_z"
#> [7] "trans_x_derivative1" "trans_y_derivative1"
#> [9] "trans_z_derivative1" "rot_x_derivative1"
#> [11] "rot_y_derivative1" "rot_z_derivative1"
#> [13] "trans_x_power2" "trans_y_power2"
#> [15] "trans_z_power2" "rot_x_power2"
#> [17] "rot_y_power2" "rot_z_power2"
#> [19] "trans_x_derivative1_power2" "trans_y_derivative1_power2"
#> [21] "trans_z_derivative1_power2" "rot_x_derivative1_power2"
#> [23] "rot_y_derivative1_power2" "rot_z_derivative1_power2"
#> [25] "csf" "white_matter"
#> [27] "a_comp_cor_*" "t_comp_cor_*"
#>
#> $raw_vars
#> [1] "cosine_*" "cosine*"
#>
#> $perc_var
#> [1] 80
#>
#> $npcs
#> [1] -1
#>
#> attr(,"class")
#> [1] "confound_strategy"
# Custom strategy: PCA motion + compcor to 5 PCs, keep cosine regressors
confound_strategy(
pca_vars = c(confound_set("motion24"), confound_set("compcor")),
raw_vars = confound_set("cosine"),
npcs = 5
)
#> $name
#> [1] "custom"
#>
#> $pca_vars
#> [1] "trans_x" "trans_y"
#> [3] "trans_z" "rot_x"
#> [5] "rot_y" "rot_z"
#> [7] "trans_x_derivative1" "trans_y_derivative1"
#> [9] "trans_z_derivative1" "rot_x_derivative1"
#> [11] "rot_y_derivative1" "rot_z_derivative1"
#> [13] "trans_x_power2" "trans_y_power2"
#> [15] "trans_z_power2" "rot_x_power2"
#> [17] "rot_y_power2" "rot_z_power2"
#> [19] "trans_x_derivative1_power2" "trans_y_derivative1_power2"
#> [21] "trans_z_derivative1_power2" "rot_x_derivative1_power2"
#> [23] "rot_y_derivative1_power2" "rot_z_derivative1_power2"
#> [25] "a_comp_cor_*" "t_comp_cor_*"
#>
#> $raw_vars
#> [1] "cosine_*" "cosine*"
#>
#> $perc_var
#> [1] -1
#>
#> $npcs
#> [1] 5
#>
#> attr(,"class")
#> [1] "confound_strategy"