Coh is documented everywhere as the magnitude-squared coherence, but the code returns the un-squared coherency magnitude.
Documented as squared:
hypyp/sync/README.md — Coh(f) = |⟨S₁₂(f)⟩|² / (⟨|S₁|²⟩ · ⟨|S₂|²⟩)
hypyp/sync/coh.py:38 (class docstring) — Coh = |⟨XY*⟩|² / (⟨|X|²⟩⟨|Y|²⟩)
hypyp/analyses.py:501 (compute_sync Modes section) — Coh = |⟨S₁₂⟩|² / (⟨|S₁|²⟩·⟨|S₂|²⟩)
hypyp/sync/kernels/cuda_amplitude.py:6 — "coh_cuda — magnitude-squared Coherence", while its own kernel computes cross / den (cuda_amplitude.py:50-52)
Implemented unsquared — hypyp/sync/coh.py:89-90:
con = np.abs(dphi) / np.sqrt(np.einsum('nil,nik->nilk', np.nansum(amp, axis=3),
np.nansum(amp, axis=3)))
Measured on a random complex signal:
code value = 0.0460569357
|S12|/sqrt(P1*P2) (unsquared) = 0.0460569357 match=True
|S12|^2/(P1*P2) (squared) = 0.0021212413 match=False
The implementation is consistent across all five backends and matches the MNE convention, so this is a documentation bug, not a numerical one. But it matters: the two quantities differ substantially over the [0,1] range, and a user comparing HyPyP output against a paper reporting squared coherence will silently mis-compare.
Suggested fix: correct the four documentation sites to |⟨S₁₂⟩| / √(⟨|S₁|²⟩·⟨|S₂|²⟩) and state explicitly that this is coherency magnitude (MNE convention), not magnitude-squared coherence.
Cohis documented everywhere as the magnitude-squared coherence, but the code returns the un-squared coherency magnitude.Documented as squared:
hypyp/sync/README.md—Coh(f) = |⟨S₁₂(f)⟩|² / (⟨|S₁|²⟩ · ⟨|S₂|²⟩)hypyp/sync/coh.py:38(class docstring) —Coh = |⟨XY*⟩|² / (⟨|X|²⟩⟨|Y|²⟩)hypyp/analyses.py:501(compute_syncModes section) —Coh = |⟨S₁₂⟩|² / (⟨|S₁|²⟩·⟨|S₂|²⟩)hypyp/sync/kernels/cuda_amplitude.py:6— "coh_cuda— magnitude-squared Coherence", while its own kernel computescross / den(cuda_amplitude.py:50-52)Implemented unsquared —
hypyp/sync/coh.py:89-90:Measured on a random complex signal:
The implementation is consistent across all five backends and matches the MNE convention, so this is a documentation bug, not a numerical one. But it matters: the two quantities differ substantially over the [0,1] range, and a user comparing HyPyP output against a paper reporting squared coherence will silently mis-compare.
Suggested fix: correct the four documentation sites to
|⟨S₁₂⟩| / √(⟨|S₁|²⟩·⟨|S₂|²⟩)and state explicitly that this is coherency magnitude (MNE convention), not magnitude-squared coherence.