<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi Jan,</p>
<p><br>
</p>
<p>Thank you Jan for the quick reply!</p>
<p>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.</p>
<p><br>
</p>
<p>Thanks,<br>
</p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p><b></b>Evan Hutcheon<b></b></p>
<p>PhD Candidate|<span style="font-size:12pt">Dr. </span><span style="font-size:12pt">Doesburg laboratory </span></p>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> fieldtrip <fieldtrip-bounces@science.ru.nl> on behalf of Schoffelen, J.M. (Jan Mathijs) via fieldtrip <fieldtrip@science.ru.nl><br>
<b>Sent:</b> Friday, August 26, 2022 3:53:28 AM<br>
<b>To:</b> FieldTrip discussion list<br>
<b>Cc:</b> Schoffelen, J.M. (Jan Mathijs)<br>
<b>Subject:</b> Re: [FieldTrip] how to map grid coordinates to destrieux atlas or AAL</font>
<div> </div>
</div>
<div>Hi Evan,
<div class=""><br class="">
</div>
<div class="">I guess your question pertains to whether there’s an easy way to map  coordinates from one known space into another known space?</div>
<div class=""><br class="">
</div>
<div class="">Yes, this is relatively straightforward if 1) this mapping is a linear one (affine transformation), and 2) if you know the mapping matrix.</div>
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">Once you have this, you can use ft_warp_apply (or ft_transform_geometry) to toggle back and forth between the different coordinate systems. </div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 26 Aug 2022, at 03:51, Evan Hutcheon via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div id="divtagdefaultwrapper" dir="ltr" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" class="">
<p style="margin-top: 0px; margin-bottom: 0px;" class=""></p>
<div style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
 Hi everyone,</div>
<div style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
<br class="">
</div>
<div style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
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).<br class="">
</div>
<div style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
<br class="">
</div>
<div style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
<br class="">
</div>
<div style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
<br class="">
</div>
<div style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
%% create a head model || vol is standard bem from FT<br class="">
        load('/rcg/bcni/users/Evan/fieldtrip-20190912/template/headmodel/standard_bem.mat')<br class="">
        headmodel        =  vol;<br class="">
        headmodel = ft_convert_units(headmodel, 'm');<br class="">
        <br class="">
        <br class="">
        cfg=[];<br class="">
        cfg.resolution = .015;  %headmodel resolution(was 0.008)<br class="">
        cfg.headmodel = headmodel;<br class="">
        source_model = ft_prepare_sourcemodel(cfg);<br class="">
        <br class="">
        %% align electrodes to head model<br class="">
        elec = ft_read_sens('standard_1020.elc');<br class="">
        elec = ft_convert_units(elec, 'm');<br class="">
        <br class="">
        scalp_index = 1; %scalp is 1<br class="">
        <br class="">
        cfg = [];<br class="">
        cfg.method = 'project'; % onto scalp surface<br class="">
        cfg.headshape = headmodel.bnd(scalp_index); % scalp surface<br class="">
        elec_realigned = ft_electroderealign(cfg,elec);<br class="">
        <br class="">
   % end<br class="">
    <br class="">
    %% align electrodes<br class="">
    % for subject<br class="">
    [v, ix, ixx] = intersect(elec_realigned.label, interp.label);<br class="">
    elecICA = elec_realigned;<br class="">
    elecICA.chanpos = elecICA.chanpos(ix,:);<br class="">
    elecICA.chantype = elecICA.chantype(ix,:);<br class="">
    elecICA.chanunit = elecICA.chanunit(ix,:);<br class="">
    elecICA.elecpos = elecICA.elecpos(ix,:);<br class="">
    elecICA.label = elecICA.label(ix);<br class="">
    elecICA.tra = elecICA.tra(ix, ix); %cant find<br class="">
    <br class="">
    %% leadfield<br class="">
    <br class="">
    cfg = [];<br class="">
    cfg.sourcemodel = source_model;    %% where are the sources?<br class="">
    cfg.headmodel   = headmodel;      %% how do currents spread?<br class="">
    cfg.elec        = elecICA;% how do sources and sensors connect?<br class="">
    cfg.normalize   = 'yes'; %was no<br class="">
    leadfield = ft_prepare_leadfield(cfg,interp);<br class="">
    <br class="">
  <br class="">
    <br class="">
    %% source estimation via LCMV<br class="">
    cfg = [];<br class="">
    cfg.trials              = 'all';<br class="">
    cfg.channel             = 'eeg';<br class="">
    cfg.covariance          = 'yes';<br class="">
    cfg.covariancewindow    = 'all';<br class="">
    cfg.keeptrials          = 'yes';<br class="">
    cfg.removemean          = 'yes';<br class="">
    timelock                = ft_timelockanalysis(cfg, interp);<br class="">
    <br class="">
    %LCMV BEAMFORMER to create spatial filter<br class="">
    cfg = [];<br class="">
    cfg.method              = 'lcmv';<br class="">
    cfg.grid                = leadfield;<br class="">
    cfg.headmodel           = headmodel;<br class="">
    cfg.elec                = elecICA;<br class="">
    cfg.lcmv.lambda         = '5%';<br class="">
    cfg.lcmv.projectmom     = 'yes';<br class="">
    cfg.lcmv.keepfilter     = 'yes';<br class="">
    cfg.lcmv.keepori        = 'yes';<br class="">
    cfg.lcmv.projectnoise   = 'yes';<br class="">
    sfilter                 = ft_sourceanalysis(cfg, timelock); % use this for your source reconstruction<br class="">
    <br class="">
    %% Source analysis<br class="">
<br class="">
    cfg = [];<br class="">
    cfg.trials              = 'all';<br class="">
    cfg.trials = any(interp.trialinfo == [5],2);%<br class="">
    cfg.covariance          = 'yes';<br class="">
    cfg.covariancewindow    = 'all';<br class="">
    cfg.keeptrials          = 'yes';<br class="">
    cfg.removemean          = 'yes';<br class="">
    timelock_trl_left          = ft_timelockanalysis(cfg, interp);<br class="">
 <br class="">
       cfg = [];<br class="">
    cfg.trials              = 'all';<br class="">
    cfg.trials = any(interp.trialinfo == [6],2);%<br class="">
    cfg.covariance          = 'yes';<br class="">
    cfg.covariancewindow    = 'all';<br class="">
    cfg.keeptrials          = 'yes';<br class="">
    cfg.removemean          = 'yes';<br class="">
    timelock_trl_right         = ft_timelockanalysis(cfg, interp);<br class="">
   <br class="">
<br class="">
    % no need at this point to generate and save the time series<br class="">
    cfg = [];<br class="">
    cfg.method              = 'lcmv';<br class="">
    cfg.grid                = leadfield;<br class="">
    cfg.headmodel           = headmodel;<br class="">
    cfg.elec                = elecICA;<br class="">
    cfg.lcmv.lambda         = '5%';<br class="">
    cfg.lcmv.projectmom     = 'yes';<br class="">
    <br class="">
    cfg.rawtrial            = 'yes';<br class="">
    cfg.grid.filter         = sfilter.avg.filter; %sfilter taken from before<br class="">
    cfg.lcmv.projectnoise   = 'yes';  % noise estimation from the single value decomposition<br class="">
    cfg.lcmv.keepmom        = 'yes';  % saves the time series<br class="">
    cfg.lcmv.fixedori       = 'yes';<br class="">
    cfg.keeptrials          = 'yes'; %'no' or 'yes<br class="">
    cfg.keepleadfield       = 'yes';<br class="">
    cfg.keepfilter          = 'no';<br class="">
    source_left                  = ft_sourceanalysis(cfg,timelock_trl_left);<br class="">
    source_right                 = ft_sourceanalysis(cfg,timelock_trl_right)</div>
<br style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
<p style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
</p>
<div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
Cheers,</div>
<div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px;" class="">
Evan</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class="">
</div>
<div id="Signature" class="">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" class="">
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><b class=""></b>Evan Hutcheon<b class=""></b></div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">PhD Candidate|<span style="font-size: 12pt;" class="">Dr. </span><span style="font-size: 12pt;" class="">Doesburg laboratory </span></div>
</div>
</div>
</div>
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">fieldtrip
 mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8eQkA6-3IGl48c4ZMcKyWvtcm4BrFh2rFjA2ZeoPixMqt0Kel7PwwS9WTKUN6FPk6jleFJ6ieJ6AHQRZuiQbRXUa_1kwfa2qgEaB4Q$" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8eQkA6-3IGl48c4ZMcKyWvtcm4BrFh2rFjA2ZeoPixMqt0Kel7PwwS9WTKUN6FPk6jleFJ6ieJ6AHQRZuiQbRXUa_1kwfa2qgEaB4Q$</a><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span> </span></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>