<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Evan,
<div class=""><br class="">
</div>
<div class="">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. <a href="https://www.fieldtriptoolbox.org/tutorial/networkanalysis_eeg/" class="">https://www.fieldtriptoolbox.org/tutorial/networkanalysis_eeg/</a> does
 a parcellated source reconstruction of EEG, but using a surface based sourcemodel and atlas.</div>
<div class=""><br class="">
</div>
<div class="">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).</div>
<div class=""><br class="">
</div>
<div class="">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: <a href="https://mailman.science.ru.nl/pipermail/fieldtrip/2020-December/040550.html" class="">https://mailman.science.ru.nl/pipermail/fieldtrip/2020-December/040550.html</a></div>
<div class=""><br class="">
</div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes and good luck,</div>
<div class=""><br class="">
</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 29 Aug 2022, at 00:11, 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, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" class="">
<p style="margin-top: 0px; margin-bottom: 0px;" class=""><font size="3" face="Calibri,Helvetica,sans-serif" class=""><span id="divtagdefaultwrapper" style="font-size: 12pt;" class=""></span></font></p>
<font size="3" face="Calibri,Helvetica,sans-serif" class="">
<div class=""><font size="2" face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class=""><span style="font-size: 16px;" class="">Hi everyone,</span></font></div>
<div class=""><font size="2" face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class=""><span style="font-size: 16px;" class=""><br class="">
</span></font></div>
<div class=""><font size="2" face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class=""><span style="font-size: 16px;" class="">I was wondering if anyone could help me
<div class="">perform a  transformation from </div>
<div class="">
<div style="margin: 14pt 30pt;" class=""><font size="2" face="Calibri,Helvetica,sans-serif" style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont;" class=""><span style="font-size: 16px;" class="">
<div id="gmail-m_3061653227071342799divtagdefaultwrapper" class=""><font size="3" class=""><span id="gmail-m_3061653227071342799divtagdefaultwrapper" style="font-size: 12pt;" class="">
<div class=""><font face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class="">cfg.headmodel           = headmodel;</font></div>
</span></font></div>
</span></font></div>
to an atlas in the MNI space?</div>
<br class="">
</span></font></div>
<div class=""><font size="2" face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class=""><span style="font-size: 16px;" class=""><br class="">
</span></font></div>
<div class=""><font size="2" face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class=""><span style="font-size: 16px;" class=""><br class="">
</span></font></div>
<div class=""><font size="2" face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class=""><span style="font-size: 16px;" class=""><br class="">
</span></font></div>
<div class=""><font size="2" face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class=""><span style="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)</span></font></div>
<br class="">
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><font size="2" face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class=""><span style="font-size: 16px;" class=""> </span></font></div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><font size="2" face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class=""><span style="font-size: 16px;" class="">Cheers,</span></font></div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><font size="2" face="Calibri,Helvetica,sans-serif,serif,EmojiFont" class=""><span style="font-size: 16px;" class="">Evan</span></font></div>
</font><br class="">
<p style="margin-top: 0px; margin-bottom: 0px;" class=""></p>
<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, 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!_rugp09USUNGXfYmtakkMZYbMx5SD-3Takn_YPOmjA0DMCiifXNu00Q_pFTN39lAkHSe9vZLnKWqxzm4XTShfwj7xy0MWC4-3Gwz_A$" 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!_rugp09USUNGXfYmtakkMZYbMx5SD-3Takn_YPOmjA0DMCiifXNu00Q_pFTN39lAkHSe9vZLnKWqxzm4XTShfwj7xy0MWC4-3Gwz_A$</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>
</body>
</html>