View source: R/batchGenerateCI2IFC.R
| batchGenerateCI2IFC | R Documentation |
Generate one classification image per participant or condition, for a two-image forced-choice reverse correlation task.
batchGenerateCI2IFC(
data,
by,
stimuli,
responses,
baseimage,
rdata,
save_as_png = TRUE,
targetpath,
antiCI = FALSE,
scaling = "autoscale",
constant = 0.1,
label = ""
)
data |
Data frame with one row per trial. |
by |
Name of the column that splits the data into units, such as participants or conditions. One CI is computed per unit. |
stimuli |
Name of the column holding the stimulus numbers of the presented stimuli. |
responses |
Name of the column holding the responses: 1 where the original stimulus was chosen, -1 where the inverted one was. |
baseimage |
String naming the base image: not its file name, but its key in the |
rdata |
Path to the |
save_as_png |
Boolean: also save the CI as a PNG image. |
targetpath |
Directory to save PNGs to. Required when |
antiCI |
Boolean: compute the anti-CI, the classification image with its sign flipped, instead of the CI. |
scaling |
Scaling method: |
constant |
Scaling constant for the noise. Used only when |
label |
Optional string added to the PNG file names to make them easier to identify. |
Splits data by the by column, calls generateCI2IFC for each part, and returns the CIs. By default each CI is also saved as a PNG.
Named list with one classification image per unit. Each is itself a list of pixel matrices: the raw noise (ci), the scaled noise (scaled), the base image (base) and the two combined (combined).
# 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)
stimulus_path <- tempfile("stimuli")
generateStimuli2IFC(
base_face_files = list(face = base_face),
n_trials = 6,
img_size = 32,
stimulus_path = stimulus_path,
seed = 1,
ncores = 1,
nscales = 1,
save_as_png = FALSE
)
rdata_file <- list.files(stimulus_path, pattern = "\\.Rdata$", full.names = TRUE)[1]
# two "participants", three trials each
data <- data.frame(
participant = rep(c("p1", "p2"), each = 3),
stimulus = 1:6,
response = sample(c(1, -1), 6, replace = TRUE)
)
cis <- suppressWarnings(batchGenerateCI2IFC(
data = data, by = "participant", stimuli = "stimulus", responses = "response",
baseimage = "face", rdata = rdata_file, save_as_png = FALSE
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.