[FieldTrip] Using Atlas ROIs in EEG Source Statistics (ft_sourcestatistics)

Roey Schurr roeysc at gmail.com
Thu Oct 10 20:48:05 CEST 2013


Hello again,

Thanks Jörn, indeed we are using the atlas you mentioned.

We also found out one of the problems was that ft_read_atlas was taken from
an EEGLAB directory and not a FT one.
Yet the problems persist in the function clusterstat, when using
cfg.avgoverroi = 'yes':

     ??? In an assignment  A(:) = B, the number of elements in A and B must
be the same.

     Error in ==> clusterstat at 210
     tmp(cfg.inside) = postailobs;

Some dimensions in our code:
The template sourcemodel gris for the singlesphere is 17 X 17 X 17
Hence the subject's sourcemodel grid for the singlesphere is 17 X 17 X 17
Hence the source reconstruction is also 17 X 17 X 17
The MNI MRI is 91 X 109 X 91
The AAL atlas is also 91 X 109 X 91

We don't understane how come "poastailobs" is 232 (twice the number of ROIs
defined in the atlas).
But still, " cfg.inside " defined all voxel that are inside the brain in
the source space, so it is clear that an assignment as that demanded by
line 210 in clusterstat would not work,

We thought we could use ft_volumelookup in order to find those voxels that
correspond to the areas that got 1 in "postailobs", but that won't work,
since we do not have the source struct available at that point in the code.

Are we using structures of insuitable dimensions? Are we doing anything
wrong? Or is there a problem with the firldtrip code itself?

Any help would be greatly appreciated!

Aia and Roey



On Wed, Oct 9, 2013 at 10:15 AM, "Jörn M. Horschig" <
jm.horschig at donders.ru.nl> wrote:

>  Hi Roey,
>
> habe you tried the atlas that is shipped with FieldTrip? It can be found
> in fieldtrip/templates/atlas/AAL/
>
> Best,
> Jörn
>
>
> On 10/8/2013 11:41 PM, Roey Schurr wrote:
>
> Dear fieldtrippers (Jan-Mathijs included),
>
>  (This message seems long, but is actually quite simple)
>
>  Having downloaded the latest fieldtrip version (20131008), we tried
> rerunning the code and got the following error:
>
>      ??? Reference to non-existent field 'coordsys'.
>
>       Error in ==> ft_volumelookup at 206
>            if     strcmp(cfg.inputcoord, 'mni') &&
>             strcmp(atlas.coordsys, 'tal')
>
>       Error in ==> statistics_wrapper at 136
>              tmp = ft_volumelookup(tmpcfg, varargin{1});
>
>       Error in ==> ft_sourcestatistics at 107
>          [stat, cfg] = statistics_wrapper(cfg, varargin{:});
>
>
>  Since the spm8 MNI atlas indeed has no "coordsys" field.
> Even if we bypass this problem (by setting "atlas.coordsys = 'mni' " by
> hand, or by simply deleting that "if" line), we still get one of two errors:
>
>  * * * * * (1) * * * * *
> If we define "cfg.roi = AAL_names;" where AAL_names stores all 90 ROIs the
> MNI atlas has to offer, we get an indices error:
>
>       ??? Subscript indices must either be real positive integers or
>       logicals.
>
>       Error in ==> statistics_wrapper at 213
>            tmp(i,:) = mean(dat(roi,:), 1);
>
>        Error in ==> ft_sourcestatistics at 107
>           [stat, cfg] = statistics_wrapper(cfg, varargin{:});
>
>
>  * * * * * (2) * * * * *
>  If we define "cfg.roi = AAL_names{1};" for example, we get a different
> error:
>
>       ??? In an assignment  A(:) = B, the number of elements in A and
>       B must be the same.
>
>       Error in ==> clusterstat at 187
>           tmp(cfg.inside) = postailobs;
>
>        Error in ==> ft_statistics_montecarlo at 326
>         [stat, cfg] = clusterstat(cfg, statrand,
>         statobs,'issource',issource);
>
>       Error in ==> statistics_wrapper at 298
>           [stat, cfg] = statmethod(cfg, dat, design,
>           'issource',issource);
>
>       Error in ==> ft_sourcestatistics at 107
>           [stat, cfg] = statistics_wrapper(cfg, varargin{:});
>
>  And in "cluserstat" appears this comment: "%this snippet is to support
> correct clustering of N-dimensional data, not fully tested yet".
> Changing line 187 to: "tmp(cfg.inside) = postailobs(1);" (and line 211 to
> "tmp(cfg.inside) = negtailobs(1);") prevents this problem, but misuses the
> variables vectors "postailobs" and "negtailobs"
>
>
>  Any ideas on how to solve this atlas source statistics problem (defining
> the coordsys field, performing statistics across all ROIs, and using the
> postailobs/negtailobs vectors) would be greatly appreciated!
>
>  Good night,
> Aia and Roey
>
>
> On Tue, Oct 8, 2013 at 9:43 AM, Roey Schurr <roeysc at gmail.com> wrote:
>
>> Dear Jan-Mathijs,
>>
>>  Thank you so much for your kind and quick answer!
>> We do hope this will fix things up. We will check it asap.
>>
>>  Best regards,
>> Aia and Roey
>>
>>
>>
>>
>> On Tue, Oct 8, 2013 at 9:38 AM, jan-mathijs schoffelen <
>> jan.schoffelen at donders.ru.nl> wrote:
>>
>>> Dear Roey and Aia,
>>>
>>>  This indeed was our bad. We have fixed it in the current version of
>>> FieldTrip.
>>> The version will be available for download tonight (CET), but you can
>>> get an instantaneous update of the code repository by doing 'ft_version
>>> update' on the Matlab command line.
>>> This will update the fieldtrip copy you are using to the latest version.
>>> Note that if you want to keep a 'static' version, you need to back up the
>>> version with a fixed date, because all changes will be incorporated.
>>>
>>>  A little note to the following piece of code:
>>>
>>>     % Load the Atlas
>>>> templateDir = which('ft_defaults'); % use a known function
>>>> (ft_defaults) to find FieldTrip's directory
>>>> backslashIndices = find(templateDir=='\');
>>>> templateDir(backslashIndices(end)+1:end) = [];      clear
>>>> backslashIndices;
>>>> cfg.atlas = [templateDir, 'template\atlas\aal\ROI_MNI_V4.nii'];
>>>>
>>>
>>>  The same can be achieved with the fullfile function (which deals with
>>> platform specific file-separators automatically):
>>>
>>>  templateDir=which('ft_defaults');
>>> cfg.atlas = fullfile(templateDir,template,atlas,ROI_MNI_V4.nii');
>>>
>>>
>>>  Best,
>>> Jan-Mathijs
>>>
>>>
>>>
>>>   On Oct 8, 2013, at 8:25 AM, Roey Schurr wrote:
>>>
>>>    Hello again,
>>>
>>>  Sorry, it seems like the older version (with ft_volumelookup) is just
>>> our mistake.
>>> However the problem is still relevant, for the function volumelookup is
>>> still undefinded in our case.
>>>
>>>  Hopefully someone might know what we did wrong.
>>>
>>>  Thank you once again!
>>> Aia and Roey
>>>
>>>
>>> On Tue, Oct 8, 2013 at 12:54 AM, Roey Schurr <roeysc at gmail.com> wrote:
>>>
>>>>  Hello all,
>>>>
>>>>  We are having some problems defining atlas-based ROIs using
>>>> ft_sourcestatistics on two source structures obtained via ft_sourceanalysis
>>>> (whose grid is later changed according to a precalculated MNI-warped grid).
>>>>
>>>>  It seems like the function "statistics_wrapper" has changed between
>>>> "fieldtrip-20130822" and "fieldtrip-20131007": line 136 now calls
>>>> "volumelookup" and not "ft_volumelookup", so we get the following error:
>>>>
>>>>        ??? Undefined function or method 'volumelookup' for input
>>>>       arguments of type 'struct'.
>>>>
>>>>        Error in ==> statistics_wrapper at 136
>>>>               tmp = volumelookup(tmpcfg, varargin{1});
>>>>
>>>>  Using the older fieldtrip vesion we get this error:
>>>>      ??? Subscript indices must either be real positive integers or
>>>>     logicals.
>>>>
>>>>        Error in ==> statistics_wrapper at 213
>>>>             tmp(i,:) = mean(dat(roi,:), 1);
>>>>
>>>>        Error in ==> ft_sourcestatistics at 107
>>>>           [stat, cfg] = statistics_wrapper(cfg, varargin{:});
>>>>
>>>>  So it seems like we didn't define the ROIs correctly, however we are
>>>> not sure why.
>>>>
>>>>  Any suggestions would be greatly appreciated!
>>>> The relevant pieceof code is attached.
>>>>
>>>>  Thank you all,
>>>> Aia and Roey
>>>>
>>>>
>>>>
>>>>  Relevant code
>>>>  ============
>>>>  % Convert sources units to mm, to fit the atlas's units
>>>> sourceCondition1 = ft_convert_units(sourceCondition1, 'mm');
>>>> sourceCondition2 = ft_convert_units(sourceCondition2, '
>>>>  design = [ ones(1,length(sourceCondition1.trial)),
>>>> 2*ones(1,length(sourceCondition2.trial)) ];
>>>>
>>>>  cfg = [];
>>>> cfg.dim = sourceCondition1.dim;
>>>> cfg.method = 'montecarlo';
>>>> cfg.statistic = 'indepsamplesT';
>>>> cfg.parameter = 'pow';
>>>>  cfg.correctm = 'cluster';
>>>> cfg.numrandomization = 1000;
>>>> cfg.alpha = 0.01;
>>>> cfg.tail = 0;
>>>> cfg.design(1,:) = design;
>>>>  cfg.ivar = 1;
>>>>
>>>>  % Load the Atlas
>>>> templateDir = which('ft_defaults'); % use a known function
>>>> (ft_defaults) to find FieldTrip's directory
>>>> backslashIndices = find(templateDir=='\');
>>>> templateDir(backslashIndices(end)+1:end) = [];      clear
>>>> backslashIndices;
>>>> cfg.atlas = [templateDir, 'template\atlas\aal\ROI_MNI_V4.nii'];
>>>>
>>>>
>>>>   cfg.roi = AAL_names; % This is a cell array of the atlas's ROIs:
>>>> "Precentral_L", "Precentral_R", etc/
>>>>
>>>>  cfg.avgoverroi   = 'yes';
>>>> cfg.hemisphere   = 'both';
>>>> cfg.inputcoord   = 'mni';
>>>>
>>>>  stat = ft_sourcestatistics(cfg, sourceCondition1, sourceCondition2);
>>>>
>>>>
>>>   _______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>
>>>
>>>          Jan-Mathijs Schoffelen, MD PhD
>>>
>>>  Donders Institute for Brain, Cognition and Behaviour,
>>> Centre for Cognitive Neuroimaging,
>>> Radboud University Nijmegen, The Netherlands
>>>
>>>  Max Planck Institute for Psycholinguistics,
>>> Nijmegen, The Netherlands
>>>
>>>  J.Schoffelen at donders.ru.nl
>>> Telephone: +31-24-3614793
>>>
>>>  http://www.hettaligebrein.nl
>>>
>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>
>>
>>
>
>
> _______________________________________________
> fieldtrip mailing listfieldtrip at donders.ru.nlhttp://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
>
> --
> Jörn M. Horschig
> PhD Student
> Donders Institute for Brain, Cognition and Behaviour
> Centre for Cognitive Neuroimaging
> Radboud University Nijmegen
> Neuronal Oscillations Group
> FieldTrip Development Team
>
> P.O. Box 9101
> NL-6500 HB Nijmegen
> The Netherlands
>
> Contact:
> E-Mail: jm.horschig at donders.ru.nl
> Tel:    +31-(0)24-36-68493
> Web: http://www.ru.nl/donders
>
> Visiting address:
> Trigon, room 2.30
> Kapittelweg 29
> NL-6525 EN Nijmegen
> The Netherlands
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20131010/dc96d8b6/attachment-0002.html>


More information about the fieldtrip mailing list