Skip to content

Commit

Permalink
Getting ready for CRAN!
Browse files Browse the repository at this point in the history
  • Loading branch information
debruine committed May 22, 2022
1 parent 666b9b6 commit 6865c87
Show file tree
Hide file tree
Showing 29 changed files with 130 additions and 194 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
^paper$
^\.github$
^man/figures/home
^cran-comments\.md$
15 changes: 5 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: webmorphR
Title: Reproducible Stimuli
Date: 2022-05-22
Version: 0.0.2.9004
Version: 0.1.0
Authors@R:
c(person(
given = "Lisa",
family = "DeBruine",
role = c("aut", "cre"),
role = c("aut", "cre", "cph"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-7523-5539")
),
Expand All @@ -17,9 +17,9 @@ Authors@R:
email = "[email protected]"
))
Description: Create reproducible image stimuli,
specialised for face images with webmorph.org templates.
specialised for face images with 'psychomorph' or 'webmorph' templates.
License: CC BY 4.0
URL: https://debruine.github.io/webmorphR, https://github.com/debruine/webmorphR
URL: https://debruine.github.io/webmorphR/, https://github.com/debruine/webmorphR
BugReports: https://github.com/debruine/webmorphR/issues
Depends:
R (>= 4.1.0)
Expand All @@ -45,12 +45,7 @@ Suggests:
testthat,
usethis,
rmarkdown,
covr,
webmorphR.stim,
webmorphR.dlib
Remotes:
debruine/webmorphR.stim,
debruine/webmorphR.dlib
covr
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export(delin)
export(demo_stim)
export(draw_tem)
export(features)
export(fpp_auto_delin)
export(get_info)
export(get_point)
export(gglabel)
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# webmorphR 0.0.2.9004
# webmorphR 0.1.0.0

* R version requirements decreased from 4.2.0 to 4.1.0
* `quick_delin()` function changed to `delin()` and upgraded to be able to update full templates
* `delin()` lets you adjust full templates now, but is still *very* experimental.
* prepared for CRAN

# webmorphR 0.0.2.9003

Expand Down
4 changes: 3 additions & 1 deletion R/align.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#' @export
#'
#' @examples
#' \dontrun{
#' # load stimuli and crop/rotate differently
#' stimuli <- demo_stim() |>
#' crop(c(0.8, 0.9), c(1.0, 0.9), x_off = c(0, 0.2)) |>
Expand All @@ -29,9 +30,10 @@
#'
#' # align to pupils of second image
#' two_pt <- align(stimuli, ref_img = 2)
#'
#'
#' # procrustes align to average position
#' proc <- align(stimuli, procrustes = TRUE)
#' }

align <- function(stimuli, pt1 = 0, pt2 = 1,
x1 = NULL, y1 = NULL, x2 = NULL, y2 = NULL,
Expand Down
52 changes: 2 additions & 50 deletions R/auto_delin.R
Original file line number Diff line number Diff line change
@@ -1,51 +1,3 @@
#' Auto-Delineation
#'
#' Automatically delineate faces using dlib in python or Face++ (an external service). Wrapper function for [fpp_auto_delin()] and [webmorphR.dlib::dlib_auto_delin()].
#'
#' @seealso [fpp_auto_delin], [webmorphR.dlib::dlib_auto_delin()]
#'
#' @param stimuli list of class stimlist
#' @param model Which shape predictor model to use (dlib7, dlib70, fpp106, fpp83)
#' @param replace if FALSE, only gets templates for images with no template
#' @param face which face to delineate in each image if there is more than 1 (only for Face++)
#' @param model_path path to a custom dlib .dat landmark file to use (model is ignored if set)
#'
#' @return stimlist with templates
#' @export
#'
#' @examples
#' \dontrun{
#' # requires an API key in .Renviron
#' auto_fpp106 <- demo_stim() |>
#' auto_delin(model = "fpp106", replace = TRUE)
#'
#' # requires debruine/webmorphR.dlib
#' auto_dlib7 <- demo_stim() |>
#' auto_delin(replace = TRUE)
#'
#' auto_dlib70 <- demo_stim() |>
#' auto_delin(model = "dlib70", replace = TRUE)
#' }
auto_delin <- function(stimuli,
model = c("dlib7", "dlib70", "fpp106", "fpp83"),
replace = FALSE,
face = 1,
model_path = NULL) {
stimuli <- validate_stimlist(stimuli)
model <- match.arg(model)

if (model %in% c("fpp106", "fpp83")) {
fpp_auto_delin(stimuli, model, replace, face)
} else if (model %in% c("dlib7", "dlib70") ||
!is.null(model_path)) {
if (requireNamespace("webmorphR.dlib", quietly = TRUE)) {
webmorphR.dlib::dlib_auto_delin(stimuli, model, replace, model_path)
} else {
stop("You need to install webmorphR.dlib to use the dlib models\n\nremotes::install_github(\"debruine/webmorphR.dlib\")")
}
}
}

#' Face++ Auto-Delineation
#'
#' Automatically delineate faces using Face++ (an external service). Since each delineation counts against a daily limit, you need to set up your own Face++ account (see details below).
Expand All @@ -71,8 +23,8 @@ auto_delin <- function(stimuli,
#' auto_fpp106 <- demo_stim() |>
#' auto_delin(model = "fpp106", replace = TRUE)
#' }
fpp_auto_delin <- function(stimuli,
model = c("dlib7", "dlib70", "fpp106", "fpp83"),
auto_delin <- function(stimuli,
model = c("fpp106", "fpp83"),
replace = FALSE,
face = 1) {
stimuli <- validate_stimlist(stimuli)
Expand Down
11 changes: 9 additions & 2 deletions R/loop.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
#'
#' @examples
#' \dontrun{
#' stimuli <- webmorphR.stim::load_stim_composite("f_") |>
#' resize(300)
#' stimuli <- demo_stim() |>
#' resize(300) |>
#' rep(4) |>
#' rotate(seq(0, 360-45, 45))
#' loop <- loop(stimuli, 5)
#' animate(loop, 10)
#' }
Expand All @@ -23,6 +25,11 @@ loop <- function(stimuli, steps = 10, ...) {
stop("You need at least 2 steps")
}

n_unique_names <- names(stimuli) |> unique() |> length()
if (n_unique_names < length(stimuli)) {
names(stimuli) <- paste0(seq_along(stimuli), "_", names(stimuli))
}

from_img <- stimuli
to_img <- c(stimuli[2:length(stimuli)], stimuli[1])
p <- seq(0, 1, length.out = steps+1)
Expand Down
2 changes: 2 additions & 0 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,12 @@ plot_stim <- function(stimuli, nrow = NULL, ncol = NULL, byrow = TRUE,
#' @export
#'
#' @examples
#' \dontrun{
#' up <- demo_stim()
#' inv <- rotate(up, 180)
#' plot_rows(upright = up, inverted = inv)
#' plot_rows(upright = up, inverted = inv, color = "dodgerblue", top_label = TRUE)
#' }
plot_rows <- function(..., top_label = FALSE) {
dots <- list(...)
is_stimlist <- sapply(dots, inherits, "stimlist")
Expand Down
2 changes: 1 addition & 1 deletion R/webmorphR-package.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' webmorphR: Reproducible Face Stimuli
#'
#' Create reproducible image stimuli, specialised for images with webmorph.org templates. See https://debruine.github.io/webmorphR/ for detailed tutorials.
#' Create reproducible image stimuli, specialised for images with webmorph.org templates.
#'
#' @docType package
#' @name webmorphR
Expand Down
8 changes: 7 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ knitr::opts_chunk$set(

<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Codecov test coverage](https://codecov.io/gh/debruine/webmorphR/branch/master/graph/badge.svg)](https://codecov.io/gh/debruine/webmorphR?branch=master)
[![Codecov test coverage](https://codecov.io/gh/debruine/webmorphR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/debruine/webmorphR?branch=master)
[![R-CMD-check](https://github.com/debruine/webmorphR/workflows/R-CMD-check/badge.svg)](https://github.com/debruine/webmorphR/actions)
<!-- badges: end -->

Expand All @@ -27,6 +27,12 @@ This development of this package was funded by ERC grant #647910 (KINSHIP).

## Installation

You can (hopefully soon) install webmorphR from CRAN with:

``` r
install_packages("webmorphR")
```

You can install the development version from [GitHub](https://github.com/) with:

``` r
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Codecov test
coverage](https://codecov.io/gh/debruine/webmorphR/branch/master/graph/badge.svg)](https://codecov.io/gh/debruine/webmorphR?branch=master)
coverage](https://codecov.io/gh/debruine/webmorphR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/debruine/webmorphR?branch=master)
[![R-CMD-check](https://github.com/debruine/webmorphR/workflows/R-CMD-check/badge.svg)](https://github.com/debruine/webmorphR/actions)
<!-- badges: end -->

Expand All @@ -23,6 +23,12 @@ This development of this package was funded by ERC grant \#647910

## Installation

You can (hopefully soon) install webmorphR from CRAN with:

``` r
install_packages("webmorphR")
```

You can install the development version from
[GitHub](https://github.com/) with:

Expand Down
6 changes: 6 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
* Several examples use dontrun{} because the functions write to disk, create images, or are long processes
2 changes: 2 additions & 0 deletions man/align.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 12 additions & 23 deletions man/auto_delin.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 0 additions & 42 deletions man/fpp_auto_delin.Rd

This file was deleted.

6 changes: 4 additions & 2 deletions man/loop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/plot_rows.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6865c87

Please sign in to comment.