Back to the main page.

Bug 1796 - prepare_headmodel checks for vol.unit, but old headmodels do not have a .unit field

Status CLOSED FIXED
Reported 2012-10-29 15:18:00 +0100
Modified 2014-03-12 12:21:41 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P3 normal
Assigned to: Jörn M. Horschig
URL:
Tags:
Depends on:
Blocks:
See also:

Jörn M. Horschig - 2012-10-29 15:18:23 +0100

I wanted to re-do some analysis and found that my headmodel (vol) does not have a .unit field which causes prepare_headmodel and thereby ft_prepare_leadfield to fail. Of course I can (will) re-do the hdm computation, but because of backwards compatibility etc. it might be wise to make prepare_headmodel more robust.


Robert Oostenveld - 2012-10-29 15:38:51 +0100

You are referring to private/prepare_headmodel.m, right? I would have expected that prior to ending up in that function it would have passed through utilities/ft_datatype_headmodel.m and that that would have added add vol.unit using ft_convert_units. But it does not. Also ft_datatype_headmodel states that vol.unit is optional. Looking at the code, it does seem to be added at the relevant pieces mac001> grep 'ft_convert_units(vol)' *.m ft_prepare_bemmodel.m:vol = ft_convert_units(vol); ft_prepare_concentricspheres.m:vol = ft_convert_units(vol); ft_prepare_headmodel.m: vol = ft_convert_units(vol); ft_prepare_localspheres.m:vol = ft_convert_units(vol); ft_prepare_singleshell.m:vol = ft_convert_units(vol); The one in ft_prepare_headmodel (the new function) is the perfect example % ensure that the geometrical units are specified if ~ft_voltype(vol, 'infinite'), vol = ft_convert_units(vol); end please add that to ft_datatype_headmodel.


Jörn M. Horschig - 2012-10-29 16:12:54 +0100

yep, that's does it, thanks! although in the meanwhile, I also re-created my headmodels - let's see what has changed ;) svn ci utilities/ft_datatype_headmodel.m -m "bugfix-#1796-adding a unit field by default to the headmodel structure" Sending utilities/ft_datatype_headmodel.m Transmitting file data . Committed revision 6805.


Robert Oostenveld - 2012-10-29 21:35:48 +0100

(In reply to comment #2) I am getting some problems with a certain script. There is now an infinite recursion due to ft_voltype calling ft_datatype_headmodel and vice versa. The reason for the ft_voltype call is to detect the infinite model. The reason for wanting to detect infinite is that can have arbitrary units. The consequence of the arbitrary units is that ft_convert_units failed on the infinite volume conductor. That is something that can be fixed... mac001> svn commit forward/ft_convert_units.m Sending forward/ft_convert_units.m Transmitting file data . Committed revision 6814. I changed a small bit to your change. mac001> svn commit forward/private/ft_datatype_headmodel.m Sending forward/private/ft_datatype_headmodel.m Transmitting file data . Committed revision 6816.