Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions ibllib/plots/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ def insert_zeros(trace):


class Density:
def __init__(self, w, fs=1, cmap='Greys_r', ax=None, taxis=0, title=None, **kwargs):
def __init__(self, w, fs=30_000, cmap='Greys_r', ax=None, taxis=0, title=None, gain=None, **kwargs):
"""
Matplotlib display of traces as a density display
Matplotlib display of traces as a density display using `imshow()`.

:param w: 2D array (numpy array dimension nsamples, ntraces)
:param fs: sampling frequency (Hz)
:param ax: axis to plot in
:param fs: sampling frequency (Hz). [default: 30000]
:param cmap: Name of MPL colormap to use in `imshow()`. [default: 'Greys_r']
:param ax: Axis to plot in. If `None`, a new one is created. [default: `None`]
:param taxis: Time axis of input array (w). [default: 0]
:param title: Title to display on plot. [default: `None`]
:param gain: Gain in dB to display. Note: overrides `vmin` and `vmax` kwargs to `imshow()`.
Default: [`None` (auto)]
:param kwargs: Key word arguments passed to `imshow()`
:return: None
"""
w = w.reshape(w.shape[0], -1)
Expand All @@ -98,6 +104,9 @@ def __init__(self, w, fs=1, cmap='Greys_r', ax=None, taxis=0, title=None, **kwar
self.figure, ax = plt.subplots()
else:
self.figure = ax.get_figure()
if gain:
kwargs["vmin"] = - 4 * (10 ** (gain / 20))
kwargs["vmax"] = -kwargs["vmin"]
self.im = ax.imshow(w, aspect='auto', cmap=cmap, extent=extent, origin=origin, **kwargs)
ax.set_ylabel(ylabel)
ax.set_xlabel(xlabel)
Expand Down