phasereset: Phase Reset

phaseresetR Documentation

Phase Reset

Description

Generates EEG, assuming a Phase Reset Thoery Approach

Usage

phasereset (frames, epochs, srate, minfr, maxfr , position, tjitter)

Arguments

frames

number of signal frames per each trial

epochs

number of simulated trials

srate

sampling rate of simulated signal in Hz

minfr

minimum frequency of the sinusoid which is being reset

maxfr

maximum frequency of the sinusoid which is being reset

postion

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

tjitter

stdev of time jitter of the reset [in frames]; default: 0 => no jitter

Details

Function generates signal composed of a single sinusoid whose phase is being reset. The frequency of the sinusoid is chosen randomly from a specified range [minfr, maxfr]. The initial phase of the sinusoid is chosen randomly.

Value

signal

simulated EEG signal; vector: 1 by frames*epochs containing concatenated trials

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

#myphasereset<-phasereset (200, 10, 250, 3, 9 , 115, 0)
#plot(myphasereset[1:200],type="l")

## The function is currently defined as
phasereset <-
  function (frames,
            epochs,
            srate,
            minfr,
            maxfr,
            position = frames / 2,
            tjitter = 0) {
    signal <- replicate(epochs * frames, 0)#generating empty wave
    for (trial in 1:epochs) {
      wavefr = runif(1, 0, 1) * (maxfr - minfr) + minfr
      initphase = runif(1, 0, 1) * 2 * pi
      pos = position + round(runif(1, 0, 1) * tjitter)
      for (i in 1:frames) {
        if (i < pos) {
          phase = i / srate * 2 * pi * wavefr + initphase
        }
        else{
          phase = (i - pos) / srate * 2 * pi * wavefr
        }
        signal[(trial - 1) * frames + i] = sin(phase)
      }
    }
    return(signal)
  }







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