Back to the main page.

Bug 2671 - error when fitting dipole to independent component

Reported 2014-08-07 12:05:00 +0200
Modified 2019-08-10 12:28:45 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to:
Depends on:
See also:

- 2014-08-07 12:05:01 +0200

Hi guys, I am trying to fit a dipole to an independent component. According to the function description this should be possible. Here's my input and all the fieldtrip output... cfg=[]; cfg.method='runica'; comp=ft_componentanalysis(cfg,data); cfg=[]; cfg.numdipoles=1; cfg.gridsearch='yes'; cfg.nonlinear='yes'; cfg.grid=subjgrid; %subject-specific grid already created. cfg.component=1; %fit to first ICA component. cfg.vol=vol; %singleshell volume conduction model already created. dip=ft_dipolefitting(cfg,comp); the input is component data with 273 components and 273 original channels the input is raw data with 273 channels and 110 trials undoing the comp balancing for the gradiometer definition undoing the comp balancing for the gradiometer definition using headmodel specified in the configuration using gradiometers specified in the data computing surface normals selected 0 channels selected 1 topographies Warning: not enough channels to perform a dipole fit > In ft_dipolefitting at 255 creating dipole grid based on user specified dipole positions using headmodel specified in the configuration using gradiometers specified in the configuration 9785 dipoles inside, 9559 dipoles outside brain the call to "ft_prepare_sourcemodel" took 0 seconds and required the additional allocation of an estimated 0 MB scanning grid ??? Reference to non-existent field 'forwpar'. Error in ==> ft_compute_leadfield at 241 dippar((i-1)*3+1, :) = [vol.forwpar.scale*pos(i, :) 1 0 0]; % single dipole with unit strength, x-orientation Error in ==> ft_dipolefitting at 331 lf = ft_compute_leadfield(grid.pos(indx,:), sens, vol); First off, I'm not too happy about 'Warning: not enough channels to perform a dipole fit'. There are of course no 'channels' as such in this data, there are component topographies and time courses. However the serious this is this lack of 'forwpar'. I dug around in the code and apparently 'forwpar' can be created by calling ft_prepare_vol_sens prior to ft_dipolefitting, so I called it first in my code and specified the new vol. [vol2,sens]=ft_prepare_vol_sens(vol,data.grad,'channel',ft_channelselection('MEG',comp.label)); however this produces a new error... scanning grid ??? Error using ==> mtimes Inner matrix dimensions must agree. Error in ==> ft_compute_leadfield at 251 lf = sens.tra * lf; Error in ==> ft_dipolefitting at 331 lf = ft_compute_leadfield(grid.pos(indx,:), sens, vol); I presume that you're not supposed to have to call ft_prepare_vol_sens yourself prior to ft_dipolefitting, but in any case it seems not to solve the problem. Can somebody advise? Can provide a data snippet if necessary although I don't think there's anything odd about the data I'm using. Best, Tom

Eelke Spaak - 2014-08-07 12:10:54 +0200

Hi Tom, Hmm I was just playing around with dipole-fitting an IC myself and everything seems to work fine. For diagnostics, could you try creating a skeleton comp structure like so: c2 = []; c2.topo = comp.topo; c2.topolabel = comp.topolabel; and doing the dipolefit on that, specifying the data's (not the comp's) grad in the configuration: .... cfg.grad = data.grad; dip = ft_dipolefitting(cfg, c2); ? Thanks.

- 2014-08-07 12:15:30 +0200

Hey, cfg.grad=data.grad fixed it! I can still do the skeleton test if you want, but for my purposes this works not.

Eelke Spaak - 2014-08-07 12:19:25 +0200

(In reply to t.marshall from comment #2) I assume the "not" should be "now"? ;) I already suspected the grad thing would fix it. ft_dipolefitting needs to know how the sources project to the original sensors, which are described by data.grad. comp.grad describes how sources project to the components. Likely somewhere in the code the channel labels (of the physical channels) are matched to the grad's channels (which, in case of comp.grad, are the IC channels), leading to an empty intersection. ft_dipolefitting's interface needs to be updated, but marking this as resolved for now.

Jim Herring - 2014-08-07 12:29:15 +0200

Is it always the case that you should use data.grad instead of comp.grad when trying to fit dipoles to IC topographies? If so, we should probably document it in the help of ft_dipolefitting, shouldn't we?

Eelke Spaak - 2014-08-07 12:31:14 +0200

(In reply to Jim Herring from comment #4) Yes, and, yes, probably :)

- 2014-08-07 12:31:49 +0200

Verily, you are correct. 'not' = 'now', I wasn't trying to be archaic.

Robert Oostenveld - 2019-08-10 12:28:45 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue describing the issue on