apply_parc: Apply function over locations in each parcel

View source: R/parc_utils.R

apply_parcR Documentation

Apply function over locations in each parcel

Description

Apply a function across all locations in each parcel, for a pair of data and parcellation "xifti" objects that are in registration with one another. By default, the mean value in each parcel is calculated.

Usage

apply_parc(
  xii,
  parc,
  FUN = mean,
  mwall_value = NA,
  return_as = c("matrix", "xifti"),
  ...
)

Arguments

xii

The "xifti" data to apply the function over, within each parcel.

parc

The "xifti" "dlabel" parcellation. Each parcel is defined by a unique key in the label table. If there are multiple columns, only the first column will be used. Alternatively, parc can just be a vector of keys whose length is the number of data locations in "xii".

FUN

A function that takes as input an M \times N matrix (M locations in a given parcel, and N measurements/columns in xii) and outputs a constant-sized (Q) numeric vector. Default: mean.

Use colMeans to obtain the average timeseries of each parcel, such as in order to compute functional connectivity.

mwall_value

If there is a medial wall in xii, what should value should medial wall locations be replaced with prior to calculation? Default: NA.

return_as

"matrix" (default) where each row corresponds to a parcel, or a "xifti" object where each location's value is the value of its corresponding parcel?

...

Additional arguments to FUN, e.g. na.rm=TRUE. Ignored if FUN=="quick_mean".

Value

A P \times Q matrix, where P is the number of parcels and Q is the length of the output of FUN. (For mean, Q = 1).

See Also

Other parcellation-related: load_parc(), load_sub_parc(), parc_add_subcortex(), parc_borders(), parc_vals_to_xifti()

Other manipulating xifti: add_surf(), apply_xifti(), combine_xifti(), convert_to_dlabel(), merge_xifti(), move_to_mwall(), move_to_submask(), newdata_xifti(), remap_cifti(), remove_xifti(), resample_cifti(), resample_cifti_from_template(), scale_xifti(), select_xifti(), set_names_xifti(), smooth_cifti(), transform_xifti()


ciftiTools documentation built on Oct. 4, 2024, 1:12 a.m.