[FieldTrip] Headmodel orientation eloreta

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Fri Apr 7 08:35:18 CEST 2023


Hi Ugo,

On 1 Apr 2023, at 23:33, Ugo Bruzadin Nunes via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Dear fieldtrip community,

I’m using some of eeglab’s dipfit settings to source-localize frequency activity, but this is mainly a fieldtrip issue. I hope anyone can help me and I appreciate any advice. I have two issues and one question.

  1.  When I plot the source localization, the orientation is 90 degrees wrong. When using dipfit in eeglab, the activity is correctly localized; but after doing all the dipfit processes – altered to plot frequency instead of component – frontal activity is being plot in the right ear. I thought something was wrong, so I artificially increased the activity at channel 12 (the anterior-most channel in my channel model), and the activity is coming from the ear in the eloreta instead. I can’t figure out where the rotation is incorrect and how I should approach the solution, since in EEGLAB the channels are correctly plotted.

You need to check the coregistration between the anatomical image that you use for visualization/source reconstruction, and the electrodes. Also you need to check the coordinate system convention used for the description of the electrodes, volume conduction model, source model, anatomical image. There’s abundant information about this on the fieldtrip website, so please check it out there.


  1.
  2.  For some reason, fieldtrip won’t accept the atlas. The error says my axis are 10mm in diameter, and the atlas is 150mm in each direction. I’m reading the ROI_MNI_V4 atlas in. Do I have to interpolate it?

You don’t mention the error, just the textual feedback you get when you visualize a geometrical object. Also, it’s unclear what is meant with ‘fieldtrip won’t accept the atlas’. The ’some reason’ that you mention in your question/issue is at this point underspecified, so I doubt if anybody can say anything sensible about this. Also it is unclear for what reason you think that you need the atlas at this stage of your analysis.


  1.
  2.  I am not sure the following code is localizing and plotting the correct frequencies. I don’t think it’s working, but I haven’t tested individual frequencies yet since I haven’t fixed the headmodel orientation issue.

I agree that you should fix any upstream issue before you can move on to the next part.

Good luck studying the online documentation.

Jan-Mathijs

Below is my code! Any feedback is welcome. Thank you so much in advance,

Ugo

Ugo Bruzadin Nunes, Ph.D. Candidate (he/him)
Visiting Assistant Professor, Psychology
Webster University


Script/Code:

EEG = pop_dipfit_settings( EEG, 'hdmfile',...
    'C:\\GitHub\\eeglab\\plugins\\dipfit3.7\\standard_BEM\\standard_vol.mat','coordformat','MNI','mrifile',...
    'C:\\GitHub\\eeglab\\plugins\\dipfit3.7\\standard_BEM\\standard_mri.mat','chanfile',...
    ['C:\\GitHub\\eeglab\\plugins\\dipfit3.7\\standard_BEM\\elec\\standard_1005.elc ' ],...
    'coord_transform',...
    [0.05476 -17.3653 -8.1318 0.075502 0.0031836 -1.5696 11.7138 12.7933 12.213] ,'chansel',[1:EEG.nbchan] );


atlas = ft_read_atlas('ROI_MNI_V4.nii');
%% compute spectral params (only need to be done once to get the right structures)

EEGdata = eeglab2fieldtrip(EEG, 'preprocessing', 'none');

cfg = [];
cfg.method    = 'mtmfft';
cfg.output    = 'powandcsd';
cfg.tapsmofrq = 10;
cfg.foilim    = range;
cfg.pad = 'nextpow2';
cfg.gpu = 'yes';
fftdata = ft_freqanalysis(cfg, EEGdata);

if ~isfield(EEG,'lor')
    EEG.lor = struct();
end

EEG.fftdata = fftdata;
%% read headmodel

p = fileparts(which('eeglab'));
if ~isfield(EEG.lor,'HM')
    headmodel = load('-mat', EEG.dipfit.hdmfile);
    headmodel = headmodel.vol;
    EEG.lor.HM = headmodel;
else
    headmodel  = EEG.lor.HM;
end

    cfg                 = [];
    cfg.elec            = fftdata.elec;
    cfg.headmodel       = headmodel;
    cfg.reducerank      = 2;
    cfg.grid.resolution = 10;   % use a 3-D grid with a 1 cm resolution
    cfg.grid.unit       = 'mm';
    cfg.channel         = { 'all' };
    cfg.parallel = 'yes';
    cfg.solver = 'cg';

    [grid] = ft_prepare_leadfield(cfg);
    EEG.lor.grid = grid;


    mri = load('-mat', EEG.dipfit.mrifile);
    mri = ft_volumereslice([], mri.mri);
    EEG.lor.mri = mri;

%% loops per frequency then plots
counter = 0;

numfreq = size(frequencies,2);

EEGlor = EEG;

vol = load('-mat', EEG.dipfit.hdmfile);

for i = 1:numfreq

    atlas = ft_read_atlas('ROI_MNI_V4.nii');

    freq = frequencies(i);

    cfg              = struct(g.ft_sourceanalysis_params{:});
    cfg.frequency    = freq;
    cfg.grid         = grid;
    cfg.headmodel    = headmodel;
    cfg.method       = 'eloreta';
    cfg.atlas        = atlas;
    cfg.roi          = atlas.tissuelabel;
    cfg.eloreta.projectnoise = 'yes';
    cfg.eloreta.lambda   = 5;
    cfg.gpu           = 'yes';

    sourcemodel = ft_sourceanalysis(cfg, fftdata);

    EEGlor.lor.cfg(numfreq) = cfg;
    EEGlor.lor.freq(numfreq) = fftdata;
    EEGlor.lor.source(numfreq) = sourcemodel;
%% load MRI and INTERPOLATE

    cfg                 = [];
    cfg.downsample      = 2;
    cfg.parameter       = 'avg.pow';
    sourcemodel.oridimord = 'pos';
    sourcemodel.momdimord = 'pos';
    sourcemodel_int        = ft_sourceinterpolate(cfg2, sourcemodel , mri);
    EEGlor.lor.source_int(numfreq) = sourcemodel_int;

%% plot
    cfg                 = [];
    cfg.method          = 'ortho';
    cfg.funparameter    = 'pow';
    ft_sourceplot(cfg2,sourcemodel_int);
    textsc(sprintf('eLoreta source localization of %d frequency power',freq), 'title');

%
end






Ugo

Ugo Bruzadin Nunes, Ph.D. Candidate (he/him)
Visiting Professor, Psychology
Webster University
Office Location: ISB room 316
Office Number: (314) 968-7677
Ugo at webster.edu<mailto:UgoBruzadinNunes at webster.edu>




Ugo



Ugo Bruzadin Nunes, Ph.D. Candidate (he/him)
Visiting Professor, Psychology
Webster University
Office Location: ISB room 316
Office Number: (314) 968-7677
Ugo at webster.edu<mailto:UgoBruzadinNunes at webster.edu>


_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!9p3MXx66w3sJ3BpeyB3zOOJ2rnhS9e86qfEPRENa5HarQKXxuGy3nqi93XHlcbveDNpFgmz9c-fVLPj_lof-45ijO_TyA5rwvhLYSg$

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230407/62037f72/attachment.htm>


More information about the fieldtrip mailing list