[FieldTrip] ft_electroderealign Reference to non-existent field error

Kirsten Petras kirsten.petras at uclouvain.be
Wed Mar 15 13:04:57 CET 2017

Dear Fieldtrippers,

I am a PhD student with at UC Louvain and am currently working on source-space analysis of 256 channel EEG data.

I am having troubles using ft_electroderealign  as follows to project my electrodes to the surface of the scalp.

cfg          = [];
cfg.method   = 'headshape';
cfg.elec     = elec_prealigned;
cfg.warp     = 'rigidbody';
cfg.headshape = mesh;
elec_aligned = ft_electroderealign(cfg);

This fails with the following error message:

Reference to non-existent field 'pos'.
Error in ft_warp_error (line 57)
  el = project_elec(input, target.pos, target.tri);
Error in fminunc (line 253)
        f = feval(funfcn{3},x,varargin{:});
Error in ft_warp_optim (line 129)
  rf = optimfun(errorfun, ri, options, pos1, pos2, 'rigidbody');
Error in ft_electroderealign (line 361)
  [norm.chanpos, norm.m] = ft_warp_optim(elec.chanpos, headshape, cfg.warp);
Caused by:
    Failure in initial user-supplied objective function evaluation. FMINUNC cannot

The electrode-positions come in the format of the EGI template, however, the coordinates have been exchanged for the actual coordinates on the individual participant (done manually from the MRI).
The Fid positions have been removed.
So the struct looks like this:
>> disp (elec_prealigned)
        chanpos: [256x3 double]
        elecpos: [256x3 double]
    homogeneous: [4x4 double]
          label: {256x1 cell}
           type: 'egi256'
           unit: 'cm'
            cfg: [1x1 struct]

Mesh is the following structure:
            hex: [4794932x8 double]
            pnt: [4940731x3 double]
         labels: [4794932x1 double]
         tissue: [4794932x1 double]
    tissuelabel: {'air'  'csf'  'gray'  'scalp'  'skull'  'white'}
           unit: 'mm'
            cfg: [1x1 struct]

At the point where it crashes, 'target' looks like this:
     pnt: [4940731x3 double]
    poly: [291320x4 double]
    unit: 'cm'

It looks like the headshape created in  ft_electroderealign lines 249-259
( if isstruct(cfg.headshape) && isfield(cfg.headshape, 'hex')
    cfg.headshape = fixpos(cfg.headshape);
    headshape = mesh2edge(cfg.headshape); )

is used as the 'target'  input for   ft_warp_optim(elec.chanpos, headshape, cfg.warp);
in line 361.

I tried replacing the input by cfg.headshape, but then the .tri field is still missing...

Would anyone have a suggestion as to what I am doing wrong here?

Thanks a lot!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170315/1ed4b677/attachment-0001.html>

More information about the fieldtrip mailing list