Export EEG Data

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Thu Jul 1 18:07:07 CEST 2010


Hi Matthias

On 25 Jun 2010, at 11:24, Matthias C. Meyer wrote:
> I recorded EEG data inside an MR Scanner with the BrainVision
> software and now I want to use Fieldtrip to run some error
> correction scripts - so far so god.
> But after that I need to write the corrected data back to the
> original EEG - data format.
> I use the ft_write_data function to do this. After some problems I
> manage to run the function, but the result is a double size
> datafile, a messed up header and a empty marker file.

How was the original data written? The brainvision dataformat allopws
for many different subformats, i.e. int16, int32, float, but also
ascii. Another subformat specification is whether the data is
multiplexed or not. The default subformat that fieldtrip writes is
multiplexed 32 bit floating point values. If the original data was 16
bit, then you would indeed expect a file that is 2x as large. That in
itself is not a problem.

> Probably the data is written in double precision.

it is not. Have a look in fieldtrip/fileio/private/
write_brainvision_eeg.m, there you see

% open the data file and write the binary data
fid = fopen(datafile, 'wb', 'ieee-le');
if length(size(dat))>2
   warning('writing segmented data as if it were continuous');
   for i=1:ntrl
     fwrite(fid, squeeze(dat(i,:,:)), 'float32');
   end
else
   fwrite(fid, dat, 'float32');
end

What do you mean with a "messed up header"? Can you look at the header
with an ascii editor?

Presumably the reason for writing to an output file is that you want
to read it in in some other software. What is the software that you
are trying to read the fieldtrip-generated BVA file into? M

> Giving the data to the function with "single(data_org.trial{1})" in
> the argument does not help.
> The command line I use to call the function is:
> ft_write_data('ScannerCor', data_org.trial{1}, 'dataformat',
> 'brainvision_eeg','header', data_org.hdr);
>
> (I copied the corrected data back to the read in matrix)
>
> I heard already, that I can tell Matlab to use only single
> precision, but it would be nice to tell that the function directly -
> Is there a way to do so?
> What do I need to do, to export the header and marker file correctly?
>

> The corrected data are exactly of the same size as the original
> data, if possible, I might also use the original marker file to get
> the trigger points.

correct. You just have to make a copy of the marker file so that it
has the same name as the new data.

best
Robert

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.



More information about the fieldtrip mailing list