View source: R/dilate_parcels.R
dilate_atlas | R Documentation |
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.
dilate_atlas(atlas, mask, radius = 4, maxn = 50)
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 |
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.
A ClusteredNeuroVol
object containing the dilated parcellation.
The object maintains the original label mappings but may include additional
voxels in existing parcels.
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.
create_brain_mask
for creating appropriate masks
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.