class mesmerize.plotting.KShapeWidget(parent=None)[source]

Bases: PyQt5.QtWidgets.QMainWindow, mesmerize.plotting.widgets.base.BasePlotWidget

User-end KShape widget


Emits output Transmission containing cluster labels

drop_opts = None

Unused by this plot widget


The input arrays for clustering

Returns:2D array, shape is [num_samples, padded_peak_curve_length]
Return type:np.ndarray

KShape object

Return type:kshape_process.KShape

Number of clusters

Return type:int

The training data for clustering

Returns:Training data as a 2D array, shape is [n_samples, padded_curve_length]
Return type:np.ndarray

Predicted cluster labels after the model converges

Returns:1D array of cluster labels that correspond to the input_data
Return type:np.ndarray

Cluster centroids

Returns:2D array, shape is [n_clusters, centroid_array]
Return type:np.ndarray

The cluster means

Returns:2D array, shape is [cluster_label, mean_array]
Return type:np.ndarray

Parameters dict.

Return type:dict
set_input(transmission: mesmerize.analysis.data_types.Transmission)[source]

Set the input Transmission for the widget

Parameters:transmission – Input Transmission
pad_input_data(a: numpy.ndarray, method: str = 'random') → numpy.ndarray[source]

Pad all the input arrays so that are of the same length. The length is determined by the largest input array. The padding value for each input array is the minimum value in that array.

Padding for each input array is either done after the array’s last index to fill up to the length of the largest input array (method ‘fill-size’) or the padding is randomly flanked to the input array (method ‘random) for easier visualization.

  • a – 1D array of input arrays where each element is a sample array
  • method – ‘fill-size’ or ‘random’

2D array of the padded arrays in the rows

start_process(*args, **kwargs)[source]

Start the the KShape clustering in a QProcess


The input transmission

Return type:Transmission
class mesmerize.plotting.widgets.kshape.widget.KShapeMeansPlot(parent)[source]

Bases: mesmerize.pyqtgraphCore.widgets.MatplotlibWidget.MatplotlibWidget

Means plots grouped by cluster membership

axs = None

array of axis objects used for drawing the means plots, shape is [nrows, ncols]

set_plots(input_arrays: numpy.ndarray, n_clusters: int, y_pred: numpy.ndarray, xzero_pos: str, error_band)[source]

Set the subplots

  • input_arrays – padded input arrays (2D), shape is [num_samples, padded_peak_curve_length]
  • n_clusters – number of clusters
  • y_pred – cluster predictions (labels)
  • xzero_pos – set the zero position as the ‘zero’ position of the input array or the ‘maxima’ of the input array
  • error_band – Type of error band to show, one of either ‘ci’ or ‘std’
class mesmerize.plotting.widgets.kshape.widget.KShapePlot(parent)[source]

Bases: PyQt5.QtWidgets.QDockWidget

Curves plots, showing a sample of individual curves from a single cluster

ax = None

The Axes object for this plot

plot = None

MatplotlibWidget() instance