dirconn.contrast_test#
- dirconn.contrast_test(estimator: Estimator, data_a: TimeSeries, data_b: TimeSeries, *, n_permutations: int, seed: int, reduce: Callable[[Connectivity], Connectivity] | str | Sequence[float] | None = None, alpha: float = 0.05, paired: bool = False) ContrastResult#
Test whether connectivity differs between two conditions or two segments of the same trials.
Permutation
iusesRNGController(seed).child(i)to shuffle the pooled trials and assigns the firstn_ato condition A, so the group sizes are kept and results do not depend on how the work is split. The estimator’s whole procedure, including a model order chosen by a criterion, is repeated on every relabelling.With
paired=Truethe data sets are two segments of the same trials, trialkofdata_aand trialkofdata_bbeing cut from the same trial. Permutationithen draws one fair coin per trial fromRNGController(seed).child(i).integers(0, 2, n_trials)and swaps the two segments of that trial when it is 1, so every trial keeps both of its segments and the groups keep their size. A relabelling and its complement give the same|statistic|, so a p-value cannot be finer than1 / 2**(n_trials - 1). An unpaired test on such data would ignore what the two segments of a trial share and compare a null that is too wide.- Parameters:
estimator (Estimator) – Any dirconn estimator.
data_a (TimeSeries) – Epoched data with the same channels, sampling frequency and number of samples, and at least two trials each. The trial counts may differ; with
paired=Truethey must be equal and the segments of equal length.data_b (TimeSeries) – Epoched data with the same channels, sampling frequency and number of samples, and at least two trials each. The trial counts may differ; with
paired=Truethey must be equal and the segments of equal length.n_permutations (int) – Number of random relabellings; the smallest p-value is
1 / (n_permutations + 1). A warning says so when fewer distinct relabellings exist than permutations drawn.seed (int) – Required.
reduce (callable, str or (float, float), optional) – Applied to every fit before comparing (see
surrogate_test()).alpha (float) – Level used for the power check, as in
surrogate_test().paired (bool) –
Truewhendata_aanddata_bare two segments of the same trials (see above).
- Return type:
- Raises:
ValueError – For incompatible conditions, invalid arguments, or a relabelled fit that leaves a cell undefined that is defined in both conditions.