userfriendlyscience (version 0.7.2)

processOpenSesameIAT: processOpenSesameIAT

Description

This function reads IAT files as generated by the OpenSesame script available at [INSERT URL].

Usage

processOpenSesameIAT(dataPath,
                     blocks.sizes = c(18, 36, 48, 36, 48),
                     blocks.congruent = c(2, 3),
                     blocks.incongruent = c(4, 5),
                     blocks.realTrials = c(3, 5),
                     blocks.practiceTrials = c(2, 4),
                     congruentLarger = TRUE,
                     responseTime.min = 400,
                     responseTime.max = 2500,
                     responseTime.penalty = 600,
                     outputFile = NULL,
                     wideOutputFile = NULL,
                     showLog = TRUE,
                     filenameRegEx = "subject-(\\d+)(\\w+)\\.csv",
                     regExValues = c("subject","session"),
                     participantVarName = "subject",
                     taskVarName = "session",
                     openSesameVarNames = list(correct = "correct",
                                               response_time = "response_time"),
                     stimulusSelectionVarName = NULL,
                     stimulusSelectionValues = NULL,
                     roundOutput = 6,
                     decimalSeparator = ".",
                     inputDecimalSeparator = ".",
                     inputfileSelectionColumns = NULL,
                     inputfileSelectionValues = NULL)

Arguments

dataPath

A directory containing the .csv files that OpenSesame provides.

blocks.sizes

A vector containing the number of trials of each block.

blocks.congruent

A vector containing the numbers of the congruent blocks.

blocks.incongruent

A vector containing the numbers of the incongruent blocks.

blocks.realTrials

A vector containing the numbers of the real trials.

blocks.practiceTrials

A vector containing the numbers of the practice trials.

congruentLarger

Whether the response latencies for the congruent trials (TRUE) or the incongruent trials (FALSE) are expected to be larger. This simply multiplies the final D600 measures with -1.

responseTime.min

Minimum number of milliseconds of response time (all shorter times will be removed).

responseTime.max

Maximum number of milliseconds of response time (all longer times will be replaced with this number).

responseTime.penalty

Penalty in milliseconds to add to the response times for incorrect responses.

outputFile

If specified, the aggregated datafile is stored in this file.

wideOutputFile

If specified, the wide version of the datafile will be stored in this file.

showLog

Boolean; if TRUE, shows the log (is stored in the resulting object anyway).

filenameRegEx

Regular expression describing the filenames. This has two purposes. First, only files matching this regular expression will be processed (note that you can set it to NULL to process all files). Second, by using "\1", "\2", etc, matched patterns can be extracted from the filenames and stored as variables in the final datafile (see sub for more information on regular expression matching). The default pattern, "subject-(\d+)(\w+)\.csv", which is read by R as "subject-(\d+)(\w+)\.csv" (because the backslash is the escape symbol, double backspaces are needed to specify one backspace, see Quotes), assumes that all filenames start with 'subject-', followed by the subject number ("\d+" matches one or more digits), immediately followed by one or more letters and digits ("\w+" matches one or more letters or digits) indicating the session that the datafile pertains to. If you only have subject numbers, you'd use "subject-(\d+)\.csv" or perhaps "subject-(\w+)\.csv" if the subjects could also have letters in their identifiers. Note that you have to include the variable names of each of these extractable patterns in regExValues!

regExValues

Here, the names of the variables extracted using the regular expression specified in filenameRegEx are provided. Must of course have the same length as the number of patterns specified in filenameRegEx, and in the same order.

participantVarName, taskVarName

Variable name of the variable identifying participants and tasks (usually extracted from the filename, so should be a value in regExValues). Tasks are usually different within-subject conditions.

openSesameVarNames

A list with the two elements 'correct' and 'response_time', which should be the variable names that OpenSesame used to write, for each trial, whether the response was correct or not ('correct') and what the response time was ('response_time');

stimulusSelectionVarName, stimulusSelectionValues

These arguments can be used to specify a subset of stimuli to process. Specify which column contains the values to select in stimulusSelectionVarName, and specify the value(s) to select in stimulusSelectionValues.

roundOutput

Number of digits to round the output to. This is useful for importing into a program that doesn't quite get how storing numbers works, such as SPSS or Excel; they sometimes don't manage to import numbers with many decimals.

decimalSeparator

When working with e.g. Excel, it can be easier to just specify the decimal separator rather than switch Excel's (and therefore Windows') locale.

inputDecimalSeparator

The decimal separator to specify to read.csv when reading the data files.

inputfileSelectionColumns, inputfileSelectionValues

This functionality still has to be implemented. Once implemented, these arguments can be used to specify a column, and a (set of) value(s) in that column to use to select which rows to process (also see stimulusSelectionVarName and stimulusSelectionValues).

Value

An object with the raw files, the processed files, and the file converted to wide format. But most users will probably specify outputFile and/or wideOutputFile to just export the output files directly.

Details

Note that this function was developed to read the OpenSesame IAT datafiles created by the OpenSesame script developed by Kenny Wolfs, Jacques van Lankveld, and Frederik van Acker at the Open University of the Netherlands. If you use a different version (for example, the one contributed to the OpenSesame paradigm repository by Hansika Kapoor, see http://osdoc.cogsci.nl/3.0/standard-tasks/#implicit-association-test-iat), you will have to specify the variable names you specified to OpenSesame for the response time and for whether the response was correct in openSesameVarNames. For example, if you use Hansika's IAT task, you'll have to specify openSesameVarNames = list(correct = "correct", response_time = "avg_rt")

Similarly, of course you will probably have to specify the number of trials per block etc. Also, you may want to set showLog to FALSE, as the logging is quite detailed.

References

Mathot, S., Schreij, D., & Theeuwes, J. (2012). OpenSesame: An open-source, graphical experiment builder for the social sciences. Behavior Research Methods, 44(2), 314-324. doi:10.3758/s13428-011-0168-7

Kapoor, H. (2015). The creative side of the Dark Triad. Creativity Research Journal, 27(1), 58-67. doi:10.1080/10400419.2014.961775.

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
### This will process all files in the specified directory, but not
### export anything
processed <- processOpenSesameIAT("C:/directory/with/datafiles");

### This will export both the aggregated datafile and the wide datafile
processed <- processOpenSesameIAT("C:/directory/with/datafiles",
                                  outputFile="C:/directory/aggregated.csv",
                                  wideOutputFile="C:/directory/wide.csv");

# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace