Back to the main page.
Bug 1509 - Wrong scaling for Brainvision data (from Christophe Phillips)
Status | CLOSED FIXED |
Reported | 2012-06-07 14:56:00 +0200 |
Modified | 2012-08-23 10:41:20 +0200 |
Product: | FieldTrip |
Component: | fileio |
Version: | unspecified |
Hardware: | PC |
Operating System: | Windows |
Importance: | P3 normal |
Assigned to: | Boris Reuderink |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Vladimir Litvak - 2012-06-07 14:56:47 +0200
Created attachment 272 Problematic header Hello Robert and Vladimir, I've got a little problem with the importation (with SPM8) of some BrainVision (BrainProducts) data. Here is the issue, see example header file (simple text) attached: - data are acquired and stored as floats (float32) - when you import them, the values are simply read in, chunk by chunk, by read_brainvision_eeg.m, and passed to the upper functionft_read_data.m, then spm_eeg_convert.m - and finally added to the new binary file (file_array) in spm_eeg_convert.m PROBLEM: when I display them the range is about +/- 2000ÁV for perfectly normal EEG!!! Then I noticed this - in the header file, for each channel there is a field called "resolution in Unit" with a value of 0.0488281 - if I manually scale my data by this .488 factor, the values are in a reasonable range +/-75ÁV Interestingly, in read_brainvision_eeg.m, when reading data in integer format (int16 or int32), there are 2 extra lines accounting for a scaling issue which precisely uses this resolution information: % compute real microvolts using the calibration factor (resolution) res = sparse(diag(hdr.resolution)); dat = res * dat; In my case this scaling should also be applied to the float data??? I checked a few BrainVision header and, depending on the amplifier and setup, data are stored as floats or integer and the resolution can be quite different. The scaling can also be different for different channel types (EEG vs. ECG). And sometimes, with floats, there is no value for resolution and then I would assume there is no scaling needed. Have you noticed this? And how can this be fixed? :-) Cheers, Chris
Boris Reuderink - 2012-07-18 17:06:16 +0200
Dear Vladmir and Chris, Thank you for reporting this issue. My understanding of yout bugreport is that imported BrainVision data is scaled correctly for integer-based binary formats, while it does not seem to be scaled for floating-point based formats. I took a look at the files 'read_brainvision_eeg.m' [1], and 'read_brainvision_vhdr.m', but to me it seems that scaling is handled equally for floats and ints. Further, I can't precisely locate the code fragment you mentiond, which suggests that it is from an older version. Does this bug persist in the current version of FieldTrip? If so, could you perhaps provide me with a minimal example that reproduces this problem (including .eeg file), or point me to the lines in [1] where ints are scaled, but floats are not? [1] http://code.google.com/p/fieldtrip/source/browse/trunk/fileio/private/read_brainvision_eeg.m Best, Boris
Vladimir Litvak - 2012-07-19 15:09:25 +0200
Yes, looks OK now after updating FT.