Subir archivos a "/"
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
|
||||
import pandas as pd
|
||||
import os
|
||||
import matplotlib.pyplot as plt
|
||||
from PIL import Image
|
||||
|
||||
# Configuración
|
||||
#CSV_PATH = "msi_clusters_results.csv"
|
||||
CSV_PATH = "msi_clusters_direct_results.csv"
|
||||
IMG_DIR = "datos_para_ai"
|
||||
OUTPUT_DIR = "resultados_clusters"
|
||||
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} - Ejemplos de Iones", 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}/galeria_cluster_{cluster_id}.png")
|
||||
plt.close()
|
||||
|
||||
print(f"Galerías guardadas en {OUTPUT_DIR}. Revisa estas imágenes para identificar qué estructura representa cada cluster.")
|
||||
Reference in New Issue
Block a user