Skip to content

Commit

Permalink
Update batch simulation plotting and run() docstring
Browse files Browse the repository at this point in the history
Co-authored-by: Nicholas Tolley <[email protected]>
Signed-off-by: samadpls <[email protected]>
  • Loading branch information
samadpls and ntolley committed Aug 4, 2024
1 parent 49541b6 commit b50680d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
19 changes: 12 additions & 7 deletions examples/howto/plot_batch_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,32 @@ def summary_func(results):
# backend='dask' if installed
print("Simulation results:", simulation_results)
###############################################################################
# Extract and Plot Results
###############################################################################
# This plot shows an overlay of all smoothed dipole waveforms from the
# batch simulation. Each line represents a different set of parameters,
# allowing us to visualize the range of responses across the parameter space.


# Extract and overlay dipole waveforms
dpl_waveforms = []
for data_list in simulation_results['simulated_data']:
for data in data_list:
dpl_waveforms.append(data['dpl'][0].data['agg'].copy().smooth(30))
window_len = 30
dpl_smooth = data['dpl'][0].copy().smooth(window_len)
dpl_waveforms.append(dpl_smooth.data['agg'])

plt.figure(figsize=(10, 6))
for waveform in dpl_waveforms:
plt.plot(waveform, alpha=0.5)
plt.plot(waveform, alpha=0.5, linewidth=3)
plt.title('Overlay of Dipole Waveforms')
plt.xlabel('Time (ms)')
plt.ylabel('Dipole Amplitude (nAm)')
plt.grid(True)
plt.tight_layout()
plt.savefig("image.png")
plt.show()
###############################################################################
# This plot displays the minimum and maximum dipole peaks across
# different synaptic strengths. This allows us to see how the range of
# dipole activity changes as we vary the synaptic strength parameter.

# Extract min and max peaks for plotting
min_peaks, max_peaks, param_values = [], [], []
for summary_list, data_list in zip(simulation_results['summary_statistics'],
simulation_results['simulated_data']):
Expand Down
12 changes: 9 additions & 3 deletions hnn_core/batch_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,15 @@ def run(self, param_grid, return_output=True,
Returns
-------
results : dict
Dictionary containing summary statistics and simulation data
if return_output is True and clear_cache is False. Otherwise,
a dictionary containing only summary statistics.
Dictionary containing 'summary_statistics' and optionally
'simulated_data'.
'simulated_data' may include keys: 'dpl', 'lfp', 'spikes',
'voltages', 'param_values', 'net', 'times'.
Notes
-----
Return content depends on summary_func, return_output, and
clear_cache settings.
"""
_validate_type(param_grid, types=(dict,), item_name='param_grid')
Expand Down

0 comments on commit b50680d

Please sign in to comment.