Adjusted all working routes, full docker pipeline verified, added extra validations for docker, reduced julia environment, tested run succesful
This commit is contained in:
@@ -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"))
|
||||
|
||||
ENV["GKSwstype"] = "100"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"))
|
||||
|
||||
ENV["GKSwstype"] = "100"
|
||||
@@ -28,7 +28,8 @@ data_path = joinpath(data_dir, imzml_files[1])
|
||||
mask_path = joinpath(data_dir, "region_of_interest.png")
|
||||
if !isfile(mask_path)
|
||||
alt = filter(f -> endswith(lowercase(f), ".png") && occursin(r"roi|mask|region", lowercase(f)), readdir(data_dir))
|
||||
mask_path = isempty(alt) ? "" : joinpath(data_dir, alt[1])
|
||||
# `nothing` means "no mask" (see julia_msi_bridge.jl); "" would be treated as a path.
|
||||
mask_path = isempty(alt) ? nothing : joinpath(data_dir, alt[1])
|
||||
end
|
||||
|
||||
println("Loading data: $data_path")
|
||||
@@ -52,7 +53,7 @@ if !isempty(bin_avg)
|
||||
# Apply the ROI mask (if present) so off-tissue pixels are excluded, matching
|
||||
# the masked get_average_spectrum path and the Stage 1 extraction policy.
|
||||
mask_mat = nothing
|
||||
if mask_path != "" && isfile(mask_path)
|
||||
if mask_path !== nothing && isfile(mask_path)
|
||||
mask_mat = MSI_src.load_and_prepare_mask(mask_path, data.image_dims)
|
||||
end
|
||||
for i in 1:size(data.imzml_data, 2)
|
||||
|
||||
Reference in New Issue
Block a user