API Reference#

class driftplots.DriftPlotter(sorter_path)[source]#

Load Kilosort sorter output and provide interactive or static drift map plots.

On construction, spike data is loaded from a Kilosort output directory and stored as read-only arrays. Plotting methods apply optional filtering (noise exclusion, amplitude filtering, decimation) before handing the data to a plot backend.

Parameters:

sorter_path (str | Path) – Path to a Kilosort sorter output directory. Must contain exactly one kilosort*.log file used to detect the KS version.

spike_times#

(num_spikes,) spike times (seconds for KS 1-3, samples for KS4).

spike_amplitudes#

(num_spikes,) spike amplitudes.

spike_depths#

(num_spikes,) spike depths along the probe (µm).

spike_templates#

(num_spikes,) template or unit id assigned to each spike.

templates#

(num_templates, num_samples, num_channels) template waveforms.

channel_locations#

(num_channels, 2) x/y positions of each channel on the probe.

drift_map_plot_interactive(decimate='estimate', exclude_noise=False, amplitude_cmap_scaling='linear', n_color_bins=20, point_size=5.0, filter_amplitude_mode=None, filter_amplitude_values=(), title=None)[source]#

Create an interactive pyqtgraph-based drift map widget.

Parameters:
  • decimate (int | bool | None | Literal['estimate']) – Keep every n-th spike. Too many spikes will slow down the plot. if "estimate"` the number of spikes will be decimated to a reasonable range (e.g. 50,000). ``False, None or 0 disables decimation.` Otherwise pass an integer e.g. 2 to keep every 2nd spike.

  • exclude_noise (bool | str) – Remove spikes labelled as noise.

  • amplitude_cmap_scaling (str | tuple[float, float]) – Colour-scaling mode or explicit (min, max) range.

  • n_color_bins (int) – Number of grey-scale colour bins for amplitude.

  • point_size (float) – Scatter-point diameter in pixels.

  • filter_amplitude_mode (str | None) – Amplitude filtering mode.

  • filter_amplitude_values (tuple[float, ...]) – Bounds for amplitude filtering.

  • title (bool | str | None) – Title of the plot

Returns:

The pyqtgraph widget. This is already populated but not yet shown, use app.exec() to display.

Return type:

DriftmapPlotWidget

drift_map_plot_matplotlib(decimate='estimate', exclude_noise=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)[source]#
Return type:

Figure

class driftplots.MultiSessionDriftmapWidget(panels, grid=None, width=700, height=820)[source]#

A grid container that displays multiple DriftmapPlotWidget panels.

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. If None, a roughly square layout is computed automatically.

  • width (int) – Width allocated per panel column (pixels).

  • height (int) – Height allocated per panel row (pixels).

plot()[source]#
driftplots.get_amplitudes(list_of_path_or_analyzer, exclude_noise=False, concatenate=False)[source]#

Load and concatenate amplitudes.npy from multiple sorter output paths.

Parameters:
  • list_of_path_or_analyzer (list[Path | SortingAnalyzer]) – List of sorter output directories, each containing amplitudes.npy.

  • concatenate (bool) – If True, concatenate all amplitudes into a single array.

Returns:

Concatenated amplitudes from all paths.

Return type:

ndarray | list[ndarray]