[FieldTrip] Issue plotting Brainnetome aligned EEG source data

Jack Fogarty jf752 at uowmail.edu.au
Wed Jun 30 12:20:22 CEST 2021

Hello Fieldtrippers!

Apologies for the long email, but I am hoping that I can get some help working with the Brainnetome atlas.


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:


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.


[cid:image003.png at 01D76DED.5573FB20]

My code is here:

%% Generate standard BEM template aligned to Brainnetome atlas

    [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
    hold on
    ft_plot_headmodel(vol,  'facecolor', 'cortex', 'edgecolor', 'none');
    alpha 0.5

    % 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';

    % 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

    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

    % 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';

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210630/0e006049/attachment-0001.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-0002.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-0003.png>

More information about the fieldtrip mailing list