[FieldTrip] Help with ft_sourcestatistics

FRANCISCO JAVIER GÓMEZ CAMPOS fjgomez-ibis at us.es
Thu Nov 17 11:18:31 CET 2022


Dear community,

I am having problems using the ft_sourcestatistics function. I would like to use this function
to conduct a within-subject analysis to establish which areas show differences between two
experimental conditions. I mainly have doubts about two aspects, the first one is about how to
attach the source analysis data, and the second one is about the design of the design matrix.

Regarding the data coming from the source analysis, I have the sources separated by
conditions (obtained by following this tutorial https://www.fieldtriptoolbox.org/tutorial/beamformer/):

Source analysis data for each condition:
freq: 4.8302
cfg: [1×1 struct]
dim: [85 110 132]
inside: [1234200×1 logical]
pos: [1234200×3 double]
method: 'average'
avg: [1×1 struct]

avg:
pow: [1234200×1 double]
noise: [1234200×1 double]
filter: {1234200×1 cell}
label: {61×1 cell}
filterdimord: '{pos}_ori_chan'

The code I use is the following (based on this code in this tutorial
https://www.fieldtriptoolbox.org/example/source_statistics/ ) :

design=[1 2]; %for 2 conditions
% run sourcestatistics using cluster based correction %
cfg = [];
cfg.dim = sourceanalysis_condition1(1).dim;

cfg.method = 'montecarlo';
cfg.statistic = 'ft_statfun_depsamplesT';
cfg.parameter = 'pow';
cfg.correctm = 'cluster';
cfg.numrandomization = 'all';
cfg.alpha = 0.05; % note that this only implies single-sided testing
cfg.tail = 0;
cfg.design(1,:) = [1:length(find(design==1)) 1:length(find(design==2))];
cfg.design(2,:) = design;
cfg.uvar = 1; % row of design matrix that contains unit variable (in this case: trials)
cfg.ivar = 2; % row of design matrix that contains independent variable (the conditions)
stat = ft_sourcestatistics(cfg, sourceanalysis_condition1, sourceanalysis_condition2)

When I run this code, I get the following error:
Error using ft_statfun_depsamplesT (line 83)
The data must contain at least two units of observation (trials or subjects).

I understand that my design matrix and/or the structure of sourceanalysis_condition are
wrong, I have tried different combinations and I cannot find the solution. I hope you can
guide me in this regard so that I can adapt it to the conditions of my study.

Thanks,
Francisco Javier Gómez,
Instituto de Biomedicina de Sevilla (IBIS)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20221117/b9ae4659/attachment.htm>


More information about the fieldtrip mailing list