added fv_plot

Sun, 21 Apr 2024 22:35:03 +0300

author
Neil Dizon <neil.dizon@helsinki.fi>
date
Sun, 21 Apr 2024 22:35:03 +0300
changeset 25
c9b06736a477
parent 24
2d9e64235ba7
child 26
ccd22bbbb02f

added fv_plot

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/src/ImGenerate.jl	Sun Apr 21 21:00:57 2024 +0300
+++ b/src/ImGenerate.jl	Sun Apr 21 22:35:03 2024 +0300
@@ -200,7 +200,7 @@
         b_true = zeros(sz...)
         extract_subimage!(b_true, im, v_cumul; threads=true)
         b = b_true .+ params.noise_level.*randn(rng,sz...)
-        v = v_true.*(1.0 .+ zero_factor*params.shake_noise_level.*randn(rng,size(v_true)...))
+        v = v_true.*(1.0 .+ params.shake_noise_level.*randn(rng,size(v_true)...))
         # Pass data to iteration routine
         data = OnlineData{DisplacementConstant}(b_true, b, v, v_true, v_cumul)
         if !put_unless_closed!(datachannel, data)
@@ -257,8 +257,8 @@
         # Apply the transformation to the image using warp
         b_true = copy(warp(im, tform, axes(im), fillvalue=Flat()))
 
-        v = v_true.*(1.0 .+ zero_factor*params.shake_noise_level.*randn(rng,size(v_true)...))
-        theta = theta_true*(1.0 + zero_factor*params.rotation_noise_level.*randn(rng))
+        v = v_true.*(1.0 .+ params.shake_noise_level.*randn(rng,size(v_true)...))
+        theta = theta_true*(1.0 + params.rotation_noise_level.*randn(rng))
 
         # Generate the true and noisy sinograms
         sinogram_true = zeros(params.radondims...)
--- a/src/PET/ImGenerate.jl	Sun Apr 21 21:00:57 2024 +0300
+++ b/src/PET/ImGenerate.jl	Sun Apr 21 22:35:03 2024 +0300
@@ -200,7 +200,7 @@
         b_true = zeros(sz...)
         extract_subimage!(b_true, im, v_cumul; threads=true)
         b = b_true .+ params.noise_level.*randn(rng,sz...)
-        v = v_true.*(1.0 .+ zero_factor*params.shake_noise_level.*randn(rng,size(v_true)...))
+        v = v_true.*(1.0 .+ params.shake_noise_level.*randn(rng,size(v_true)...))
         # Pass data to iteration routine
         data = OnlineData{DisplacementConstant}(b_true, b, v, v_true, v_cumul)
         if !put_unless_closed!(datachannel, data)
@@ -257,8 +257,8 @@
         # Apply the transformation to the image using warp
         b_true = copy(warp(im, tform, axes(im), fillvalue=Flat()))
 
-        v = v_true.*(1.0 .+ zero_factor*params.shake_noise_level.*randn(rng,size(v_true)...))
-        theta = theta_true*(1.0 + zero_factor*params.rotation_noise_level.*randn(rng))
+        v = v_true.*(1.0 .+ params.shake_noise_level.*randn(rng,size(v_true)...))
+        theta = theta_true*(1.0 + params.rotation_noise_level.*randn(rng))
 
         # Generate the true and noisy sinograms
         sinogram_true = zeros(params.radondims...)
--- a/src/PET/PET.jl	Sun Apr 21 21:00:57 2024 +0300
+++ b/src/PET/PET.jl	Sun Apr 21 22:35:03 2024 +0300
@@ -97,8 +97,10 @@
     maxiter = 4000,
     save_results = true,
     save_images = true,
-    save_images_iters = Set([100, 200, 300, 500, 800, 1000,
-                             1300, 1500, 1800, 2000, 4000]),
+    save_images_iters = Set([100, 300, 500, 800, 1000,
+                             1300, 1500, 1800, 2000,
+                             2300, 2500, 2800, 3000,
+                             3300, 3500, 3800, 4000]),
     pixelwise_displacement=false,
     dual_flow = true,
     prox_predict = true,
@@ -127,7 +129,7 @@
     sino_sparsity = 0.5,            # Percentage of zero parts in the mask
     L = 300.0,
     L_experiment = false,
-    stable_interval = union(Set(1500:2000),Set(3500:4000)),
+    stable_interval = union(Set(1:1000),Set(2500:3000)),
 )
 
 const shepplogan = imgen_shepplogan_radon(p_knownâ‚€_pet.sz)
@@ -558,9 +560,11 @@
 
 function plot_pet(kwargs...)
     ssim_plot("shepplogan")
+    psnr_plot("shepplogan")
+    fv_plot("shepplogan")
     ssim_plot("brainphantom")
-    psnr_plot("shepplogan")
     psnr_plot("brainphantom")
+    fv_plot("brainphantom")
 end
 
 
--- a/src/PET/PlotResults.jl	Sun Apr 21 21:00:57 2024 +0300
+++ b/src/PET/PlotResults.jl	Sun Apr 21 22:35:03 2024 +0300
@@ -160,10 +160,38 @@
          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      
+
     layout = Layout(legend_title_text="Function values")  # Set legend title
     
     if save_plot && !isempty(save_path)
-        plotlyjs = plot([orig;identity;adhoc;rotation;affine], layout)
+        plotlyjs = plot([orig;identity;adhoc;rotation;affine;zerodual],layout)
         open(save_path, "w") do io
             PlotlyBase.to_html(io, plotlyjs.plot)
         end
@@ -171,7 +199,7 @@
         println("Please provide a valid save path.")
     end
 
-    return  plot([orig;identity;adhoc;rotation;affine],layout)
+    return  plot([orig;identity;adhoc;rotation;affine;zerodual],layout)
 end
 
 
--- a/src/PredictPDPS.jl	Sun Apr 21 21:00:57 2024 +0300
+++ b/src/PredictPDPS.jl	Sun Apr 21 22:35:03 2024 +0300
@@ -127,8 +127,8 @@
     save_images_iters = Set([1, 2, 3, 5,
                              10, 25, 30, 50,
                              100, 250, 300, 500,
-                             1000, 2500, 3000, 5000,
-                             10000]),
+                             1000, 2000, 2500, 3000, 4000, 5000,
+                             6000, 7000, 7500, 8000, 9000, 10000]),
     pixelwise_displacement=false,
     dual_flow = true,
     prox_predict = true,
@@ -136,7 +136,7 @@
     init = :zero,
     plot_movement = false,
     # stable_interval = Set(),
-    stable_interval = union(Set(1000:2000),Set(3000:4000),Set(5000:7000),Set(9000:10000)),
+    stable_interval = union(Set(1:1500),Set(6000:7500)),
 )
 
 const square = imgen_square((200, 300))
@@ -594,6 +594,7 @@
 function plot_denoising(kwargs...)
     ssim_plot("lighthouse")
     psnr_plot("lighthouse")
+    fv_plot("lighthouse")
 end
 
 

mercurial