View source: R/generateStimuli2IFC.R
| generateStimuli2IFC | R Documentation |
Generate stimuli for a two-image forced-choice reverse correlation task.
generateStimuli2IFC(
base_face_files,
n_trials = 770,
img_size = 512,
stimulus_path,
label = "rcic",
use_same_parameters = TRUE,
seed = 1,
maximize_baseimage_contrast = TRUE,
noise_type = "sinusoid",
nscales = 5,
sigma = 25,
ncores = default_ncores(),
return_as_dataframe = FALSE,
save_as_png = TRUE,
save_rdata = TRUE
)
base_face_files |
Named list of base image files, e.g. |
n_trials |
Number of trials. Each trial gets two images per base image: one with the noise added (original) and one with it subtracted (inverted). |
img_size |
Width and height of the square stimulus images, in pixels. It must be divisible by |
stimulus_path |
Directory to save the stimuli and the |
label |
Label put at the start of each file name. |
use_same_parameters |
Boolean: all base images share one set of noise parameters ( |
seed |
Seed for the random number generator, for reproducibility. It is saved in the |
maximize_baseimage_contrast |
Boolean: rescale the base image's pixel values to maximize its contrast. A base image with no contrast at all, every pixel the same value, cannot be rescaled and is rejected with an error. It can still be used with |
noise_type |
Noise pattern type: |
nscales |
Number of spatial scales (default: 5). Each additional scale adds a higher spatial frequency. |
sigma |
Sigma of the Gabor patches when |
ncores |
Number of CPU cores to use (default: |
return_as_dataframe |
Boolean: return a data frame with the raw noise of the generated stimuli (default: |
save_as_png |
Boolean: write the stimuli to disk as PNG images (default: |
save_rdata |
Boolean: save the |
Saves the stimuli as PNGs, together with an .Rdata file holding the parameters used to
generate each stimulus. Analysing the responses later requires that file.
Nothing: everything is saved to files. With return_as_dataframe = TRUE, the data frame described there.
# a synthetic square grayscale image stands in for a real base face photo
base_face <- tempfile(fileext = ".png")
png::writePNG(matrix(runif(32 * 32), 32, 32), base_face)
generateStimuli2IFC(
base_face_files = list(face = base_face),
n_trials = 4,
img_size = 32,
stimulus_path = tempfile("stimuli"),
seed = 1,
ncores = 1,
nscales = 1
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.