Skip to contents

Checks if an object is a stimulus or list of stimuli and repairs common problems.

Usage

as_stimlist(x)

Arguments

x

The object

Value

A stimlist

Details

Some webmorphR functions, like plot() and print() require objects to have a "stimlist" class. If you've processed a list of stimuli with iterator functions like lapply() or purrr::map() and the resulting object prints or plots oddly, it is probably unclassed, and this function will fix that.

See also

Stimulus creating functions animate(), blank(), new_stimlist(), new_stim(), read_img(), read_stim(), read_tem(), write_stim()

Examples

stimuli <- demo_stim() |>
  lapply(function(stim) {
    # remove template lines
    stim$lines <- NULL
    return(stim)
  })
  
class(stimuli)
#> [1] "list"

if (FALSE) {
plot(stimuli) # error
}

s <- as_stimlist(stimuli)
class(s)
#> [1] "stimlist" "list"    
plot(s)