morphoclass.xai.embedding_visualization module

Plot embeddings for outlier detection.

morphoclass.xai.embedding_visualization.embed_latent_features(X, embedder=None)

Embed latent features to 2-dimensional space.

Parameters
  • X (list_like) – Latent features of the dataset.

  • embedder (sklearn.decomposition.PCA, umap, .., optional) – The algorithm for dimensionality reduction.

Returns

  • embedding_x (np.ndarray) – The first dimension of the embedding.

  • embedding_y (np.ndarray) – The second dimension of the embedding.

morphoclass.xai.embedding_visualization.generate_empty_image()matplotlib.figure.Figure

Generate empty image as a placeholder.

Returns

An empty matplotlib figure.

Return type

matplotlib.figure.Figure

morphoclass.xai.embedding_visualization.generate_image(sample: torch_geometric.data.data.Data)matplotlib.figure.Figure

Generate image based on morphology.

Parameters

sample – A morphology data sample.

Returns

A matplotlib figure with the morphology plot.

Return type

matplotlib.figure.Figure

morphoclass.xai.embedding_visualization.get_embeddings_figure(x_coordinates, y_coordinates, dataset, predictions, train_idx, val_idx, cleanlab_ordered_label_errors, cleanlab_self_confidence)

Get figure with latent feature embeddings in 2-dimensional space.

Parameters
  • x_coordinates (np.ndarray) – The first dimension of the embedding. Shape (train_size + val_size,)

  • y_coordinates (np.ndarray) – The second dimension of the embedding. Shape (train_size + val_size,)

  • dataset (morphoclass.data.MorphologyDataset) – Dataset with morphologies. Size train_size + val_size

  • predictions (list_like) – The predicted values (both validation and training indices). Shape (train_size + val_size,)

  • train_idx (list_like) – The indices of the training dataset.

  • val_idx (list_like) – The indices of the validation dataset.

  • cleanlab_ordered_label_errors (list_like) – Ordered label indices representing samples with wrong label.

  • cleanlab_self_confidence (list_like) – Self confidence is the holdout probability that an example belongs to its given class label.

Returns

figure – Figure with embeddings.

Return type

plotly.graph_objects.Figure

morphoclass.xai.embedding_visualization.get_images(dataset)

Get information images of morphologies for click event.

Parameters

dataset (morphoclass.data.MorphologyDataset) – Dataset with morphologies.

Returns

image_data_sources – Dictionary with morphology name key and encoded image value.

Return type

dict

morphoclass.xai.embedding_visualization.get_outlier_detection_app(figures, dataset, description_text=None)

Visualize outlier detection in dash app for interactivity.

Parameters
  • figures (list) – List of plotly figures.

  • dataset (morphoclass.morphology_dataset.MorphologyDataset) – Dataset with neuronal morphologies.

  • description_text (str, optional) – Checkpoint information.

Returns

app – Application instance.

Return type

dash.Dash