Skip to contents

Reports how many polygon vertices each region is drawn from. The total is the figure the create_*() pipelines warn about when an atlas is large, and the one atlas_simplify() brings down, so it is the number to watch when tuning an atlas for size.

Usage

count_vertices(atlas)

Arguments

atlas

A ggseg_atlas.

Value

A named integer vector, one element per geometry label value, in the order those values appear in the atlas. When geometry is missing a label, it is counted in a separate "<NA>" entry. Take sum() of the vector for the atlas total; that total is every vertex the atlas carries, so it always agrees with the large-atlas warning.

Details

Counts are summed across views, so a region that appears on the lateral and medial views is reported once.

See also

atlas_simplify() to bring the count down, and atlas_smooth(), which raises it again – rounding a corner off means inserting points.

Other atlas geometry: atlas_dilate(), atlas_polish(), atlas_simplify(), atlas_smooth()

Examples

dk <- ggseg.formats::dk()

# The total is what the large-atlas warning reports.
sum(count_vertices(dk))
#> [1] 5391

# Which regions are the expensive ones?
head(sort(count_vertices(dk), decreasing = TRUE))
#> lh_superiortemporal rh_superiortemporal      rh_postcentral       rh_precentral 
#>                 178                 158                 154                 154 
#>       lh_precentral      lh_postcentral 
#>                 150                 148