Skip to contents

Generate a permutation map from a set of cortical regions of interest to itself, while (approximately) preserving contiguity and hemispheric symmetry. The function is based on a rotation of the FreeSurfer projection of coordinates of a set of regions of interest on the sphere. #' This function is modified from the original version available at: https://github.com/frantisekvasa/rotate_parcellation. Please cite relevant papers from this source if you used this function.

Usage

rotate_parcellation(
  coord.l = NULL,
  coord.r = NULL,
  nrot = 5000,
  method = c("hungarian", "vasa"),
  seed = NULL
)

Arguments

coord.l

Coordinates of left hemisphere regions on the sphere (array of size n(LH regions) x 3). Can be NULL if only right hemisphere is used.

coord.r

Coordinates of right hemisphere regions on the sphere (array of size n(RH regions) x 3). Can be NULL if only left hemisphere is used.

nrot

Number of rotations (default = 5000).

method

Method to match rotated and unrotated regions; options are 'vasa' (faster, can be suboptimal) or 'hungarian' (default, slower, optimal).

seed

Seed for reproducibility.

Value

Array of permutations, from set of regions to itself (array of size n(total regions) x nrot).

Details

Modifications include:

  • Added support for scenarios where only one hemisphere's coordinates are provided.

  • Improved handling of coordinate dimensions and conditional concatenation of reference and rotation indices.

  • Included importFrom directives for required functions from matrixStats and clue.

  • Ensured the function generates nrot + 100 permutations, removes duplicates, and returns exactly nrot unique permutations.