Skip to content

Commit

Permalink
sty : simplify the reordering of the correlation matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
celprov committed Mar 24, 2023
1 parent 00ea0e8 commit 97fd28b
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions mriqc_learn/viz/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ def plot_corrmat(

# Cluster rows (if arguments enabled)
if sorted:
import pandas as pd
from scipy.cluster.hierarchy import linkage, dendrogram, fcluster

Z = linkage(data, 'complete', optimal_ordering=True)
Expand All @@ -228,14 +227,8 @@ def plot_corrmat(
# Keep the indices to sort labels
labels_order = np.argsort(labels)

# Build a new dataframe with the sorted columns
for idx, i in enumerate(data.columns[labels_order]):
if idx == 0:
clustered = pd.DataFrame(data[i])
else:
df_to_append = pd.DataFrame(data[i])
clustered = pd.concat([clustered, df_to_append], axis=1)
data = clustered
# Reorder data
data = data.take(labels_order, axis=0).take(labels_order, axis=1)

if hasattr(data, "columns"):
col_labels = data.columns
Expand Down

0 comments on commit 97fd28b

Please sign in to comment.