ButtonBox: Difference between revisions
Jump to navigation
Jump to search
→Python/PsychoPy: add linux serial Tags: Mobile edit Mobile web edit |
mNo edit summary |
||
| (14 intermediate revisions by 4 users not shown) | |||
| Line 4: | Line 4: | ||
| caption = 2018 Buttonbox | | caption = 2018 Buttonbox | ||
| downloads = {{bulleted list | | downloads = {{bulleted list | ||
| | | {{Surfdrive|https://surfdrive.surf.nl/s/KZzgpmC5oK5JBNr|Buttonbox 2018}} | ||
| [https://pypi.python.org/pypi/RuSocSci RuSocSci] (Python package) | | [https://pypi.python.org/pypi/RuSocSci RuSocSci] (Python package) | ||
}} | }} | ||
| Line 13: | Line 13: | ||
| caption = 2013 Buttonbox | | caption = 2013 Buttonbox | ||
| downloads = {{bulleted list | | downloads = {{bulleted list | ||
| | | {{Surfdrive|https://surfdrive.surf.nl/s/KZzgpmC5oK5JBNr|Buttonbox 2015}} | ||
| [https://pypi.python.org/pypi/RuSocSci RuSocSci] (Python package) | | [https://pypi.python.org/pypi/RuSocSci RuSocSci] (Python package) | ||
}} | }} | ||
| Line 22: | Line 22: | ||
The output connector has two binary eight bit ports: input and output. The two ports can be used for responses (input) and stimulus triggers (output). Two 12 bits analog outputs and three 12 bits analog inputs. The output connector has a sound and voicekey which triggers when a amplitude reaches a threshold. By using the serial port, the BITSI can be used platform independently: it works on Windows, Linux and Mac OSX. Most programming environments and stimulus packages support serial communication. | The output connector has two binary eight bit ports: input and output. The two ports can be used for responses (input) and stimulus triggers (output). Two 12 bits analog outputs and three 12 bits analog inputs. The output connector has a sound and voicekey which triggers when a amplitude reaches a threshold. By using the serial port, the BITSI can be used platform independently: it works on Windows, Linux and Mac OSX. Most programming environments and stimulus packages support serial communication. | ||
There is currently a [[Microsoft Windows driver issue]]. | ⚠️ There is currently a [[ButtonBox/Microsoft Windows driver issue|Windows driver issue]]. | ||
== BITSI Protocol == | == BITSI Protocol == | ||
| Line 223: | Line 223: | ||
=== Python/PsychoPy === | === Python/PsychoPy === | ||
Download this site-package to use the buttonbox: [https://pypi.python.org/pypi/RuSocSci rusocsci] | Download this site-package to use the buttonbox: [https://pypi.python.org/pypi/RuSocSci rusocsci] | ||
or use in windows command 'pip install --upgrade rusocsci' | |||
'''Example using buttons from the buttonbox in Python:''' | '''Example using buttons from the buttonbox in Python:''' | ||
| Line 270: | Line 272: | ||
# select a function | # select a function | ||
bb.sendMarker(val=(ord(X))) | 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))) | bb.sendMarker(val=(ord('M'))) #select marker out | ||
bb.sendMarker(val=115) | bb.sendMarker(val=115) #set marker value 115 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 337: | Line 339: | ||
For more documentation click here: http://pythonhosted.org//RuSocSci/index.html | For more documentation click here: http://pythonhosted.org//RuSocSci/index.html | ||
<br> | |||
<br> | |||
=== Matlab === | === Matlab === | ||
'''Example using markers with the Buttonbox in Matlab:''' | |||
<syntaxhighlight lang="matlab" line style=" | Download the file Bitsi.m from the DCCN website: https://intranet.donders.ru.nl/index.php?id=bitsim0 | ||
<br> Make sure to have this file in your Matlab path. | |||
<syntaxhighlight lang="matlab" line style="overflow:auto;"> | |||
% At the start of your script, create the buttonbox serial object | |||
bb = Bitsi("COM2"); | |||
% other code | |||
: | |||
</syntaxhighlight> | |||
% | |||
BITSI simple mode: | |||
% | <syntaxhighlight lang="matlab" line style="overflow:auto;"> | ||
bb. | % This example is for an EEG system sampling at 500Hz samplerate. | ||
% at the start of your script, reset marker | |||
bb. | samplerate = 500; | ||
pulseLen = 2000/samplerate; % get pulse time length for a 2 samples delay | |||
bb. | bb.sendTrigger(0); | ||
% send a marker | |||
val = 1; % val: this is your marker code, range code 1-255 | |||
bb.sendTrigger(val); | |||
java.lang.Thread.sleep(pulseLen); % wait long enough for the EEG system to capture the trigger, i.e., 2000/samplerate ms | |||
% 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. Another solution using a timer object instead of a simple delay is outlined below. | |||
</syntaxhighlight> | |||
BITSI extended mode: | |||
<syntaxhighlight lang="matlab" line style="overflow:auto;"> | |||
samplerate = 500; | |||
pulseLen = 2000/samplerate; % get pulse time length for a 2 samples delay | |||
% select a function | |||
bb.sendTrigger(uint8('X')); % select pulse time | |||
bb.sendTrigger(pulseLen); % set time of duration pulse to (2000/samplerate) ms | |||
val = 1; % val: this is your marker code, range code 1-255 | |||
bb.sendTrigger(uint8('M')); % select marker out | |||
bb.sendTrigger(val); % val: this is your marker code, range code 1-255 | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="matlab" line style="overflow:auto;"> | |||
% At the end of your script, close the buttonbox serial object | |||
: | |||
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> | |||