Line 272: |
Line 272: |
| | | |
| # select a function | | # select a function |
− | bb.sendMarker(val=(ord(X))) #select pulse time | + | bb.sendMarker(val=(ord('X'))) #select pulse time |
| bb.sendMarker(val=2) #set time of dureation pulse to 2ms | | bb.sendMarker(val=2) #set time of dureation pulse to 2ms |
| | | |
− | bb.sendMarker(val=(ord(M))) #select marker out | + | bb.sendMarker(val=(ord('M'))) #select marker out |
− | bb.sendMarker(val=115) #set marker value 115 | + | bb.sendMarker(val=115) #set marker value 115 |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
Line 341: |
Line 341: |
| <br> | | <br> |
| <br> | | <br> |
| + | |
| === Matlab === | | === Matlab === |
| '''Example using markers with the Buttonbox in Matlab:''' | | '''Example using markers with the Buttonbox in Matlab:''' |
Line 358: |
Line 359: |
| % at the start of your script, reset marker | | % at the start of your script, reset marker |
| samplerate = 500; | | samplerate = 500; |
− | pulseLen = 2000/samplerate; | + | pulseLen = 2000/samplerate; % get pulse time length for a 2 samples delay |
| bb.sendTrigger(0); | | bb.sendTrigger(0); |
| % send a marker | | % send a marker |
Line 365: |
Line 366: |
| 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 371: |
Line 372: |
| <syntaxhighlight lang="matlab" line style="overflow:auto;"> | | <syntaxhighlight lang="matlab" line style="overflow:auto;"> |
| samplerate = 500; | | samplerate = 500; |
− | pulseLen = 2000/samplerate; | + | pulseLen = 2000/samplerate; % get pulse time length for a 2 samples delay |
| % select a function | | % select a function |
| bb.sendTrigger(uint8('X')); % select pulse time | | bb.sendTrigger(uint8('X')); % select pulse time |
Line 385: |
Line 386: |
| : | | : |
| 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> |