Back to the main page.

Bug 673 - output of ft_dipolefitting is incorrect

Status CLOSED FIXED
Reported 2011-05-17 12:21:00 +0200
Modified 2011-07-13 14:47:01 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P1 normal
Assigned to: Cristiano Micheli
URL:
Tags:
Depends on:
Blocks:
See also:

Gio Piantoni - 2011-05-17 12:21:59 +0200

Hi, ft_dipolefitting works really well but the output is rather inconsistent. With cfg.numdipoles = 2; cfg.symmetry = 'x'; cfg.model = 'regional'; ft_dipolefitting gives the wrong output in dipole.dip.pos. At line 385-6 of ft_dipolefitting: dip.pos = grid.pos(grid.inside(indx),:); % note that for a symmetric dipole pair this results in a vector dip.pos = reshape(dip.pos, cfg.numdipoles, 3); % convert to a Nx3 array where grid.pos is a 8360x6 matrix, dip.pos becomes a 1x6 vector (1x3 for the first dipole and 1x3 for the second dipole). But reshape in Matlab is column-major, so dip.pos after reshape is in the wrong order. I suggest: dip.pos = reshape(pos, 3, cfg.numdipoles)'; Example: dip.pos = [1 2 3 4 5 6]; wrongreshape = reshape(dip.pos, cfg.numdipoles, 3); wrongreshape 1 3 5 2 4 6 goodreshape = reshape(dip.pos, 3, cfg.numdipoles)'; 1 2 3 4 5 6 Line 391 should then become: fprintf('found minimum after scanning on grid point [%g %g %g; %g %g %g]\n', dip.pos(1,1), dip.pos(1,2), dip.pos(1,3), dip.pos(2,1), dip.pos(2,2), dip.pos(2,3)); Otherwise don't reshape at all but keep dimensions consistent. An example of (non-critical) inconsistency is: cfg.model = 'moving'; cfg.numdipoles = 2; cfg.symmetry = []; The output is dipole.dip(1) pos: [2x3 double] mom: [6x1 double] Sorry for the somewhat cryptic message. Thanks for your help!!!


Robert Oostenveld - 2011-07-13 14:47:01 +0200

changed the status for a whole bunch of resolved bugs to CLOSED