Back to the main page.

Bug 2375 - Problem with MEG localspheres when working in meters

Status CLOSED INVALID
Reported 2013-11-13 17:17:00 +0100
Modified 2014-02-24 10:56:29 +0100
Product: FieldTrip
Component: forward
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P3 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Vladimir Litvak - 2013-11-13 17:17:45 +0100

I'm switching SPM forward modeling to SI units and when I prepare local spheres with everything in meters I get all the spheres with identical origin and radius. Example input is attached, Run with: vol = ft_prepare_headmodel(cfg, headshape);


Vladimir Litvak - 2013-11-13 17:18:29 +0100

Created attachment 558 Inputs for testing


Robert Oostenveld - 2013-11-19 14:34:31 +0100

confirmed, I see ... channel = MRT44, 2562 surface points, center = [ 0.0 -0.0 0.1], radius = 0.1 channel = MRT45, 2562 surface points, center = [ 0.0 -0.0 0.1], radius = 0.1 channel = MRT46, 2562 surface points, center = [ 0.0 -0.0 0.1], radius = 0.1 channel = MRT47, 2562 surface points, center = [ 0.0 -0.0 0.1], radius = 0.1 channel = MRT51, 2562 surface points, center = [ 0.0 -0.0 0.1], radius = 0.1 channel = MRT52, 2562 surface points, center = [ 0.0 -0.0 0.1], radius = 0.1 channel = MRT53, 2562 surface points, center = [ 0.0 -0.0 0.1], radius = 0.1 ... for all channels.


Robert Oostenveld - 2013-11-19 14:36:39 +0100

ft_prepare_headmodel has the options % LOCALSPHERES % cfg.grad % cfg.tissue (see above; in combination with 'seg' input; default options are 'brain' or 'scalp') % cfg.feedback (optional) % cfg.radius (optional) % cfg.maxradius (optional) % cfg.baseline (optional) which have empty defaults and are passed in line 347 like this vol = ft_headmodel_localspheres(geometry, cfg.grad, 'feedback', cfg.feedback, 'radius', cfg.radius, 'maxradius', cfg.maxradius, 'baseline', cfg.baseline, 'singlesphere', cfg.singlesphere); that means that ft_headmodel_localspheres is setting the defaults and that those are in the incorrect units.


Robert Oostenveld - 2013-11-19 14:58:18 +0100

hmm, this is a user error. The cfg you specified has >> load('/home/common/matlab/fieldtrip/data/test/bug2375/localspheres_bug.mat'); >> cfg cfg = feedback: 'yes' showcallinfo: 'no' grad: [1x1 struct] radius: 85 maxradius: 200 method: 'localspheres' siunits: 'yes' So you have specified a radius of 85 meter. All 2562 headshape points fall within that radius and therefore it uses all points for all channels. With this it works fine % fix the cfg and try again cfg = rmfield(cfg, 'radius'); cfg = rmfield(cfg, 'maxradius'); vol = ft_prepare_headmodel(cfg, headshape);


Robert Oostenveld - 2013-11-19 15:02:37 +0100

Had cyou specified cfg.units = 'mm' and had ft_prepare_headmodel passed it on to ft_headmodel_localspheres, then your cfg would have worked. But we don't want ft_headmodel_xxx functions to do unit conversions, and apparently ft_prepare_headmodel was already not passing on units to some (but not all) of the ft_headmodel_xxx. functions It did trigger me to look at how units are passed to ft_headmodel_xxx functions. These now have it mac001> grep -l getopt.*unit ft_headmodel_* ft_headmodel_concentricspheres.m ft_headmodel_fns.m ft_headmodel_localspheres.m ft_headmodel_singlesphere.m and mac001> grep ft_headmodel.*unit ft_prepare_headmodel.m vol = ft_headmodel_singlesphere(geometry, 'conductivity', cfg.conductivity, 'unit', cfg.unit); vol = ft_headmodel_fns(data.seg, 'tissue', cfg.tissue, 'tissueval', cfg.tissueval, 'tissuecond', cfg.conductivity, 'sens', sens, 'transform', cfg.transform, 'unit', cfg.unit); So there are 4 ft_headmodel_xxx functions that right now could do something with units, and 2 that actually get the units. I will remove the units as input option from all ft_headmodel_xxx functions.


Robert Oostenveld - 2013-11-19 15:24:40 +0100

Do not allow the user to specify the units for the ft_headmodel_xxx functions, the geometry should be used to determine the units consistently: mac001> svn commit Sending forward/ft_headmodel_concentricspheres.m Sending forward/ft_headmodel_fns.m Sending forward/ft_headmodel_infinite.m Sending forward/ft_headmodel_localspheres.m Sending forward/ft_headmodel_singlesphere.m Sending ft_prepare_headmodel.m Transmitting file data ...... Committed revision 8817. Oh, and of course the units should be SI if you want to ensure that the forward models return correctly scaled leadfields.


Robert Oostenveld - 2013-11-19 15:26:23 +0100

Added test script. mac001> svn commit test/test_bug2375.m Adding test/test_bug2375.m Transmitting file data . Committed revision 8818.


Robert Oostenveld - 2014-02-24 10:56:29 +0100

I closed several bugs at once that all have been resolved for some time. If you disagree, please reopen.