Changes

Jump to navigation Jump to search
no edit summary
Line 6: Line 6:  
This is an example of a very simple 'experiment' in which letters will appear on the screen one by one to form sentences. In this experiment, adding a new character to a string is called an ''epoch''. A series of epochs that results in a complete sentence is called a ''sequence''. Subjects can press a button when they are ready for the next sentence (sequence). A flowchart of the experiment is shown below:
 
This is an example of a very simple 'experiment' in which letters will appear on the screen one by one to form sentences. In this experiment, adding a new character to a string is called an ''epoch''. A series of epochs that results in a complete sentence is called a ''sequence''. Subjects can press a button when they are ready for the next sentence (sequence). A flowchart of the experiment is shown below:
   −
[[File:DocsSectionsExampleSentences.Flowchart.png]]
+
[[File:DocsSectionsExampleSentences_Flowchart.png|841px|235x]]
    
''Figure 1: Flowchart of the Sentences example experiment''
 
''Figure 1: Flowchart of the Sentences example experiment''
 
== Building the experiment ==
 
== Building the experiment ==
   −
As described in the [[BrainStreamBuildingExperiments Building|Experiments]] section, a number of files are needed to define an experiment. In the following, we will show how to create each of these files. If you want to have a look at the final result before reading this tutorial, the experiment file (.exp) for this example can be found in <tt>/brainstream_mds/examples/blocks/sentences/sentences.exp</tt>.
+
As described in the [[BrainStreamBuildingExperiments|Building Experiments]] section, a number of files are needed to define an experiment. In the following, we will show how to create each of these files. If you want to have a look at the final result before reading this tutorial, the experiment file (.exp) for this example can be found in <tt>/brainstream_mds/examples/blocks/sentences/sentences.exp</tt>.
    
<div id="BrainStream.[[DocsSectionsBlockFile]]"></div>
 
<div id="BrainStream.[[DocsSectionsBlockFile]]"></div>
Line 79: Line 79:  
| BS_INIT || EVENT || <strong>bs_send_buffer_marker('init_sequence','eeg',0,'now')<br /></strong> || [] || 0 || []  
 
| BS_INIT || EVENT || <strong>bs_send_buffer_marker('init_sequence','eeg',0,'now')<br /></strong> || [] || 0 || []  
 
|-
 
|-
| <strong>init_sequence <br /></strong> || <strong>EVENT <br /></strong> || <strong>initSequence <br /></strong> || <strong>put </strong> || |  
+
| <strong>init_sequence <br /></strong> || <strong>EVENT <br /></strong> || <strong>initSequence <br /></strong> || <strong>put </strong> || ||  
 
|}
 
|}
   Line 130: Line 130:     
If the outcome of the decision is that another sequence should be displayed, the marker start_sequence will be inserted. At the start of a new sequence, the variable <em>epoch_count </em>must be set to 0. Then BrainStream must wait for a button press from the participant, which is achieved by specifying timepoint 'button_1' for this event. The displaying of the characters is handled by the function displayString. This function will not be discussed in detail, but it is important to know that it requires the content of the variables <em>stimsequence </em>and<em> sequence_count.</em> Therefore, get statements must be specified for these variables. Now we have reached the next decision point in the experiment flowchart, where we need to decide whether to start a new epoch or end the sequence. We will insert marker ''next_epoch'' to trigger this decision making step.
 
If the outcome of the decision is that another sequence should be displayed, the marker start_sequence will be inserted. At the start of a new sequence, the variable <em>epoch_count </em>must be set to 0. Then BrainStream must wait for a button press from the participant, which is achieved by specifying timepoint 'button_1' for this event. The displaying of the characters is handled by the function displayString. This function will not be discussed in detail, but it is important to know that it requires the content of the variables <em>stimsequence </em>and<em> sequence_count.</em> Therefore, get statements must be specified for these variables. Now we have reached the next decision point in the experiment flowchart, where we need to decide whether to start a new epoch or end the sequence. We will insert marker ''next_epoch'' to trigger this decision making step.
{| border="1"
+
{| class="wikitable"
 
|-
 
|-
 
| '''<strong>marker</strong>''' || '''<strong>time</strong>''' || '''<strong>function</strong>''' || '''<strong>stimsequence</strong>''' || '''<strong>sequence_count</strong>''' || '''<strong>epoch_count</strong>'''  
 
| '''<strong>marker</strong>''' || '''<strong>time</strong>''' || '''<strong>function</strong>''' || '''<strong>stimsequence</strong>''' || '''<strong>sequence_count</strong>''' || '''<strong>epoch_count</strong>'''  
Line 149: Line 149:     
When the next_epoch marker comes in, first the epoch counter must be increased by 1. Subsequently, we need to write a function that uses the content of ''stimsequence'' and the current values of ''sequence_count'' and ''epoch_count'' to decide whether to start a new epoch. We will call this function <tt>nextEpoch</tt>. Because the function needs the content of all our variables as input, we must specify get statements for these variables. The Actions table now looks like this:
 
When the next_epoch marker comes in, first the epoch counter must be increased by 1. Subsequently, we need to write a function that uses the content of ''stimsequence'' and the current values of ''sequence_count'' and ''epoch_count'' to decide whether to start a new epoch. We will call this function <tt>nextEpoch</tt>. Because the function needs the content of all our variables as input, we must specify get statements for these variables. The Actions table now looks like this:
{| border="1"
+
{| class="wikitable"
 
|-
 
|-
 
| '''<strong>marker</strong>''' || '''<strong>time</strong>''' || '''<strong>function</strong>''' || '''<strong>stimsequence</strong>''' || '''<strong>sequence_count</strong>''' || '''<strong>epoch_count</strong>'''  
 
| '''<strong>marker</strong>''' || '''<strong>time</strong>''' || '''<strong>function</strong>''' || '''<strong>stimsequence</strong>''' || '''<strong>sequence_count</strong>''' || '''<strong>epoch_count</strong>'''  
Line 179: Line 179:  
</pre>If the outcome of the decision is that another character should be displayed, the marker proc_epoch will be inserted. As we want to use this marker for data selection (see [[BrainStreamExampleSentences#DataSelection|next section]), accurate synchronization between marker and data is required. Therefore, we will insert this marker [[BrainStreamMarkerHandling#HardwareMarker|via the hardware]. When this marker arrives, the displayString function will be used to show the current character. After this has been done, we insert the next_epoch marker and thereby return to the question whether to start another epoch. The next_epoch marker is inserted 0.25 seconds after the bs_send_buffer_marker function is called. As a result, there is a pause of approximately 0.25 seconds between the appearance of each character on the screen.
 
</pre>If the outcome of the decision is that another character should be displayed, the marker proc_epoch will be inserted. As we want to use this marker for data selection (see [[BrainStreamExampleSentences#DataSelection|next section]), accurate synchronization between marker and data is required. Therefore, we will insert this marker [[BrainStreamMarkerHandling#HardwareMarker|via the hardware]. When this marker arrives, the displayString function will be used to show the current character. After this has been done, we insert the next_epoch marker and thereby return to the question whether to start another epoch. The next_epoch marker is inserted 0.25 seconds after the bs_send_buffer_marker function is called. As a result, there is a pause of approximately 0.25 seconds between the appearance of each character on the screen.
   −
{| border="1"
+
{| class="wikitable"
 
|-
 
|-
 
| '''<strong>marker</strong>''' || '''<strong>time</strong>''' || '''<strong>function</strong>''' || '''<strong>stimsequence</strong>''' || '''<strong>sequence_count</strong>''' || '''<strong>epoch_count</strong>'''  
 
| '''<strong>marker</strong>''' || '''<strong>time</strong>''' || '''<strong>function</strong>''' || '''<strong>stimsequence</strong>''' || '''<strong>sequence_count</strong>''' || '''<strong>epoch_count</strong>'''  
Line 204: Line 204:     
When all epochs of a sequence have been processed, the <tt>nextEpoch</tt> function will insert the end_sequence marker. When this marker arrives, we immediately insert the next_sequence marker, thereby returning to the question whether to start another sequence. The next_sequence marker is inserted 1 second after the bs_send_buffer_marker function is called. As a result, there is a pause of approximately 1 second between each sequence. The Actions table now contains all the necessary steps of the experiment.
 
When all epochs of a sequence have been processed, the <tt>nextEpoch</tt> function will insert the end_sequence marker. When this marker arrives, we immediately insert the next_sequence marker, thereby returning to the question whether to start another sequence. The next_sequence marker is inserted 1 second after the bs_send_buffer_marker function is called. As a result, there is a pause of approximately 1 second between each sequence. The Actions table now contains all the necessary steps of the experiment.
{| border="1"
+
{| class="wikitable"
 
|-
 
|-
 
| '''<strong>marker</strong>''' || '''<strong>time</strong>''' || '''<strong>function</strong>''' || '''<strong>stimsequence</strong>''' || '''<strong>sequence_count</strong>''' || '''<strong>epoch_count</strong>'''  
 
| '''<strong>marker</strong>''' || '''<strong>time</strong>''' || '''<strong>function</strong>''' || '''<strong>stimsequence</strong>''' || '''<strong>sequence_count</strong>''' || '''<strong>epoch_count</strong>'''  
Line 210: Line 210:  
| BS_INIT || EVENT || bs_send_buffer_marker('init_sequence','eeg',0,'now') || [] || 0 || []  
 
| BS_INIT || EVENT || bs_send_buffer_marker('init_sequence','eeg',0,'now') || [] || 0 || []  
 
|-
 
|-
| init_sequence || EVENT || initSequence || put || |  
+
| init_sequence || EVENT || initSequence || put || ||  
 
|-
 
|-
| || | bs_send_buffer_marker('next_sequence','eeg',0,'now') || | ||  
+
| || || bs_send_buffer_marker('next_sequence','eeg',0,'now') || || ||  
 
|-
 
|-
 
| next_sequence || EVENT || nextSequence || get || $self+1, get ||  
 
| next_sequence || EVENT || nextSequence || get || $self+1, get ||  
Line 218: Line 218:  
| start_sequence || button_1 || displayString('') || get || get || 0  
 
| start_sequence || button_1 || displayString('') || get || get || 0  
 
|-
 
|-
| || | bs_send_buffer_marker('next_epoch','eeg',0,'now') || | ||  
+
| || || bs_send_buffer_marker('next_epoch','eeg',0,'now') || || ||  
 
|-
 
|-
 
| next_epoch || EVENT || nextEpoch || get || get || $self+1, get  
 
| next_epoch || EVENT || nextEpoch || get || get || $self+1, get  
 
|-
 
|-
| proc_epoch || EVENT || displayString() || | ||  
+
| proc_epoch || EVENT || displayString() || || ||  
 
|-
 
|-
| || | bs_send_buffer_marker('next_epoch','eeg',0.25,'now') || | ||  
+
| || || bs_send_buffer_marker('next_epoch','eeg',0.25,'now') || || ||  
 
|-
 
|-
| <strong>end_sequence</strong> || <strong>EVENT</strong> || <strong>bs_send_buffer_marker('next_sequence','eeg',1,'now')</strong> || | ||  
+
| <strong>end_sequence</strong> || <strong>EVENT</strong> || <strong>bs_send_buffer_marker('next_sequence','eeg',1,'now')</strong> || || ||  
    
|}
 
|}
Line 238: Line 238:  
New epochs are started by the proc_epoch marker. We will therefore use this marker to trigger data selection. For now, we will only print the message 'Process the data' in the Matlab command window every time data is collected. However, instead of showing a simple message you could also write functions to actually process the data. This is the new Actions table:
 
New epochs are started by the proc_epoch marker. We will therefore use this marker to trigger data selection. For now, we will only print the message 'Process the data' in the Matlab command window every time data is collected. However, instead of showing a simple message you could also write functions to actually process the data. This is the new Actions table:
   −
{| border="1"
+
{|class="wikitable"
 
|-
 
|-
 
| '''<strong>marker</strong>''' || '''<strong>time</strong>''' || '''<strong>function</strong>''' || '''<strong>stimsequence</strong>''' || '''<strong>sequence_count</strong>''' || '''<strong>epoch_count</strong>'''  
 
| '''<strong>marker</strong>''' || '''<strong>time</strong>''' || '''<strong>function</strong>''' || '''<strong>stimsequence</strong>''' || '''<strong>sequence_count</strong>''' || '''<strong>epoch_count</strong>'''  
Line 244: Line 244:  
| BS_INIT || EVENT || bs_send_buffer_marker('init_sequence','eeg',0,'now') || [] || 0 || []  
 
| BS_INIT || EVENT || bs_send_buffer_marker('init_sequence','eeg',0,'now') || [] || 0 || []  
 
|-
 
|-
| init_sequence || EVENT || initSequence || put || |  
+
| init_sequence || EVENT || initSequence || put || ||  
 
|-
 
|-
| || | bs_send_buffer_marker('next_sequence','eeg',0,'now') || | ||  
+
| || || bs_send_buffer_marker('next_sequence','eeg',0,'now') || || ||  
 
|-
 
|-
 
| next_sequence || EVENT || nextSequence || get || $self+1, get ||  
 
| next_sequence || EVENT || nextSequence || get || $self+1, get ||  
Line 252: Line 252:  
| start_sequence || button_1 || displayString('') || get || get || 0  
 
| start_sequence || button_1 || displayString('') || get || get || 0  
 
|-
 
|-
| || | bs_send_buffer_marker('next_epoch','eeg',0,'now') || | ||  
+
| || || bs_send_buffer_marker('next_epoch','eeg',0,'now') || || ||  
 
|-
 
|-
 
| next_epoch || EVENT || nextEpoch || get || get || $self+1, get  
 
| next_epoch || EVENT || nextEpoch || get || get || $self+1, get  
 
|-
 
|-
| proc_epoch || EVENT || displayString() || | ||  
+
| proc_epoch || EVENT || displayString() || || ||  
 
|-
 
|-
| || | bs_send_buffer_marker('next_epoch','eeg',0.25,'now') || | ||  
+
| || || bs_send_buffer_marker('next_epoch','eeg',0.25,'now') || || ||  
 
|-
 
|-
| || <strong>DATA <br /></strong> || <strong>bs_disp('Process the data')</strong> || | ||  
+
| || <strong>DATA <br /></strong> || <strong>bs_disp('Process the data')</strong> || || ||  
 
|-
 
|-
| end_sequence || EVENT || bs_send_buffer_marker('next_sequence','eeg',1,'now') || | ||  
+
| end_sequence || EVENT || bs_send_buffer_marker('next_sequence','eeg',1,'now') || || ||  
    
|}
 
|}
   −
We also need a [.DocsSectionsBuildingExperiments#SecDataSel DataSelection table] to specify the exact time window of data selection. If we want to record one second of data after the onset of each epoch, our DataSelection table looks like this:
+
We also need a [[BrainStreamBuildingExperiments#SecDataSel|DataSelection table]] to specify the exact time window of data selection. If we want to record one second of data after the onset of each epoch, our DataSelection table looks like this:
{| border="1"
+
{| class="wikitable"
 
|-
 
|-
 
| '''marker''' || '''begintime''' || '''endtime''' || '''datasource'''  
 
| '''marker''' || '''begintime''' || '''endtime''' || '''datasource'''  
Line 275: Line 275:  
|}
 
|}
   −
In this experiment, the fourth column ''datasource'' is not absolutely necessary. As only one data source (simulated EEG data, see [.DocsSectionsExampleSentences#BrainStream.[[DocsSectionsBlockFile]] blocksettings]) is used, BrainStream will automatically apply all data selection settings to this data source.
+
In this experiment, the fourth column ''datasource'' is not absolutely necessary. As only one data source (simulated EEG data, see [[BrainStreamExampleSentences#BrainStream|blocksettings]) is used, BrainStream will automatically apply all data selection settings to this data source.
 +
 
 
=== Creating the Dictionary table ===
 
=== Creating the Dictionary table ===
   −
The [.DocsSectionsBuildingExperiments#SecDict Dictionary table] specifies a marker number for each marker that is used in this experiment. The Dictionary table looks like this:
+
The [[BrainStreamBuildingExperiments#SecDict|Dictionary table]] specifies a marker number for each marker that is used in this experiment. The Dictionary table looks like this:
{| border="1"
+
{| class="wikitable"
 
|-
 
|-
 
| '''marker''' || '''type''' || '''value''' || '''datasource'''  
 
| '''marker''' || '''type''' || '''value''' || '''datasource'''  
Line 299: Line 300:  
|}
 
|}
   −
In this experiment, the fourth column ''datasource'' is not absolutely necessary. As only one data source (simulated EEG data, see [.DocsSectionsExampleSentences#BrainStream.[[DocsSectionsBlockFile]] blocksettings]) is used, BrainStream will automatically apply all marker settings to this data source.
+
In this experiment, the fourth column ''datasource'' is not absolutely necessary. As only one data source (simulated EEG data, see [[BrainStreamExampleSentences#BrainStream|blocksettings]) is used, BrainStream will automatically apply all marker settings to this data source.
 +
 
 
== Testing the experiment ==
 
== Testing the experiment ==
    
The easiest way to create all files that define this experiment is via the [.DocsSectionsBrainStreamEditor BrainStream editor]. You can open the editor by typing <tt>bs_editor</tt> in the Matlab command window (make sure that <tt>brainstream_mds/core</tt> is your current working directory). An experiment file (.exp) has already been created for this example experiment and is located in <tt>/brainstream_mds/examples/blocks/sentences/sentences.exp</tt>. If you open this file in the BrainStream editor, the experiment looks like this:
 
The easiest way to create all files that define this experiment is via the [.DocsSectionsBrainStreamEditor BrainStream editor]. You can open the editor by typing <tt>bs_editor</tt> in the Matlab command window (make sure that <tt>brainstream_mds/core</tt> is your current working directory). An experiment file (.exp) has already been created for this example experiment and is located in <tt>/brainstream_mds/examples/blocks/sentences/sentences.exp</tt>. If you open this file in the BrainStream editor, the experiment looks like this:
   −
[[File:DocsSectionsExampleSentences.BS_editor.png]]
+
[[File:DocsSectionsExampleSentences_BS_editor.png|1054px|658x]]
    
''Figure 2: The Sentences Experiment in the BrainStream Editor''
 
''Figure 2: The Sentences Experiment in the BrainStream Editor''

Navigation menu