Skip to content

Commit

Permalink
Refactor batch simulation parameters and backend
Browse files Browse the repository at this point in the history
Signed-off-by: samadpls <[email protected]>
  • Loading branch information
samadpls committed Oct 19, 2024
1 parent d7aad96 commit 2a513c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/howto/plot_batch_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def set_params(param_values, net=None):


param_grid = {
'weight_basket': np.logspace(-4 - 1, 10),
'weight_basket': np.logspace(-4, - 1, 10),
'weight_pyr': np.logspace(-4, -1, 10)
}

Expand Down
7 changes: 7 additions & 0 deletions hnn_core/tests/test_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ def test_dipole_visualization(setup_net):
# multiple TFRs get averaged
fig = plot_tfr_morlet(dpls, freqs=np.arange(23, 26, 1.), n_cycles=3,
show=False)
# when min_freq > max_freq (y-axis inversion)
fig = plot_tfr_morlet(dpls, freqs=np.array([30, 20, 10]),
n_cycles=3, show=False)
ax = fig.get_axes()[0]
y_limits = ax.get_ylim()
assert y_limits[0] > y_limits[1], \
"Y-axis should be inverted when min_freq > max_freq"

with pytest.raises(RuntimeError,
match="All dipoles must be scaled equally!"):
Expand Down
5 changes: 5 additions & 0 deletions hnn_core/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ def plot_tfr_morlet(dpl, freqs, *, n_cycles=7., tmin=None, tmax=None,
power = np.mean(trial_power, axis=0)
im = ax.pcolormesh(times, freqs, power[0, 0, ...], cmap=colormap,
shading='auto')

if freqs[0] > freqs[-1]:
freqs = freqs[::-1]
ax.invert_yaxis()

ax.set_xlabel('Time (ms)')
ax.set_ylabel('Frequency (Hz)')

Expand Down

0 comments on commit 2a513c5

Please sign in to comment.