Import your individual ERP data files.

Share:

Description

load.data imports your individual ERP data files. File extensions must be .txt and file names must be in the format: YourFile_Condition.txt (e.g., SS34_Positive.txt). Raw data files to be imported should be organized as follows:

  • each electrode must be a separate column

  • voltages at each time point should be listed under the appropriate electrode column as rows

  • no other data should be present in the raw data file (e.g., subject, condition, time, etc.)

Usage

1
load.data(path, condition, num.subs, epoch.st, epoch.end, header = FALSE)

Arguments

path

The folder path containing your ERP files

condition

In quotes, a string indicating which trial type you will be importing (i.e., the condition indicated in the file name)

num.subs

The number of files (subjects) to import for a given condition

epoch.st

The earliest time point sampled in the ERP files, including the basline (e.g., -200)

epoch.end

The final time point sampled in the ERP files

header

Only accepts values of TRUE or FALSE. Used to specify whether or not there is an existing header row in the ERP files. If there is no header, load.data will supply one (see details below).

Details

  • Name each individual file following the format mentioned above (e.g., SS34_Positive.txt). load.data will ignore all text preceding the "_", and treat all text following the "_" as the condition, (e.g., Positive). Use only one "_" in the file name (i.e., to separate your own naming convention from the condition); using multiple "_" characters will lead to faulty importing of data. The erp.easy convention for subjects is a capital "S" followed by the number corresponding to the order in which the file was loaded (e.g., S1, S2, etc.). Subjects will be loaded into the "Subject" column of the returned data frame.

  • If no header is present in the ERP files, one will be supplied, using the standard R convention of a capital "V" followed by increasing integers (e.g., V1, V2, V3). Use these automatically assigned column name values to refer to the electrodes (unless a header is provided in the raw data file).

  • Enter the starting time of the baseline, if present in your individual files, in epoch.st (e.g., -200).

  • Once the desired data frames have been loaded, they can be exported as a number of different file types.

  • The sample rate will be calculated for you, based on the starting (epoch.st) and ending (epoch.end) time points of the recording epoch and the number of time points in a given condition (the number of rows in your file for each condition).

Value

A single, concatenated data frame of all electrode data for all subjects organized into columns, with three added columns:

  1. "Subject" containing repeating subject names

  2. "Stimulus" containing repeating condition names (e.g., Neutral)

  3. "Time" containing a repeating list of timepoints sampled

Note

While importing data must be done using a separate function call for each condition, it can be convenient to use R's native rbind.data.frame() command to bind several loaded conditions (variables) into a single data frame consisting of multiple conditions. All erp.easy functions will act on all conditions included in the data frame passed to the function. For example, if you'd like to see all conditions plotted, simply use rbind.data.frame() to make a single data frame to pass to an erp.easy plotting function, and you will see all added conditions plotted simultaneously in the same figure (as opposed to making separate data frames for each condition, then passing each data frame separately to a function).

Author(s)

Travis Moore

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
# Importing data for a condition named "Neutral" (file names: "Sub1_Neutral.txt",
"Sub2_Neutral.txt", etc.)
neutral <- load.data(path = "/Users/Username/Folder/", condition = "Neutral",
num.subs = 20, epoch.st = -200, epoch.end = 899, header = FALSE)

# Adding imported data named "positive" to the imported "neutral" data
combo <- rbind.data.frame(neutral, positive)

## End(Not run)