Back to the main page.

Bug 2551 - sourcemodel from disk contains many dipoles outside of brain (singleshell)

Status CLOSED INVALID
Reported 2014-04-30 11:19:00 +0200
Modified 2015-10-06 01:22:55 +0200
Product: FieldTrip
Component: forward
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Roemer van der Meij
URL:
Tags:
Depends on:
Blocks:
See also:

Roemer van der Meij - 2014-04-30 11:19:40 +0200

Perhaps I'm missing something obvious, but when plotting the headmodel and the sourcemodel's dipoles there shouldn't be any dipoles outside of the headmodel (I understood it this way from the example script, FAQ and an answer from Robert on the mailing list). Attached are 4 figures. All display sourcemodels at 10mm resolution and a headmodel. 1) sourcemodel from disk and headmodel from disk (cfg.inwardshift=0) 2) sourcemodel from disk and generated headmodel (cfg.inwardshift=0) 3) generated sourcemodel and generated headmodel (cfg.inwardshift=0) 3) generated sourcemodel and generated headmodel (cfg.inwardshift=-1.5) Number 1 and 2 show many dipoles outside of the brain (approx. half of them). Number 3 contains the same ingredients, only they were generated anew. All of them have in their cfg an inwardshift of 0. However, the first two look as if they are generated with an inward shift of about -1.5 (outward). Figure 4 is the same as 3, but with an inwardshift = -1.5. (I included figure 2 to be sure it was not related to the headmodel on disk being generated in an older version. Note the small difference in headmodels in fig 1 and 2) I found this while warping an individual's grid in MNI space via ft_prepare_sourcemodel. Below is the code that generates the figures. Am I missing something silly here? % set path fieldtrippath = '~/fieldtrip-dev/'; %%%%%% figure 1 % load headmodel and sourcemodel templatehdmfn = [fieldtrippath 'template/headmodel/standard_singleshell.mat']; templatehdm = load(templatehdmfn); templatesourcemodel = load('~/fieldtrip-dev/template/sourcemodel/standard_sourcemodel3d10mm.mat'); figure hold on ft_plot_vol(templatehdm.vol, 'facecolor', 'cortex', 'edgecolor', 'none');alpha 0.5; camlight; ft_plot_mesh(templatesourcemodel.sourcemodel.pos(templatesourcemodel.sourcemodel.inside,:)); %%%%%% %%%%%% figure 2 % generate headmodel and load sourcemodel templatemrifn = [fieldtrippath 'external/spm8/templates/T1.nii']; templatemri = ft_read_mri(templatemrifn); templatemri.coordsys = 'spm'; cfg = []; templateseg = ft_volumesegment(cfg, templatemri); templateseg = ft_convert_units(templateseg,'cm'); cfg = []; cfg.method = 'singleshell'; templatehdm = ft_prepare_headmodel(cfg, templateseg); templatehdm = ft_convert_units(templatehdm, 'cm'); % Convert the vol to cm, since the grid will also be expressed in cm % load sourcemodel templatesourcefn = '~/fieldtrip-dev/template/sourcemodel/standard_sourcemodel3d10mm.mat'; templatesourcemodel = load(templatesourcefn); figure hold on ft_plot_vol(templatehdm, 'facecolor', 'cortex', 'edgecolor', 'none');alpha 0.5; camlight; ft_plot_mesh(templatesourcemodel.sourcemodel.pos(templatesourcemodel.sourcemodel.inside,:)); %%%%%% %%%%%% figure 3 % generate headmodel and generate sourcemodel % templatemrifn = [fieldtrippath 'external/spm8/templates/T1.nii']; % templatemri = ft_read_mri(templatemrifn); % templatemri.coordsys = 'spm'; % cfg = []; % templateseg = ft_volumesegment(cfg, templatemri); % templateseg = ft_convert_units(templateseg,'cm'); cfg = []; cfg.method = 'singleshell'; templatehdm = ft_prepare_headmodel(cfg, templateseg); templatehdm = ft_convert_units(templatehdm, 'cm'); % Convert the vol to cm, since the grid will also be expressed in cm % construct sourcemodel 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 = 0; cfg.vol = templatehdm; templatesourcemodel = ft_prepare_sourcemodel(cfg); % make a figure with the template head model and dipole grid figure hold on ft_plot_vol(templatehdm, 'facecolor', 'cortex', 'edgecolor', 'none');alpha 0.5; camlight; ft_plot_mesh(templatesourcemodel.pos(templatesourcemodel.inside,:)); %%%%%% %%%%%% figure 4 % generate headmodel and generate sourcemodel % templatemrifn = [fieldtrippath 'external/spm8/templates/T1.nii']; % templatemri = ft_read_mri(templatemrifn); % templatemri.coordsys = 'spm'; % cfg = []; % templateseg = ft_volumesegment(cfg, templatemri); % templateseg = ft_convert_units(templateseg,'cm'); cfg = []; cfg.method = 'singleshell'; templatehdm = ft_prepare_headmodel(cfg, templateseg); templatehdm = ft_convert_units(templatehdm, 'cm'); % Convert the vol to cm, since the grid will also be expressed in cm % construct sourcemodel 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 = templatehdm; templatesourcemodel = ft_prepare_sourcemodel(cfg); % make a figure with the template head model and dipole grid figure hold on ft_plot_vol(templatehdm, 'facecolor', 'cortex', 'edgecolor', 'none');alpha 0.5; camlight; ft_plot_mesh(templatesourcemodel.pos(templatesourcemodel.inside,:)); %%%%%%


Roemer van der Meij - 2014-04-30 11:20:18 +0200

Created attachment 615 fig1


Roemer van der Meij - 2014-04-30 11:20:42 +0200

Created attachment 616 fig2


Roemer van der Meij - 2014-04-30 11:21:04 +0200

Created attachment 617 fig3


Roemer van der Meij - 2014-04-30 11:21:20 +0200

Created attachment 618 fig4


Roemer van der Meij - 2014-04-30 11:38:51 +0200

To make it explicit, I could be a total idiot here :). As the example script below makes it seem completely normal that there are dipoles outside of the shell: http://fieldtrip.fcdonders.nl/example/create_single-subject_grids_in_individual_head_space_that_are_all_aligned_in_mni_space However, this other FAQ makes it it seem very abnormal: http://fieldtrip.fcdonders.nl/faq/why_is_there_a_rim_around_the_brain_for_which_the_source_reconstruction_is_not_computed I created this bug because cfg.inwardshift = 0 in the sourcemodels on disk, but the results suggest an actual cfg.inwardshift = -1.5, and because of the incongruence of the above.


Robert Oostenveld - 2014-04-30 12:04:04 +0200

Please try >> ft_plot_mesh(sourcemodel.pos(sourcemodel.inside,:), 'vertexcolor', 'r') >> ft_plot_mesh(sourcemodel.pos(sourcemodel.outside,:), 'vertexcolor', 'b') and then rotate the figure in 3D The source model describes a regular 3-D grid that is 18x21x18. Not all grid points are inside the brain compartment, so for those the lead field and source estimates are not to be computed. The inside/outside specification is used to flag grid points that are inside/outside the brain compartment. I won't judge you along the http://en.wikipedia.org/wiki/DSM-5 scales, but I don't see any issue with it.


Roemer van der Meij - 2014-04-30 12:34:10 +0200

Haha, dear god no, at least judge me by DSM4R! ;) I understand that the inside/outside fields mark which dipole positions are inside or outside the brain compartment, and is used as a flag to compute leadfields/filters/etc for only those positions that we would want to. I guess there is no harm done if positions are included which accidentally outside? During plotting they are automatically discarded I think, statistics I do not know. However, it still is unnecessary computation if they are mislabeled as 'inside', right? Or is the labeling correct and I am still missing something? In the attached figures I only plotted 'inside' grid points. In fig 5 now attached I plot both and mark them as red/blue (inside/outside). So this (fig5) really does not reflect a mislabeling?


Roemer van der Meij - 2014-04-30 12:34:44 +0200

Created attachment 619 fig5


Robert Oostenveld - 2014-04-30 15:34:01 +0200

we discussed this at the FT meeting. Roemer will make a faq that explains it, using a spherical volume conductor and source points that are inside a proper brain compartment.


Roemer van der Meij - 2014-04-30 18:42:33 +0200

Hey Robert, I made a 'opzetje' for a FAQ here: http://fieldtrip.fcdonders.nl/faq/is_it_good_or_bad_to_have_dipole_locations_outside_of_the_brain_for_which_the_source_reconstruction_is_computed I think it contains most of the elements we talked about? I tried to phrase it as simple as possible. I'm not sure on some details, specifically some of the yes/no statements I make. Could you use your Hammer-of-Purity on this?


Roemer van der Meij - 2015-10-06 01:22:55 +0200

Closing old resolved bugs