convert .mat to .gdf

Come here to discuss about OpenViBE in general!
Post Reply
iuri
Posts: 15
Joined: Thu Jul 02, 2009 12:05 pm

convert .mat to .gdf

Post by iuri »

Hi there,

I am trying to convert a .mat file to a .gdf file in order to be able to use the data with openvibe Designer suport.

i believe i need information about the original file, such as specific info regarding number of chanels, blocks, events, etc,
in order to fulfill the gdf data structure and then do the convertion.

I can get those information just by accessing the .mat file using MatLab. So far no problem at all.

The sample data is the dataset from BCI competition IV 2008.
I downloaded from http://ida.first.fraunhofer.de/projects ... tition_iv/

So far, i see i have to convert it manually. So i studied .mat and gdf file formats.
The original file ".mat file", is described bellow.
>> mydata = load('S1.mat');

training_data: {1x4 cell}
test_data: [74x400x10 double]
Info: [1x1 struct]

a sample of .gdf file format is described bellow
HDR =
TYPE: 'GDF'
VERSION: 2.1100
FileName: 'TEST_78PCW_e1.GDF'
T0: [2009 7 7 10 25 17.6350]
FILE: [1x1 struct]
Patient: [1x1 struct]
HeadLen: 2048
NS: 6
SPR: 1000
NRec: 10
SampleRate: 1.0246e+003
FLAG: [1x1 struct]
EVENT: [1x1 struct]
Label: {6x1 cell}
LeadIdCode: [0 0 0 0 0 0]
PhysDimCode: [4275 4274 544 512 512 6048]
PhysDim: {6x1 cell}
Filter: [1x1 struct]
PhysMax: [100 100 100 100 100 100]
PhysMin: [0 0 0 0 0 0]
DigMax: [100 100 100 100 100 1000]
DigMin: [0 0 0 0 0 0]
Transducer: {6x1 cell}
Cal: [1 1 1 1 1 0.1000]
Off: [0 0 0 0 0 0]
GDFTYP: [3 3 3 3 3 3]
LowPass: []
HighPass: []
Notch: []
ELEC: [1x1 struct]
Impedance: [0 0 0 0 0 0]
AS: [1x1 struct]
Dur: 0.9760
REC: [1x1 struct]
Manufacturer: [1x1 struct]
InChanSelect: [1 2 3 4 5 6]
Calib: [7x6 double]
Classlabel: [0x1 double]
TRIG: [0x1 double]
CHANTYP: ' '

my question is:
1. Where the raw data from the .mat file goes into the gdf file structure?
2. Does OpenVibe suport .mat files? I believe it doesn't. I haven't found any reference yet.
3. How do i properly convert from .mat to a valid .gdf file to use it on openVibe designer?

cheers,
iuri

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: convert .mat to .gdf

Post by yrenard »

OpenViBE does not read nor write .mat files right now. If you have knowledge of .mat file format, you can write a file reader yourself (please look at the brainamp file reader as a reference in openvibe-plugins/file-io/trunc/src). Alternatively, you could perform the conversion with another software. I think the fastest way to proceed would probably be to use either the EEG Lab or the biosig toolbox for MATLAB.

ChangeWind
Posts: 9
Joined: Wed Nov 25, 2009 11:16 am

Re: convert .mat to .gdf

Post by ChangeWind »

Hi Yrenard,
I have done some testing.
I took the GDF file (e.g. Voxel-display.gdf) provided by OpenVIBE (work with OpenVIBE GDF reader) and import it into EEGLAB and immediately export it back to GDF (e.g. Voxel-display2.gdf). The OpenVIBE no longer read the second file (Voxel-display2.gdf).

I did this test because earliar I export a MAT file into GDF in EEGlab and it was not imported by OpenVIBE GDFreader. I suspect there is something wrong perhaps with the export so I test the process again with the Voxel-display.gdf.

It seems that the latest EEGLAB mofified the File.GDF file such that it no longer readable.

The problem I am stuck now is that the GDF format, used solely by OpenVIBE, is not compatible with the GDF format export by EEGLAB (which actually use BioSIG to process the data).

Do you have suggestion on what other way to import data into OpenVIBE.

I have problem getting the OpenVIBE source compiled.
a) If anyone could send me a project file of visual studio 2008 express so I could proceed with writing a reader file based on modification of Brainamp reader.

b) Could OpenVIBE team kindly provide a ASCII reader which just take two files. A 1x32 array of channel name and the second file is the signal data, e.g. 1000x32 (for 1000 sampled points)

Thank you for your feedback

CW.

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: convert .mat to .gdf

Post by yrenard »

Dear ChangeWind,

Unfortunately, the GDF related implementations have been really tricky to realize. The multiple implementations that you'll find online slightly differ from each other, and slightly differ from the official spreadsheet describing the format. It was hard to get something working with biosig and EEGLab but it worked at that time (it was back in 2007). Hopefully, you can get the openvibe recorded in MATLAB. But unfortunately you can't get them from MATLAB to OpenViBE. Do you have a particular error message telling what went wrong ? Can you post a bug report and attach a (small) sample GDF file ? As the GDF files we find online usually don't fit the official spreadsheet, it would be hard to tell who is wrong between the exporter and the importer ;) However, the exporter is part of biosig which should be the reference implementation so I guess we have to do this work on our side !

As a workaround for now, if EEGLab can export brainamp files, I expect them to work... If you want to take this implementation as an example to build your own file format importer, feel free to look at openvibe-plugins/file-io/trunc/src !

Concerning your question about importing text files, this is not possible at the moment. But it should be very easy to do...

Yann

Post Reply