From b50680de3c898bbf6a2a68d63a86e9f8aa73e4e1 Mon Sep 17 00:00:00 2001 From: samadpls Date: Sun, 4 Aug 2024 19:12:16 +0500 Subject: [PATCH] Update batch simulation plotting and run() docstring Co-authored-by: Nicholas Tolley <55253912+ntolley@users.noreply.github.com> Signed-off-by: samadpls --- examples/howto/plot_batch_simulate.py | 19 ++++++++++++------- hnn_core/batch_simulate.py | 12 +++++++++--- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/examples/howto/plot_batch_simulate.py b/examples/howto/plot_batch_simulate.py index 1dfd26dfc..79c61778a 100644 --- a/examples/howto/plot_batch_simulate.py +++ b/examples/howto/plot_batch_simulate.py @@ -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']): diff --git a/hnn_core/batch_simulate.py b/hnn_core/batch_simulate.py index 13cbf8fb5..964efa10f 100644 --- a/hnn_core/batch_simulate.py +++ b/hnn_core/batch_simulate.py @@ -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')