Back to the main page.

Bug 2355 - get rid of the cfg.sourceunits option

Status CLOSED FIXED
Reported 2013-10-31 15:52:00 +0100
Modified 2014-02-24 10:56:20 +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: 1794
See also:

Robert Oostenveld - 2013-10-31 15:52:08 +0100

related to preparing spm12 the geometrical units have to be dealt with more consistently. After discussion with JM, we decided that the cfg.sourceunits has to be removed from the code. It seems primarily to be used in ft_prepare_sourcemodel.m and functions that rely on ft_prepare_sourcemodel.m. For spm12 support (and consistent leadfield units etc) we have decided that the output of ft_prepare_headmodel should from now on be in SI units, i.e. in meter, and that units of vol are not to be changed afterwards. Affected functions include mac001> grep cfg.sourceunit *.m ft_dipolefitting.m: try, tmpcfg.sourceunits = cfg.sourceunits; end ft_megrealign.m:try, tmpcfg.sourceunits = cfg.sourceunits; end ft_prepare_headmodel.m:cfg.sourceunits = ft_getopt(cfg, 'sourceunits'); ft_prepare_leadfield.m:% cfg.sourceunits = ft_getopt(cfg, 'sourceunits'); % the default for this is set inside prepare_headmodel ft_prepare_leadfield.m:try, tmpcfg.sourceunits = cfg.sourceunits; end ft_prepare_localspheres.m:if ~isfield(cfg, 'sourceunits'), cfg.sourceunits = 'cm'; end ft_prepare_sourcemodel.m:% cfg.sourceunits = 'auto' (in which case the sourceunits default to the unit in the ft_prepare_sourcemodel.m:% cfg.sourceunits = 'auto'(in which case the sourceunits default to the unit in the ft_prepare_sourcemodel.m:% cfg.sourceunits = 'auto' (in which case the sourceunits default to the unit in the ft_prepare_sourcemodel.m:% cfg.sourceunits ft_prepare_sourcemodel.m: cfg.sourceunits = ft_getopt(cfg, 'sourceunits', 'auto'); ft_prepare_sourcemodel.m: cfg.sourceunits = ft_getopt(cfg, 'sourceunits', 'auto'); ft_prepare_sourcemodel.m: cfg.sourceunits = ft_getopt(cfg, 'sourceunits', 'auto'); ft_prepare_sourcemodel.m: cfg.sourceunits = ft_getopt(cfg, 'sourceunits', 'auto'); ft_prepare_sourcemodel.m:% ensure cfg.sourceunits to have a value and/or enforce the units in the sensors ft_prepare_sourcemodel.m: if strcmp(cfg.sourceunits, 'auto') && ~isfield(sens, 'unit') ft_prepare_sourcemodel.m: cfg.sourceunits = sens.unit; ft_prepare_sourcemodel.m: elseif strcmp(cfg.sourceunits, 'auto') && isfield(sens, 'unit') ft_prepare_sourcemodel.m: cfg.sourceunits = sens.unit; ft_prepare_sourcemodel.m: elseif ~strcmp(cfg.sourceunits, 'auto') ft_prepare_sourcemodel.m: sens = ft_convert_units(sens, cfg.sourceunits); ft_prepare_sourcemodel.m: if strcmp(cfg.sourceunits, 'auto') ft_prepare_sourcemodel.m: cfg.sourceunits = 'cm'; ft_prepare_sourcemodel.m:% ensure the vol to have the same units as cfg.sourceunits ft_prepare_sourcemodel.m: vol = ft_convert_units(vol, cfg.sourceunits); ft_prepare_sourcemodel.m: grid = ft_convert_units(grid, cfg.sourceunits); ft_prepare_sourcemodel.m: switch cfg.sourceunits ft_prepare_sourcemodel.m: scale = scalingfactor(cfg.sourceunits, mri.unit); ft_prepare_sourcemodel.m: grid.unit = cfg.sourceunits; ft_prepare_sourcemodel.m: grid = ft_convert_units(grid, cfg.sourceunits); ft_sourceanalysis.m: try, tmpcfg.sourceunits = cfg.sourceunits; end


Robert Oostenveld - 2013-10-31 16:33:51 +0100

any function that calls ft_compute_leadfield(pos, vol, sens) has to ensure that grid.pos (which is the 1st input argument) and grid.unit are consistent with sens.unit and pos.unit.


Robert Oostenveld - 2013-11-01 12:31:40 +0100

The following test scripts exist that are to be considered in updating the code: mac001> grep -l ft_prepare_sourcemodel *.m test_bug1040.m test_bug1794.m test_bug1832.m test_bug1901.m test_bug1956.m test_bug2355.m test_ft_prepare_sourcemodel.m test_headmodel_simbio.m test_tutorial_beamforming_extended.m


Robert Oostenveld - 2013-11-01 14:25:29 +0100

I replaced cfg.sourceunits by cfg.grid.unit in ft_prepare_sourcemodel mac001> svn commit test/test_bug2355.m ft_prepare_sourcemodel.m Sending ft_prepare_sourcemodel.m Adding test/test_bug2355.m Transmitting file data .. Committed revision 8691. mac001> svn commit utilities/ft_checkconfig.m Sending utilities/ft_checkconfig.m Transmitting file data . Committed revision 8692.


Robert Oostenveld - 2013-11-01 14:31:28 +0100

together with mac001> svn commit Sending fileio/ft_read_header.m Sending forward/ft_compute_leadfield.m Sending forward/ft_convert_units.m Sending ft_prepare_headmodel.m Sending ft_prepare_leadfield.m Sending ft_prepare_mesh.m Sending ft_volumerealign.m Sending private/bounding_mesh.m Sending private/prepare_headmodel.m Sending test/test_bug1956.m Sending utilities/ft_datatype_sens.m Transmitting file data ........... Committed revision 8695. which pertains to a collection of SPM12 related changes, I think that it now should be resolved. There is a test script for backward compatibility testing.


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

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