From b988c7fb529dd2c87de659d945b3809b53802d58 Mon Sep 17 00:00:00 2001 From: "Austin E. Soplata" Date: Tue, 26 Nov 2024 12:24:08 -0500 Subject: [PATCH] fix: add GUI log error msg if spect args invalid (#944) --- hnn_core/gui/_viz_manager.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/hnn_core/gui/_viz_manager.py b/hnn_core/gui/_viz_manager.py index bd0d71792..34748b636 100644 --- a/hnn_core/gui/_viz_manager.py +++ b/hnn_core/gui/_viz_manager.py @@ -303,12 +303,23 @@ def _update_ax(fig, ax, single_simulation, sim_name, plot_type, plot_config): step_f = 1.0 freqs = np.arange(min_f, max_f, step_f) n_cycles = freqs / 2. - dpls_copied[0].plot_tfr_morlet( - freqs, - n_cycles=n_cycles, - colormap=plot_config['spectrogram_cm'], - ax=ax, colorbar_inside=True, - show=False) + + try: + dpls_copied[0].plot_tfr_morlet( + freqs, + n_cycles=n_cycles, + colormap=plot_config['spectrogram_cm'], + ax=ax, colorbar_inside=True, + show=False) + + except ValueError as ex: + if str(ex) == ('At least one of the wavelets is longer than ' + 'the signal. Use a longer signal or shorter ' + 'wavelets.'): + logger.error('At least one of the wavelets is ' + 'longer than the signal. Use a longer signal ' + 'or shorter wavelets. No spectrogram will be ' + 'plotted.') elif 'dipole' in plot_type: if len(dpls_copied) > 0: