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


Number of clusters :rtype: int


The training data for clustering

Returns:Training data as a 2D array, [num_samples, padded_peak_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


The cluster means

Returns:2D array, [cluster_label, cluster_mean_array]

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

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_curves = None

The axis on which the curves are drawn

plot = None

MatplotlibWidget() instancehu