dilate_atlas: Dilate Atlas Parcellation Boundaries

View source: R/dilate_parcels.R

dilate_atlasR Documentation

Dilate Atlas Parcellation Boundaries

Description

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.

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

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.

Value

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

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

create_brain_mask for creating appropriate masks

Examples

## Not run: 
# Load an atlas
atlas <- get_aseg_atlas()

# Create a brain mask
mask <- create_brain_mask(atlas)

# Dilate parcels by 4 voxels
dilated <- dilate_atlas(atlas, mask, radius = 4)

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

## End(Not run)


bbuchsbaum/neuroatlas documentation built on Dec. 24, 2024, 4:22 a.m.