Function for repositioning pre-joined atlas data (i.e. data and atlas already joined to a single data frame). This makes it possible for users to reposition the geometry data for the atlas for control over final plot layout. For even more detailed control over the positioning, the "hemi" and "side" columns should be converted into factors and ordered by wanted order of appearance.

reposition_brain(data, position = "horizontal")

Arguments

data

sf-data.frame of joined brain atlas and data

position

position formula for slices

Value

sf-data.frame with repositioned slices

Examples

reposition_brain(dk, hemi ~ side)
#> Simple feature collection with 90 features and 7 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -6.721809 ymin: -6.721809 xmax: 678.9027 ymax: 458.6913
#> CRS:           NA
#> # A tibble: 90 × 8
#>    atlas type     hemi  side    region     label roi                    geometry
#>  * <chr> <chr>    <chr> <chr>   <chr>      <chr> <chr>            <MULTIPOLYGON>
#>  1 dk    cortical left  lateral NA         NA    0001  (((84.32563 34.46407, 84…
#>  2 dk    cortical left  lateral bankssts   lh_b… 0002  (((214.8215 108.8139, 21…
#>  3 dk    cortical left  lateral caudal mi… lh_c… 0004  (((106.16 184.3144, 93.6…
#>  4 dk    cortical left  lateral fusiform   lh_f… 0008  (((256.5481 48.35713, 24…
#>  5 dk    cortical left  lateral inferior … lh_i… 0009  (((218.4373 161.6233, 21…
#>  6 dk    cortical left  lateral inferior … lh_i… 0010  (((250.7745 70.75764, 24…
#>  7 dk    cortical left  lateral lateral o… lh_l… 0012  (((277.4615 115.0523, 27…
#>  8 dk    cortical left  lateral lateral o… lh_l… 0013  (((66.26648 69.56474, 56…
#>  9 dk    cortical left  lateral middle te… lh_m… 0016  (((238.0128 91.25816, 23…
#> 10 dk    cortical left  lateral pars oper… lh_p… 0019  (((79.03391 126.496, 74.…
#> # ℹ 80 more rows
reposition_brain(dk, side ~ hemi)
#> Simple feature collection with 90 features and 7 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -6.713058 ymin: -6.713058 xmax: 678.0189 ymax: 454.7964
#> CRS:           NA
#> # A tibble: 90 × 8
#>    atlas type     hemi  side    region     label roi                    geometry
#>  * <chr> <chr>    <chr> <chr>   <chr>      <chr> <chr>            <MULTIPOLYGON>
#>  1 dk    cortical left  lateral NA         NA    0001  (((84.32563 34.46407, 84…
#>  2 dk    cortical left  lateral bankssts   lh_b… 0002  (((214.8215 108.8139, 21…
#>  3 dk    cortical left  lateral caudal mi… lh_c… 0004  (((106.16 184.3144, 93.6…
#>  4 dk    cortical left  lateral fusiform   lh_f… 0008  (((256.5481 48.35713, 24…
#>  5 dk    cortical left  lateral inferior … lh_i… 0009  (((218.4373 161.6233, 21…
#>  6 dk    cortical left  lateral inferior … lh_i… 0010  (((250.7745 70.75764, 24…
#>  7 dk    cortical left  lateral lateral o… lh_l… 0012  (((277.4615 115.0523, 27…
#>  8 dk    cortical left  lateral lateral o… lh_l… 0013  (((66.26648 69.56474, 56…
#>  9 dk    cortical left  lateral middle te… lh_m… 0016  (((238.0128 91.25816, 23…
#> 10 dk    cortical left  lateral pars oper… lh_p… 0019  (((79.03391 126.496, 74.…
#> # ℹ 80 more rows
reposition_brain(dk, hemi + side ~ .)
#> Simple feature collection with 90 features and 7 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -9.41141 ymin: -9.41141 xmax: 314.9482 ymax: 950.5524
#> CRS:           NA
#> # A tibble: 90 × 8
#>    atlas type     hemi  side    region     label roi                    geometry
#>  * <chr> <chr>    <chr> <chr>   <chr>      <chr> <chr>            <MULTIPOLYGON>
#>  1 dk    cortical left  lateral NA         NA    0001  (((84.32563 34.46407, 84…
#>  2 dk    cortical left  lateral bankssts   lh_b… 0002  (((214.8215 108.8139, 21…
#>  3 dk    cortical left  lateral caudal mi… lh_c… 0004  (((106.16 184.3144, 93.6…
#>  4 dk    cortical left  lateral fusiform   lh_f… 0008  (((256.5481 48.35713, 24…
#>  5 dk    cortical left  lateral inferior … lh_i… 0009  (((218.4373 161.6233, 21…
#>  6 dk    cortical left  lateral inferior … lh_i… 0010  (((250.7745 70.75764, 24…
#>  7 dk    cortical left  lateral lateral o… lh_l… 0012  (((277.4615 115.0523, 27…
#>  8 dk    cortical left  lateral lateral o… lh_l… 0013  (((66.26648 69.56474, 56…
#>  9 dk    cortical left  lateral middle te… lh_m… 0016  (((238.0128 91.25816, 23…
#> 10 dk    cortical left  lateral pars oper… lh_p… 0019  (((79.03391 126.496, 74.…
#> # ℹ 80 more rows
reposition_brain(dk, . ~ hemi + side)
#> Simple feature collection with 90 features and 7 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -14.04594 ymin: -14.04594 xmax: 1418.64 ymax: 219.4866
#> CRS:           NA
#> # A tibble: 90 × 8
#>    atlas type     hemi  side    region     label roi                    geometry
#>  * <chr> <chr>    <chr> <chr>   <chr>      <chr> <chr>            <MULTIPOLYGON>
#>  1 dk    cortical left  lateral NA         NA    0001  (((84.32563 34.46407, 84…
#>  2 dk    cortical left  lateral bankssts   lh_b… 0002  (((214.8215 108.8139, 21…
#>  3 dk    cortical left  lateral caudal mi… lh_c… 0004  (((106.16 184.3144, 93.6…
#>  4 dk    cortical left  lateral fusiform   lh_f… 0008  (((256.5481 48.35713, 24…
#>  5 dk    cortical left  lateral inferior … lh_i… 0009  (((218.4373 161.6233, 21…
#>  6 dk    cortical left  lateral inferior … lh_i… 0010  (((250.7745 70.75764, 24…
#>  7 dk    cortical left  lateral lateral o… lh_l… 0012  (((277.4615 115.0523, 27…
#>  8 dk    cortical left  lateral lateral o… lh_l… 0013  (((66.26648 69.56474, 56…
#>  9 dk    cortical left  lateral middle te… lh_m… 0016  (((238.0128 91.25816, 23…
#> 10 dk    cortical left  lateral pars oper… lh_p… 0019  (((79.03391 126.496, 74.…
#> # ℹ 80 more rows