Fri, 03 May 2024 17:16:21 +0300
remove activated dual
0 | 1 | ################## |
2 | # Our main module | |
3 | ################## | |
4 | ||
5 | __precompile__() | |
6 | ||
7 | module PredictPDPS | |
8 | ||
9 | ######################## | |
10 | # Load external modules | |
11 | ######################## | |
12 | ||
36 | 13 | using ImageTools.ImFilter: gaussian |
0 | 14 | using AlgTools.Util |
15 | ||
16 | ##################### | |
17 | # Load local modules | |
18 | ##################### | |
19 | ||
20 | include("OpticalFlow.jl") | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
21 | include("Radon.jl") |
0 | 22 | include("ImGenerate.jl") |
36 | 23 | include("Run.jl") |
24 | include("AlgorithmProximal.jl") | |
0 | 25 | include("AlgorithmBothMulti.jl") |
26 | include("AlgorithmFB.jl") | |
27 | include("AlgorithmFBDual.jl") | |
36 | 28 | include("AlgorithmNew.jl") |
34
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
29 | include("Stats.jl") |
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
30 | #include("PlotResults.jl") |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
31 | include("PET/PET.jl") |
5 | 32 | |
23
1c4b7d1f261f
added plotting functions
Neil Dizon <neil.dizon@helsinki.fi>
parents:
22
diff
changeset
|
33 | |
36 | 34 | import .AlgorithmBothMulti, |
0 | 35 | .AlgorithmFB, |
5 | 36 | .AlgorithmFBDual, |
37 | .AlgorithmProximal, | |
36 | 38 | .AlgorithmNew |
0 | 39 | |
40 | using .ImGenerate | |
36 | 41 | using .OpticalFlow |
34
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
42 | using .Stats |
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
43 | #using .PlotResults |
23
1c4b7d1f261f
added plotting functions
Neil Dizon <neil.dizon@helsinki.fi>
parents:
22
diff
changeset
|
44 | using .PET |
36 | 45 | using .Run |
0 | 46 | |
47 | ############## | |
48 | # Our exports | |
49 | ############## | |
50 | ||
51 | export run_experiments, | |
52 | batchrun_article, | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
53 | demo_known1, demo_known2, demo_known3, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
54 | demo_unknown1,demo_unknown2,demo_unknown3, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
55 | batchrun_denoising, |
18
e6a2ebaf467d
added data generation for new phantom
Neil Dizon <neil.dizon@helsinki.fi>
parents:
8
diff
changeset
|
56 | batchrun_predictors, |
34
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
57 | demo_denoising1, demo_denoising2, demo_denoising3, |
50 | 58 | demo_denoising4, demo_denoising5, demo_denoising6, demo_denoising7, #demo_denoising8, |
34
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
59 | demo_petS1, demo_petS2, demo_petS3, |
18
e6a2ebaf467d
added data generation for new phantom
Neil Dizon <neil.dizon@helsinki.fi>
parents:
8
diff
changeset
|
60 | demo_petS4, demo_petS5, demo_petS6, demo_petS7, |
34
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
61 | demo_petB1, demo_petB2, demo_petB3, |
18
e6a2ebaf467d
added data generation for new phantom
Neil Dizon <neil.dizon@helsinki.fi>
parents:
8
diff
changeset
|
62 | demo_petB4, demo_petB5, demo_petB6, demo_petB7, |
e6a2ebaf467d
added data generation for new phantom
Neil Dizon <neil.dizon@helsinki.fi>
parents:
8
diff
changeset
|
63 | batchrun_shepplogan, batchrun_brainphantom, batchrun_pet, |
34
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
64 | calculate_statistics |
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
65 | #plot_denoising, plot_pet, |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
66 | |
0 | 67 | ################################### |
68 | # Parameterisation and experiments | |
69 | ################################### | |
70 | ||
71 | const default_save_prefix="img/" | |
72 | ||
73 | const default_params = ( | |
74 | ρ = 0, | |
75 | verbose_iter = 100, | |
76 | maxiter = 10000, | |
77 | save_results = true, | |
78 | save_images = true, | |
79 | save_images_iters = Set([1, 2, 3, 5, | |
80 | 10, 25, 30, 50, | |
81 | 100, 250, 300, 500, | |
25 | 82 | 1000, 2000, 2500, 3000, 4000, 5000, |
29
6a0ca7047f68
added new plots and filmstrips
Neil Dizon <neil.dizon@helsinki.fi>
parents:
28
diff
changeset
|
83 | 6000, 7000, 7500, 8000, 9000, 10000, 8700]), |
0 | 84 | pixelwise_displacement=false, |
36 | 85 | dual_flow = true, # For AlgorithmProximalfrom 2019 paper |
0 | 86 | handle_interrupt = true, |
87 | init = :zero, | |
88 | plot_movement = false, | |
27 | 89 | stable_interval = Set(0), |
0 | 90 | ) |
91 | ||
92 | const square = imgen_square((200, 300)) | |
93 | const lighthouse = imgen_shake("lighthouse", (200, 300)) | |
94 | ||
36 | 95 | const p_known₀ = default_params ⬿ ( |
0 | 96 | noise_level = 0.5, |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
97 | shake_noise_level = 0.05, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
98 | shake = 2, |
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
99 | α = 0.15, |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
100 | ρ̃₀ = 1, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
101 | σ̃₀ = 1, |
0 | 102 | δ = 0.9, |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
103 | σ₀ = 1, |
0 | 104 | τ₀ = 0.01, |
105 | ) | |
106 | ||
45 | 107 | # Experiments for 2019 paper |
108 | ||
36 | 109 | const p_unknown₀ = default_params ⬿ ( |
0 | 110 | noise_level = 0.3, |
111 | shake_noise_level = 0.05, | |
112 | shake = 2, | |
113 | α = 0.2, | |
114 | ρ̃₀ = 1, | |
115 | σ̃₀ = 1, | |
116 | σ₀ = 1, | |
117 | δ = 0.9, | |
118 | λ = 1, | |
119 | θ = (300*200)*100^3, | |
120 | kernel = gaussian((3, 3), (11, 11)), | |
121 | timestep = 0.5, | |
122 | displacement_count = 100, | |
123 | τ₀ = 0.01, | |
124 | ) | |
125 | ||
126 | const experiments_pdps_known = ( | |
36 | 127 | Experiment(AlgorithmProximal, DisplacementConstant, lighthouse, |
46 | 128 | p_known₀ ⬿ (phantom_ρ = 0,)), |
36 | 129 | Experiment(AlgorithmProximal, DisplacementConstant, lighthouse, |
0 | 130 | p_known₀ ⬿ (phantom_ρ = 100,)), |
36 | 131 | Experiment(AlgorithmProximal, DisplacementConstant, square, |
0 | 132 | p_known₀ ⬿ (phantom_ρ = 0,)) |
133 | ) | |
134 | ||
135 | const experiments_pdps_unknown_multi = ( | |
136 | Experiment(AlgorithmBothMulti, DisplacementConstant, lighthouse, | |
137 | p_unknown₀ ⬿ (phantom_ρ = 0,)), | |
138 | Experiment(AlgorithmBothMulti, DisplacementConstant, lighthouse, | |
139 | p_unknown₀ ⬿ (phantom_ρ = 100,)), | |
140 | Experiment(AlgorithmBothMulti, DisplacementConstant, square, | |
141 | p_unknown₀ ⬿ (phantom_ρ = 0,)), | |
142 | ) | |
143 | ||
144 | const experiments_fb_known = ( | |
145 | Experiment(AlgorithmFB, DisplacementConstant, lighthouse, | |
146 | p_known₀ ⬿ (τ̃₀=0.9, fb_inner_iterations = 10)), | |
147 | ) | |
148 | ||
149 | const experiments_all = Iterators.flatten(( | |
150 | experiments_pdps_known, | |
151 | experiments_pdps_unknown_multi, | |
152 | experiments_fb_known | |
153 | )) | |
154 | ||
36 | 155 | # Image stabilisation experiments for 2024 paper. PET experiments are in PET/PET.jl |
156 | ||
45 | 157 | const p_known₀_denoising = default_params ⬿ ( |
158 | noise_level = 0.5, | |
159 | shake_noise_level = 0.025, | |
160 | shake = 2.0, | |
161 | α = 0.25, | |
162 | ρ̃₀ = 1.0, | |
163 | σ̃₀ = 1.0, | |
164 | δ = 0.9, | |
165 | σ₀ = 1.0, | |
166 | τ₀ = 0.01, | |
167 | #stable_interval = Set(0), | |
168 | stable_interval = union(Set(2500:5000),Set(8700:10000)), | |
169 | ) | |
170 | ||
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
171 | const denoising_experiments_pdps_known = ( |
36 | 172 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, |
173 | p_known₀_denoising ⬿ (predictor=DualScaling(),)), | |
174 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, | |
175 | p_known₀_denoising ⬿ (predictor=Greedy(),)), | |
176 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, | |
177 | p_known₀_denoising ⬿ (predictor=nothing,),), | |
178 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, | |
179 | p_known₀_denoising ⬿ (predictor=PrimalOnly(),)), | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
180 | Experiment(AlgorithmProximal, DisplacementConstant, lighthouse, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
181 | p_known₀_denoising ⬿ (phantom_ρ = 100,)), |
36 | 182 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, |
183 | p_known₀_denoising ⬿ (predictor=Rotation(),)), | |
184 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, | |
185 | p_known₀_denoising ⬿ (predictor=ZeroDual(),)), | |
50 | 186 | # Experiment(AlgorithmNew, DisplacementConstant, lighthouse, |
187 | # p_known₀_denoising ⬿ (predictor=ActivatedDual(),)), | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
188 | ) |
5 | 189 | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
190 | const denoising_experiments_all = Iterators.flatten(( |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
191 | denoising_experiments_pdps_known, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
192 | )) |
5 | 193 | |
0 | 194 | ####################### |
195 | # Demos and batch runs | |
196 | ####################### | |
197 | ||
198 | function demo(experiment; kwargs...) | |
199 | run_experiments(;experiments=(experiment,), | |
200 | save_results=false, | |
201 | save_images=false, | |
36 | 202 | save_prefix=default_save_prefix, |
0 | 203 | visualise=true, |
204 | recalculate=true, | |
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
205 | verbose_iter=50, |
5 | 206 | fullscreen=true, |
0 | 207 | kwargs...) |
208 | end | |
209 | ||
210 | demo_known1 = () -> demo(experiments_pdps_known[3]) | |
211 | demo_known2 = () -> demo(experiments_pdps_known[1]) | |
212 | demo_known3 = () -> demo(experiments_pdps_known[2]) | |
5 | 213 | |
0 | 214 | demo_unknown1 = () -> demo(experiments_pdps_unknown_multi[3], plot_movement=true) |
215 | demo_unknown2 = () -> demo(experiments_pdps_unknown_multi[1], plot_movement=true) | |
216 | demo_unknown3 = () -> demo(experiments_pdps_unknown_multi[2], plot_movement=true) | |
217 | ||
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
218 | demo_denoising1 = () -> demo(denoising_experiments_pdps_known[1]) # Dual scaling |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
219 | demo_denoising2 = () -> demo(denoising_experiments_pdps_known[2]) # Greedy |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
220 | demo_denoising3 = () -> demo(denoising_experiments_pdps_known[3]) # No Prediction |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
221 | demo_denoising4 = () -> demo(denoising_experiments_pdps_known[4]) # Primal Only |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
222 | demo_denoising5 = () -> demo(denoising_experiments_pdps_known[5]) # Proximal (old) |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
223 | demo_denoising6 = () -> demo(denoising_experiments_pdps_known[6]) # Rotation |
20
7d3a75b875fa
added zero dual predictor for denoising
Neil Dizon <neil.dizon@helsinki.fi>
parents:
18
diff
changeset
|
224 | demo_denoising7 = () -> demo(denoising_experiments_pdps_known[7]) # Zero dual |
50 | 225 | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
226 | |
0 | 227 | function batchrun_article(kwargs...) |
228 | run_experiments(;experiments=experiments_all, | |
36 | 229 | save_prefix=default_save_prefix, |
0 | 230 | save_results=true, |
231 | save_images=true, | |
232 | visualise=false, | |
233 | recalculate=false, | |
234 | kwargs...) | |
235 | end | |
236 | ||
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
237 | function batchrun_denoising(;kwargs...) |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
238 | run_experiments(;experiments=denoising_experiments_all, |
36 | 239 | save_prefix=default_save_prefix, |
5 | 240 | save_results=true, |
241 | save_images=true, | |
242 | visualise=false, | |
243 | recalculate=false, | |
244 | kwargs...) | |
245 | end | |
246 | ||
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
247 | |
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
248 | function batchrun_predictors(;kwargs...) |
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
249 | batchrun_denoising(;kwargs...) |
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
250 | batchrun_pet(;kwargs...) |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
251 | end |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
252 | |
23
1c4b7d1f261f
added plotting functions
Neil Dizon <neil.dizon@helsinki.fi>
parents:
22
diff
changeset
|
253 | ######################### |
1c4b7d1f261f
added plotting functions
Neil Dizon <neil.dizon@helsinki.fi>
parents:
22
diff
changeset
|
254 | # Plotting SSIM and PSNR |
1c4b7d1f261f
added plotting functions
Neil Dizon <neil.dizon@helsinki.fi>
parents:
22
diff
changeset
|
255 | ######################### |
1c4b7d1f261f
added plotting functions
Neil Dizon <neil.dizon@helsinki.fi>
parents:
22
diff
changeset
|
256 | |
34
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
257 | #function plot_denoising(kwargs...) |
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
258 | # ssim_plot("lighthouse") |
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
259 | # psnr_plot("lighthouse") |
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
260 | # fv_plot("lighthouse") |
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
261 | #end |
23
1c4b7d1f261f
added plotting functions
Neil Dizon <neil.dizon@helsinki.fi>
parents:
22
diff
changeset
|
262 | |
0 | 263 | end # Module |