[FieldTrip] unit problem when following example script: Create MNI-aligned grids in individual head-space BUG?
Ingrid Nieuwenhuis
inieuwenhuis at berkeley.edu
Fri Apr 12 19:51:34 CEST 2013
Thanks both,
I do agree it's a bug then, because the units are known to the functions
and they should not behave like this. The units should be converted
automatically, or an error should appear telling the user to convert
units to match. Anyway, a bugs already filed and a work around is
possible, so all good. By the way, I also found a way around my self
that might be useful for others to know. There are templates in
FieldTrip now (great all this pre-made stuff). So I just did below, and
voila :)
Thanks,
Ingrid
%%% my work around %%%
load('standard_sourcemodel3d7point5mm')
% read the single subject anatomical MRI
mri = ft_read_mri(['D:\FT_DATA\Subject01', filesep, 'Subject01.mri']);
% create the subject specific grid, using the template grid that has
just been loaded
cfg = [];
cfg.grid.warpmni = 'yes';
cfg.grid.template = sourcemodel;
cfg.grid.nonlinear = 'yes'; % use non-linear normalization
cfg.mri = mri;
cfg.sourceunits = 'mm';
grid = ft_prepare_sourcemodel(cfg);
On 4/12/2013 1:14 AM, Erik te Woerd wrote:
> Hi Ingrid,
>
> I also encountered this problem when following the tutorial, but was
> able to solve it in the way Diego suggests it below. While following
> the tutorial, all variables should be returned with corresponding
> units, but in ft_prepare_headmodel this doesn't work.
> I reported it already to bugzilla and it's being looked after...
>
> Best,
>
> Erik
>
>
> 2013/4/12 Diego Lozano Soldevilla <d.lozanosoldevilla at fcdonders.ru.nl
> <mailto:d.lozanosoldevilla at fcdonders.ru.nl>>
>
> Hi Ingrid,
>
> I had similar problem with MEG and changing the units with
> ft_convert_units solved the issue:
>
> vol = ft_convert_units(vol,'cm')
>
> If not, please file a bug with a piece of data and I'll have a look,
>
> best,
>
> Diego
>
>
>
>
> On 11 April 2013 20:30, Ingrid Nieuwenhuis
> <inieuwenhuis at berkeley.edu <mailto:inieuwenhuis at berkeley.edu>> wrote:
>
> Hi all,
>
> When I follow the code according to the example matlab script
> "Create MNI-aligned grids in individual head-space" something
> goes all wrong with the units.
>
> I've followed the code (pasted below, from the wiki), but when
> I make the figure with the template head model and dipole
> grid, it's wrong (see attached ..._problem.png). The dipole
> grid is tiny in the bottom of the head model. The black area
> is the dipole grid, not good.
> template_grid =
> xgrid: [1x41 double]
> ygrid: [1x41 double]
> zgrid: [1x41 double]
> dim: [41 41 41]
> pos: [68921x3 double]
> unit: 'mm'
> inside: [1x68910 double]
> outside: [758 759 760 761 799 800 801 802 843 884 925]
> cfg: [1x1 struct]
>
> It's a problem with the units, because the template grid has
> 'mm' in the unit field, but when I look in the xgrid, ygrid,
> zgrid and pos fields the numbers are clearly cm not mm.
> However, when I multiply my xyzgrid and pos field by 10, the
> grid is not tight (see attached ..._multiplied10.png). It
> looks like the unit problem messed up the determination of
> what's inside and outside. As you can see in the
> template_grid, there are only a few grid point outside, which
> is clearly not correct (maybe inside/outside was determined on
> wrong units?).
>
> So, it looks like a bug to me, or am I doing something wrong?
> I'm using the newest FT version.
>
> Thanks,
> Ingrid
>
> %%% CODE FROM WIKI %%%
> template = ft_read_mri([cur_path_FT 'external',
> filesep, 'spm8', filesep,'templates', filesep,'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.unit = 'cm';
> cfg.grid.tight = 'yes';
> cfg.inwardshift = -1.5;
> cfg.vol = template_vol;
> template_grid = ft_prepare_sourcemodel(cfg);
>
> % make a figure with the template head model and dipole grid
> figure
> hold on
> ft_plot_vol(template_vol);
> ft_plot_mesh(template_grid);
>
> --
> Ingrid Nieuwenhuis PhD
> Postdoctoral Fellow
> Sleep and Neuroimaging Laboratory
> Department of Psychology
> University of California, Berkeley
> California 94720-1650
> Tolman Hall, room 5305
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl <mailto:fieldtrip at donders.ru.nl>
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl <mailto:fieldtrip at donders.ru.nl>
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
--
Ingrid Nieuwenhuis PhD
Postdoctoral Fellow
Sleep and Neuroimaging Laboratory
Department of Psychology
University of California, Berkeley
California 94720-1650
Tolman Hall, room 5305
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20130412/c6498649/attachment-0002.html>
More information about the fieldtrip
mailing list