[FieldTrip] Help with ft_sourcestatistics input
Matteo Maran
maran at cbs.mpg.de
Thu Jul 30 13:58:52 CEST 2020
Dear Tao and Xavier,
I was also struggling with the .dim field of the cfg structure, and indeed I was getting the same error as the one you reported with the MNE data. From previous Q&A on the mailing list I found the following info which might be useful:
https://mailman.science.ru.nl/pipermail/fieldtrip/2017-June/037494.html
https://mailman.science.ru.nl/pipermail/fieldtrip/2016-July/023582.html
As far as I read from the reply to the first question, you need cfg.dim or cfg.tri, according to the source model you used. Loading the templates from http://www.fieldtriptoolbox.org/template/sourcemodel/ I see that the templates defined on a 3D grid have a .dim field (e.g. standard_sourcemodel3d10mm), but no .tri field. On the other side, source model templates for MNE have a .tri but no .dim field (e.g. sourcemodel = ft_read_headshape('cortex_20484.surf.gii') ). This is then reflected in the field of the data you give as an input to ft_sourcestatistics.
load(standard_sourcemodel3d10mm.mat)
sourcemodel =
struct with fields:
dim: [18 21 18]
pos: [6804×3 double]
inside: [6804×1 logical]
cfg: [1×1 struct]
unit: 'cm'
% Note that 18*21*18 = 6804
sourcemodel = ft_read_headshape('cortex_20484.surf.gii') )
sourcemodel =
struct with fields:
pos: [20484×3 double]
tri: [40960×3 double]
unit: 'mm'
Indeed, if you have a look at the second question posted above, you can see that cfg.tri instead of cfg.dim was specified. Maybe this can be of help.
Best wishes,
Matteo
----- Original Message -----
From: "Xavier Vrijdag" <x.vrijdag at auckland.ac.nz>
To: "fieldtrip" <fieldtrip at science.ru.nl>
Sent: Thursday, July 23, 2020 10:27:42 PM
Subject: Re: [FieldTrip] Help with ft_sourcestatistics input
Hi Tao,
I am not sure about the cfg.neighbours setting, but the error looks like a SPM version issue I had before as well. I solved it by adding:
cfg.spmversion = 'spm12' ;
regards,
Xavier
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Tao Wang <wangtao0331 at tju.edu.cn>
Reply to: FieldTrip discussion list <fieldtrip at science.ru.nl>
Date: Friday, 24 July 2020 at 3:26 AM
To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Subject: [FieldTrip] Help with ft_sourcestatistics input
Dear community,
My name is Tao Wang and I study at Tianjin University. My research direction is to explore ways(tDCS\tACS) to improve working memory. I ’ m looking to perform a cluster-based permutation test on my source data(the result from ft_sourceanalysis).
I carefully read the function help and the tutorial( http://www.fieldtriptoolbox.org/example/source_statistics/ ). However, I receive the following error message:
Error using spm_bwlabel
spm_bwlabel: CONN must be 6, 18 or 26
Error in clusterstat (line 191)
[posclusobs, posnum] = spm_bwlabel(tmp, 2*numdims);
Error in ft_statistics_montecarlo (line 353)
[stat, cfg] = clusterstat(cfg, statrand, statobs);
Error in ft_sourcestatistics (line 202)
[stat, cfg] = statmethod(cfg, dat, design);
I am running the following:
cfg=[];
cfg.parameter='pow';
cfg.method='montecarlo';
cfg.statistic = 'ft_statfun_depsamplesT';
cfg.correctm = 'cluster';
cfg.clusteralpha = 0.05;
cfg.clusterstatistic = 'maxsum';
cfg.tail=0;
cfg.clustertail=0;
cfg.alpha=0.025;
cfg.numrandomization = 1000;
nsubj = 10;
cfg.design(1,:) = [1:nsubj 1:nsubj];
cfg.design(2,:) = [ones(1,nsubj)*1 ones(1,nsubj)*2];
cfg.uvar = 1; % row of design matrix that contains unit variable (in this case: subjects)
cfg.ivar = 2; % row of design matrix that contains independent variable (the conditions)
stat = ft_sourcestatistics(cfg, grandavgA{:}, grandavgB{:});
My data:
display (grandavgA{1})
time: [1 × 400 double]
inside: [8196 × 1 logical]
pos: [8196 × 3 double]
tri: [16384 × 3 double]
method: 'average'
avg: [1 × 1 struct]
cfg: [1 × 1 struct]
display(grandavgA{1}.avg)
mom: {1 × 8196 cell}
pow: [8196 × 1 double] %I used ‘ 8196 × 1 double ’ instead of ‘ 8196 × 400 double ’
noisecov: {1 × 8196 cell}
Do I need to set cfg.neighbours, like the settings in the tutorial "Cluster-based permutation tests on event related fields"? (I noticed cfg.dim, but it doesn ’ t appear in my source struct)
Can someone tell me if there is something wrong with the cfg settings I use or if I am doing something wrong at any other place? Any tips anyone has would be very much appreciated!
Hope that helps!
Best,
Tao
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
More information about the fieldtrip
mailing list