Skip to content

Commit

Permalink
Updated kwargs options for plot_spikes_hist
Browse files Browse the repository at this point in the history
parent 54bd278
author samadpls <[email protected]> 1710875966 +0500
committer samadpls <[email protected]> 1712241138 +0500

Added `kwargs` options to `plot_spikes_hist`

Signed-off-by: samadpls <[email protected]>

refactored

removed extra line
  • Loading branch information
samadpls committed Apr 4, 2024
1 parent 54bd278 commit 90f5cff
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Changelog
returned for cases when there should be no valid matches, by `George Dang`_
in :gh:`739`

- Added kwargs options to `plot_spikes_hist` for adjusting the histogram plots of spiking activity,
by `Abdul Samad`_ in :gh:`732`.

Bug
~~~
- Fix inconsistent connection mapping from drive gids to cell gids, by
Expand Down
6 changes: 4 additions & 2 deletions hnn_core/cell_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def plot_spikes_raster(self, trial_idx=None, ax=None, show=True):
cell_response=self, trial_idx=trial_idx, ax=ax, show=show)

def plot_spikes_hist(self, trial_idx=None, ax=None, spike_types=None,
color=None, show=True):
color=None, show=True, **kwargs_hist):
"""Plot the histogram of spiking activity across trials.
Parameters
Expand Down Expand Up @@ -392,6 +392,8 @@ def plot_spikes_hist(self, trial_idx=None, ax=None, spike_types=None,
If None, default color cycle used.
show : bool
If True, show the figure.
**kwargs_hist : dict
Additional keyword arguments to pass to ax.hist.
Returns
-------
Expand All @@ -400,7 +402,7 @@ def plot_spikes_hist(self, trial_idx=None, ax=None, spike_types=None,
"""
return plot_spikes_hist(self, trial_idx=trial_idx, ax=ax,
spike_types=spike_types, color=color,
show=show)
show=show, **kwargs_hist)

def to_dict(self):
"""Return cell response as a dict object.
Expand Down
6 changes: 5 additions & 1 deletion hnn_core/tests/test_cell_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def test_cell_response(tmp_path):
spike_gids=spike_gids,
spike_types=spike_types,
times=sim_times)
cell_response.plot_spikes_hist(show=False)
kwargs_hist = dict(alpha=0.25)
fig = cell_response.plot_spikes_hist(show=False, **kwargs_hist)
assert all(patch.get_alpha() == kwargs_hist['alpha']
for patch in fig.axes[0].patches
), "Alpha value not applied to all patches"

# Testing writing using txt files
with pytest.warns(DeprecationWarning,
Expand Down
6 changes: 4 additions & 2 deletions hnn_core/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def plot_dipole(dpl, tmin=None, tmax=None, ax=None, layer='agg', decim=None,


def plot_spikes_hist(cell_response, trial_idx=None, ax=None, spike_types=None,
color=None, show=True):
color=None, show=True, **kwargs_hist):
"""Plot the histogram of spiking activity across trials.
Parameters
Expand Down Expand Up @@ -369,6 +369,8 @@ def plot_spikes_hist(cell_response, trial_idx=None, ax=None, spike_types=None,
If None, default color cycle used.
show : bool
If True, show the figure.
**kwargs : dict
Additional keyword arguments to pass to ax.hist.
Returns
-------
Expand Down Expand Up @@ -473,7 +475,7 @@ def plot_spikes_hist(cell_response, trial_idx=None, ax=None, spike_types=None,
for spike_label, plot_data in spike_type_times.items():
hist_color = spike_color[spike_label]
ax.hist(plot_data, bins,
label=spike_label, color=hist_color)
label=spike_label, color=hist_color, **kwargs_hist)

ax.set_ylabel("Counts")
ax.legend()
Expand Down

0 comments on commit 90f5cff

Please sign in to comment.