Wed, 24 Apr 2024 11:34:09 +0300
added function to generate table
Manifest.toml | file | annotate | diff | comparison | revisions | |
Project.toml | file | annotate | diff | comparison | revisions | |
src/.DS_Store | file | annotate | diff | comparison | revisions | |
src/ImGenerate.jl | file | annotate | diff | comparison | revisions | |
src/PET/ImGenerate.jl | file | annotate | diff | comparison | revisions | |
src/PET/PET.jl | file | annotate | diff | comparison | revisions | |
src/PET/PlotResults.jl | file | annotate | diff | comparison | revisions | |
src/PredictPDPS.jl | file | annotate | diff | comparison | revisions |
--- a/Manifest.toml Mon Apr 22 13:28:58 2024 +0300 +++ b/Manifest.toml Wed Apr 24 11:34:09 2024 +0300 @@ -287,6 +287,12 @@ uuid = "2e619515-83b5-522b-bb60-26c02a35a201" version = "2.5.0+0" +[[EzXML]] +deps = ["Printf", "XML2_jll"] +git-tree-sha1 = "380053d61bb9064d6aa4a9777413b40429c79901" +uuid = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615" +version = "1.2.0" + [[FFMPEG_jll]] deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "JLLWrappers", "LAME_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "PCRE2_jll", "Zlib_jll", "libaom_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"] git-tree-sha1 = "ab3f7e1819dba9434a3a5126510c8fda3a4e7000" @@ -434,9 +440,9 @@ [[HTTP]] deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "ExceptionUnwrapping", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"] -git-tree-sha1 = "8e59b47b9dc525b70550ca082ce85bcd7f5477cd" +git-tree-sha1 = "2c3ec1f90bb4a8f7beafb0cffea8a4c3f4e636ab" uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" -version = "1.10.5" +version = "1.10.6" [[HarfBuzz_jll]] deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "Graphite2_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Pkg"] @@ -588,9 +594,9 @@ [[IntelOpenMP_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "5fdf2fe6724d8caabf43b557b84ce53f3b7e2f6b" +git-tree-sha1 = "be50fe8df3acbffa0274a744f1a99d29c45a57f4" uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0" -version = "2024.0.2+0" +version = "2024.1.0+0" [[InteractiveUtils]] deps = ["Markdown"] @@ -835,16 +841,16 @@ version = "0.10.6" [[MKL_jll]] -deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl"] -git-tree-sha1 = "72dc3cf284559eb8f53aa593fe62cb33f83ed0c0" +deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "oneTBB_jll"] +git-tree-sha1 = "80b2833b56d466b3858d565adcd16a4a05f2089b" uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7" -version = "2024.0.0+0" +version = "2024.1.0+0" [[MPICH_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"] -git-tree-sha1 = "656036b9ed6f942d35e536e249600bc31d0f9df8" +git-tree-sha1 = "d8a7bf80c88326ebc98b7d38437208c3a0f20725" uuid = "7cb0a576-ebde-5e09-9194-50597f1243b4" -version = "4.2.0+0" +version = "4.2.1+0" [[MPIPreferences]] deps = ["Libdl", "Preferences"] @@ -853,10 +859,10 @@ version = "0.1.10" [[MPItrampoline_jll]] -deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"] -git-tree-sha1 = "77c3bd69fdb024d75af38713e883d0f249ce19c2" +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML"] +git-tree-sha1 = "3f884417b47a96d87e7c6219f8f7b30ce67f4f2c" uuid = "f1f71cc9-e9ae-5b93-9b94-4fe0e1ad3748" -version = "5.3.2+0" +version = "5.3.3+0" [[MacroTools]] deps = ["Markdown", "Random"] @@ -1519,6 +1525,12 @@ uuid = "76eceee3-57b5-4d4a-8e66-0e911cebbf60" version = "1.6.1" +[[XLSX]] +deps = ["Artifacts", "Dates", "EzXML", "Printf", "Tables", "ZipFile"] +git-tree-sha1 = "319b05e790046f18f12b8eae542546518ef1a88f" +uuid = "fdbf4ff8-1666-58a4-91e7-1b58723a45e0" +version = "0.10.1" + [[XML2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"] git-tree-sha1 = "532e22cf7be8462035d092ff21fada7527e2c488" @@ -1681,6 +1693,12 @@ uuid = "c5fb5394-a638-5e4d-96e5-b29de1b5cf10" version = "1.5.0+0" +[[ZipFile]] +deps = ["Libdl", "Printf", "Zlib_jll"] +git-tree-sha1 = "f492b7fe1698e623024e873244f10d89c95c340a" +uuid = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea" +version = "0.10.1" + [[Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" @@ -1774,6 +1792,12 @@ uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" version = "1.52.0+1" +[[oneTBB_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "7d0ea0f4895ef2f5cb83645fa689e52cb55cf493" +uuid = "1317d2d5-d96f-522e-a858-c73665f53c3e" +version = "2021.12.0+0" + [[p7zip_jll]] deps = ["Artifacts", "Libdl"] uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
--- a/Project.toml Mon Apr 22 13:28:58 2024 +0300 +++ b/Project.toml Wed Apr 24 11:34:09 2024 +0300 @@ -30,4 +30,6 @@ Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc" Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" +Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990" +XLSX = "fdbf4ff8-1666-58a4-91e7-1b58723a45e0"
--- a/src/ImGenerate.jl Mon Apr 22 13:28:58 2024 +0300 +++ b/src/ImGenerate.jl Wed Apr 24 11:34:09 2024 +0300 @@ -20,7 +20,7 @@ # Added for reproducibility import StableRNGs: StableRNG, Random -const rng = StableRNG(9182737465) +const rng = StableRNG(314159) # Added for PET import PoissonRandom: pois_rand @@ -189,7 +189,8 @@ zero_factor = indx in params.stable_interval ? 0.0 : 1.0 # Restart the seed to enable comparison across predictors - Random.seed!(rng,9182737465) + #Random.seed!(rng,951508) # algreadygood + Random.seed!(rng,67584) nextv = shake(params) v_true = zero_factor.*nextv() @@ -238,7 +239,7 @@ zero_factor = indx in params.stable_interval ? 0.0 : 1.0 # Restart the seed to enable comparison across predictors - Random.seed!(rng,9182737465) + Random.seed!(rng,314159) nextv = shake(params) v_true = zero_factor.*nextv()
--- a/src/PET/ImGenerate.jl Mon Apr 22 13:28:58 2024 +0300 +++ b/src/PET/ImGenerate.jl Wed Apr 24 11:34:09 2024 +0300 @@ -20,7 +20,7 @@ # Added for reproducibility import StableRNGs: StableRNG, Random -const rng = StableRNG(9182737465) +const rng = StableRNG(314159) # Added for PET import PoissonRandom: pois_rand @@ -189,7 +189,8 @@ zero_factor = indx in params.stable_interval ? 0.0 : 1.0 # Restart the seed to enable comparison across predictors - Random.seed!(rng,9182737465) + Random.seed!(rng,314159) + nextv = shake(params) v_true = zero_factor.*nextv() @@ -238,7 +239,7 @@ zero_factor = indx in params.stable_interval ? 0.0 : 1.0 # Restart the seed to enable comparison across predictors - Random.seed!(rng,9182737465) + Random.seed!(rng,314159) nextv = shake(params) v_true = zero_factor.*nextv()
--- a/src/PET/PET.jl Mon Apr 22 13:28:58 2024 +0300 +++ b/src/PET/PET.jl Wed Apr 24 11:34:09 2024 +0300 @@ -22,10 +22,7 @@ using ImageTools.ImFilter: gaussian # For PET -#using Colors -#using ColorTypes using ColorSchemes -#using PerceptualColourMaps ##################### # Load local modules @@ -107,6 +104,7 @@ handle_interrupt = true, init = :zero, plot_movement = false, + stable_interval = Set(0), ) const p_known₀_pet = ( @@ -115,23 +113,22 @@ shake = 1.0, rotation_factor = 0.075, rotation_noise_level = 0.0075, - α = 1.0, + α = 0.15, ρ̃₀ = 1.0, σ̃₀ = 1.0, δ = 0.9, - σ₀ = 0.5, + σ₀ = 1.0, τ₀ = 0.9, λ = 1, radondims = [128,64], sz = (256,256), scale = 1, c = 1.0, - sino_sparsity = 0.5, # Percentage of zero parts in the mask + sino_sparsity = 0.5, L = 300.0, L_experiment = false, - stable_interval = Set(0), - # stable_interval = union(Set(1:1000),Set(2500:3000)), - # stable_interval = union(Set(1000:2000),Set(3000:4000)), + #stable_interval = Set(0), + stable_interval = union(Set(1000:2000),Set(3500:4000)), ) const shepplogan = imgen_shepplogan_radon(p_known₀_pet.sz) @@ -221,7 +218,7 @@ function name(e::Experiment, p) ig = e.imgen # return "$(ig.name)_$(e.mod.identifier)_$(@sprintf "%x" hash(p))" - return "$(ig.name)_$(e.mod.identifier)_$(Int64(10000*p.σ₀))_$(Int64(10000*p.τ₀))" + return "$(ig.name)_$(e.mod.identifier)_$(Int64(100*p.α))_$(Int64(10000*p.σ₀))_$(Int64(10000*p.τ₀))" end function write_tex(texfile, e_params) @@ -308,8 +305,8 @@ # datafile = e_params.save_prefix * ".jld2" write_log(perffile, st.log, "# params = $(e_params)\n") - write_log(hififile, st.log_hifi, "# params = $(e_params)\n") - write_tex(texfile, e_params) + #write_log(hififile, st.log_hifi, "# params = $(e_params)\n") + #write_tex(texfile, e_params) # @save datafile x y st params end @@ -346,7 +343,7 @@ save_images=false, visualise=true, recalculate=true, - verbose_iter=1, + verbose_iter=50, fullscreen=true, kwargs...) end @@ -368,7 +365,7 @@ demo_petB7 = () -> demo(brainphantom_experiments_pdps_known[7]) # Zero dual -function batchrun_shepplogan(kwargs...) +function batchrun_shepplogan(;kwargs...) run_experiments(;experiments=shepplogan_experiments_all, save_results=true, save_images=true, @@ -377,7 +374,7 @@ kwargs...) end -function batchrun_brainphantom(kwargs...) +function batchrun_brainphantom(;kwargs...) run_experiments(;experiments=brainphantom_experiments_all, save_results=true, save_images=true, @@ -386,9 +383,9 @@ kwargs...) end -function batchrun_pet(kwargs...) - batchrun_shepplogan() - batchrun_brainphantom() +function batchrun_pet(;kwargs...) + batchrun_shepplogan(;kwargs...) + batchrun_brainphantom(;kwargs...) end ######################################################
--- a/src/PET/PlotResults.jl Mon Apr 22 13:28:58 2024 +0300 +++ b/src/PET/PlotResults.jl Wed Apr 24 11:34:09 2024 +0300 @@ -9,6 +9,7 @@ using DelimitedFiles, CSV, DataFrames using PlotlyJS +using Colors export fv_plot, ssim_plot, psnr_plot @@ -26,7 +27,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -39,9 +40,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="dot", name="proxi") + line_color=line_color, line_dash="dot", name="proxi (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(orig, trace) end @@ -54,7 +57,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -67,9 +70,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="dashdot", name="primo") + line_color=line_color, line_dash="dashdot", name="primo (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -83,7 +88,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -96,9 +101,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="dash", name="greed τ") + line_color=line_color, line_dash="dash", name="greed (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -112,7 +119,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -125,9 +132,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="longdashdot", name="rotat") + line_color=line_color, line_dash="longdashdot", name="rotat (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -141,7 +150,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -154,44 +163,48 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="solid", name="dusca") + line_color=line_color, line_dash="solid", name="dusca (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end - ##################################################### - zerodual = Vector{GenericTrace{Dict{Symbol, Any}}}() - ##################################################### - directory_path = "./img/" - files = readdir(directory_path) - filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_zerodual") && endswith(file, "0.txt"), files) - - # Define an array of line styles and colors - # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] - - for (index,file) in enumerate(filtered_files) - filename = directory_path*file - #data = readdlm(filename, '\t', skipstart=1) - data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame - - # Extract the columns you want to plot - X = Int64.(data[mystart:myend,:iter]) - Y = Float64.(data[mystart:myend, :function_value]) - - #line_style = line_styles[i] - line_color = line_colors[index] - - trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="longdash", name="zerod") - push!(identity, trace) - end + ##################################################### + zerodual = Vector{GenericTrace{Dict{Symbol, Any}}}() + ##################################################### + directory_path = "./img/" + files = readdir(directory_path) + filtered_files = filter(file -> startswith(file, "$(name)256x256_pdps_known_zerodual") && endswith(file, "0.txt"), files) + + # Define an array of line styles and colors + # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] + line_colors = distinguishable_colors(15) + + for (index,file) in enumerate(filtered_files) + filename = directory_path*file + #data = readdlm(filename, '\t', skipstart=1) + data = CSV.File(filename, delim='\t'; header = 2) |> DataFrame + + # Extract the columns you want to plot + X = Int64.(data[mystart:myend,:iter]) + Y = Float64.(data[mystart:myend, :function_value]) + + #line_style = line_styles[i] + line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) + + trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", + line_color=line_color, line_dash="longdash", name="zerod (α=$α, τ₀=$τ₀, σ₀=$σ₀)") + push!(identity, trace) + end layout = Layout(legend_title_text="Function values") # Set legend title if save_plot && !isempty(save_path) - plotlyjs = plot([orig;identity;adhoc;rotation;affine;zerodual],layout) + plotlyjs = plot([orig;identity;adhoc;rotation;affine;zerodual], layout) open(save_path, "w") do io PlotlyBase.to_html(io, plotlyjs.plot) end @@ -217,7 +230,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -230,9 +243,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="dot", name="proxi") + line_color=line_color, line_dash="dot", name="proxi (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(orig, trace) end @@ -245,7 +260,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -258,9 +273,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="dashdot", name="primo") + line_color=line_color, line_dash="dashdot", name="primo (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -274,7 +291,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -287,9 +304,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="dash", name="greed") + line_color=line_color, line_dash="dash", name="greed (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -303,7 +322,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -316,9 +335,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="longdashdot", name="rotat") + line_color=line_color, line_dash="longdashdot", name="rotat (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -332,7 +353,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -345,9 +366,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="solid", name="dusca") + line_color=line_color, line_dash="solid", name="dusca (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -360,7 +383,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -373,13 +396,15 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="longdash", name="zerod") + line_color=line_color, line_dash="longdash", name="zerod (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end - layout = Layout(yaxis_type="log", legend_title_text="SSIM") # Set legend title + layout = Layout(yaxis_type="log",legend_title_text="SSIM") # Set legend title if save_plot && !isempty(save_path) plotlyjs = plot([orig;identity;adhoc;rotation;affine;zerodual], layout) @@ -409,7 +434,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -422,9 +447,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="dot", name="proxi") + line_color=line_color, line_dash="dot", name="proxi (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(orig, trace) end @@ -437,7 +464,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -450,9 +477,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="dashdot", name="primo") + line_color=line_color, line_dash="dashdot", name="primo (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -466,7 +495,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -479,9 +508,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="dash", name="greed") + line_color=line_color, line_dash="dash", name="greed (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -495,7 +526,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -508,9 +539,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="longdashdot", name="rotat") + line_color=line_color, line_dash="longdashdot", name="rotat (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -523,7 +556,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -536,9 +569,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="solid", name="dusca") + line_color=line_color, line_dash="solid", name="dusca (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -551,7 +586,7 @@ # Define an array of line styles and colors # line_styles = ["solid", "dash", "dot", "dashdot", "longdash"] - line_colors = ["blue", "red", "green", "orange", "purple", "cyan", "magenta", "yellow", "grey"] + line_colors = distinguishable_colors(15) for (index,file) in enumerate(filtered_files) filename = directory_path*file @@ -564,9 +599,11 @@ #line_style = line_styles[i] line_color = line_colors[index] + # Extract parameters for legend + α, τ₀, σ₀ = extract_parameters(filename) trace = PlotlyJS.scatter(;x=X, y=Y, mode="lines", hovertemplate="%{x:.0f},%{y:.1f}", - line_color=line_color, line_dash="longdash", name="zerod") + line_color=line_color, line_dash="longdash", name="zerod (α=$α, τ₀=$τ₀, σ₀=$σ₀)") push!(identity, trace) end @@ -585,5 +622,35 @@ return plot([orig;identity;adhoc;rotation;affine;zerodual],layout) end +###################### +# Parameter extraction +###################### +function extract_parameters(filename :: String) + # Extracting parameters + params_line = readlines(filename)[1] + + # Split the line by commas and trim each part + params_parts = map(strip, split(params_line, ',')) + + # Initialize variables to store parameter values + α_value, τ₀_value, σ₀_value = missing, missing, missing + + # Look for specific substrings to identify the values of α, τ₀, and σ₀ + for param_part in params_parts + if contains(param_part, "α = ") + α_value = parse(Float64, split(param_part, '=')[2]) + elseif contains(param_part, "τ₀ = ") + τ₀_value = parse(Float64, split(param_part, '=')[2]) + elseif contains(param_part, "σ₀ = ") + σ₀_value = parse(Float64, split(param_part, '=')[2]) + end + end + + # Assign the values to α, τ₀, and σ₀ + α = α_value + τ₀ = τ₀_value + σ₀ = σ₀_value + return α, τ₀, σ₀ +end end # Module \ No newline at end of file
--- a/src/PredictPDPS.jl Mon Apr 22 13:28:58 2024 +0300 +++ b/src/PredictPDPS.jl Wed Apr 24 11:34:09 2024 +0300 @@ -92,7 +92,7 @@ demo_petB1, demo_petB2, demo_petB3, demo_petB4, demo_petB5, demo_petB6, demo_petB7, batchrun_shepplogan, batchrun_brainphantom, batchrun_pet, - plot_denoising, plot_pet + plot_denoising, plot_pet, calculate_statistics ################################### # Parameterisation and experiments @@ -144,22 +144,22 @@ const p_known₀_denoising = ( noise_level = 0.5, shake_noise_level = 0.025, - shake = 3.0, + shake = 2.0, α = 1.0, ρ̃₀ = 1.0, σ̃₀ = 1.0, δ = 0.9, - σ₀ = 0.1, + σ₀ = 1.0, τ₀ = 0.01, - # stable_interval = union(Set(1:1500),Set(6000:7500)), - # stable_interval = union(Set(2000:4000),Set(8000:10000)), + #stable_interval = Set(0), + stable_interval = union(Set(2500:5000),Set(8750:10000)), ) const p_known₀ = ( noise_level = 0.5, shake_noise_level = 0.05, shake = 2, - α = 1, + α = 0.15, ρ̃₀ = 1, σ̃₀ = 1, δ = 0.9, @@ -275,7 +275,7 @@ function name(e::Experiment, p) ig = e.imgen # return "$(ig.name)_$(e.mod.identifier)_$(@sprintf "%x" hash(p))" - return "$(ig.name)_$(e.mod.identifier)_$(Int64(10000*p.σ₀))_$(Int64(10000*p.τ₀))" + return "$(ig.name)_$(e.mod.identifier)_$(Int64(100*p.α))_$(Int64(10000*p.σ₀))_$(Int64(10000*p.τ₀))" end function write_tex(texfile, e_params) @@ -362,8 +362,8 @@ # datafile = e_params.save_prefix * ".jld2" write_log(perffile, st.log, "# params = $(e_params)\n") - write_log(hififile, st.log_hifi, "# params = $(e_params)\n") - write_tex(texfile, e_params) + #write_log(hififile, st.log_hifi, "# params = $(e_params)\n") + #write_tex(texfile, e_params) # @save datafile x y st params end @@ -400,7 +400,7 @@ save_images=false, visualise=true, recalculate=true, - verbose_iter=1, + verbose_iter=50, fullscreen=true, kwargs...) end @@ -430,7 +430,7 @@ kwargs...) end -function batchrun_denoising(kwargs...) +function batchrun_denoising(;kwargs...) run_experiments(;experiments=denoising_experiments_all, save_results=true, save_images=true, @@ -440,9 +440,9 @@ end -function batchrun_predictors(kwargs...) - batchrun_denoising() - batchrun_pet() +function batchrun_predictors(;kwargs...) + batchrun_denoising(;kwargs...) + batchrun_pet(;kwargs...) end ######################################################