<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="">
Hey Guys,
<div class=""><br class="">
</div>
<div class="">I’m trying to make sense of some source-space analyses I’ve done and I wondered if I could get some expert input. I have computed a source-level contrast between condition A and B across subjects. Each subject performed both conditions. Specifically,
I ran a one tailed test to reveal clusters where condition A showed significantly greater activation than condition B. My code to run this contrast is here:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);">
%Group Stats</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg=[];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.dim = grandavgA{1}.dim;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.method = <span class="" style="color: rgb(170, 4, 249);">'montecarlo'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(170, 4, 249);">
<span class="" style="color: rgb(0, 0, 0);">cfg.statistic = </span>'ft_statfun_depsamplesT'<span class="" style="color: rgb(0, 0, 0);">;</span></div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.parameter = <span class="" style="color: rgb(170, 4, 249);">'pow'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.correctm = <span class="" style="color: rgb(170, 4, 249);">'cluster'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.numrandomization = 1000;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.clusteralpha = 0.05;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.alpha = 0.05; </div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.tail = 1; <font color="#028009" class="">%One tailed, see where A>B (I hope??)</font></div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
nsubj=numel(grandavgZero);</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.design(1,:) = [1:nsubj 1:nsubj];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.design(2,:) = [ones(1,nsubj)*1 ones(1,nsubj)*2];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);">
<span class="" style="color: rgb(0, 0, 0);">cfg.uvar = 1; </span>% row of design matrix that contains unit variable (in this case: subjects)</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);">
<span class="" style="color: rgb(0, 0, 0);">cfg.ivar = 2; </span>% row of design matrix that contains independent variable (the conditions)</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9); min-height: 13px;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9); min-height: 13px;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
stat = ft_sourcestatistics(cfg,grandavgA{:}, grandavgB{:}); <span class="" style="caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9);">%where grandavgA etc. are cell arrays containing subject-level source reconstructions of condition A and B separately</span></div>
</div>
<div class=""><br class="">
</div>
<div class="">This contrast reveals a large, significant occipito/parietal/temporal cluster where condition A has greater activity than B. I am then using this positive cluster mask as an ROI to create virtual channels and visualise the source-level ERFs for
both condition A and B. I do this for each subject, warping the MNI coordinates of the cluster to individual subject-specific space, calculating virtual channels for each of the N pos within the cluster mask, giving me N*3 (multiplied by 3 for each XYZ direction
of the dipole) virtual channels for each trial for each condition. The relevant code to do this per subject is here:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
gridpos= ft_warp_apply(M,stat.pos(stat.mask,:));<span class="" style="caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9);">%Calculate spatial filter for each voxel over all data</span></div>
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);">
%Calculate spatial filter for each voxel over all data</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg = [];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.method = <span class="" style="color: rgb(170, 4, 249);">'lcmv'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.sourcemodel = sourcemodel; <span class="" style="caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9);"> %subject specific source model</span></div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.sourcemodel.pos = gridpos;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.sourcemodel.inside = true(length(cfg.sourcemodel.pos),1);</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.unit = sourcemodel.unit;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.headmodel = headmodel;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.lcmv.keepfilter = <span class="" style="color: rgb(170, 4, 249);">'yes'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.lcmv.lambda = <span class="" style="color: rgb(170, 4, 249);">'5%'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.channel = {<span class="" style="color: rgb(170, 4, 249);">'MEG'</span>};</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.senstype = <span class="" style="color: rgb(170, 4, 249);">'MEG'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
sourceavg = ft_sourceanalysis(cfg, avg);</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
dot_filter = cell2mat(sourceavg.avg.filter);</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
chansel = ft_channelselection(<span class="" style="color: rgb(170, 4, 249);">'MEG'</span>, meg_data.label); <span class="" style="color: rgb(2, 128, 9);">% find MEG sensor names</span></div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
chanindx = match_str(meg_data.label, chansel); </div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
<span class="" style="color: rgb(14, 0, 255);">for </span>c = 1:length(conditions)</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cond = conditions(c);</div>
<div class="" style="margin: 0px; font-stretch: normal; line-height: normal;"><font face="Courier" class=""><span class="" style="font-size: 11px;"> </span></font><font face="Courier" class=""><span class="" style="font-size: 11px;"><font color="#0e00ff" class="">if </font>strcmp(cond,</span><span class="" style="caret-color: rgb(14, 0, 255); font-size: 11px;">’</span><span class="" style="font-size: 11px;">A’)</span></font></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;" class="">
<br class="webkit-block-placeholder">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg = [];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.trials = meg_data.trialinfo(:,5) == c;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
data = ft_selectdata(cfg,dot_trials);</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
<span class="" style="color: rgb(14, 0, 255);">elseif </span>strcmp(cond,<span class="" style="caret-color: rgb(14, 0, 255);">’B</span>’)</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg = [];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.trials = meg_data.trialinfo(:,5) == c;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
data = ft_selectdata(cfg,dot_trials);</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
<span class="" style="color: rgb(14, 0, 255);">end</span></div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(14, 0, 255); min-height: 13px;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
condvc = [];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
condvc.label = {<span class="" style="color: rgb(170, 4, 249);">'x' 'y' 'z'</span>};</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
condvc.time = data.time;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
<span class="" style="color: rgb(14, 0, 255);">for </span>i = 1:length(data.trial)</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
condvc.trial{i} = dot_filter * data.trial{i}(chanindx,:); <span class="" style="caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9);">%compute virtual channel</span></div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
<span class="" style="color: rgb(14, 0, 255);">end</span></div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(14, 0, 255); min-height: 13px;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg = [];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
avgcond = ft_timelockanalysis(cfg,condvc);<span class="" style="caret-color: rgb(2, 128, 9); color: rgb(2, 128, 9);">%compute subject level ERF for each condition</span></div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
VCs{subj,cond} = avgcond;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
<span class="" style="color: rgb(14, 0, 255);">end </span></div>
</div>
<div class=""><br class="">
</div>
<div class="">The issue is that once I’ve taken the grand average of the virtual channel ERFs per each condition across subjects, the ERF for condition B (blue) is statistically significantly greater than condition A (red) across the timepoints the original
source contrast was computed over. This seems completely backwards. Surely my process is essentially double-dipping, and I should see a greater ERF for condition A over condition B, given that I'm using virtual channels computed within a cluster where A was
significantly greater than B at the whole brain level. I’ve tried it this way but also just using the peak voxel within the cluster based on the t-stat, but I get the same counterintuitive pattern of ERF results.</div>
<div class=""><br class="">
</div>
<div class="">
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);">
%% Compute Grand Avg over Subjects</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg = [];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.channel = <span class="" style="color: rgb(170, 4, 249);">'all'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.latency = <span class="" style="color: rgb(170, 4, 249);">'all'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.parameter = <span class="" style="color: rgb(170, 4, 249);">'avg'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
grandavg_A = ft_timelockgrandaverage(cfg,VCs{:,1});</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
grandavg_B = ft_timelockgrandaverage(cfg,VCs{:,2});</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
<br class="">
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);">
%% Plot Average Source-Level ERF For Zero vs non-zero</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg = [];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.channel = <span class="" style="color: rgb(170, 4, 249);">'all'</span>;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(2, 128, 9);">
%cfg.showlegend = 'yes';</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.linewidth = 1.75;</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
cfg.linecolor = [1,0,0; 0,0,1];</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier;">
ft_singleplotER(cfg, grandavg_A, grandavg_B);</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; color: rgb(170, 4, 249);">
<br class="">
</div>
</div>
<div class="" style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Courier; min-height: 13px;">
<br class="">
</div>
<div class="">Am I thinking about this in the correct way, or have I made some error in my code? I’ve not copied my entire scripts so as not to clutter this question, but I hope I have supplied enough for you to follow my method. </div>
<div class=""><br class="">
</div>
<div class="">All the best,</div>
<div class="">Benjy</div>
</body>
</html>