Back to the main page.

Bug 3176 - ft_electroderealign problems with cfg.headshape.pnt and .pos

Status CLOSED FIXED
Reported 2016-08-22 17:22:00 +0200
Modified 2017-01-17 11:29:43 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Jens Klinzing - 2016-08-22 17:22:56 +0200

ft_electroderealign requires the field cfg.headshape.pnt. However, even if this field is present it is moved to .pos in line 271 by calling cfg.headshape = fixpos(cfg.headshape). One line later (line 272) ft_electroderealign calls headshape = mesh2edge(cfg.headshape) which refers to the field .pnt, leading to the error: ---- Reference to non-existent field 'pnt'. Error in mesh2edge (line 82) newbnd.pnt = bnd.pnt; Error in ft_electroderealign (line 272) headshape = mesh2edge(cfg.headshape); ---- You can recreate the problem by loading the vol from: ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/headmodel_fem/vol.mat ...and executing the following code: elec = ft_read_sens('standard_1020.elc'); cfg = []; cfg.method = 'interactive'; cfg.elec = elec; cfg.headshape = vol; elec_aligned = ft_electroderealign(cfg);


Jens Klinzing - 2016-08-23 10:59:40 +0200

The problem occurs because mesh2edge is called from fieldtrip/private. There is another mesh2edge in fieldtrip/forward/private. There the line 82 newbnd.pnt = bnd.pnt; (fieldtrip/private) ...is replaced by bnd = fixpos(bnd); newbnd.pos = bnd.pos; (fieldtrip/forward/private) ...which fixes the problem. Can this be changed also in the fieldtrip/private/mesh2edge? I don't know if this would break any other functions. If it doesn't here is a pull request making the change: https://github.com/fieldtrip/fieldtrip/pull/210


Robert Oostenveld - 2016-08-23 12:39:06 +0200

(In reply to Jens Klinzing from comment #1) hmm, the fieldtrip/bin/synchronize-private.sh script should be automatically triggered after every commit and should cause any identical files to remain identical (in case one copy is updated). I see in the sh script that # mesh2edge.m ARRAY=() ARRAY+=(forward/private/mesh2edge.m) ARRAY+=(plotting/private/mesh2edge.m) sync ${ARRAY[*]} which is consistent with mac011> find . -name mesh2edge.m ./forward/private/mesh2edge.m ./plotting/private/mesh2edge.m ./private/mesh2edge.m so the one in fieldtrip/private is not listed in the sync script, which has caused it to get out of sync with the (already previously fixed) other copies. I see some other changes in forward/private/mesh2edge.m that are not in private/mesh2edge.m, so I'll copy the whole file over. this fixes it: mac011> git commit [master 3b00b78] FIX - mesh2edge was not synched properly, see http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3176 and thanks to Jens 2 files changed, 14 insertions(+), 5 deletions(-) mac011> git push upstream master X11 forwarding request failed on channel 0 You're about to push master, is that what you intended? [y|n] y Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 557 bytes | 0 bytes/s, done. Total 5 (delta 3), reused 0 (delta 0) remote: Resolving deltas: 100% (3/3), completed with 3 local objects. To git@github.com:fieldtrip/fieldtrip.git 146d785..3b00b78 master -> master I will ignore the PR. Thanks anyway for that, as that was the fastest way for me to figure out what was wrong.


Robert Oostenveld - 2017-01-17 11:29:43 +0100

closed multiple bugs that were resolved some time ago