<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 all,
<div class=""><br class="">
</div>
<div class="">I’m trying to implement some MVPA decoding analyses in source space using MEG data collected on a CTF system. I have gone through different tutorials to perform the source reconstruction (namely <a href="https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/workshop/aarhus/beamformingerf/__;!!HJOPV4FYYWzcc1jazlU!6dJY9xn9eTEqqGoXULa_OMBzAvS3Cl7jDWxpxhESR-a61x1hEJWt38h4sKsVfLMoG9DIkPTj6qamNi18fKgf9dtYDIaRLfHvTw$" class="">https://www.fieldtriptoolbox.org/workshop/aarhus/beamformingerf/</a>; <a href="https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/workshop/paris2019/handson_sourceanalysis/__;!!HJOPV4FYYWzcc1jazlU!6dJY9xn9eTEqqGoXULa_OMBzAvS3Cl7jDWxpxhESR-a61x1hEJWt38h4sKsVfLMoG9DIkPTj6qamNi18fKgf9dtYDIZKqhJFug$" class="">https://www.fieldtriptoolbox.org/workshop/paris2019/handson_sourceanalysis/</a>).</div>
<div class=""><br class="">
</div>
<div class="">To train my decoder, I will obviously need trial by trial activity estimates for each of the virtual channels. The issue is that these tutorials, and most other information I can find, only go into how to extract condition-level source estimates.
 I have an idea of how to do this for individual trials, but it’s such a shift from the tutorials I wondered if I could check whether my plan will work conceptually and technically. </div>
<div class=""><br class="">
</div>
<div class="">My current code (to obtain condition level estimates) is as follows:</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);" class="">
    % Compute Covariance Matrix</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg = [];</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.covariance = <span style="color: #aa04f9" class="">'yes'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    avg = ft_timelockanalysis(cfg,meg_data); %meg_data = datazero + datanotzero;</div>
<p style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
    <br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.keeptrials = <span style="color: #aa04f9" class="">'yes'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    avgzero = ft_timelockanalysis(cfg,datazero); %condition 1 = ‘zero'</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    avgnotzero = ft_timelockanalysis(cfg,datanotzero); %condition 2 = ’not zero'</div>
<p style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
    <br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);" class="">
<span style="color: #000000" class="">    </span>%Calculate spatial filter for each voxel over all data</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg = [];</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.method = <span style="color: #aa04f9" class="">'lcmv'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.sourcemodel = sourcemodel_new;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.headmodel = headmodel_new;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.lcmv.keepfilter = <span style="color: #aa04f9" class="">'yes'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.lcmv.lambda = <span style="color: #aa04f9" class="">'5%'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.lcmv.weightnorm = <span style="color: #aa04f9" class="">'unitnoisegain'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.lcmv.fixedori = <span style="color: #aa04f9" class="">'yes'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.channel = {<span style="color: #aa04f9" class="">'MEG'</span>};</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.senstype = <span style="color: #aa04f9" class="">'MEG'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    sourceavg = ft_sourceanalysis(cfg, avg); %compute filters over all trials</div>
<p style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
    <br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);" class="">
<span style="color: #000000" class="">    </span>%Now apply this filter to zero and not-zero data separately</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg = [];</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.method = <span style="color: #aa04f9" class="">'lcmv'</span>;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.sourcemodel = sourcemodel_new;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.sourcemodel.filter = sourceavg.avg.filter;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    cfg.headmodel = headmodel_new;</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    sourcezero = ft_sourceanalysis(cfg, avgzero);</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;" class="">
    sourcenotzero = ft_sourceanalysis(cfg, avgnotzero);</div>
</div>
<div class=""><br class="">
</div>
<div class="">Would I be correct to simply alter this pipeline so that I perform the call to ft_timelockanalysis and estimate the covariance matrix for each trial individually, rather than each condition? Then I was planning to simply run the ft_sourceanalysis
 function on each of these trials individually, keeping track of which trial belongs to which condition for later use in decoding. I can then go into the source output from the sourceanalysis and extract the .mom field to get the virtual channel data per trial,
 which I plan to then enter into the decoder.</div>
<div class=""><br class="">
</div>
<div class="">Does this make sense conceptually? It seems a logical step from the beamforming of condition level signals, but I’ve come to learn it’s rarely that simple!</div>
<div class=""><br class="">
</div>
<div class="">I hope that all makes sense,</div>
<div class=""><br class="">
</div>
<div class="">Benjy</div>
</body>
</html>