KShape

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

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

User-end KShape widget

sig_output_changed

Emits output Transmission containing cluster labels

drop_opts = None

Unused by this plot widget

property input_arrays

The input arrays for clustering

Returns

2D array, shape is [num_samples, padded_peak_curve_length]

Return type

np.ndarray

property ks

tslearn KShape object

property n_clusters

Number of clusters

Return type

int

property train_data

The training data for clustering

Returns

Training data as a 2D array, shape is [n_samples, padded_curve_length]

Return type

np.ndarray

property y_pred

Predicted cluster labels after the model converges

Returns

1D array of cluster labels that correspond to the input_data

Return type

np.ndarray

property cluster_centers

Cluster centroids

Returns

2D array, shape is [n_clusters, centroid_array]

Return type

np.ndarray

property cluster_means

The cluster means

Returns

2D array, shape is [cluster_label, mean_array]

Return type

np.ndarray

property params

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.

Parameters
  • a – 1D array of input arrays where each element is a sample array

  • method – ‘fill-size’ or ‘random’

Returns

2D array of the padded arrays in the rows

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

Start the the KShape clustering in a QProcess

property transmission

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

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

Parameters
  • 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

The Axes object for this plot

plot

MatplotlibWidget() instance