Page 1 of 1

Mat to gdf,edt,bci2000dat

Posted: 19 Jun 2010, 09:08
by eelamin
Hello

I am experiencing problem in converting eeg signal in the format .mat
into any format that supported by the bci2000 offline analysis toolbox
I will be pleased if someone help me

Elgasim

Posted: 21 Jun 2010, 06:46
by mellinger
In order to save data as a BCI2000 data file, you will need to provide parameter and state (event, trigger) information in a suitable format, and then use the save_bcidat mex file to write out the file.

Could you give more information about what you want to do?

--Juergen

Posted: 24 Jun 2010, 11:51
by eelamin
can you tell me more about the parameters and triger events and how can i add it to the data?

Posted: 25 Jun 2010, 08:38
by mellinger
What kind of data do you have? Sensorimotor rhythms, or evoked potentials?

Posted: 25 Jun 2010, 11:07
by eelamin
My data is berlin bci competition IV data set one "(seven subjects imagining three types of movement right hand, left hand, and leg movement) utilizing motor imagery

Posted: 25 Jun 2010, 12:33
by mellinger
You will need to specify target conditions for each point in time. Create a struct variable "states" with a member "StimulusCode" in Matlab, which is a N x 1 matrix. It should have as many entries as there are samples in the data set. For each point in time, assign a StimulusCode of 0, 1, 2, or 3, depending on which imagination was performed at that point in time:
  • 0 when no imagination was performed,
    1 when right hand movement was imagined,
    2 during left hand imagination,
    3 during leg movement imagination.
In addition, you need to specify the sampling rate as a BCI2000 parameter. In Matlab, create a struct variable "parameters", with a member "SamplingRate", which is itself a struct, with the following fields (replace the number in the Value field with the actual sampling rate):

Code: Select all

>> parameters.SamplingRate

ans = 

         Section: 'Source'
            Type: 'int'
    DefaultValue: '256Hz'
        LowRange: '1'
       HighRange: ''
         Comment: 'sample rate'
           Value: {'600'}
    NumericValue: 600
Assuming that the EEG signal is contained in a variable called "signal" with dimensions channels x samples, run the following command:

save_bcidat('myfile.dat', signal, states, parameters);

The resulting file should be suited for use with the BCI2000 OfflineAnalysis program.

Posted: 01 Jul 2010, 02:50
by eelamin
I had constructed the structures states,parameters with their substructures stimuluscode, samplingrate respectively but,when using the command:
save_bcidat('myfile.dat', signal, states, parameters);
returns:
??? Error using ==> save_bcidat
Parameter values must be strings or cell arrays of strings.

and when i convert the parameters.sampling rate into cell using the command:
struct2cell
it returns:
??? Error using ==> save_bcidat
Could not access string field "Section".
would yu help me please

Posted: 01 Jul 2010, 08:33
by mellinger
Did you enclose the parameter value into curly braces as in

Code: Select all

parameters.SamplingRate.Value = {'600‘}
?

Posted: 01 Jul 2010, 08:46
by eelamin
yes i wrote the code:
SamplingRate= struct('Section','Source','Type','int','DefaultValue','256Hz','LowRange','1','HighRange','','Comment','sample rate','Value',{'100'},'NumericValue','100');

Posted: 02 Jul 2010, 00:50
by eelamin
yes i wrote the code:
SamplingRate= struct('Section','Source','Type','int','DefaultValue','256Hz','LowRange','1','HighRange','','Comment','sample rate','Value',{'100'},'NumericValue','100');
but, the problem is still running

Posted: 02 Jul 2010, 08:29
by mellinger
When you write

Code: Select all

parameters.SamplingRate
what does the output look like?

Posted: 02 Jul 2010, 17:25
by eelamin
the code looks like:
>> parameters.SamplingRate

ans =

Section: 'Source'
Type: 'int16'
DefaultValue: '256Hz'
LowRange: '1'
HighRange: ''
Comment: 'sample rate'
Value: '{100}'
NumericValue: '100'


and when using the command struct2cell it looks like;
>> parameters.SamplingRate

ans =

'Source'
'int16'
'256Hz'
'1'
''
'sample rate'
'{100}'
'100'

Posted: 05 Jul 2010, 08:27
by mellinger
Look at the curly braces in the "Value" field. The field should read {'100'} but it reads '{100}'. Once you correct this, it should work.