Skip to content

Commit

Permalink
adapted atlases to ggseg <= 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
drmowinckels committed Nov 18, 2020
1 parent a6d34c1 commit fdf59cd
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 25 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# ggsegChen 1.0.01

* adapted atlases to ggseg <= 1.6.0
* Added a `NEWS.md` file to track changes to the package.
10 changes: 4 additions & 6 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ knitr::opts_chunk$set(
comment = "#>",
fig.path = "man/figures/README-",
fig.width = 6,
out.width = "100%"
out.width = "100%",
fig.retina = 3
)
devtools::load_all(".")
```
Expand Down Expand Up @@ -49,21 +50,18 @@ library(ggsegChen)
```{r}
library(ggseg)
ggseg(atlas = chenAr, mapping = aes(fill = region)) +
scale_fill_brain("chenAr", package = "ggsegChen") +
plot(chenAr) +
labs(title = "Chen areal (chenAr)") +
theme(legend.position = "bottom",
legend.text = element_text(size = 9)) +
guides(fill = guide_legend(ncol = 3))
```
```{r fig.height = 6}
ggseg(atlas = chenTh, mapping = aes(fill = region)) +
scale_fill_brain("chenTh", package = "ggsegChen") +
plot(chenTh) +
labs(title = "Chen thickness (chenTh)") +
theme(legend.position = "bottom",
legend.text = element_text(size = 9)) +
guides(fill = guide_legend(ncol = 2))
```

<!-- ```{r "noneval", eval=FALSE} -->
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ library(ggsegChen)
``` r
library(ggseg)

ggseg(atlas = chenAr, mapping = aes(fill = region)) +
scale_fill_brain("chenAr", package = "ggsegChen") +
plot(chenAr) +
labs(title = "Chen areal (chenAr)") +
theme(legend.position = "bottom",
legend.text = element_text(size = 9)) +
Expand All @@ -57,8 +56,7 @@ ggseg(atlas = chenAr, mapping = aes(fill = region)) +
<img src="man/figures/README-unnamed-chunk-3-1.png" width="100%" />

``` r
ggseg(atlas = chenTh, mapping = aes(fill = region)) +
scale_fill_brain("chenTh", package = "ggsegChen") +
plot(chenTh) +
labs(title = "Chen thickness (chenTh)") +
theme(legend.position = "bottom",
legend.text = element_text(size = 9)) +
Expand Down
4 changes: 4 additions & 0 deletions data-raw/chen.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ chenTh <- chenTh %>%
long - diff, long))

chenTh <- as_ggseg_atlas(chenTh)
chenTh <- as_brain_atlas(chenTh)
chenTh$palette <- brain_pals$chenTh
usethis::use_data(chenTh, internal = FALSE, overwrite = TRUE, compress = "xz")


Expand Down Expand Up @@ -71,6 +73,8 @@ chenAr <- chenAr %>%
long - diff, long))

chenAr <- as_ggseg_atlas(chenAr)
chenAr <- as_brain_atlas(chenAr)
chenAr$palette <- brain_pals$chenAr
usethis::use_data(chenAr, internal = FALSE, overwrite = TRUE, compress = "xz")


Expand Down
Binary file modified data/chenAr.rda
Binary file not shown.
Binary file modified data/chenTh.rda
Binary file not shown.
Binary file modified man/figures/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 3 additions & 8 deletions tests/testthat/test-chenAr.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
# ggseg ----
context("test-chenAr-adapt_scales")
test_that("Check that ggseg:::adapt_scales is working", {
expect_equal(mode(ggseg:::adapt_scales(unnest(chenAr, ggseg))), "list")
})

context("test-chenAr-palettes")
test_that("check new palettes work", {
expect_equal(length(brain_pal("chenAr", package = "ggsegChen")), 12)

expect_error(brain_pal("chenAr"), "not a valid")

expect_true(all(names(brain_pal("chenAr", package = "ggsegChen")) %in% chenAr$region))
expect_true(all(names(brain_pal("chenAr", package = "ggsegChen")) %in% brain_regions(chenAr)))
})

context("test-chenAr-ggseg-atlas")
test_that("atlases are true ggseg atlases", {

expect_true(is_ggseg_atlas(chenAr))

expect_true(is_brain_atlas(chenAr))
expect_true(is_ggseg_atlas(as_ggseg_atlas(chenAr)))
})

context("test-chenAr-ggseg")
Expand Down
10 changes: 3 additions & 7 deletions tests/testthat/test-chenTh.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# ggseg ----
context("test-chenTh-adapt_scales")
test_that("Check that ggseg:::adapt_scales is working", {
expect_equal(mode(ggseg:::adapt_scales(unnest(chenTh, ggseg))), "list")
})

context("test-chenTh-palettes")
test_that("check new palettes work", {
expect_equal(length(brain_pal("chenTh", package = "ggsegChen")), 12)

expect_error(brain_pal("chenTh"), "not a valid")

expect_true(all(names(brain_pal("chenTh", package = "ggsegChen")) %in% chenTh$region))
expect_true(all(names(brain_pal("chenTh", package = "ggsegChen")) %in% brain_regions(chenTh)))
})

context("test-chenTh-ggseg-atlas")
test_that("atlases are true ggseg atlases", {

expect_true(is_ggseg_atlas(chenTh))
expect_true(is_brain_atlas(chenTh))
expect_true(is_ggseg_atlas(as_ggseg_atlas(chenTh)))

})

Expand Down

0 comments on commit fdf59cd

Please sign in to comment.