read_fcdc_header problem

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Thu Jul 10 09:15:48 CEST 2008

Hi Paul

On 9 Jul 2008, at 10:23, Paul van den Hurk wrote:
> If I change the script
> 	info = dir(hdr.DataFile);
> into:
> 	info = dir(filename);
> the problem seems to be solved.

Thanks for the detailled report and suggestion. The snippet of code
that you are having a problem with is for determining the number of
samples in the data, and it does that by determining the size of the
file (in bytes). In the low-level read_brainvision_vhdr function the
filename is the string with the *.vhrd file, whereas hdr. DataFile
should be pointing to the filename with the *.dat file. Your
suggested fix would hence determine the number of samples incorrectly.

Since there is not an error in
   info = dir(hdr.DataFile);
itself, I suspect that hdr does have the DataFile field, but that it
points to a filename which cannot be found by the dir command. That
is the case due to the file being in another directory, which is
actually even stated as "FIXME" in the code.

I have changed it to

% determine the number of samples by looking at the binary file
if strcmp(hdr.DataFormat, 'BINARY')
   % the data file is supposed to be located in the same directory as
the header file
   % but that might be on another location than the present working
   [p, f, x] = fileparts(filename);
   datafile = fullfile(p, hdr.DataFile);
   info = dir(datafile);
   if isempty(info)
     error('cannot determine the location of the data file %s',
   switch lower(hdr.BinaryFormat)

The new version will be on FCDC home/common in 10 minutes and on the
ftp server this evening.

best regards,

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 and

More information about the fieldtrip mailing list