Functions for modifying brain atlas objects. These cover three areas:
atlas_region_remove(atlas, pattern, match_on = c("region", "label"))atlas_region_contextual(atlas, pattern, match_on = c("region", "label"))
atlas_region_rename(atlas, pattern, replacement)
atlas_region_keep(atlas, pattern, match_on = c("region", "label"))
atlas_core_add(atlas, data, by = "region")
atlas_view_remove(atlas, views)
atlas_view_keep(atlas, views)
atlas_view_remove_region(
atlas,
pattern,
match_on = c("label", "region"),
views = NULL
)
atlas_view_remove_small(atlas, min_area, views = NULL)
atlas_view_gather(atlas, gap = 0.15)
atlas_view_reorder(atlas, order, gap = 0.15)
Modified ggseg_atlas object
A ggseg_atlas object
Character pattern to match. Uses
grepl(..., ignore.case = TRUE).
Column to match against: "region" or "label".
For atlas_region_rename(): replacement string or
function.
For atlas_core_add(): data.frame with metadata to join.
For atlas_core_add(): column(s) to join by. Default "region".
For view functions: character vector of view names or
patterns. Multiple values collapsed with "|" for matching.
For atlas_view_remove_small(): minimum polygon
area to keep. Context geometries are never removed.
Proportional gap between views (default 0.15 = 15% of max width).
For atlas_view_reorder(): character vector of desired
view order. Unspecified views appended at end.
atlas_region_contextual(): Keep geometry for visual context but remove
from core, palette, and 3D data. Context geometries render grey and don't
appear in legends.
atlas_region_rename(): Rename regions matching a pattern. Only
affects the region column, not label. If replacement is a function,
it receives matched names and returns new names.
atlas_region_keep(): Keep only matching regions. Non-matching
regions are removed from core, palette, and 3D data but sf geometry
is preserved for surface continuity.
atlas_core_add(): Join additional metadata columns to
atlas core.
atlas_view_remove(): Remove views matching pattern from sf data.
atlas_view_keep(): Keep only views matching pattern.
atlas_view_remove_region(): Remove specific region geometry from sf
data only. Core, palette, and 3D data are unchanged.
atlas_view_remove_small(): Remove region geometries below a minimum
area threshold. Context geometries (labels not in core) are never
removed. Optionally scope to specific views.
atlas_view_gather(): Reposition remaining views to close gaps
after view removal.
atlas_view_reorder(): Reorder views and reposition. Views not
in order are appended at end.
Region manipulation modifies which regions are active in the atlas:
atlas_region_remove(): completely remove regions
atlas_region_contextual(): keep geometry but remove from core/palette
atlas_region_rename(): rename regions in core
atlas_region_keep(): keep only matching regions
View manipulation modifies the 2D sf geometry data:
atlas_view_remove(): remove entire views
atlas_view_keep(): keep only matching views
atlas_view_remove_region(): remove specific region geometry from sf
atlas_view_remove_small(): remove small polygon fragments
atlas_view_gather(): reposition views to close gaps
atlas_view_reorder(): change view order
Core manipulation modifies atlas metadata:
atlas_core_add(): join additional metadata columns
dk() |>
atlas_region_remove("bankssts") |>
atlas_region_keep("frontal", match_on = "region")
Run the code above in your browser using DataLab