Skip to contents

Expands the boundaries of brain atlas parcels by dilating them into adjacent unassigned voxels within a specified mask. This is useful for filling small gaps between parcels or extending parcels into neighboring regions.

Usage

dilate_atlas(atlas, mask, radius = 4, maxn = 50)

Arguments

atlas

An object of class "atlas" containing the parcellation to be dilated

mask

A binary mask (NeuroVol object) specifying valid voxels for dilation. Dilation will only occur within non-zero mask values. Can also be a character string representing a TemplateFlow space ID (e.g., "MNI152NLin2009cAsym"), in which case the corresponding standard brain mask will be fetched from TemplateFlow. Alternatively, can be a list of arguments to pass to `neuroatlas::get_template` to fetch a specific mask.

radius

Numeric. The maximum distance (in voxels) to search for neighboring parcels when dilating. Default: 4

maxn

Integer. Maximum number of neighboring voxels to consider when determining parcel assignment. Default: 50

Value

A ClusteredNeuroVol object containing the dilated parcellation. The object maintains the original label mappings but may include additional voxels in existing parcels.

Details

The dilation process:

  • Identifies unassigned voxels within the mask that are adjacent to existing parcels

  • For each unassigned voxel, finds nearby assigned voxels within the specified radius

  • Assigns the unassigned voxel to the nearest parcel

  • Respects mask boundaries to prevent dilation into unwanted regions

The function uses a k-d tree implementation (via rflann) for efficient nearest neighbor searches in 3D space.

References

The algorithm uses the FLANN library for efficient nearest neighbor searches: Muja, M., & Lowe, D. G. (2014). Scalable nearest neighbor algorithms for high dimensional data. IEEE Transactions on Pattern Analysis and Machine Intelligence, 36(11), 2227-2240.

See also

get_template_brainmask for creating appropriate masks from TemplateFlow

Examples

if (FALSE) { # \dontrun{
# Load an atlas
atlas <- get_aseg_atlas()

# Use TemplateFlow brain mask
dilated <- dilate_atlas(atlas, "MNI152NLin2009cAsym", radius = 4)

# More conservative dilation with fewer neighbors
dilated_conservative <- dilate_atlas(atlas, "MNI152NLin2009cAsym", radius = 2, maxn = 20)
} # }