Changes

Jump to navigation Jump to search
767 bytes added ,  09:29, 1 June 2023
m
no edit summary
Line 365: Line 365:  
java.lang.Thread.sleep(pulseLen);    % wait long enough for the EEG system to capture the trigger, i.e., 2000/samplerate ms
 
java.lang.Thread.sleep(pulseLen);    % wait long enough for the EEG system to capture the trigger, i.e., 2000/samplerate ms
 
% reset marker
 
% reset marker
bb.sendTrigger(0)                % Note: if resetting the marker is not possible at this moment in code, you can decide to do this later as long as it has taken place long enough before the next marker has to be sent.
+
bb.sendTrigger(0)                % Note: if resetting the marker is not possible at this moment in code, you can decide to do this later as long as it has taken place long enough before the next marker has to be sent. Another solution using a timer object instead of a simple delay is outlined below.
 
</syntaxhighlight>
 
</syntaxhighlight>
   Line 385: Line 385:  
     :
 
     :
 
bb.close();
 
bb.close();
 +
</syntaxhighlight>
 +
 +
Reset marker using a timer:
 +
<syntaxhighlight lang="matlab" line style="overflow:auto;">
 +
% At the start of your script, define timer object and callback function
 +
pulseTime = 0.004; % trigger pulse duration in s. NB: extra time will be added due to overhead in calling Matlab functions related to the timer event.
 +
resetMarker = timer('TimerFcn',@(x,y)bb.sendTrigger(0),'StartDelay',pulseTime);
 +
 +
% replace the code to send a marker with:
 +
val = 1;                                    % val: this is your marker code, range code 1-255
 +
bb.sendTrigger(val);
 +
resetMarker.start(); % this will call bb.sendTrigger(0) after pulseTime seconds (plus some additional overhead)
 +
 
</syntaxhighlight>
 
</syntaxhighlight>

Navigation menu