[FieldTrip] how to map grid coordinates to destrieux atlas or AAL
Schoffelen, J.M. (Jan Mathijs)
janmathijs.schoffelen at donders.ru.nl
Fri Aug 26 12:53:28 CEST 2022
Hi Evan,
I guess your question pertains to whether there’s an easy way to map coordinates from one known space into another known space?
Yes, this is relatively straightforward if 1) this mapping is a linear one (affine transformation), and 2) if you know the mapping matrix.
So the solution boils down to finding out how the coordinate system in which the electrodes etc are expressed relates to the coordinate system of the atlas.
Once you have this, you can use ft_warp_apply (or ft_transform_geometry) to toggle back and forth between the different coordinate systems.
Best wishes,
Jan-Mathijs
On 26 Aug 2022, at 03:51, Evan Hutcheon via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:
Hi everyone,
I have added my code below for source reconstruction on a grid based on the standard_bem headmodel, and am wondering if there is an easy way to map my grid coordinates to the destrieux atlas, or another atlas (like AAL).
%% 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!8eQkA6-3IGl48c4ZMcKyWvtcm4BrFh2rFjA2ZeoPixMqt0Kel7PwwS9WTKUN6FPk6jleFJ6ieJ6AHQRZuiQbRXUa_1kwfa2qgEaB4Q$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220826/4ed96915/attachment.htm>
More information about the fieldtrip
mailing list