Back to the main page.
Bug 2153 - Check read_brainvision_eeg.m
Status | CLOSED FIXED |
Reported | 2013-05-03 12:17:00 +0200 |
Modified | 2015-07-15 13:30:49 +0200 |
Product: | FieldTrip |
Component: | fileio |
Version: | unspecified |
Hardware: | PC |
Operating System: | Windows |
Importance: | P3 normal |
Assigned to: | Jim Herring |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Andrea Brovelli - 2013-05-03 12:17:52 +0200
Dear all, there might be a bug in the code read_brainvision_eeg.m Line 64 now reads: fseek(fid, hdr.NumberOfChannels*2*(begsample-1), 'cof'); And I think it should be (as for Line 79): fseek(fid, hdr.NumberOfChannels*samplesize*(begsample-1), 'cof'); I did not check the rest of the code, though, because it seemed to work.... Thanks a lot bye Andrea
Eelke Spaak - 2013-05-03 12:55:56 +0200
*** Bug 2154 has been marked as a duplicate of this bug. ***
Jan-Mathijs Schoffelen - 2013-05-07 06:42:17 +0200
Hi Andrea, Could you be a bit more specific? What's going wrong in your case? Do you have a snippet of data that can be used by us to reproduce the problem?
Andrea Brovelli - 2013-05-07 08:47:25 +0200
(In reply to comment #2) Hello Jan-Mathijs, even though the cfg.tfl is correct, the trial data I get take only half of the trial length at the time. So, imagine I have 3 trials of length 1000 points. The indeces of the data I get are: 1 1000 500 1500 1000 2000 The number of trials is correct but the data is epoched incorrectly. If I change Line 64 as: fseek(fid, hdr.NumberOfChannels*samplesize*(begsample-1), 'cof'); it works. The variable samplesize was set to 2. If you look at Line 79 you'll see the same kind of script. I cant send you some figures this afternoon though. bye Andrea
Jim Herring - 2013-06-13 10:46:10 +0200
I can see what the problem might be, if there are no channels selected the offset in the binary file is set by: fseek(fid, hdr.NumberOfChannels*2*(begsample-1), 'cof'); whereas if specific channels are selected the offset is set by fseek(fid, hdr.NumberOfChannels*samplesize*(begsample-1) + (chanindx(chan)-1)*samplesize, 'bof'); The main difference being that samplesize is fixed to '2' in case no channels are selected. The samplesize, however, depends on hdr.BinaryFormat. Only in the case that hdr.BinaryFormat is 'int_16' the samplesize is 2. In case of 'int_32' and 'ieee_float_32' the samplesize is 4. In those cases the offset set by fseek will be half of that what it should be when no specific channels are selected. As I am a brainvision user myself and never had these issues I looked into it. I didn't have issues because my datasets are stored in 'int_16' (samplesize=2). This might also be related to bug2068. It could be that in that case the wrong data is read-in as well.
Jim Herring - 2013-06-13 12:07:11 +0200
I've made the change and committed it. I'll also try to find out if bug2068 is related. Sending read_brainvision_eeg.m Transmitting file data . Committed revision 8256.
Andrea Brovelli - 2013-06-13 12:33:09 +0200
(In reply to comment #5) Excellent job ! Thanks a lot Andrea
Jan-Mathijs Schoffelen - 2013-06-13 12:34:48 +0200
Yes, the boys are trained by the best...
Jim Herring - 2013-08-02 09:07:36 +0200
This bug is solved, bug2068 appears to be a duplicate of this bug.