Learn R Programming

erp.easy (version 1.0.0)

load.data: Import your individual ERP data files.

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

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).

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

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).

Examples

Run this code
## 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)

Run the code above in your browser using DataLab