Adjusted all working routes, full docker pipeline verified, added extra validations for docker, reduced julia environment, tested run succesful

This commit is contained in:
Pixelguy14
2026-10-08 20:51:43 -06:00
parent 19fdd8af16
commit bab8f4d2a9
28 changed files with 290 additions and 499 deletions
+7 -6
View File
@@ -1,6 +1,6 @@
using Pkg
script_dir = @__DIR__
project_root = joinpath(script_dir, "..", "..")
project_root = joinpath(script_dir, "..")
Pkg.activate(joinpath(project_root, "environment"))
@@ -8,7 +8,6 @@ push!(LOAD_PATH, joinpath(project_root, "src"))
include(joinpath(project_root, "src", "MSI_src.jl"))
using .MSI_src
using Statistics, Images, Interpolations, BenchmarkTools
import julia_mzML_imzML
data_dir = length(ARGS) >= 1 ? ARGS[1] : joinpath(project_root, "data")
dataset_name = length(ARGS) >= 2 ? ARGS[2] : splitdir(data_dir)[2]
@@ -24,7 +23,9 @@ data_path = joinpath(data_dir, imzml_files[1])
mask_path = joinpath(data_dir, "region_of_interest.png")
if !isfile(mask_path)
alt_masks = filter(f -> endswith(lowercase(f), ".png") && occursin(r"roi|mask|region", lowercase(f)), readdir(data_dir))
mask_path = isempty(alt_masks) ? "" : joinpath(data_dir, alt_masks[1])
# `nothing` (not "") means "no mask": MSI_src treats nothing as unmasked, whereas
# an empty string is interpreted as a path and errors in load_and_prepare_mask.
mask_path = isempty(alt_masks) ? nothing : joinpath(data_dir, alt_masks[1])
end
output_folder = joinpath(project_root, "outputs", "ion_images", dataset_name)
@@ -35,7 +36,7 @@ mkpath(viridis_folder)
println("--- JULIA BATCH ENGINE: $dataset_name ---")
println("Data: $data_path")
println("Mask: $(isempty(mask_path) ? "none" : mask_path)")
println("Mask: $(mask_path === nothing ? "none" : mask_path)")
println("Output (grayscale): $output_folder")
println("Output (viridis): $viridis_folder")
@@ -43,7 +44,7 @@ println("--- JULIA BATCH ENGINE ---")
# Apply Julia's native ViridisPalette (256-entry, 0xRRGGBB) to a 0..255 intensity map.
function apply_viridis(intensity_matrix::AbstractMatrix{Float32})
palette = julia_mzML_imzML.ViridisPalette
palette = MSI_src.ViridisPalette
h, w = size(intensity_matrix)
rgb = Matrix{RGB{N0f8}}(undef, h, w)
@inbounds for j in 1:w, i in 1:h
@@ -186,7 +187,7 @@ function run_production_pipeline()
end
println("Step 5+6: Batched Ion Extraction, TrIQ Normalization & 256x256 Zero-Padding...")
mask_matrix = MSI_src.load_and_prepare_mask(mask_path, (data.image_dims[1], data.image_dims[2]))
mask_matrix = mask_path === nothing ? nothing : MSI_src.load_and_prepare_mask(mask_path, (data.image_dims[1], data.image_dims[2]))
exported_count = Threads.Atomic{Int}(0)
target_size = (256, 256)