epoch.samples: Epoch sample data

View source: R/utilities.R

epoch.samplesR Documentation

Epoch sample data

Description

epoch.samples is used for time-locking sample data to a particular event and creating separate epochs.

Usage

epoch.samples(timelock, samples, sample.field = "paL", epoch = c(-100, 100),
  messages = NULL, eyetrial = FALSE)

Arguments

timelock

either a string or pattern that matches a messsage sent to Eyelink (e.g., 'STIMONSET', 'TRIAL [0-9]*'), or a vector of times for events of interest.

samples

a data frame of sample data obtained from edf.samples, edf.all, or edf.trials.

sample.field

a character corresponding to the sample field that you are epoching (e.g., 'paL' or 'paR')

epoch

the starting and ending samples of the epoch, relative to the event (decault = c(-100, 100))

messages

a data frame obtained from edf.messages, edf.all, or edf.trials which contains the messages sent to Eyelink. Only necessary if timelock is a character

eyetrial

logical indicating whether to include the eyetrial resulting from edf.trials. This will be included as part of the messages data frame if you use edf.trials. Default = FALSE

Details

This is a basic function for epoching sample data (such as pupil diameter) relative to some time-locking event. The event is indicated either as a message sent to the Eyelink during the experiment, or as a vector of times of events (which must correspond to time in the sample data frame).

Value

a list with fields:

  • timelock a numeric vector of the time-locking events

  • epoch.window a vector indicating the epoch times you specified with epoch

  • sample.field a character indicating the sample field you specified with sample.field

  • message if a message is provided, a character vector indicating the message for each epoch

  • eyetrial if eyetrial=TRUE, then the corresponding eyetrial for each epoch

  • epochs a matrix of the actual epoched data (events x epoch_width)

Author(s)

Jason Hubbard, hubbard3@uoregon.edu

Examples

## Not run: 

#the easiest way is to use edf.trials:
trials <- edf.trials('/path/to/EDFfile.edf',samples=T,eventmask=T)
trials$samples$paR[trials$samples$blink==1] <- NA #quick blink removal, not perfect
epochdata <- epoch.samples('STIMONSET',trials$samples,sample.field='paR',
                           epoch=c(-500,500),messages=trials$messages,eyetrial=T)
 #plot it!
 matplot(t(epochdata$epochs[1:20,]),type='l')

#if you want to timelock to some type of event:
events <- edf.events('/path/to/EDFfile.edf',type='STARTSACC',fields='sttime')
samples <- edf.samples('/path/to/EDFfile.edf')
epochdata <- epoch.samples(events$sttime,samples,sample.field='paR',epoch=c(-500,1))



## End(Not run)

jashubbard/edfR documentation built on Aug. 4, 2022, 5:18 p.m.