Back to the main page.

Bug 1703 - add elan2fieldtrip and fieldtrip2elan to exchange data back and forth

Status ASSIGNED
Reported 2012-09-07 14:51:00 +0200
Modified 2012-11-09 17:22:17 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to: Pierre-Emmanuel Aguera
URL:
Tags:
Depends on:
Blocks:
See also:

Pierre-Emmanuel Aguera - 2012-09-07 14:51:58 +0200

As you mentioned [at Biomag], it would indeed be great to be able to do import/export operations between Fieldtrip and Elan. Can you please send me some guidelines and information that could be useful to help me write the code to import ELAN data into fieldtrip and possibly export FieldTrip data into an ELAN format.


Robert Oostenveld - 2012-09-07 14:54:47 +0200

Hi Piesse-Emmanuel please have a look at this collection of converter functions in FieldTrip and let me know which one suits the best. manzana> ls fieldtrip/*2*.m besa2fieldtrip.m loreta2fieldtrip.m spm2fieldtrip.m fieldtrip2fiff.m nutmeg2fieldtrip.m fieldtrip2spss.m spass2fieldtrip.m I suspect that converters like function ft_struct = elan2fieldtrip(filename) and function fieldtrip2elan(filename, ft_struct) would make most sense, but I am not sure. Do you have a URL pointing to ELAN documentation?


Pierre-Emmanuel Aguera - 2012-09-07 16:28:03 +0200

(In reply to comment #1) Hi Robert, I already have 2 Matlab function to convert Elan to Fieldtrip structure : eeg2fieldtrip : convert continuous data (or concatenated epochs), and read event for another event (text) file. For continuous data file, we can read events from the file (events are not modified after import), and we can also read events from an event file after preprocessing (recoding events, rejection, ...). ep2fieldtrip : convert evoked potential data (averaged data or frequency profile, only one event : stimulus) Both may be one function. I looked at the converters. I think besa2fieldtrip is a good example. I can make elan2fieldtrip with 2 usages : function ft_struct = elan2fieldtrip(data_filename) function ft_struct = elan2fieldtrip(data_filename, event_filename) To convert back to ELAN, function fieldtrip2elan(filename, ft_struct) seems to be a good candidate. You will find ELAN documentation at : http://elan.lyon.inserm.fr/?q=doc_main


Pierre-Emmanuel Aguera - 2012-09-07 16:52:14 +0200

(In reply to comment #1) Hi Robert, I already have 2 Matlab function to convert Elan to Fieldtrip structure : eeg2fieldtrip : convert continuous data (or concatenated epochs), and read event for another event (text) file. For continuous data file, we can read events from the file (events are not modified after import), and we can also read events from an event file after preprocessing (recoding events, rejection, ...). ep2fieldtrip : convert evoked potential data (averaged data or frequency profile, only one event : stimulus) Both may be one function. I looked at the converters. I think besa2fieldtrip is a good example. I can make elan2fieldtrip with 2 usages : function ft_struct = elan2fieldtrip(data_filename) function ft_struct = elan2fieldtrip(data_filename, event_filename) To convert back to ELAN, function fieldtrip2elan(filename, ft_struct) seems to be a good candidate. You will find ELAN documentation at : http://elan.lyon.inserm.fr/?q=doc_main


Robert Oostenveld - 2012-09-20 10:08:12 +0200

Hi Pierre-Emmanuel, Sorry for t he delay in following this up. Your suggestion sounds like a good plan. In the ELAN documentation I see "The first step consists in converting your own continuous EEG or MEG data files to the ELAN internal format. Thereafter, all processing will only concern files in ELAN format (continuous data files [.eeg files], average responses [.p files], trigger position [.pos files], time-frequency data [.tf files], …)." Would all of these file formats then be covered? Once you have the two functions, could you also provide a test file like test_elan.m filename = { somedata.eeg otherdata.p ...} for i=1:length(filename) data = elan2fieldtrip(filename{i}); % read from disk elan2fieldtrip(['output_' filename{i}], data); % write back end and send that to us together with the data? If I can confirm that the functions work as expected, then I'll add the code to fieldtrip. thanks Robert


Pierre-Emmanuel Aguera - 2012-09-20 16:49:09 +0200

(In reply to comment #4) Hi Robert, I plan to convert continuous data (.eeg) and average responses (.p). Because continuous data files are not epoched, I need to read events from trigger position file (.pos) to do the epoching. I will send you some test files with elan2fieldtrip and fieldtrip2elan functions. Pierre-Emmanuel


Pierre-Emmanuel Aguera - 2012-11-09 16:53:18 +0100

Created attachment 366 Matlab files


Pierre-Emmanuel Aguera - 2012-11-09 16:54:08 +0100

Hi Robert, After a long delay (I'm sorry), I finished the 2 functions elan2fieldtrip.m and fieldtrip2elan.m . These 2 functions can import/export continuous data, evoked potentials or averaged data, and time-frequency data. They call 6 other functions (private) : read_elan_eeg.m, write_elan_eeg.m, read_elan_ep.m, write_elan_ep, read_elan_tf.m and write_elan_tf.m . I attach these 8 matlab files as elan_fieldtrip.tar.gz . I also attach data files with a test file test_elan.m as test_elan_data.tar.gz


Pierre-Emmanuel Aguera - 2012-11-09 17:22:17 +0100

Created attachment 368 Data test files