Repository navigation
Description
Summary
For method="tort", Comodulogram.fit() accepts amplitude centers at and above Nyquist and returns finite MI without a warning. With fs=1000, a center labeled 550 Hz produces the same MI as 450 Hz in the reproduction below. Separately, high_fq_range="auto" includes exactly 500 Hz.
Tested against upstream commit 24dc3ed1917b (source reports 0.3.2), with Python 3.10.18, NumPy 2.2.6, SciPy 1.14.1, scikit-learn 1.6.1, and Matplotlib 3.10.3. The reproduction below executes the unmodified pinned upstream source.
Minimal reproduction
import numpy as np
from pactools import Comodulogram
fs = 1000.0
t = np.arange(12000) / fs
x = (np.cos(2 * np.pi * 20 * t)
+ (1 + 0.5 * np.cos(2 * np.pi * 20 * t))
* np.cos(2 * np.pi * 450 * t))[None, :]
mask = np.ones_like(x, dtype=bool)
mask[:, 2000:10000] = False
for centers in ([450.0, 500.0, 550.0], "auto"):
est = Comodulogram(
fs=fs, low_fq_range=[20.0], low_fq_width=2.0,
high_fq_range=centers, high_fq_width=40.0,
method="tort", n_surrogates=0, progress_bar=False,
)
est.fit(x, mask=mask) # Both calls currently succeed without a warning.
print("requested:", centers)
print("last amplitude center:", est.high_fq_range[-1])
print("all MI values finite:", np.isfinite(est.comod_).all())
if isinstance(centers, list):
print("MI:", est.comod_[0])Output:
requested: [450.0, 500.0, 550.0]
last amplitude center: 550.0
all MI values finite: True
MI: [0.0112861 0.10482495 0.0112861 ]
requested: auto
last amplitude center: 500.0
all MI values finite: True
The input contains only frequencies below Nyquist (20 Hz and the 430/450/470-Hz AM components). The 550-Hz output label therefore does not represent a distinct sampled frequency: the native sampled kernel aliases it onto 450 Hz.
Expected behavior / proposed scope
- For methods constructing bandpass phase/amplitude features, reject centers above Nyquist before filter construction, with an informative error.
- Address exact Nyquist explicitly: the sine quadrature degenerates there, so it is not an ordinary analytic-envelope center. I would suggest excluding it from the automatic grid and rejecting it for this path, or documenting a deliberate special interpretation.
- Document response/bandwidth constraints near DC and Nyquist separately. Merely placing a center below Nyquist does not guarantee adequate sideband support; this report does not propose one universal bandwidth margin.
Source locations
- Automatic amplitude grid:
np.linspace(max(self.low_fq_range), self.fs / 2.0, 80)includes its upper endpoint. - Native filtering validation: checks
frequency <= 0, without an upper-frequency check. - Sampled cosine/sine construction.
This is a frequency-domain validation issue, distinct from the finite-response overlap discussed in #32 and the alternative MNE filter path in #34. It is demonstrated here for native Tort filtering; it is not a claim about physiological PAC or an empirical statistical false-positive rate.
Addendum: This post was created by OpenAI Codex.
Activity