Eliminar preparar_datos_simclr.jl
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
using MSI_src
|
||||
using Statistics, Images, Interpolations
|
||||
|
||||
# 1. Configuración
|
||||
path_data = "Hoja.imzML"
|
||||
path_mask = "region_interes.png"
|
||||
output_folder = "datos_para_ai"
|
||||
img_size = (224, 224) # Tamaño estándar para CNN
|
||||
mkpath(output_folder)
|
||||
|
||||
# 2. Carga de datos
|
||||
data = OpenMSIData(path_data)
|
||||
|
||||
# 3. Obtener picos importantes (puedes usar tu lógica anterior)
|
||||
mzs, avg_ints = MSI_src.get_average_spectrum(data, mask_path=path_mask)
|
||||
umbral = maximum(avg_ints) * 0.02
|
||||
indices_picos = findall(x -> x > umbral, avg_ints)
|
||||
|
||||
println("Exportando $(length(indices_picos)) iones...")
|
||||
|
||||
for idx in indices_picos
|
||||
mz_val = mzs[idx]
|
||||
if mz_val < 50.0 || mz_val > 700.0 continue end
|
||||
|
||||
# A. Extraer slice (puro, sin plots)
|
||||
raw_slice = MSI_src.get_mz_slice(data, mz_val, 0.05, mask_path=path_mask)
|
||||
|
||||
# B. Normalización TrIQ (como en tu script)
|
||||
vals = filter(x -> x > 0 && isfinite(x), raw_slice)
|
||||
if isempty(vals) continue end
|
||||
q = quantile(vals, 0.98)
|
||||
q = q == 0 ? maximum(vals) : q
|
||||
enhanced = clamp.(raw_slice ./ q, 0.0, 1.0)
|
||||
|
||||
# C. Reescalar a 224x224 (Crucial para la CNN)
|
||||
# Usamos imresize de Images.jl
|
||||
img_resized = imresize(enhanced, img_size)
|
||||
|
||||
# D. Guardar como PNG puro (Escala de grises, sin ejes)
|
||||
nombre = "ion_$(round(mz_val, digits=2)).png"
|
||||
save(joinpath(output_folder, nombre), Gray.(img_resized))
|
||||
end
|
||||
Reference in New Issue
Block a user