peak: Peak

View source: R/man.R

peakR Documentation

Peak

Description

Generates Classicaly simulated Peak (ERP) from an EEG signal

Usage

peak(frames,epochs,srate,peakfr,position = frames / 2,tjitter = 0,wave = NULL)

Arguments

frames

number of signal frames per each trial

epochs

number of simulated trials

srate

sampling rate of simulated signal in Hz

peakfr

frequency of sinusoid whos half of the cycle is taken to form the peak

position

position of the peak [in frames]; default: frames/2 => in the middle

tjitter

stdev of time jitter of the peak; default: 0 => no jitter

wave

if defined the signal is composed not from a peak, but complete sinusoid.

Value

Signal

Vector of length frames*epochs containing peak part of a simulated EEG signal

Author(s)

Adapted from Yeung N,Bogacz R, Holroyd C, Nieuwenhuis S, Cohen J

References

https://data.mrc.ox.ac.uk/data-set/simulated-eeg-data-generator

Examples

#mypeak<-peak(200,10,250,7,115)
#plot(mypeak[1:200])


## The function is currently defined as

peak <-
  function(frames,
           epochs,
           srate,
           peakfr,
           position = frames / 2,
           tjitter = 0,
           wave = NULL) {
    mypeak <- c(1, 5, 4, 9, 0)
    mypeak
    signal <- replicate(epochs * frames, 0)
    for (trial in 1:epochs) {
      pos = position + round(runif(1, 0, 1) * tjitter)

      for (i in 1:frames) {
        phase = (i - pos) / srate * 2 * pi * peakfr
        if ((is.null(wave) == FALSE) ||
            (phase < pi / 2 &&
             phase > -pi / 2)) {
          #if wave | (phase < pi/2 & phase > -pi/2)
          signal[(trial - 1) * frames + i] = cos(phase)
        }
      }
    }
    return(signal)
  }












connolr3/eegdatasim documentation built on April 14, 2022, 10:39 a.m.