problems using fieldtrip

Hoi Fei Kwok h.f.kwok at BHAM.AC.UK
Tue Aug 9 16:14:22 CEST 2005

Dear Robert,

I have just tried to put breakpoints in some of the m-files to see what the
problems are. I have found some potential causes of the problem. Starting
from line 133 of the 'read_fcdc_header.m':

 if ctferror && haseegsf
    % try to read it using the CTF importer from the NIH and Daren Weber
      tmp = ctf_read_res4(fileparts(headerfile), 0);
      ctferror = 0;
      % convert the header into a structure that FieldTrip understands
      hdr              = [];
      hdr.Fs           = tmp.setup.sample_rate;
      hdr.nChans       = length(;
      hdr.nSamples     = tmp.setup.number_samples;
      hdr.nSamplesPre  = tmp.setup.pretrigger_samples;
      hdr.nTrials      = tmp.setup.number_trials;
      for i=1:length(
        hdr.label{i}   =;
      hdr.label        = hdr.label(:);
      % add a gradiometer structure for forward and inverse modelling
      hdr.grad         = nimh2grad(tmp);
      % also store the original header, so that it can be reused by
      hdr.orig         = tmp;
      ctferror = 1;
  if ctferror
    error('could not read CTF res4 header file');

In the above section of codes, the hdr is redefined and then on line 151,
the variable tmp is passed as an input argument for 'nimh2grad'. On line 22
of nimh2grad:

sel = hdr.sensor.index.meg;

now hdr is tmp (as tmp is the input argument). However, when I examined tmp
after coming out of the function, I found that there isn't a field
tmp.sensor.index.meg. Instead, I found things like the meg_left_central,
meg_left_frontal, etc but just not 'meg'. Therefore, I think sel was
assigned as an empty matrix and that implies length(sel)=0 and so the for
loop starting from line 30 of 'nimh2grad.m' was not executed.

I am not sure if you agree with my conclusion and if anything can be done
about it.

Hoi Fei

-----Original Message-----
From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On Behalf
Of Robert Oostenveld
Sent: 09 August 2005 14:39
Subject: Re: [FIELDTRIP] problems using fieldtrip

Dear Hoi Fei

On 9-aug-2005, at 15:05, Hoi Fei Kwok wrote:
> This is the first time that I am using FieldTrip. Just like to ask
> what
> other software are needed besides MATLAB in order to run the
> tutorials. I

Some parts of the tutorials use CTF specific applications. That is
commercial software only available to CTF MEG users. However, you can
skip those parts of the tutorial. Furthermore, I think that there is
a tutorial that refers to MRIcro, you can get that here: http://

> have tried to run the tutorials after downloading and unzipping the
> but I ran into problems.
> Firstly, in the Event Related Averaging tutorial, the
> EventRelatedAveraging.m was mentioned but I could not find the file.

you can copy and paste all matlab instructions from the pdf into the
matlab command line window. I will also make the demo scripts
available for download on the website, but I won't be able to do that

> Secondly, after I created a cfg structure with 'Subject01.ds' as the
> dataset and all the other field properties as instructed in the
> tutorial, I
> got the following error message when using the preprocessing.m:
> CTF_READ_RES4 [v  1.12]
> ??? Error using ==> read_fcdc_header
> could not read CTF res4 header file
> Error in ==> preprocessing at 219
> hdr = read_fcdc_header(cfg.headerfile);

Are you at the right location with Matlab? I.e., if you type "pwd",
does that correspond with the directory where Subject01.ds is located?

best regards,

More information about the fieldtrip mailing list