[FieldTrip] Circ_stat toolbox in FT's cluster-based permutation statistics

Julian Keil julian.keil at gmail.com
Wed May 18 08:07:46 CEST 2022

Hi David,

ages ago I wrote a stat_fun for this to be used specifically for a project.
Here’s the code, maybe it still works and does what you want to do.
Basically, you run the ww-test, and then feed the stat-field back to the montecarlo statistics function.

function [s] = statfun_wwtest(cfg, dat, design)

selA = find(design(cfg.ivar,:)==1); % selecton condition 1 or A
selB = find(design(cfg.ivar,:)==2); % selecton condition 2 or B
dfA  = length(selA);
dfB  = length(selB);

if (dfA+dfB)<size(design, 2)
  % there are apparently replications that belong neither to condition 1, nor to condition 2
  warning('inappropriate design, it should only contain 1''s and 2''s');
    for comp=1:length(dat)
        [pval table] = circ_wwtest(dat(comp,selA),dat(comp,selB));
    % the stat field is used in STATISTICS_MONTECARLO to make the
    % randomization distribution, but you can also return other fields
    % which will be passed on to the command line in the end.
s.stat = stat;
s.prob = prob;

Hope this helps,


> Am 18.05.2022 um 00:55 schrieb David Marcel Baum via fieldtrip <fieldtrip at science.ru.nl>:
> Hello Everyone,
> I am attempting to use Fieldtrip's cluster-based permutation statistics on phase estimates (circular values). Thus I cannot use the statistic functions provided by Fieldtrip (e.g., "ft_statfun_depsamplesT.m"). I would like to integrate the circstat toolbox into Fieldtrip instead. Could someone help me validate that the following approach is correct:
> Create a ft_statfun_[NewName].m that does:
> 1. For each sample (here: channel), calculate the F value using the circstat function circ_wwtest.m
> 2. Get the critical F value using "finv"
> Would be happy and grateful about any input!
> Regards
> David
> --
> David Marcel BAUM
> Instituto de Ingeniería Biológica y Médica
> Pontificia Universidad Católica de Chile
> Santiago, Chile
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220518/adcadb9c/attachment.htm>

More information about the fieldtrip mailing list