Tests whether the spatial correlation between two parcellated brain maps is stronger than expected by chance, using the spin-test framework of Alexander-Bloch et al. (2018). Parcel centroids on each hemisphere's sphere are randomly rotated and reassigned to the nearest original centroid of the same hemisphere, generating a null distribution of correlations that preserves spatial autocorrelation and hemisphere membership.
Arguments
- map1
Numeric vector of parcel values (length K, aligned to atlas parcels).
- map2
Numeric vector of parcel values (length K, aligned to atlas parcels).
- atlas
A surface atlas object (class
"surfatlas") withlh_atlasandrh_atlasfields, or any atlas whose geometry can provide sphere coordinates. Whensphereis a K x 3 centroid matrix,atlas$hemimust give each parcel's hemisphere ("left"or"right").- n_perm
Integer. Number of spin permutations. Default: 1000.
- cor_method
Character. Correlation method passed to
cor. One of"pearson","spearman", or"kendall". Default:"pearson".- sphere
Optional sphere geometry. Either a list with elements
lhandrh, each an N x 3 matrix of sphere vertex coordinates for that hemisphere (in the hemisphere's own sphere coordinate frame), or a K x 3 matrix of parcel centroids inatlas$idsorder. IfNULL(default), sphere coordinates are fetched viaload_surface_template(..., "sphere")using the atlas'ssurface_space.- seed
Optional integer seed for reproducibility.
- hemi_rotation
Character. How the right-hemisphere rotation relates to the left-hemisphere rotation in each permutation.
"mirror"(default, as in Alexander-Bloch et al. 2018) draws one random rotation for the left hemisphere and applies its reflection across the mid-sagittal (x = 0) plane to the right hemisphere, so homologous locations rotate homologously."independent"draws a separate random rotation for each hemisphere. In both cases each hemisphere is rotated on its own sphere and parcels are only reassigned within their own hemisphere.
Value
A list of class "spin_test" with:
- observed
The observed correlation between
map1andmap2.- null_distribution
Numeric vector of length
n_permcontaining null correlations.- p_value
Two-sided p-value: proportion of null correlations with absolute value >= the observed absolute correlation.
- n_perm
Number of permutations performed.
- hemi_rotation
The hemisphere rotation scheme used.
- permutations
K x
n_perminteger matrix; columnigives, for each parcel, the index of the parcel whosemap2value it receives in permutationi.
Details
The algorithm:
Compute parcel centroids on each hemisphere's sphere by averaging the sphere coordinates of that hemisphere's vertices belonging to each parcel.
For each permutation, generate a uniform random 3D rotation matrix (from the Haar measure on SO(3)) for the left hemisphere and derive the right-hemisphere rotation according to
hemi_rotation. Rotate the centroids of each hemisphere with that hemisphere's rotation, then reassign each rotated centroid to its nearest original centroid in the same hemisphere usingnn.Compute the correlation of
map1with the permutedmap2(values shuffled according to the reassignment).The p-value is
(sum(abs(null) >= abs(observed)) + 1) / (n_perm + 1).
Nearest-centroid reassignment can map several rotated parcels to the same original parcel (sampling with replacement), as in the original Alexander-Bloch et al. (2018) procedure.
References
Alexander-Bloch, A. F., et al. (2018). On testing for spatial correspondence between maps of human brain structure and function. NeuroImage, 178, 540-551.
Examples
if (FALSE) { # \dontrun{
atlas <- get_schaefer_surfatlas(parcels = "100", networks = "7")
K <- length(atlas$ids)
map1 <- rnorm(K)
map2 <- map1 + rnorm(K, sd = 0.5)
res <- spin_test(map1, map2, atlas, n_perm = 500, seed = 42)
print(res)
} # }