spectral_connectivity.statistics.power_fisher_z_transform#

power_fisher_z_transform(spectrum1: ndarray[tuple[int, ...], dtype[floating]], n_obs1: int, spectrum2: ndarray[tuple[int, ...], dtype[floating]] | float = 0, n_obs2: int = 0) ndarray[tuple[int, ...], dtype[floating]][source]#

Transform power spectrum estimates for statistical testing.

Applies log-transformation with bias correction to power spectrum estimates, enabling approximately normal distributions for hypothesis testing. Can perform one-sample test against baseline or two-sample comparison.

Parameters:
  • spectrum1 (NDArray[floating], shape (...,)) – Power spectrum estimates from first condition.

  • n_obs1 (int) – Number of observations for spectrum1 (n_tapers * n_trials).

  • spectrum2 (NDArray[floating] or float, default=0) – Power spectrum estimates from second condition for comparison. If 0, performs one-sample test.

  • n_obs2 (int, default=0) – Number of observations for spectrum2 (n_tapers * n_trials).

Returns:

z_scores – Z-scores for statistical testing of power differences.

Return type:

NDArray[floating], shape (…,)

Examples

>>> import numpy as np
>>> # One-sample test against baseline
>>> power1 = np.array([0.5, 1.0, 2.0, 0.8])
>>> z_one = power_fisher_z_transform(power1, n_obs1=100)
>>>
>>> # Two-sample comparison
>>> power2 = np.array([0.3, 0.8, 1.5, 0.9])
>>> z_two = power_fisher_z_transform(power1, 100, power2, 120)

Notes

Uses bias correction based on sample size to improve the normal approximation for statistical testing.