| phasereset | R Documentation |
Generates EEG, assuming a Phase Reset Thoery Approach
phasereset (frames, epochs, srate, minfr, maxfr , position, tjitter)
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 |
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.
signal |
simulated EEG signal; vector: 1 by frames*epochs containing concatenated trials |
Adapted from Yeung N,Bogacz R, Holroyd C, Nieuwenhuis S, Cohen J
https://data.mrc.ox.ac.uk/data-set/simulated-eeg-data-generator
#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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.