Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mne/viz/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,12 @@ def plot_raw_psd(raw, tmin=0., tmax=np.inf, fmin=0, fmax=np.inf, proj=False,
# Convert PSDs to dB
if dB:
psds = 10 * np.log10(psds)
if np.any(np.isinf(psds)):
where = np.flatnonzero(np.isinf(psds.min(1)))
chs = [raw.ch_names[i] for i in picks[where]]
raise ValueError("Infinite value in PSD for channel(s) %s. "
"These channels might be dead." %
', '.join(chs))
unit = 'dB'
else:
unit = 'power'
Expand Down
3 changes: 3 additions & 0 deletions mne/viz/tests/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def test_plot_raw_psd():
# topo psd
raw.plot_psd_topo()
plt.close('all')
# with a flat channel
raw[5, :] = 0
assert_raises(ValueError, raw.plot_psd)


def test_plot_sensors():
Expand Down