peak | R Documentation |
Generates Classicaly simulated Peak (ERP) from an EEG signal
peak(frames,epochs,srate,peakfr,position = frames / 2,tjitter = 0,wave = NULL)
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. |
Signal |
Vector of length frames*epochs containing peak part of a simulated EEG signal |
Adapted from Yeung N,Bogacz R, Holroyd C, Nieuwenhuis S, Cohen J
https://data.mrc.ox.ac.uk/data-set/simulated-eeg-data-generator
#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) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.