Back to the main page.

Bug 2755 - ft_convert_units ignores grid.resolution

Status CLOSED FIXED
Reported 2014-11-05 23:35:00 +0100
Modified 2015-02-11 10:40:39 +0100
Product: FieldTrip
Component: forward
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also: http://bugzilla.fcdonders.nl/show_bug.cgi?id=1983

Marc Lalancette - 2014-11-05 23:35:34 +0100

ft_prepare_leadfield calls prepare_headmodel before ft_prepare_sourcemodel. prepare_headmodel may call ft_convert_units to convert cfg.grid units, for example when using cfg.siunits = 'yes', but the grid may not have been "constructed" yet, for example: cfg.grid.resolution = 1; cfg.grid.unit = 'cm'; Because ft_convert_units ignores the resolution field, the grid will not be as the user intended, e.g. with siunits = 'yes', it becomes a grid with 1 m resolution. By the way, I just found and started using siunits='yes' now, to minimize the number of explicit conversions in my code. I think it should be mentioned in the documentation of ft_prepare/compute_headmodel. Without this option, lead field units and thus projected power and moment units are "unusual", as I found out a little while ago and mentioned in a post: http://mailman.science.ru.nl/pipermail/fieldtrip/2014-September/008438.html I also noted that while ft_compute_leadfield has options to specify units (chanunit, dipoleunit), ft_prepare_leadfield does not provide access to them, so I still have to "manually" convert to get say fT/Am. I'm guessing this is still on the to-do list related to http://bugzilla.fcdonders.nl/show_bug.cgi?id=686


Marc Lalancette - 2014-11-06 00:11:39 +0100

Fix: ft_convert_units line 191, insert: if isfield(obj, 'resolution'), obj.resolution = scale * obj.resolution; end % x,y,zgrid can also be 'auto' if isfield(obj, 'xgrid') && ~ischar(obj.xgrid), obj.xgrid = scale * obj.xgrid; end if isfield(obj, 'ygrid') && ~ischar(obj.ygrid), obj.ygrid = scale * obj.ygrid; end if isfield(obj, 'zgrid') && ~ischar(obj.zgrid), obj.zgrid = scale * obj.zgrid; end Not sure if there are other potential grid fields that should also be converted.


Marc Lalancette - 2014-11-06 00:13:30 +0100

(In reply to Marc Lalancette from comment #1) Actually, dipole grid is a bit lower, so insert at line 216.


Robert Oostenveld - 2014-11-08 12:33:14 +0100

(In reply to Marc Lalancette from comment #2) thanks, done. mac011> svn commit forward/ft_convert_units.m Sending forward/ft_convert_units.m Transmitting file data . Committed revision 9941.


Robert Oostenveld - 2015-02-11 10:40:39 +0100

Closed several bugs that were recently resolved. Please reopen if you are not happy with the resolution.