[FieldTrip] Fwd: manually adding channel info and reference

Roy Cox roycox.roycox at gmail.com
Mon Jun 7 10:15:51 CEST 2021

hi all,

reposting this because I'm not sure it went through..


I'm having some trouble specifying several kinds of EEG recording
details/metadata required for further processing. From looking at
tutorials, functions, and the mailing list, it appears that Fieldtrip
usually determines these things cleverly from the input data, but in my
case this information needs to be manually added.

My data are 8-h continuous 265-channel signals in Brainvision format (256
"active" EEG channels, the implicit EEG reference [Cz, flatline], and 8
bipolar physiological signals). Data were originally recorded in EGI's mff
format, but have since been downsampled and converted to Brainvision (no
doubt resulting in some loss of metadata).

After reading data into Fieldtrip, I'm left with this bare-bones structure:

data_ft =

  struct with fields:

    fsample: 250
      trial: {[265×7671535 single]}
       time: {[1×7671535 double]}
      label: {1×265 cell}
        cfg: [1×1 struct]

Basically the data and channel labels (as present in the Brainvision file),
nothing more.

I get my EEG electrode coordinates from reading the header of one of the
original mffs:

hdr_mff = ft_read_header(mff_file)

elec_eeg =

  struct with fields:

     chanpos: [257×3 double]
    chantype: {257×1 cell}
    chanunit: {257×1 cell}
     elecpos: [257×3 double]
       label: {257×1 cell}
        type: 'egi256'
        unit: 'cm'

So this reflects the 256+1 EEG electrodes, but not the physiological
signals (presumably because the mff file doesn't - and couldn't - hold this
information). I can turn these EEG coordinates into an EEG layout that
looks accurate (and very similar to the EGI template layout provided in

cfg = [];
cfg.elec = elec_eeg;
mff_layout = ft_prepare_layout(cfg);

So far so good.

Q1: how do I add (mock) location information for the bipolar phys signals?
I imagine I'll run into trouble if channel/electrode counts don't match
between ft_data and elec_eeg. It would also be nice to be able to create a
layout that includes the phys signals (which means they should be present
in the elec_eeg struct). Do I manually expand the elec_eeg fields from 257
to 265? Suggestions for mock values that work well with ft_prepare_layout?

Q2: how/where do I specify that the 8 phys channels are not EEG? Can
elec_eeg.chantype be set to "non-eeg" or even more specific types (e.g., we
have ecg, emg, etc..)? I can't find an overview of allowed channel types.
And is it only the elec_eeg structure that needs this info, or do I need to
specify it elsewhere too? (Ultimately, I'd like to be able to use
ft_selectdata to select specific channel types etc.)

Q3: how/where do I indicate that the first 256 channels are referenced to
channel 257 (Cz, which is flatline), and that channels 258-265 are bipolar
channels, such that later re-referencing works as intended? (I know having
the EEG refence channel explicitly in the data is uncommon, so perhaps it
needs to be deleted?)

Thanks for any input!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210607/13e0fa4e/attachment.htm>

More information about the fieldtrip mailing list