[FieldTrip] how to transform cfg.headmodel to an atlas in MNI space
Schoffelen, J.M. (Jan Mathijs)
janmathijs.schoffelen at donders.ru.nl
Tue Sep 6 15:25:37 CEST 2022
Hi Evan,
I think that there are several threads in the discussion list’s archive which relate to what you want to achieve. It might be useful to browse that a bit in more detail. Also, there’s ample documentation on the website, e.g. https://www.fieldtriptoolbox.org/tutorial/networkanalysis_eeg/ does a parcellated source reconstruction of EEG, but using a surface based sourcemodel and atlas.
The long story short of it is that you want to label each of the points in your sourcemodel according to some atlas. In order to do so, these two objects need to be in register, and they need to be sampled at the same locations (e.g. for a 3D voxel grid at the same resolution).
From the code that you pasted in your e-mail, it seems that the coordinate system of the electrodes and headmodel (and sourcemodel) match with one another. You can check the approximate coordinate system by using ft_determine_coordsys(dataobject). This gives you an interactive figure that allows you to add labels to the positive pointing x/y/z/ axes and possibly to the origin. Given that the standard headmodel was obtained from a template brain, I suspect that this coordinate system is well behaved, and the same as the one that a well-behaved atlas is defined in. I don’t have any control over which atlas you are using, but assuming that indeed this atlas is well-behaved, my next step would be to interpolate this atlas onto the lower resolution source model, e.g. following a recipe that is similar to: https://mailman.science.ru.nl/pipermail/fieldtrip/2020-December/040550.html
Once you have performed your source reconstruction, you can easily use ft_sourceparcellate, or ft_virtualchannel, to combine across dipoles that belong to the same parcel. Note that some atlases do not make an explicit distinction between a left and right hemispheric parcel, so if you don’t want to sweep those onto a single heap, you need to massage the atlas a bit before interpolating it.
Best wishes and good luck,
Jan-Mathijs
On 29 Aug 2022, at 00:11, Evan Hutcheon via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:
Hi everyone,
I was wondering if anyone could help me
perform a transformation from
cfg.headmodel = headmodel;
to an atlas in the MNI space?
%% create a head model || vol is standard bem from FT
load('/rcg/bcni/users/Evan/fieldtrip-20190912/template/headmodel/standard_bem.mat')
headmodel = vol;
headmodel = ft_convert_units(headmodel, 'm');
cfg=[];
cfg.resolution = .015; %headmodel resolution(was 0.008)
cfg.headmodel = headmodel;
source_model = ft_prepare_sourcemodel(cfg);
%% align electrodes to head model
elec = ft_read_sens('standard_1020.elc');
elec = ft_convert_units(elec, 'm');
scalp_index = 1; %scalp is 1
cfg = [];
cfg.method = 'project'; % onto scalp surface
cfg.headshape = headmodel.bnd(scalp_index); % scalp surface
elec_realigned = ft_electroderealign(cfg,elec);
% end
%% align electrodes
% for subject
[v, ix, ixx] = intersect(elec_realigned.label, interp.label);
elecICA = elec_realigned;
elecICA.chanpos = elecICA.chanpos(ix,:);
elecICA.chantype = elecICA.chantype(ix,:);
elecICA.chanunit = elecICA.chanunit(ix,:);
elecICA.elecpos = elecICA.elecpos(ix,:);
elecICA.label = elecICA.label(ix);
elecICA.tra = elecICA.tra(ix, ix); %cant find
%% leadfield
cfg = [];
cfg.sourcemodel = source_model; %% where are the sources?
cfg.headmodel = headmodel; %% how do currents spread?
cfg.elec = elecICA;% how do sources and sensors connect?
cfg.normalize = 'yes'; %was no
leadfield = ft_prepare_leadfield(cfg,interp);
%% source estimation via LCMV
cfg = [];
cfg.trials = 'all';
cfg.channel = 'eeg';
cfg.covariance = 'yes';
cfg.covariancewindow = 'all';
cfg.keeptrials = 'yes';
cfg.removemean = 'yes';
timelock = ft_timelockanalysis(cfg, interp);
%LCMV BEAMFORMER to create spatial filter
cfg = [];
cfg.method = 'lcmv';
cfg.grid = leadfield;
cfg.headmodel = headmodel;
cfg.elec = elecICA;
cfg.lcmv.lambda = '5%';
cfg.lcmv.projectmom = 'yes';
cfg.lcmv.keepfilter = 'yes';
cfg.lcmv.keepori = 'yes';
cfg.lcmv.projectnoise = 'yes';
sfilter = ft_sourceanalysis(cfg, timelock); % use this for your source reconstruction
%% Source analysis
cfg = [];
cfg.trials = 'all';
cfg.trials = any(interp.trialinfo == [5],2);%
cfg.covariance = 'yes';
cfg.covariancewindow = 'all';
cfg.keeptrials = 'yes';
cfg.removemean = 'yes';
timelock_trl_left = ft_timelockanalysis(cfg, interp);
cfg = [];
cfg.trials = 'all';
cfg.trials = any(interp.trialinfo == [6],2);%
cfg.covariance = 'yes';
cfg.covariancewindow = 'all';
cfg.keeptrials = 'yes';
cfg.removemean = 'yes';
timelock_trl_right = ft_timelockanalysis(cfg, interp);
% no need at this point to generate and save the time series
cfg = [];
cfg.method = 'lcmv';
cfg.grid = leadfield;
cfg.headmodel = headmodel;
cfg.elec = elecICA;
cfg.lcmv.lambda = '5%';
cfg.lcmv.projectmom = 'yes';
cfg.rawtrial = 'yes';
cfg.grid.filter = sfilter.avg.filter; %sfilter taken from before
cfg.lcmv.projectnoise = 'yes'; % noise estimation from the single value decomposition
cfg.lcmv.keepmom = 'yes'; % saves the time series
cfg.lcmv.fixedori = 'yes';
cfg.keeptrials = 'yes'; %'no' or 'yes
cfg.keepleadfield = 'yes';
cfg.keepfilter = 'no';
source_left = ft_sourceanalysis(cfg,timelock_trl_left);
source_right = ft_sourceanalysis(cfg,timelock_trl_right)
Cheers,
Evan
Evan Hutcheon
PhD Candidate|Dr. Doesburg laboratory
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_rugp09USUNGXfYmtakkMZYbMx5SD-3Takn_YPOmjA0DMCiifXNu00Q_pFTN39lAkHSe9vZLnKWqxzm4XTShfwj7xy0MWC4-3Gwz_A$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220906/40c8bde9/attachment.htm>
More information about the fieldtrip
mailing list