README.md

webmorphR

Codecov test
coverage

The goal of webmorphR is to make the construction of image stimuli more reproducible, with a focus on face stimuli and integrating with webmorph.org.

See articles for details on image manipulations, webmorph.org integration, make figures, and making stimuli.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("facelab/webmorphR")
library(webmorphR)
#> 
#> ************
#> Welcome to webmorphR. For support and examples visit:
#> https://facelab.github.io/webmorphR/
#> If this package is useful, please cite it:
#> http://doi.org/10.5281/zenodo.???????
#> ************
#> 
#> Attaching package: 'webmorphR'
#> The following object is masked from 'package:base':
#> 
#>     transform

Reproducible stimulus construction

Load faces from the CC-BY licensed Face Research Lab London Set.

face_set <- demo_stim("london")[2:7]%>%
  setnames(prefix = "orig_", pattern = "_03", replacement = "") %>%
  resize(1/3)

rainbow <- c("#983E82", "#E2A458", "#F5DC70", "#59935B", "#467AAC", "#61589C")

stimuli <- face_set %>%
  mirror("frl") %>%
  setnames(pattern = "orig", replacement = "mirror") %>%
  c(face_set, .) %>%
  mask(c("face", "neck", "ears"), fill = rainbow) %>%
  crop(0.6, 0.8)

Save your stimuli

write_stim(stimuli, dir = "mystimuli")

Easily create figures to illustrate your research.

stimuli %>%
  pad(40, 0, 0, 0) %>%
  label() %>%
  plot(nrow = 2)

Automatic Delineation

Read in images with webmorph templates, or automatically delineate images with Face++. Auto-delineation requires a free API key from Face++; averaging and transforming require a webmorph account.

imgdir <- system.file("extdata/zoom", package = "webmorphR")
stimuli <- read_stim(imgdir, "jpg") %>% 
  auto_delin()

Now you can procrustes align the images and crop them all to the same dimensions.

aligned <- align(stimuli, procrustes = TRUE, patch = TRUE) %>%
  crop_pad(250, 50, 50, 50)

plot(aligned)

You can even add image labels and turn your images into an animated gif.

gif <- aligned %>%
  resize(height = 300) %>%
  crop(height = 1.2, y_off = -.2, fill = "black") %>%
  label(c("15cm", "30cm", "45cm", "60cm"), color = "white") %>%
  animate(filename = "man/figures/zoom.gif")



facelab/webmorph documentation built on April 11, 2021, 6:34 a.m.