Reading in Neuroscan files

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Wed Jul 2 11:49:56 CEST 2008

Hi Monika,

On 30 Jun 2008, at 13:21, Monika Mellem wrote:
> I have noticed some things when reading in both Neuroscan .eeg
> and .cnt files.
> 1) When reading a Neuroscan .eeg file, read_event.m seems to put
> either
> "accept" or "reject" into the field event.value.  According to how
> event.field is used later on, it should be putting the trigger
> values in
> this field which are in tmp.sweep.type.  I modified the code as
> shown below.

Thanks for the suggestion. I have changed it into the following

    for i=1:hdr.nTrials
       % the *.eeg file has a fixed trigger value for each trial
       % furthermore each trial has the label 'accept' or 'reject'
       tmp = read_ns_eeg(filename, i);
       % create an event with the trigger value
       event(end+1).type     = 'trial';
       event(end  ).sample   = (i-1)*hdr.nSamples + 1;
       event(end  ).value    = tmp.sweep.type;  % trigger value
       event(end  ).offset   = -hdr.nSamplesPre;
       event(end  ).duration =  hdr.nSamples;
       % create an event with the boolean accept/reject code
       event(end+1).type     = 'accept';
       event(end  ).sample   = (i-1)*hdr.nSamples + 1;
       event(end  ).value    = tmp.sweep.accept;  % boolean value
indicating accept/reject
       event(end  ).offset   = -hdr.nSamplesPre;
       event(end  ).duration =  hdr.nSamples;

This encodes both the event value (trigger code) and the accept/
reject state, albeit in different events. The two events can be
combined in a trialfun of course.

> 2) When reading in a Neuroscan .cnt file, read_header.m puts some bad
> channel labels into hdr.label using what it gets from the
> read_ns_cnt.m file
> (around line 564).  Whatever is in orig.chan.names starts with the
> correct
> channels (about 10 of them) and then has blank values or odd
> characters for
> the rest of the channel labels.

This seems like a bug w.r.t. the reading of the header in general. I
was not able to reproduce the problem. Could you send me the .cnt
file that has the problem, e.g. using or on

best regards,

> As a quick fix for just the channel labels,
> I just took the channel labels that read_ns_hdr.m finds and
> substituted them
> into hdr.label.  See below.  This doesn't fix the underlying
> problem in
> read_ns_cnt.m though which seems to be with the variables chandat and
> r.chan.names (lines 140-141).
> orig = read_ns_hdr(filename);
> hdr.label = orig.label;
> hdr.orig.chan.names = orig.label;

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