[FieldTrip] Missing resolution Information in *vhdr causes ft_preprocessing to return only NaNs

Karch, Julian karch at mpib-berlin.mpg.de
Wed Jan 25 17:30:11 CET 2012


Hi,

it seems like I solved the problem.

If you export your data to the ieee floating point format the resolution entry vanishes. I assume that it is just don't needed anymore as the entries are in micro volt then.

This was taken into account by the read_brainvision_eeg function until  12/08/2011. On This day a couple of changes were committed. Leading to the fact that ieee_float_32 data is also multiplied with the resolution

==================================================================================================
if strcmpi(hdr.DataFormat, 'binary') && strcmpi(hdr.DataOrientation, 'multiplexed') && any(strcmpi(hdr.BinaryFormat, {'int_16', 'int_32', 'ieee_float_32'}))
[...]
calib = diag(hdr.resolution);
% using a sparse multiplication speeds it up
dat = full(sparse(calib) * dat);
=============================================================

The pre 12/08/2011 version looks like that
============================================================
elseif strcmpi(hdr.DataFormat, 'binary') && strcmpi(hdr.DataOrientation, 'multiplexed') && strcmpi(hdr.BinaryFormat, 'ieee_float_32')
fid = fopen(filename, 'rb', 'ieee-le');
fseek(fid, hdr.NumberOfChannels*4*(begsample-1), 'cof');
[dat, siz] = fread(fid, [hdr.NumberOfChannels, (endsample-begsample+1)], 'float32');
 fclose(fid);
==========================================================

So ieee data was not multiplied by the resolution. Which is probably the correct behavior. I changed the function such that it doesn't multiply the ieee data with the resolution and it seems work. You can look at it here: http://matlab.nopaste.dk/p4635. The changes are just the if statements in line 67and 81. It would be great if you could incorporate a similar change to the read_brainvision_eeg function.

Best,

Julian Karch


Von: fieldtrip-bounces at donders.ru.nl [mailto:fieldtrip-bounces at donders.ru.nl] Im Auftrag von Casper van Heck
Gesendet: Wednesday, January 25, 2012 2:47 PM
An: Email discussion list for the FieldTrip project
Betreff: Re: [FieldTrip] Missing resolution Information in *vhdr causes ft_preprocessing to return only NaNs

Julian,

Brainvision Analyzer is somewhat finicky, but I've never seen it do this, and I don't seem to be able to reproduce the problem here.

If you can get access to the original datasets, then rereferencing in Fieldtrip might be a solution.

And if you can't get the original datasets, then you could try editing the header files to include the resolution. I don't think the resolution should change after rereferencing, so you could simply put the resolution in there. Alternatively, specifying the resolution in hdr.orig.resolution should be possible, perhaps with some editing.
Also, since Fieldtrip could open the files earlier, it would stand to reason that it either 'makes up' some values, doesn't need them (which would be odd), or somehow deduces them from other values. However, in my *.vhdr files it specifies the resolution twice, once below [Channel Infos] and once under [Channels], but nothing I can find that defines it any other way. So, I'm guessing Fieldtrip used to make them up, but doesn't anymore. So, placing a resolution in the files or specifying it in Fieldtrip should not be a problem. Ideally, you would want the original resolution, but if that's not known, you could try winging it with a value that seems 'close enough'.

Hope this helps,

Casper van Heck

On Wed, Jan 25, 2012 at 1:49 PM, Karch, Julian <karch at mpib-berlin.mpg.de<mailto:karch at mpib-berlin.mpg.de>> wrote:
Hi,

thanks for your answer. It seems that I was a little imprecise. Of course the original data set doesn't change but if I export the a data set after setting a new reference in Brainvision Analyzer the header looks like that:

Original header real.vhdr
===============================
Brain Vision Data Exchange Header File Version 1.0
; Data created by the Vision Recorder
[...]
Ch4=Fz,,0.1,µV

 realnewRef.vhdr
===============================
Brain Vision Data Exchange Header File Version 1.0
; Data created from history path: real/Raw Data/New Reference
[...]
Ch4=Fz,Avg,,µV

This was just a test I did with some random data. I don't have acess to the orginal recording for the data sets I want to read in. The header from them look like
Brain Vision Data Exchange Header File Version 1.0
; Data created from history path: passive3101/Raw Data/Filters/New Reference/Attentive
[...]
Ch12=Fz,ref new,,

Like I said what's really strange that I think I was able to preprocess the exact same data set a couple of month ago.

Thanks for your help!

Best,

Julian




Von: fieldtrip-bounces at donders.ru.nl<mailto:fieldtrip-bounces at donders.ru.nl> [mailto:fieldtrip-bounces at donders.ru.nl<mailto:fieldtrip-bounces at donders.ru.nl>] Im Auftrag von Casper van Heck
Gesendet: Wednesday, January 25, 2012 10:10 AM
An: Email discussion list for the FieldTrip project
Betreff: Re: [FieldTrip] Missing resolution Information in *vhdr causes ft_preprocessing to return only NaNs

Julian,

It is my understanding that the header file doesn't change at all, since Brainvision Analyzer stores all changes either in the 'history' files or temporary files in the history folder. The *.vhdr and *.eeg (and marker files, if any) should be unchanged after preprocessing. Therefore, resolution information should still be there.

Could you check the contents of the header file with notepad?
It should say something like this for every channel under "[Channel Infos]":
Ch27=Fz,,0.0715,µV

Also, you could try to open it with Brainvision Analyzer, and see if that gives an error of sorts.

Sincerely,

Casper van Heck

On Tue, Jan 24, 2012 at 11:54 PM, Karch, Julian <karch at mpib-berlin.mpg.de<mailto:karch at mpib-berlin.mpg.de>> wrote:
Hi,

I'm working on a brainvision EEG dataset  which was preprocessed by someone else using Brainvision Analyzer. One part of his preprocessing was to set a new reference. This processing step makes the resolution information in the *vhdr file disappear. Because of that hdr.orig.resolution=NaN for all channels.  As result of that the lines
                calib = diag(hdr.resolution(chanindx));
      % using a sparse multiplication speeds it up
      dat = full(sparse(calib) * dat);
in read_brainvision_eeg produce only NaN. This again results in trials which only contain NaNs.

I do weekly updates of fieldtrip using svn. Because I'm quite sure if was able to read in, using ft_preprocssing, the excact same dataset, even with the same cfg file, earlier this year I checked the modifications for the last half year or so but I couldn't find any change which could have broken it.
My two questions are. How would you handle this problem? Just plug in some random numbers like 0.1 ? Is this an issue with fieldtrip or am I doing something wrong? Were there any changes to the involved functions which could have changed the behavior in that way?

Thanks in advance!

Best,

Julian

Julian Karch
Research Assistant

Center for Lifespan Psychology
MPI for Human Development
Lentzeallee 94, 14195 Berlin, Germany
phone: +49-30-82406-296<tel:%2B49-30-82406-296>
fax: +49-30-8249939<tel:%2B49-30-8249939>
web: http://www.mpib-berlin.mpg.de


_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip


_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20120125/545bc21a/attachment-0002.html>


More information about the fieldtrip mailing list