API Reference#
- class driftplots.DriftPlotter(path_or_analyzer, verbose=True)[source]#
Load Kilosort or SpikeInterface output and plot drift maps.
On construction, spike data is loaded from a Kilosort output directory or a SpikeInterface
SortingAnalyzerand stored as read-only arrays.- Parameters:
path_or_analyzer (
str|Path) – Path to a Kilosort sorter output directory, or a SpikeInterfaceSortingAnalyzerobject. When a path is given it must contain exactly onekilosort*.logfile, which is used to detect the Kilosort version.
- drift_map_plot_interactive(decimate='estimate', good_units_only=False, amplitude_cmap_scaling='linear', n_color_bins=20, point_size=5.0, filter_amplitude_mode=None, filter_amplitude_values=(), title=None, verbose=True)[source]#
Create an interactive pyqtgraph-based drift map widget.
- Parameters:
decimate (
int|bool|None|Literal['estimate']) – Thin the spike dataset before plotting. Pass"estimate"to automatically reduce spikes to a reasonable count (≈ 100 000). PassFalse,None, or0to disable decimation. Pass an integer n to keep every n-th spike.good_units_only (
bool|str) – IfTrue, only spikes belonging to “good” units are displayed. For Kilosort, this is taken from the cluster_groups.csv / cluster_group.tsv file that reflects labels set in Phy. For a SortingAnalyzer, a string must be passed. The labels are taken from the sorting property with the passed name (e.g. “KSLabel”).amplitude_cmap_scaling (
str|tuple[float,float]) – Controls how spike amplitudes are mapped to the greyscale colormap. Pass"linear"or"log2"or"log10"for automatic scaling, or a(min, max)tuple to set explicit bounds. When explicit bounds are set, the scaling is linear.n_color_bins (
int) – Number of discrete greyscale bins used to colour spikes by amplitude.point_size (
float) – Diameter of each scatter point in pixels.filter_amplitude_mode (
str|None) – Controls how spikes are filtered based on amplitude before plotting."percentile"treats the bounds as percentile ranks;"absolute"treats them as raw amplitude values.Nonedisables amplitude filtering.filter_amplitude_values (
tuple[float,...]) –(low, high)bounds for amplitude filtering, used as set byfilter_amplitude_mode. Ignored whenfilter_amplitude_modeisNone.title (
bool|str|None) – Plot title. Pass a string to set a custom title,Trueto use a default title, orNone/Falseto suppress the title entirely.verbose (
bool) – If True, messages are printed.
- Returns:
The pyqtgraph widget. The widget is already populated but not yet shown; call
app.exec()to display it.- Return type:
DriftmapPlotWidget
- drift_map_plot_matplotlib(decimate='estimate', good_units_only=False, amplitude_cmap_scaling='linear', n_color_bins=20, point_size=5.0, filter_amplitude_mode=None, filter_amplitude_values=(), add_histogram_plot=False, weight_histogram_by_amplitude=False, title=None, ax=None, verbose=True)[source]#
Create a static Matplotlib drift map figure.
- Parameters:
decimate (
int|bool|None|Literal['estimate']) – Thin the spike dataset before plotting. Pass"estimate"to automatically reduce spikes to a reasonable count (≈ 100 000). PassFalse,None, or0to disable decimation. Pass an integer n to keep every n-th spike.good_units_only (
bool|str) – IfTrue, only spikes belonging to “good” units are displayed. For Kilosort, this is taken from the cluster_groups.csv / cluster_group.tsv file that reflects labels set in Phy. For a SortingAnalyzer, a string must be passed. The labels are taken from the sorting property with the passed name (e.g. “KSLabel”).amplitude_cmap_scaling (
str|tuple[float,float]) – Controls how spike amplitudes are mapped to the greyscale colormap. Pass"linear"or"log2"or"log10"for automatic scaling, or a(min, max)tuple to set explicit bounds. When explicit bounds are set, the scaling is linear.n_color_bins (
int) – Number of discrete greyscale bins used to colour spikes by amplitude.point_size (
float) – Diameter of each scatter point in pixels.filter_amplitude_mode (
str|None) – Controls how spikes are filtered based on amplitude before plotting."percentile"treats the bounds as percentile ranks;"absolute"treats them as raw amplitude values.Nonedisables amplitude filtering.filter_amplitude_values (
tuple[float,...]) –(low, high)bounds for amplitude filtering, used as set byfilter_amplitude_mode. Ignored whenfilter_amplitude_modeisNone.add_histogram_plot (
bool) – IfTrue, add a side panel showing a depth histogram of spike activity.weight_histogram_by_amplitude (
bool) – IfTrue, weight the depth histogram by spike amplitude rather than counting spikes uniformly. Only used whenadd_histogram_plotisTrue.title (
bool|str|None) – Plot title. Pass a string to set a custom title,Trueto use a default title, orNone/Falseto suppress the title entirely.ax (
Axes|None) – Existing Matplotlib axis to draw the drift map on. Whenadd_histogram_plotisTrue, a histogram axis is added beside this axis.verbose (
bool) – If True, messages are printed.
- Returns:
The populated Matplotlib figure.
- Return type:
Figure
- class driftplots.MultiSessionDriftmapWidget(panels, grid=None, width=700, height=820)[source]#
A grid container that displays multiple
DriftmapPlotWidgetpanels.Panels are laid out on an auto-computed (or user-specified) grid and their scatter-plot y-axes are linked so scrolling / zooming in one panel keeps all panels in sync.
- Parameters:
panels (
list[DriftmapPlotWidget]) – Drift-map widgets to arrange in the grid.grid (
tuple[int,int] |None) – Explicit(n_rows, n_cols)layout. IfNone, a roughly square layout is computed automatically.width (
int) – Width allocated per panel column (pixels).height (
int) – Height allocated per panel row (pixels).
- driftplots.get_amplitudes(list_of_path_or_analyzer, good_units_only=False, concatenate=False, verbose=True)[source]#
Return spike amplitudes from one or more sorter outputs.
- Parameters:
list_of_path_or_analyzer (
list[Path|SortingAnalyzer]) – Kilosort output directory paths or SpikeInterfaceSortingAnalyzerobjects to load amplitudes from. Can be a mix of both.good_units_only (
bool|str) – IfTrue, only spikes belonging to “good” units are displayed. For Kilosort, this is taken from the cluster_groups.csv / cluster_group.tsv file that reflects labels set in Phy. For a SortingAnalyzer, a string must be passed. The labels are taken from the sorting property with the passed name (e.g. “KSLabel”).concatenate (
bool) – IfTrue, concatenate all per-session amplitude arrays into a single 1-D array. IfFalse(default), return a list with one array per session.verbose (
bool) – If True, messages are printed.
- Returns:
When
concatenate=True, a single 1-D array of all spike amplitudes. Whenconcatenate=False, a list of 1-D arrays, one per entry inlist_of_path_or_analyzer.- Return type:
ndarray|list[ndarray]