Back to the main page.

Bug 2946 - improve exporting of FieldTrip data to BESA for external processing

Status ASSIGNED
Reported 2015-08-19 17:06:00 +0200
Modified 2015-09-01 14:48:53 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P5 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Robert Oostenveld - 2015-08-19 17:06:04 +0200


Robert Oostenveld - 2015-08-19 17:08:33 +0200

this is to follow up the discussion I had with Harald in Helsinki. An email which Harald send me on 31 July contains a pdf document from Todor with example code. I think that that code can become the basis of a generic besa2fieldtrip function.


Robert Oostenveld - 2015-08-19 17:11:26 +0200

I wrote a first version. mac011> svn commit fieldtrip2besa.m Adding fieldtrip2besa.m Transmitting file data . Committed revision 10609. Harald and/or Todor, could you check it out? Where is the code for besa_save2Avr etc. located? As a download somewhere on your site? FieldTrip includes fieldtrip/external/besa/ with some reading functions, which are (I guess) originally all from Karsten.


Robert Oostenveld - 2015-08-21 09:48:51 +0200

Harald wrote: These files are part of the package “MATLAB2BESA.zip” which is available as download under http://www.besa.de/downloads/matlab/ in the section Export functions from MATLAB to BESA I added it to ft_hastoolbox, which will refer to the website if the user does not have them on his path. mac011> svn commit fieldtrip2besa.m utilities/ft_hastoolbox.m Sending fieldtrip2besa.m Sending utilities/ft_hastoolbox.m Transmitting file data .. Committed revision 10618.


Todor Jordanov - 2015-08-31 17:00:43 +0200

Just to avoid duplication of the sources, please take a look at fieldtrip/external/besa/MATLAB2BESA/. The required source files were already submitted there. Please let me know if I should delete the folder, however, I have access only for the folder "besa" and if the files are somewhere else, then I'll not be able to keep them up to date. One file is missing there: "besa_transformCartesian2Spherical.m", but I can submit it too. Please let me know how to proceed.


Robert Oostenveld - 2015-09-01 08:59:39 +0200

(In reply to Todor Jordanov from comment #4) Hi Todor, FieldTrip will not automatically add fieldtrip/external/besa/matlab2besa to the path, that only works in ft_hastoolbox for directories at the level of fieldtrip/external/xxx itself. Why not move the files one directory up and extend the README a bit?


Todor Jordanov - 2015-09-01 11:56:37 +0200

(In reply to Robert Oostenveld from comment #5) Hi Robert, I removed the folder matlab2besa and moved the files one folder up. As next I am going to test the script fieldtrip2besa.m.


Todor Jordanov - 2015-09-01 14:48:53 +0200

(In reply to Robert Oostenveld from comment #5) I tested the script fieldtrip2besa a bit and i found some problems: 1. The variable custom_path is not defined, however, the exporting functions need that variable in order to know where to save the files. One option would be to define the variable like this: % Get the current path. The files are going to be exported here. custom_path = pwd(); or to add a new input parameter to the function fieldtrip2besa. 2. In the case of data resulted from "ft_preprocessing" the single trials are stored in a cell array of matrices and the call of squeeze(...) does not work in the switch case "raw". The solution would be to call squeeze like this: data_matrix = squeeze(data.trial{iTr}); 3. All the sensor level values are multiplied by 1e15 in order to get the values in femto Tesla, however, this is only valid for MEG data. Maybe it would be better to remove that constant or to make difference between MEG and EEG and multiply by 1e15 only in the case of MEG. 4. I was not able to run the export of an ".elp" file. The following error was generated: >> fieldtrip2besa('filename_elp', timelock_cond1.grad, timelock_cond1.label) Error using ft_getopt the first input should contain key-value pairs Error in fieldtrip2besa (line 26) channel = ft_getopt(varargin, 'channel'); 5. In the example I used to write the documentation one channel was defined as bad and in the script one channel is removed. See: NumBadChannels = 1; % A106 This should not be used in fieldtrip2besa since in all cases one channel is going to be removed by the export of the elp-file. Alternatively, one can define some kind of input parameter for the bad channels. I tried to make the changes by myself but I do not have access to change files outside of external/besa.