Example 2: Visual speller

Part 4

In previous parts of the experiment, stimulus presentation timing was not accurate. Epochs occurred later than specified and the time between stimuli was not constant throughout a sequence. In this part of the example, we will improve these timing issues by using a loop function for stimulus presentation.

The loop function runSequence replaces most actions of the stimulus presentation plug-in. The new flowchart of the plug-in looks like this:


Figure 1: Stimulus presentation plug-in flowchart

This is the runSequence function:

function ev = runSequence(ev)
isi = 0.2; % inter-stimulus-interval
flashed = 0;
count = 0;
while 1
    if ~flashed
        % randomly highlight row or column and send stim_## marker
        ev = highlightGrid(ev);
        ev = bs_send_hardware_marker(ev,sprintf('stim_%d',ev.stimCode),'eeg'); % mark the data with what happened
        % dim higlighted row or column
        ev = showGrid(ev);
        ev = bs_send_hardware_marker(ev,'highlightOff','eeg'); % also mark this moment
    count = count + 1;
    if count >= 2*bs_get_blockvalue(ev,'Experiment','nRep',10)
        ev = bs_send_buffer_marker(ev,'endSequence','eeg',.3); % N.B. enough extra for ERP to finish...
    flashed = ~flashed;
    pause(max(0, count*(isi/2)-toc));

This loop function should make sure that the time between to stimuli is always 200 ms, during which period a row or column is flashed for 100 ms and the non-highlighted grid is shown for the next 100 ms. Matlab's tic, toc and pause functions are used for stimulus timing.

Topic attachments
I Attachment Action Size Date Who Comment
pngpng StimPres4.png manage 51.6 K 04 Jan 2012 - 13:22 MarjoleinVanDerWaal  
Edit | Attach | Print version | History: r6 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 04 Jan 2012 - 14:12:15 - MarjoleinVanDerWaal
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback