Back to the main page.
Bug 1832 - ensure that the MNI template grid works without the user having to deal with unit conversions
Status | ASSIGNED |
Reported | 2012-11-14 13:18:00 +0100 |
Modified | 2013-11-20 14:56:38 +0100 |
Product: | FieldTrip |
Component: | documentation |
Version: | unspecified |
Hardware: | PC |
Operating System: | Windows |
Importance: | P3 normal |
Assigned to: | Robert Oostenveld |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Roemer van der Meij - 2012-11-14 13:18:41 +0100
it includes the following code % NOTE: the path to the template file is user-specific template = ft_read_mri('~/matlab/fieldtrip/external/spm8/templates/T1.nii'); template.coordsys = 'spm'; % so that FieldTrip knows how to interpret the coordinate system % segment the template brain and construct a volume conduction model (i.e. head model): this is needed % for the inside/outside detection of voxels. cfg = []; template_seg = ft_volumesegment(cfg, template); cfg = []; cfg.method = 'singleshell'; template_vol = ft_prepare_headmodel(cfg, template_seg); % construct the dipole grid in the template brain coordinates % the source units are in cm % the negative inwardshift means an outward shift of the brain surface for inside/outside detection cfg = []; cfg.grid.xgrid = -20:1:20; cfg.grid.ygrid = -20:1:20; cfg.grid.zgrid = -20:1:20; cfg.grid.tight = 'yes'; cfg.inwardshift = -1.5; cfg.vol = template_vol; template_grid = ft_prepare_sourcemodel(cfg); The different FT objects (structures) should all have the field "unit" with either mm, cm or m. TODO: 1) make test script that checks on the units in these objects (with assert) 2) also go through the rest of the example script and check on units
Jörn M. Horschig - 2012-11-14 16:50:19 +0100
turns out that I was misunderstanding Zuka, and the conversion was not necessary. I will make the testscript anyway and check, cannot harm to have that
Jörn M. Horschig - 2012-12-12 10:37:01 +0100
template_grid has no .units should it take over those from the vol?
Jörn M. Horschig - 2012-12-12 10:37:50 +0100
adding the wise bosses to CC, cause they might know whether a template_grid should have a .unit field. Should it?
Robert Oostenveld - 2012-12-12 10:50:45 +0100
(In reply to comment #3) The unit field is optional in many data structures, so not required, but still desired. If an input object from a mat file does not have a unit field, somewhere along the line ft_convert_units would be called, which together with ft_estimate_units would assign the correct units. When the object is created from the most recent FieldTrip version itself, it should have units. Related to this code, I suggest to test for in the following cfg = ... template_seg = ft_volumesegment(cfg, template); cfg = ... template_vol = ft_prepare_headmodel(cfg, template_seg); cfg = ... template_grid = ft_prepare_sourcemodel(cfg); each of the outputs having a unit. What happens if you take a grid with mm and a vol with cm and do ft_prepare_leadfield? Or with an cfg.grad that is inconsistent?
Jörn M. Horschig - 2012-12-12 10:56:19 +0100
(In reply to comment #4) if vol has .unit and I call cfg = ... cfg.vol = template_vol; template_grid = ft_prepare_sourcemodel(cfg); then template_grid does not have .unit currently gonna check the leadfield stuff after the group meeting
Jan-Mathijs Schoffelen - 2012-12-12 10:58:21 +0100
just call ft_convert_units(template_grid)
Robert Oostenveld - 2012-12-12 11:07:28 +0100
(In reply to comment #6) who should call this, the FT function or the user?
Jan-Mathijs Schoffelen - 2012-12-12 11:09:23 +0100
I don't care
Jörn M. Horschig - 2013-01-31 11:25:17 +0100
I do care, cause it's my bug ;) so?
Jörn M. Horschig - 2013-01-31 11:26:03 +0100
readded JM, cause he didn' care but I'd like him to care ;)
Jörn M. Horschig - 2013-07-24 12:35:29 +0200
okay, the grid issue seems to be resolved. new issue: template_grid = xgrid: [-70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70] ygrid: [-90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50] zgrid: [-60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80] dim: [15 15 15] pos: [3375x3 double] unit: 'mm' % prepare leadfield cfg = []; cfg.grid = template_grid; cfg.vol = template_vol; cfg.channel = 'EEG'; cfg.elec = ft_read_sens('standard_1020.elc'); template_grid_lf = ft_prepare_leadfield(cfg) template_grid_lf = pos: [3375x3 double] dim: [15 15 15] xgrid: [-70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70] ygrid: [-90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50] zgrid: [-60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80] unit: 'cm' whoopsy, what's going on there, change of unit without conversion? The pos-field is actually converted properly, but the xgrid/ygrid/zgrid variables not, which make this look a bit weird. action: remove xgrid/ygrid/zgrid?
Jörn M. Horschig - 2013-07-24 12:37:17 +0200
another minor question: the leadfield structure is always in 'cm', no matter what the input units are. fine with primates, but strange when someone wants to do this on a mosquito brain