# [FieldTrip] how to map grid coordinates to destrieux atlas or AAL

Evan Hutcheon evan_hutcheon at sfu.ca
Fri Aug 26 20:31:31 CEST 2022

```Hi Jan,

Thank you Jan for the quick reply!

Apologizes for my ignorance but I am still pretty new to fiedltrip and analyzing eeg data, but how would I find the coordinate system of the atlas and electrodes? Also, how would I know if mapping was linear? I used the fiedltrip standard Bem for the headmodel.

Thanks,

Evan Hutcheon

PhD Candidate|Dr. Doesburg laboratory

________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip at science.ru.nl>
Sent: Friday, August 26, 2022 3:53:28 AM
To: FieldTrip discussion list
Cc: Schoffelen, J.M. (Jan Mathijs)
Subject: Re: [FieldTrip] how to map grid coordinates to destrieux atlas or AAL

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

cfg=[];
cfg.resolution = .015;  %headmodel resolution(was 0.008)
source_model = ft_prepare_sourcemodel(cfg);

%% align electrodes to head model
elec = ft_convert_units(elec, 'm');

scalp_index = 1; %scalp is 1

cfg = [];
cfg.method = 'project'; % onto 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

cfg = [];
cfg.sourcemodel = source_model;    %% where are the sources?
cfg.elec        = elecICA;% how do sources and sensors connect?
cfg.normalize   = 'yes'; %was no

%% 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.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.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.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/cbdf4deb/attachment.htm>
```