Subir archivos a "/"

This commit is contained in:
2026-05-15 21:01:47 +02:00
parent 0ab94352e0
commit 5fac719a23
+33
View File
@@ -0,0 +1,33 @@
import pandas as pd
import os
import matplotlib.pyplot as plt
from PIL import Image
# Configuration
# CSV_PATH = "msi_clusters_results.csv"
CSV_PATH = "msi_clusters_direct_results.csv"
IMG_DIR = "datos_para_ai"
OUTPUT_DIR = "cluster_results"
os.makedirs(OUTPUT_DIR, exist_ok=True)
df = pd.DataFrame(pd.read_csv(CSV_PATH))
for cluster_id in sorted(df['cluster'].unique()):
cluster_ions = df[df['cluster'] == cluster_id]['ion_image'].head(9).tolist()
fig, axes = plt.subplots(3, 3, figsize=(10, 10))
fig.suptitle(f"Cluster {cluster_id} - Ion Examples", fontsize=16)
for i, ax in enumerate(axes.flat):
if i < len(cluster_ions):
img_path = os.path.join(IMG_DIR, cluster_ions[i])
img = Image.open(img_path)
ax.imshow(img, cmap='gray')
ax.set_title(cluster_ions[i], fontsize=8)
ax.axis('off')
plt.tight_layout()
plt.savefig(f"{OUTPUT_DIR}/cluster_gallery_{cluster_id}.png")
plt.close()
print(f"Galleries saved in {OUTPUT_DIR}. Review these images to identify which structure each cluster represents.")