Export Single Trial Data

From BESA® Wiki
Jump to: navigation, search

Rationale

This article describes how to export single-trial EEG or MEG raw data for further analysis in an external program, e.g. in Matlab.

Steps to follow

1 Load data in BESA

The data are then displayed in the review window. Now you can either

  • use the ERP module to define a condition and reject any trials with artifacts (see the BESA Help section on ERP for more information), or
  • directly move to the export of all epochs around a particular trigger.

2 Export data from BESA

Select "File -> Export...". The export dialog opens:

Figure 1 "Export data" dialog

Make sure that the options "Epochs around triggers" and "Original data" are selected. In the section "Target formats", choose the option of choice:

  • If you want to create ASCII files for offline analysis, select "ASCII multiplexed" or "ASCII vectorized"
  • If you want to analyze data directly in Matlab, select "Send to MATLAB"

For the "Interval..." select a long enough time span as shown in figure 2:

Figure 2 "Epoch around trigger" dialog

Then click the "Triggers..." button to select which trigger code or condition will be used. If you want to export the epochs around a trigger code: Make sure that the trigger code you want is selected - e.g. the trigger code 1 in this example.

Figure 3 "Trigger codes" dialog

If you want to export the epochs around a condition: Check the box "Conditions". Then ensure that the condition of choice is selected (e.g. condition "Rare" in the example.

Figure 4 "Epoch around condition" dialog

After clicking "OK" BESA Research either exports the data, or - if that option was chosen - sends the data to Matlab. In case of Matlab, it opens the Matlab window and creates the structure "besa_channels". From Matlab save the structure as "besa_channels.mat".

3 data in Matlab

The Matlab structure "besa_channels" contains several fields like in the following example of a 27-channel EEG file with 200 samples:

             datafile: [1x99 char]
         channeltypes: {1x27 cell}
        channellabels: {1x27 cell}
         channelunits: {1x27 cell}
   channelcoordinates: [27x9 double]
              montage: 'Original'
              filters: 'Filters off'
         samplingrate: 320
       HSPcoordinates: [3x3 double]
             HSPtypes: {'Fiducial'  'Fiducial'  'Fiducial'}
            HSPlabels: {'FidNz'  'FidT9'  'FidT10'}
           headcenter: [7.5559e-16 7.6294e-09 0.0359]
           headradius: 0.0850
   electrodethickness: 0
           structtype: 'besa_channels'
             datatype: 'Epoched_Data'
                 data: [1x200 struct]