Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable spearman and kendall feature correlation matrices from the GUI #44

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,20 @@ def Train_object_classifier(image: "napari.types.ImageData",
return result


@register_function(menu="Measurement tables > Feature correlation matrix (pandas, APOC)")
def show_feature_correlation_matrix(layer: "napari.layers.Layer", viewer:napari.Viewer = None):
@register_function(menu="Measurement tables > Feature correlation matrix (pandas, APOC)",
method={'choices':['pearson', 'kendall', 'spearman']})
def show_feature_correlation_matrix(layer: "napari.layers.Layer", method:str='pearson', viewer:napari.Viewer = None):
from ._dock_widget import update_table_gui
import pandas as pd
correlation_matrix = pd.DataFrame(layer.properties).dropna().corr()
correlation_matrix = pd.DataFrame(layer.properties).dropna().corr(method=method)

if viewer is not None:
table = QTableWidget()
table.setColumnCount(len(correlation_matrix))
table.setRowCount(len(correlation_matrix))

update_table_gui(table, correlation_matrix, minimum_value=-1, maximum_value=1)
viewer.window.add_dock_widget(table, name="Feature correlation matrix")
viewer.window.add_dock_widget(table, name=f"Feature {method} correlation matrix")
else:
return correlation_matrix

Expand Down
Loading