Skip to content

Commit bb70db9

Browse files
edenoclaude
andcommitted
fix: correct global coherence plotting for Nyquist frequency fix
The Nyquist frequency fix changed how frequencies are returned: - connectivity.frequencies now includes the Nyquist frequency (N//2+1 freqs) - global_coherence() returns data for ALL frequencies (both +/-) Updated the global coherence plotting code to: 1. Extract first N//2+1 frequencies from global_coherence 2. Use connectivity.frequencies directly (no manual Nyquist append) 3. Add proper edge for pcolormesh grid to match data dimensions This fixes the pcolormesh dimension mismatch error. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 6cc0845 commit bb70db9

File tree

2 files changed

+62
-47
lines changed

2 files changed

+62
-47
lines changed

examples/Tutorial_On_Simulated_Examples.ipynb

Lines changed: 54 additions & 44 deletions
Large diffs are not rendered by default.

examples/Tutorial_On_Simulated_Examples.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,16 +2424,21 @@
24242424

24252425
global_coherence, unnormalized_global_coherence = connectivity.global_coherence()
24262426
print(global_coherence.shape) # n_time, n_frequencies, n_components
2427+
2428+
# Extract non-negative frequencies (first N//2+1 frequencies)
2429+
n_nonneg_freqs = len(connectivity.frequencies)
2430+
global_coherence_nonneg = global_coherence[:, :n_nonneg_freqs, 0].T # (freqs, time)
2431+
24272432
time_grid, freq_grid = np.meshgrid(
24282433
np.append(connectivity.time, time_extent[-1]),
2429-
np.append(connectivity.frequencies, multitaper.nyquist_frequency),
2434+
np.append(connectivity.frequencies, connectivity.frequencies[-1]), # Add edge for pcolormesh
24302435
)
24312436
plt.figure()
24322437
plt.pcolormesh(
24332438
time_grid,
24342439
freq_grid,
2435-
global_coherence[:, connectivity.all_frequencies >= 0, 0].T,
2436-
shading="auto",
2440+
global_coherence_nonneg,
2441+
shading="flat",
24372442
)
24382443
plt.title("Global Coherence (1st component)")
24392444
plt.xlabel("Time [s]")

0 commit comments

Comments
 (0)