Skip to content

Commit

Permalink
Update glm_spectrum.py
Browse files Browse the repository at this point in the history
`plot_joint_spectrum` by default automatically determines which topo's to plot. However, it only looks for positive peaks, while it is probably more reasonable to look for any extrema (especially when plotting contrasts, or EEG data). 
With these changes, `find_peaks` is applied to the absolute data.
  • Loading branch information
matsvanes authored Jan 9, 2024
1 parent 16619b6 commit 6ef8bf6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions osl/glm/glm_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,9 @@ def plot_joint_spectrum(xvect, psd, info, ax=None, freqs='auto', base=1,
fx = prep_scaled_freq(base, xvect)

if freqs == 'auto':
topo_freq_inds = signal.find_peaks(psd.mean(axis=1), distance=xvect.shape[0]/3)[0]
topo_freq_inds = signal.find_peaks(np.abs(psd.mean(axis=1)), distance=xvect.shape[0]/3)[0]
if len(topo_freq_inds) > 2:
I = np.argsort(psd.mean(axis=1)[topo_freq_inds])[-2:]
I = np.argsort(np.abs(psd.mean(axis=1))[topo_freq_inds])[-2:]
topo_freq_inds = topo_freq_inds[I]
freqs = xvect[topo_freq_inds]
else:
Expand Down

0 comments on commit 6ef8bf6

Please sign in to comment.