Joins data frame with a brain-atlas object.

brain_join(data, atlas, by = NULL)

Arguments

data

data.frame

atlas

atlas data

by

optional character vector of column to join by

Value

either an sf-object (if brain atlas) or a tibble (if ggseg-atlas) with merged atlas and data

Examples

someData = data.frame(
    region = c("transverse temporal", "insula",
                "precentral","superior parietal"),
    p = sample(seq(0,.5,.001), 4),
    stringsAsFactors = FALSE)

brain_join(someData, dk)
#> merging atlas and data by 'region'
#> Simple feature collection with 90 features and 8 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 0 ymin: 0 xmax: 1390.585 ymax: 205.4407
#> CRS:           NA
#> First 10 features:
#>    atlas     type hemi    side                region                   label
#> 1     dk cortical left lateral                  <NA>                    <NA>
#> 2     dk cortical left lateral              bankssts             lh_bankssts
#> 3     dk cortical left lateral caudal middle frontal  lh_caudalmiddlefrontal
#> 4     dk cortical left lateral              fusiform             lh_fusiform
#> 5     dk cortical left lateral     inferior parietal     lh_inferiorparietal
#> 6     dk cortical left lateral     inferior temporal     lh_inferiortemporal
#> 7     dk cortical left lateral     lateral occipital     lh_lateraloccipital
#> 8     dk cortical left lateral lateral orbitofrontal lh_lateralorbitofrontal
#> 9     dk cortical left lateral       middle temporal       lh_middletemporal
#> 10    dk cortical left lateral      pars opercularis      lh_parsopercularis
#>     roi  p                       geometry
#> 1  0001 NA MULTIPOLYGON (((84.32563 34...
#> 2  0002 NA MULTIPOLYGON (((214.8215 10...
#> 3  0004 NA MULTIPOLYGON (((106.16 184....
#> 4  0008 NA MULTIPOLYGON (((256.5481 48...
#> 5  0009 NA MULTIPOLYGON (((218.4373 16...
#> 6  0010 NA MULTIPOLYGON (((250.7745 70...
#> 7  0012 NA MULTIPOLYGON (((277.4615 11...
#> 8  0013 NA MULTIPOLYGON (((66.26648 69...
#> 9  0016 NA MULTIPOLYGON (((238.0128 91...
#> 10 0019 NA MULTIPOLYGON (((79.03391 12...
brain_join(someData, dk, "region")
#> Simple feature collection with 90 features and 8 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 0 ymin: 0 xmax: 1390.585 ymax: 205.4407
#> CRS:           NA
#> First 10 features:
#>    atlas     type hemi    side                region                   label
#> 1     dk cortical left lateral                  <NA>                    <NA>
#> 2     dk cortical left lateral              bankssts             lh_bankssts
#> 3     dk cortical left lateral caudal middle frontal  lh_caudalmiddlefrontal
#> 4     dk cortical left lateral              fusiform             lh_fusiform
#> 5     dk cortical left lateral     inferior parietal     lh_inferiorparietal
#> 6     dk cortical left lateral     inferior temporal     lh_inferiortemporal
#> 7     dk cortical left lateral     lateral occipital     lh_lateraloccipital
#> 8     dk cortical left lateral lateral orbitofrontal lh_lateralorbitofrontal
#> 9     dk cortical left lateral       middle temporal       lh_middletemporal
#> 10    dk cortical left lateral      pars opercularis      lh_parsopercularis
#>     roi  p                       geometry
#> 1  0001 NA MULTIPOLYGON (((84.32563 34...
#> 2  0002 NA MULTIPOLYGON (((214.8215 10...
#> 3  0004 NA MULTIPOLYGON (((106.16 184....
#> 4  0008 NA MULTIPOLYGON (((256.5481 48...
#> 5  0009 NA MULTIPOLYGON (((218.4373 16...
#> 6  0010 NA MULTIPOLYGON (((250.7745 70...
#> 7  0012 NA MULTIPOLYGON (((277.4615 11...
#> 8  0013 NA MULTIPOLYGON (((66.26648 69...
#> 9  0016 NA MULTIPOLYGON (((238.0128 91...
#> 10 0019 NA MULTIPOLYGON (((79.03391 12...