<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1" style="word-wrap:break-word">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi Jan-Mathijs,
<br>
<br>
thank you for your fast response. To have a comparable grid of course makes sense.
<br>
<br>
I have looked at the link you proposed and I have one more question. Do I undersatand it correctly that I first have to generate a template grid, secodly use it for grid =  ft_prepare_sourcemodel(cfg) and finally take grid.pos and grid.dim (but not template_grid.pos
 and template_grid.dim) for each of my source reconstructions? <br>
<br>
I am a little irritated as in the link it says: "You can use these single subjects' MNI grids in source analysis. After that you should put
<strong>.pos</strong> and <strong>.dim</strong> field <strong>from the template_grid onto the subjects's source</strong>, which is thereby in MNI coordinates."
<br>
<br>
Best,<br>
David<br>
<br>
<div>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-size:13px">
<hr>
<font face="Tahoma" size="2"><font color="003366">Dr. David Pedrosa<br>
</font></font><font color="003366" face="Tahoma" size="2"><br>
Clinical Research Fellow</font><font color="003366" face="Tahoma" size="2"><br>
</font><font color="003366" face="Tahoma" size="2"><span dir="ltr" style="font-size:10pt">
<div>
<div><span style="font-size:13px">
<div><font size="2"><span style="font-size:10pt">Medical Research Council Brain Network Dynamics Unit at the University of Oxford<br>
Nuffield Department of Clinical Neurosciences</span></font></div>
<div>University of Oxford</div>
<div>Level 6, West Wing</div>
<div>John Radcliffe Hospital, OX3 9DU<br>
</div>
</span></div>
</div>
</span></font><font color="003366" face="Tahoma" size="2"><span style="font-size:10pt"><u>Tel:</u>
</span></font><font face="Tahoma" size="2"><span style="font-size:10pt"><font color="003366">+44 (0)1865 572490<br>
<u>E-Mail:</u> </font><font color="333333">david.pedrosa@ndcn.ox.ac.uk<br>
</font></span></font><font size="2"><span style="font-size:10pt"><br>
<a href="http://www.mrcbndu.ox.ac.uk/" target="_blank">http://www.mrcbndu.ox.ac.uk/</a></span></font><br>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF679563"><font color="#000000" face="Tahoma" size="2"><b>Von:</b> fieldtrip-bounces@science.ru.nl [fieldtrip-bounces@science.ru.nl]" im Auftrag von "Schoffelen, J.M. (Jan Mathijs) [jan.schoffelen@donders.ru.nl]<br>
<b>Gesendet:</b> Donnerstag, 4. Juni 2015 12:12<br>
<b>An:</b> FieldTrip discussion list<br>
<b>Betreff:</b> Re: [FieldTrip] Question on group statistics for coherence differences<br>
</font><br>
</div>
<div></div>
<div>Hi David,
<div><br>
</div>
<div>This rather uninformative error suggests, that the positions at which you estimated the source activity is not consistent across participants. FieldTrip’s data bookkeeping machinery checks for this, and the aim is to continue working only on those data-points
 (spatial locations, channels, frequency bins, time points) that all datasets have in common. This check and bookkeeping operation is performed by FieldTrip’s intermediate level function ft_selectdata, and the error you get relates to the fact that the function
 as of yet lacks functionality to compare and prune spatial locations (as opposed to channels, frequency bins and time points). Yet, to make a somewhat tedious and boring story short, for your purpose you probably shouldn't want to need this  subselection,
 at least when ensuring that across participants the spatial locations are comparable for all of your ordinal dipole locations (for instance, even though the physical location expressed in 3D cartesian coordinates of a dipole location in the left motor cortex
 has different numbers for a subject with a large head, compared to a subject with a small head, if they are both represented in say the 100th row of your data matrix, they can be still used together). </div>
<div>In the code you pasted below it doesn’t seem that the grid positions for the individual subjects are directly comparable, and I suggest to look at the below link to build such a step into your own pipeline:</div>
<div><br>
</div>
<div><a href="http://www.fieldtriptoolbox.org/example/create_single-subject_grids_in_individual_head_space_that_are_all_aligned_in_mni_space" target="_blank">http://www.fieldtriptoolbox.org/example/create_single-subject_grids_in_individual_head_space_that_are_all_aligned_in_mni_space</a></div>
<div><br>
</div>
<div>Once you have the data represented such that equivalent dipole positions are comparable across participants, you can fool ft_sourcestatistics by replacing the sourceAct_all{x}.pos field with a set of positions that is the same for all subjects, e.g. using
 the positions defined on a ‘template grid’.</div>
<div><br>
</div>
<div>Best,</div>
<div>Jan-Mathijs</div>
<div><br>
</div>
<div>
<div>
<div>On Jun 4, 2015, at 12:33 PM, David Pedrosa <<a href="mailto:david.pedrosa@ndcn.ox.ac.uk" target="_blank">david.pedrosa@ndcn.ox.ac.uk</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div style="font-family:Calibri; font-size:15px; font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">
<div style="direction:ltr; font-family:Tahoma; font-size:10pt">Dear List,<br>
<br>
I adressed a similar issue before (<a href="http://mailman.science.ru.nl/pipermail/fieldtrip/2015-May/009237.html" target="_blank">http://mailman.science.ru.nl/pipermail/fieldtrip/2015-May/009237.html</a>), which I would like to extend with some more information
 and the used code. I am interested in computing a permutation test for coherence between two conditions based on cluster statistics. The conditions are rest and activation. However I do not manage to get the source statistics to work, as it gives me an error
 stating:<br>
<br>
Error using ft_selectdata>getselection_pos (line 1123)<br>
not yet implemented<br>
<br>
Error in ft_selectdata (line 263)<br>
if haspos,     [selpos,     cfg] = getselection_pos    (cfg, varargin{:}, cfg.tolerance, cfg.select); end<br>
<br>
Error in ft_sourcestatistics (line 119)<br>
[varargin{:}] = ft_selectdata(tmpcfg, varargin{:});<br>
<br>
I assume my design for the stats is not correct, but I'm not sure what this error is actually telling me and I would appreciate any help.<br>
Thanks in advance.<br>
<br>
%% computing cross-spectral density matrices<br>
cfg = [];<br>
cfg.method    = 'mtmfft';<br>
cfg.output    = 'fourier';<br>
cfg.taper     = 'dpss';<br>
cfg.tapsmofrq = 0.5*(abs(diff([3 8])));<br>
cfg.frequency    = 5.5;<br>
cfg.keeptrials = 'yes';<br>
cfg.channel         = {'EEG', 'EMG'};<br>
cfg.channelcmb      = {'EEG' 'EEG'; 'EMG' 'EEG'};<br>
freqRest = ft_freqanalysis(cfg, data_rest);<br>
freqAct = ft_freqanalysis(cfg, data_act);<br>
<br>
%% computation of common filter<span class="Apple-converted-space"> </span><br>
dataAll = ft_appenddata([], data_rest, data_act);<br>
freqAll = ft_freqanalysis(cfg, dataAll);<br>
<br>
%% Leadfield matrix generation<br>
cfg                 = [];<br>
cfg.elec            = sens;<span class="Apple-converted-space"> </span><br>
cfg.vol             = vol;    % vol from individual MRI (computed before)<br>
cfg.reducerank      = 3;<br>
cfg.channel         = {'EEG'};<br>
cfg.grid.resolution = 5;   % use a 3-D grid with a 5 mm resolution<br>
cfg.grid.unit       = 'mm';<br>
cfg.normalize       = 'yes';<br>
[grid] = ft_prepare_leadfield(cfg);<br>
<br>
%% Source analysis with DICS beamformer<br>
cfg              = [];<br>
cfg.frequency    = 5.5;<br>
cfg.grid        = grid;<br>
cfg.method       = 'dics';<br>
cfg.refchan      = 'EMG';<br>
cfg.channel         = {'EEG' 'EMG'};<br>
cfg.tapsmofrq = 0.5*(abs(diff([3 8])));<br>
cfg.vol          = vol;<br>
cfg.dics.projectnoise = 'yes';<br>
cfg.dics.lambda       = '5%';<br>
cfg.dics.keepfilter   = 'yes';<br>
cfg.dics.realfilter   = 'no';<br>
sourceAll = ft_sourceanalysis(cfg, freqAll);<br>
cfg.grid.filter = sourceAll.avg.filter; % common flter as computed before<br>
<br>
sourceAct = ft_sourceanalysis(cfg, freqAct);<br>
sourceRest = ft_sourceanalysis(cfg, freqRest);<br>
sourceRest.time = data_rest.time;<br>
sourceAct.time = data_act.time;<br>
<br>
% At this point, data is concatenated into two structures, where each cell includes data of one subject for both rest (=baseline, sourceRest_all) and activation (sourceAct_all).<br>
<br>
%%  Group statistics<br>
cfg = [];<br>
cfg.channel     = 'all';<br>
cfg.avgovertime = 'yes';<br>
cfg.parameter   = 'avg.coh';<br>
cfg.method      = 'montecarlo';<br>
cfg.statistic   = 'ft_statfun_depsamplesT';<br>
cfg.alpha       = 0.05;<br>
cfg.correctm    = 'cluster';<br>
cfg.numrandomization = 1000;<br>
<br>
nsubj=numel(sourceAct_all);<br>
cfg.design(1,1:2*nsubj)  = [ones(1,nsubj) 2*ones(1,nsubj)];<br>
cfg.design(2,1:2*nsubj)  = [1:nsubj 1:nsubj];<br>
cfg.ivar                = 1; % the 1st row in cfg.design contains the independent variable<br>
cfg.uvar                = 2; % the 2nd row in cfg.design contains the subject number<br>
 <br>
stat = ft_sourcestatistics(cfg,sourceAct_all{:},sourceRest_all{:});<br>
<div><br>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-size:13px">
<hr>
<font face="Tahoma" size="2"><font color="003366">Dr. David Pedrosa<br>
</font></font><font color="003366" face="Tahoma" size="2"><br>
Clinical Research Fellow</font><font color="003366" face="Tahoma" size="2"><br>
</font><font color="003366" face="Tahoma" size="2"><span dir="ltr" style="font-size:10pt">
<div>
<div><span style="font-size:13px">
<div><font size="2"><span style="font-size:10pt">Medical Research Council Brain Network Dynamics Unit at the University of Oxford<br>
Nuffield Department of Clinical Neurosciences</span></font></div>
<div>University of Oxford</div>
<div>Level 6, West Wing</div>
<div>John Radcliffe Hospital, OX3 9DU<br>
</div>
</span></div>
</div>
</span></font><font color="003366" face="Tahoma" size="2"><span style="font-size:10pt"><u>Tel:</u><span class="Apple-converted-space"> </span></span></font><font face="Tahoma" size="2"><span style="font-size:10pt"><font color="003366">+44 (0)1865 572490<br>
<u>E-Mail:</u><span class="Apple-converted-space"> </span></font><font color="333333"><a href="mailto:david.pedrosa@ndcn.ox.ac.uk" target="_blank">david.pedrosa@ndcn.ox.ac.uk</a><br>
</font></span></font><font size="2"><span style="font-size:10pt"><br>
<a href="http://www.mrcbndu.ox.ac.uk/" target="_blank">http://www.mrcbndu.ox.ac.uk/</a></span></font><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>