[FieldTrip] Issue plotting Brainnetome aligned EEG source data
Schoffelen, J.M. (Jan Mathijs)
janmathijs.schoffelen at donders.ru.nl
Thu Jul 1 08:42:32 CEST 2021
Hi Jack,
It is a bit unclear to me what the relevance of the atlas is in all this.
It seems that you encounter an issue with visualization, where the on-the-fly interpolation from a volumetric representation to a surface results in - for you - unexpected interpolation effects. Specifically, there are vertices in the surface mesh that get assigned a ’nan’ functional value, probably because those vertices are in (or too close to) the ‘~inside’ compartment of the volumetric grid.
The solution to this would be to create your source model with a little bit of inwardshift. This is a cfg option for ft_prepare_sourcemodel, please consult the function’s documentation and the website for how to use this.
The atlas should not be used a priori to define the ‘inside’ compartment. You can map the dipoles onto the anatomical parcels after you performed the source reconstruction.
Best wishes,
Jan-Mathijs
> On 1 Jul 2021, at 05:57, Jack Fogarty via fieldtrip <fieldtrip at science.ru.nl> wrote:
>
> Hi everyone,
>
> After more digging it appears I have a similar issue as to the one pointed out in this previous request to the FT mailing list although there doesn't appear to be a clear solution. See, "surface plot with atlas limited template_grid.inside ", at
> https://mailman.science.ru.nl/pipermail/fieldtrip/2017-June/024483.html
>
> Essentially, when I use ft_sourceplot to display my source results on a surface there are 'holes' or empty vertices on the surface, where it looks like the data is missing or not interpolated to the default surface file. I've created a template grid aligned to the brainnetome atlas for my source analyses and I am wondering if it is not compatible or there is simply an issue with 'source interpolate'.
>
> Has anyone come across this and/or know why it occurs and if there is a solution?
>
> It should be possible to replicate and visualise the same (or at least a visually similar) issue by plotting template grid 'inside values' with this code:
>
> ft_defaults
> [ftver, ftpath] = ft_version;
>
> % Load the Headmodel
> load(fullfile(ftpath, 'template/headmodel/standard_bem.mat'));
>
> % Prepare the template grid 'standard sourcemodel'
> cfg = [];
> cfg.xgrid = 'auto';
> cfg.ygrid = 'auto';
> cfg.zgrid = 'auto';
> cfg.unit = 'mm';
> cfg.tight = 'yes';
> cfg.resolution = 7;
> cfg.headmodel = vol;
> template_grid = ft_prepare_sourcemodel(cfg);
>
> % Read in Brainnetome Atlas; ensure its units are consistent with template
> atlas = ft_read_atlas(fullfile(ftpath, 'template/atlas/brainnetome/BNA_MPM_thr25_1.25mm.nii'));
>
> % Ensure units are consistent between atlas and sourcemodel
> atlas = ft_convert_units(atlas,'mm');
> template_grid = ft_convert_units(template_grid,'mm');
>
> % Check the coordsys field exists in sourcemodel
> if ~isfield(template_grid, 'coordsys');
> template_grid.coordsys = 'mni';
> end
>
> % Create binary mask for all grid points inside the Brainnetome atlas locations
> cfg = [];
> cfg.atlas = atlas;
> cfg.roi = atlas.tissuelabel; % here you can also specify a single label, i.e. single ROI
> cfg.inputcoord = 'mni';
> mask = ft_volumelookup(cfg, template_grid);
>
> template_grid.inside = false(template_grid.dim);
> template_grid.inside(mask == 1) = true;
>
> cfg = [];
> cfg.method = 'surface';
> cfg.funparameter = 'inside';
> cfg.funcolormap = 'hsv';
> ft_sourceplot(cfg,template_grid);
>
> Cheers,
> Jack
>
>
>
> Message: 1
> Date: Wed, 30 Jun 2021 10:20:22 +0000
> From: Jack Fogarty <jf752 at uowmail.edu.au>
> To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
> Subject: [FieldTrip] Issue plotting Brainnetome aligned EEG source
> data
> Message-ID:
> <SYBPR01MB5308E7903F7D080B1F042675C2019 at SYBPR01MB5308.ausprd01.prod.outlook.com>
>
> Content-Type: text/plain; charset="utf-8"
>
> Hello Fieldtrippers!
>
> Apologies for the long email, but I am hoping that I can get some help working with the Brainnetome atlas.
>
> Background
>
> Ultimately, I want to explore EEG connectivity between Brainnetome ROIs. I don't have individual MRI data, just resting EEG, so I am first trying to develop a standard template grid (sourcemodel) aligned to the Brainnetome atlas so I can explore EEG source analyses and easily examine the output in terms of the Brainnetome ROIs. I am following this Fieldtrip tutorial to create a template grid using the standard BEM and Brainnetome atlas provided by Fieldtrip. I went with this because I had trouble interpolating to the Brainnetome atlas and this seemed like an efficient way to create a standard template that I could apply to multiple subjects:
> https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/example/create_single-subject_grids_in_individual_head_space_that_are_all_aligned_in_brain_atlas_based_mni_space/__;!!HJOPV4FYYWzcc1jazlU!qxNYm5UX4r247zxfCBJ131UKIxbWXgzqM0w90neZ3KOfI1PkrlTTd0PH_LB64dBWEwQgYvR3qz0yU2Q$
>
> Issue
>
> My code runs, but whenever I attempt to plot my source results using ft_sourceplot it seems that some data is not interpolated to parts of the brain surface. I'm not sure, but I believe this could be an issue in the ft_volumelookup stage; that is, when I create a binary mask of all locations in the template grid that match the atlas locations, some grid points may be missed and considered 'empty'. Is there a specific problem in my code causing this? Or a way to address it so that I am capturing all the data in the analysis and/or plotting stages?
>
> I have attached an image of the final plot with the funny/missing data (which appears as the grey patches on some gyri) and my code is below. Any help would be really appreciated.
>
> Thanks,
> Jack
>
> [cid:image003.png at 01D76DED.5573FB20]
>
> My code is here:
>
> %% Generate standard BEM template aligned to Brainnetome atlas
>
> ft_defaults
> [ftver, ftpath] = ft_version;
>
> % Load the Headmodel
> load(fullfile(ftpath, 'template/headmodel/standard_bem.mat')); % Colin27
>
> % Prepare the template grid 'standard sourcemodel'
> cfg = [];
> cfg.xgrid = 'auto';
> cfg.ygrid = 'auto';
> cfg.zgrid = 'auto';
> cfg.unit = 'mm';
> cfg.tight = 'yes';
> cfg.resolution = 7;
> cfg.headmodel = vol;
> template_grid = ft_prepare_sourcemodel(cfg);
>
> % Check alignment of the template grid and headmodel
> figure;
> hold on
> ft_plot_mesh(template_grid.pos(template_grid.inside,:));
> ft_plot_headmodel(vol, 'facecolor', 'cortex', 'edgecolor', 'none');
> ft_plot_axes(vol);
> alpha 0.5
> camlight
>
> % Read in Brainnetome Atlas; ensure its units are consistent with template
> atlas = ft_read_atlas(fullfile(ftpath, 'template/atlas/brainnetome/BNA_MPM_thr25_1.25mm.nii'));
>
> % Ensure units are consistent between atlas and sourcemodel
> atlas = ft_convert_units(atlas,'mm');
> template_grid = ft_convert_units(template_grid,'mm');
>
> % Check the coordsys field exists in sourcemodel
> if ~isfield(template_grid, 'coordsys');
> template_grid.coordsys = 'mni';
> end
>
> % Create binary mask for all grid points inside the Brainnetome atlas locations
> cfg = [];
> cfg.atlas = atlas;
> cfg.roi = atlas.tissuelabel; % here you can also specify a single label, i.e. single ROI
> cfg.inputcoord = 'mni';
> mask = ft_volumelookup(cfg, template_grid);
> template_grid.inside = false(template_grid.dim);
> template_grid.inside(mask == 1) = true;
>
> % Check grid points inside the Brainnetome atlas
> figure;
> ft_plot_mesh(template_grid.pos(template_grid.inside,:),'vertexcolor','black','vertexalpha',0.5);
>
> clearvars -except atlas template_grid vol
>
> %% EEG source analysis and plotting
>
> setenv('PATH', 'C:\Program Files\OpenMEEG\bin');
> setenv('LD_LIBRARY_PATH', 'C:\Program Files\OpenMEEG\lib');
>
> % Load preprocessed EEG data
> load('C:\Users\jf752\Desktop\Processing\source_analysis\test_data');
>
> % Realign electrodes
> cfg = [];
> cfg.method = 'interactive';
> cfg.headshape = vol.bnd(1);
> cfg.elec = cln_data.elec;
> elec_aligned = ft_electroderealign(cfg);
>
> cln_data.elec = elec_aligned;
>
> % Prepare the Leadfield
> cfg = [];
> cfg.elec = cln_data.elec;
> cfg.channel = cln_data.label;
> cfg.headmodel = vol;
> cfg.sourcemodel.pos = template_grid.pos;
>
> leadfield = ft_prepare_leadfield(cfg);
>
> % Run Frequency Analysis
> cfg = [];
> cfg.method = 'mtmfft';
> cfg.output = 'powandcsd';
> cfg.keeptrials = 'yes';
> cfg.tapsmofrq = 1;
> cfg.foi = 10;
> freq = ft_freqanalysis(cfg, cln_data);
>
> % Run eLORETA Source Localisation
> cfg = [];
> cfg.method = 'eloreta';
> cfg.frequency = 10; % single number in Hz
> cfg.sourcemodel = leadfield;
> cfg.headmodel = vol;
> cfg.elec = cln_data.elec;
> cfg.projectnoise = 'yes';
>
> source_freq = ft_sourceanalysis(cfg, freq);
>
> % Plot the 10 Hz power on surface
> cfg = [];
> cfg.method = 'surface';
> cfg.funparameter = 'avg.pow';
> ft_sourceplot(cfg,source_freq);
>
>
>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210630/0e006049/attachment.htm>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: image003.png
> Type: image/png
> Size: 108734 bytes
> Desc: image003.png
> URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210630/0e006049/attachment.png>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: volume_lookup_error.png
> Type: image/png
> Size: 274456 bytes
> Desc: volume_lookup_error.png
> URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210630/0e006049/attachment-0001.png>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!qxNYm5UX4r247zxfCBJ131UKIxbWXgzqM0w90neZ3KOfI1PkrlTTd0PH_LB64dBWEwQgYvR37ylD3hA$
>
>
> ------------------------------
>
> End of fieldtrip Digest, Vol 127, Issue 20
> ******************************************
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!qxNYm5UX4r247zxfCBJ131UKIxbWXgzqM0w90neZ3KOfI1PkrlTTd0PH_LB64dBWEwQgYvR37ylD3hA$
More information about the fieldtrip
mailing list