[FieldTrip] Help with ft_freqstatistics

Zito Giuseppe Angelo giuseppeangelo.zito at hest.ethz.ch
Thu Mar 24 09:20:08 CET 2022


Dear Fieldtrip Community,

I would like to ask a question on ft_freqstatistics.

I have a design with 20 subjects and 2 conditions, which I imported from EEGlab with the function ft_preprocessing. I the extract the power in the frequency band of interest and I save it using ft_freqanalysis (see link to myData.mat).
I also created a layout where I modified the standard GSN-HydroCel-129 cap to fit with my own layout, and I computed the neighbours with the function ft_prepare neighbours (see link to myClusters.mat)

I then tried to run the stats with ft_freqstatistics to study differences in power spectrum between conditions in a within-subject design. However, when running ft_freqstatistics, I receive the following error:


Error using ft_checkdata (line 538)
This function requires freq data as input, see ft_datatype_freq.

Error in ft_freqstatistics (line 91)
  varargin{i} = ft_checkdata(varargin{i}, 'datatype', 'freq', 'feedback', 'no');


It seems to be related with the wrong formatting of the input, but the help of ft_checkdata states that the function should accept the data formatted with ft_freqanalysis.
Here is my code:

%% Load data into FieldTrip and extract the frequencies
for i = 1:length(participants)
    for j = 1:length(conditions)

        fileName = [folderPath participants{i} '\' participants{i} '_' conditions{j} '.set'];

        cfg = [];
        cfg.dataset = fileName;
        % Load the data from EEGlab to FieldTrip
        data{i,j} = ft_preprocessing(cfg);

        % Set parameters
        cfg.method = 'mtmfft';
        cfg.output = 'pow';
        cfg.channel = 'all';
        cfg.trials = 'all';
        cfg.keeptrials = 'yes';
        cfg.pad = 'nextpow2';
        cfg.foilim = [4 36]; % frequency band of interest
        cfg.taper = 'dpss';
        cfg.tapsmofrq  = 2;

        % Extract the frequencies
        freq{i,j} = ft_freqanalysis(cfg, data{i,j});
    end
end
freq1 = freq(:,1)';
freq9 = freq(:,9)';


%% Run the stats
clear
load myData.mat
load myClusters.mat
cfg = [];
% cfg.neighbours = myClusters;
cfg.channel     = 'all';
cfg.parameter   = 'powspctrm';
cfg.method      = 'montecarlo';
% cfg.frequency   = [4 36];
%cfg.method = 'analytic';
cfg.statistic = 'depsamplesT';
%cfg.statistic = 'ft_statfun_depsamplesFmultivariate';
cfg.channels = 'all';
cfg.alpha       = 0.05;
cfg.tail = 0;
% cfg.correctm    = 'cluster';
cfg.correcttail = 'alpha';
cfg.numrandomization = 'all';
cfg.ivar                = 2; % the independent variable
cfg.uvar                = 1;
nSub = 20;
cfg.design(1,1:2*nSub)  = [1:nSub 1:nSub];
cfg.design(2,1:2*nSub)  = [ones(1,nSub) 2*ones(1,nSub)];

stat = ft_freqstatistics(cfg, freq1,freq9);

Any idea of where the problem is?
Please, find here the link to the files:
https://polybox.ethz.ch/index.php/s/6nTJuNXICnRK1Uc
https://polybox.ethz.ch/index.php/s/3IA5vhgz6c7X0Bd

Thank you very much,
Giuseppe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220324/64928725/attachment.htm>


More information about the fieldtrip mailing list