ibl_alignment_gui.plugins.cluster_features

Functions

_create_correlograms_array

Return a zeroed array to accumulate correlograms into.

_diff_shifted

Return the difference between arr and a copy shifted by steps.

_increment

Increment some indices in a 1D vector of non-negative integers.

_index_of

Replace scalars in an array by their indices in a lookup table.

_symmetrize_correlograms

Return the symmetrized version of the cross-correlogram arrays.

callback

Triggered when a cluster in a scatter plot is clicked.

compute_timescales

Compute time vectors for autocorrelogram and template waveform plots.

get_autocorr

Compute the autocorrelogram for a specific cluster.

get_template_wf

Retrieve the template waveform for a specific cluster.

setup

Set up the Cluster Features plugin.

xcorr

Compute all pairwise cross-correlograms among the clusters in spike_clusters.

Classes

ClusterPopup

A popup qt window per cluster.

ClusterPopupManager

Manager for multiple cluster popups in the GUI.

class ibl_alignment_gui.plugins.cluster_features.ClusterPopup(title, view, data=None)[source]

Bases: PopupWindow

A popup qt window per cluster.

Shows plots of the cluster autocorrelogram and template waveform.

Parameters:
  • title (str) – The title of the popup window.

  • data (dict or None) – A dictionary containing data to be plotted in the popup.

  • parent (QtWidgets.QMainWindow or None) – The parent window of the popup.

setup()[source]

Configure the plots inside the popup window.

Return type:

None

class ibl_alignment_gui.plugins.cluster_features.ClusterPopupManager(controller)[source]

Bases: object

Manager for multiple cluster popups in the GUI.

Variables:
  • parent_view (QtWidgets.QMainWindow) – The main window of the application.

  • cluster_popups (list) – A list of currently open cluster popups.

  • popup_status (bool) – Status indicating whether popups are minimised or shown.

add_popup(shank, clust_no, config, data)[source]

Add a new cluster popup to the manager and set up its signals.

Parameters:
  • shank (str) – The name of shank

  • clust_no (int) – The cluster number.

  • config (str) – The config of the shank

  • data (dict) – A dict containing data to be plotted in the popup.

Return type:

None

close_popups()[source]

Close all cluster popups and reset the list.

Return type:

None

minimise_popups()[source]

Toggle between minimizing and restoring all cluster popups.

Return type:

None

popup_closed(popup)[source]

Triggered when a popup is closed by the user.

Parameters:

popup (ClusterPopup) – The cluster popup that was closed.

Return type:

None

popup_entered(popup)[source]

Triggered when the mouse enters a popup.

Return type:

None

popup_left()[source]

Triggered when the mouse leaves a popup.

Return type:

None

teardown(_controller)[source]

Close all cluster popups when the session changes.

Invoked via execute_plugins('teardown', controller) at the start of a session rebuild so popups tied to the previous session do not linger or get reused.

Parameters:

_controller (AlignmentGUIController) – The main application controller. Accepted to match the plugin hook signature but unused.

Return type:

None

ibl_alignment_gui.plugins.cluster_features.callback(controller, items, _, point)[source]

Triggered when a cluster in a scatter plot is clicked.

Computes autocorrelation and template waveform for the selected cluster and opens a popup showing the plots.

Parameters:
  • controller (AlignmentGUIController) – The main application controller.

  • items (ShankController) – The shank controller containing cluster data.

  • point (pg.ScatterPlotItem) – The clicked scatter item in the scatter plot.

Return type:

None

ibl_alignment_gui.plugins.cluster_features.compute_timescales(plot_loader)[source]

Compute time vectors for autocorrelogram and template waveform plots.

Parameters:

plot_loader (PlotLoader) – The plot loader object containing spike and cluster data.

Return type:

tuple[ndarray, ndarray]

Returns:

  • t_autocorr (np.ndarray) – The time vector for autocorrelogram (ms).

  • t_template (np.ndarray) – The time vector for template waveform (ms).

ibl_alignment_gui.plugins.cluster_features.get_autocorr(plot_loader, clust_idx)[source]

Compute the autocorrelogram for a specific cluster.

Parameters:
  • plot_loader (PlotLoader) – The plot loader object containing spike and cluster data.

  • clust_idx (int) – Index of the cluster

Return type:

tuple[ndarray, int]

Returns:

  • autocorr (np.ndarray) – The autocorrelogram of the selected cluster

  • clust_id (int) – The cluster id of the selected cluster

ibl_alignment_gui.plugins.cluster_features.get_template_wf(plot_loader, clust_idx)[source]

Retrieve the template waveform for a specific cluster.

Parameters:
  • plot_loader (PlotLoader) – The plot loader object containing spike and cluster data.

  • clust_idx (int) – Index of the cluster

Returns:

template_wf – The template waveform of the selected cluster

Return type:

np.ndarray

ibl_alignment_gui.plugins.cluster_features.setup(controller)[source]

Set up the Cluster Features plugin.

Adds a submenu to the main GUI for managing the cluster popups.

Parameters:

controller (AlignmentGUIController) – The main application controller.

Return type:

None

ibl_alignment_gui.plugins.cluster_features.xcorr(spike_times, spike_clusters, bin_size=None, window_size=None)[source]

Compute all pairwise cross-correlograms among the clusters in spike_clusters.

Parameters:
  • spike_times (np.ndarray) – Spike times in seconds. Must be sorted in increasing order.

  • spike_clusters (np.ndarray) – Spike-cluster mapping, same shape as spike_times.

  • bin_size (float) – Size of the bin, in seconds.

  • window_size (float) – Size of the window, in seconds.

Returns:

An (n_clusters, n_clusters, winsize_samples) array holding all pairwise cross-correlograms.

Return type:

np.ndarray