Back to the main page.
Bug 1901 - changes in units seems to affect SPM
Status | CLOSED FIXED |
Reported | 2012-12-18 10:05:00 +0100 |
Modified | 2012-12-31 11:46:28 +0100 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | PC |
Operating System: | Mac OS |
Importance: | P3 normal |
Assigned to: | Robert Oostenveld |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Robert Oostenveld - 2012-12-18 10:05:21 +0100
On Wed, Dec 12, 2012 at 3:57 PM, Thomas FitzGerald wrote: HI Vladimir Gareth writing from Tom#s machine. Tom is using the custom head model. So starting with cfg = reducerank: 2 grad: [1x1 struct] channel: {274x1 cell} vol: [1x1 struct] grid: [1x1 struct] feedback: 'off' inwardshift: 0 where cfg.grid.resolution=5 cfg.vol= bnd: [1x1 struct] type: 'nolte' unit: 'mm' grid = ft_prepare_leadfield(cfg); we get only 10 dipoles in the grid. Changing gridstep to .05 (instead of 5) however and we get 9980. Is it possible that the units on the input to ft_prepare_leadfield have changed since the last release ?
Robert Oostenveld - 2012-12-18 10:05:29 +0100
On 12 Dec 2012, at 20:58, Vladimir Litvak wrote: Yes, that sounds like something that has to do with changes in units. I'm CCing Robert as in principle he's aiming to maintain backward compatibility and prevent this kind of things from happening so the exact reason is worth investigating. I hope there are no related problems for MSP and VB-ECD Vladimir
Robert Oostenveld - 2012-12-18 10:20:08 +0100
I made a test script (which I'll add to SVN later) and used it for debugging. I found the following piece of code (old already) in private/prepare_headmodel % ensure that the units are the same, if not, use cm as the default if ~strcmp(vol.unit, sens.unit) || ~strcmp(vol.unit, cfg.sourceunits) if isempty(cfg.sourceunits) cfg.sourceunits = 'cm'; end vol = ft_convert_units(vol, cfg.sourceunits); sens = ft_convert_units(sens, cfg.sourceunits); end See also http://code.google.com/p/fieldtrip/source/browse/trunk/private/prepare_headmodel.m#56 Here the code fails, because vol and sens both have mm, and still it converts to cm. That is due to cfg.sourceunits being initialized as empty (as default) and thereby the second strcmp failing.
Robert Oostenveld - 2012-12-18 10:21:21 +0100
I am to blame for the bug, see http://code.google.com/p/fieldtrip/source/diff?spec=svn6678&r=6678&format=side&path=/trunk/private/prepare_headmodel.m&old_path=/trunk/private/prepare_headmodel.m&old=5174
Robert Oostenveld - 2012-12-18 10:42:07 +0100
mac001> svn commit ../private/prepare_headmodel.m ./test_bug1901.m Sending private/prepare_headmodel.m Adding test/test_bug1901.m Transmitting file data .. Committed revision 7223. ------------------------------------------------------------------------ r7223 | roboos | 2012-12-18 10:41:37 +0100 (Tue, 18 Dec 2012) | 3 lines bugfix - the sourcemodel units were always converted to cm, also if the vol and grad input were in mm and cfg.sourceunits was not specified. This caused a problem for spm, see http://bugzilla.fcdonders.nl/show_bug.cgi?id=1901. Fixed and made a test script.