Thu, 25 Apr 2024 14:48:54 -0500
oops
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, |
20
7d3a75b875fa
added zero dual predictor for denoising
Neil Dizon <neil.dizon@helsinki.fi>
parents:
18
diff
changeset
|
58 | demo_denoising4, demo_denoising5, demo_denoising6, demo_denoising7, |
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₀_denoising = default_params ⬿ ( |
27 | 96 | noise_level = 0.5, |
97 | shake_noise_level = 0.025, | |
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
98 | shake = 2.0, |
27 | 99 | α = 1.0, |
100 | ρ̃₀ = 1.0, | |
101 | σ̃₀ = 1.0, | |
102 | δ = 0.9, | |
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
103 | σ₀ = 1.0, |
27 | 104 | τ₀ = 0.01, |
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
105 | #stable_interval = Set(0), |
29
6a0ca7047f68
added new plots and filmstrips
Neil Dizon <neil.dizon@helsinki.fi>
parents:
28
diff
changeset
|
106 | stable_interval = union(Set(2500:5000),Set(8700:10000)), |
27 | 107 | ) |
108 | ||
36 | 109 | const p_known₀ = default_params ⬿ ( |
0 | 110 | noise_level = 0.5, |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
111 | shake_noise_level = 0.05, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
112 | shake = 2, |
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
113 | α = 0.15, |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
114 | ρ̃₀ = 1, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
115 | σ̃₀ = 1, |
0 | 116 | δ = 0.9, |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
117 | σ₀ = 1, |
0 | 118 | τ₀ = 0.01, |
119 | ) | |
120 | ||
36 | 121 | const p_unknown₀ = default_params ⬿ ( |
0 | 122 | noise_level = 0.3, |
123 | shake_noise_level = 0.05, | |
124 | shake = 2, | |
125 | α = 0.2, | |
126 | ρ̃₀ = 1, | |
127 | σ̃₀ = 1, | |
128 | σ₀ = 1, | |
129 | δ = 0.9, | |
130 | λ = 1, | |
131 | θ = (300*200)*100^3, | |
132 | kernel = gaussian((3, 3), (11, 11)), | |
133 | timestep = 0.5, | |
134 | displacement_count = 100, | |
135 | τ₀ = 0.01, | |
136 | ) | |
137 | ||
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
138 | |
36 | 139 | # Experiments for 2019 paper |
140 | ||
0 | 141 | const experiments_pdps_known = ( |
36 | 142 | Experiment(AlgorithmProximal, DisplacementConstant, lighthouse, |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
143 | p_known₀_denoising ⬿ (phantom_ρ = 0,)), |
36 | 144 | Experiment(AlgorithmProximal, DisplacementConstant, lighthouse, |
0 | 145 | p_known₀ ⬿ (phantom_ρ = 100,)), |
36 | 146 | Experiment(AlgorithmProximal, DisplacementConstant, square, |
0 | 147 | p_known₀ ⬿ (phantom_ρ = 0,)) |
148 | ) | |
149 | ||
150 | const experiments_pdps_unknown_multi = ( | |
151 | Experiment(AlgorithmBothMulti, DisplacementConstant, lighthouse, | |
152 | p_unknown₀ ⬿ (phantom_ρ = 0,)), | |
153 | Experiment(AlgorithmBothMulti, DisplacementConstant, lighthouse, | |
154 | p_unknown₀ ⬿ (phantom_ρ = 100,)), | |
155 | Experiment(AlgorithmBothMulti, DisplacementConstant, square, | |
156 | p_unknown₀ ⬿ (phantom_ρ = 0,)), | |
157 | ) | |
158 | ||
159 | const experiments_fb_known = ( | |
160 | Experiment(AlgorithmFB, DisplacementConstant, lighthouse, | |
161 | p_known₀ ⬿ (τ̃₀=0.9, fb_inner_iterations = 10)), | |
162 | ) | |
163 | ||
164 | const experiments_all = Iterators.flatten(( | |
165 | experiments_pdps_known, | |
166 | experiments_pdps_unknown_multi, | |
167 | experiments_fb_known | |
168 | )) | |
169 | ||
36 | 170 | # Image stabilisation experiments for 2024 paper. PET experiments are in PET/PET.jl |
171 | ||
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
172 | const denoising_experiments_pdps_known = ( |
36 | 173 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, |
174 | p_known₀_denoising ⬿ (predictor=DualScaling(),)), | |
175 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, | |
176 | p_known₀_denoising ⬿ (predictor=Greedy(),)), | |
177 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, | |
178 | p_known₀_denoising ⬿ (predictor=nothing,),), | |
179 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, | |
180 | p_known₀_denoising ⬿ (predictor=PrimalOnly(),)), | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
181 | Experiment(AlgorithmProximal, DisplacementConstant, lighthouse, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
182 | p_known₀_denoising ⬿ (phantom_ρ = 100,)), |
36 | 183 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, |
184 | p_known₀_denoising ⬿ (predictor=Rotation(),)), | |
185 | Experiment(AlgorithmNew, DisplacementConstant, lighthouse, | |
186 | p_known₀_denoising ⬿ (predictor=ZeroDual(),)), | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
187 | ) |
5 | 188 | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
189 | const denoising_experiments_all = Iterators.flatten(( |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
190 | denoising_experiments_pdps_known, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
191 | )) |
5 | 192 | |
0 | 193 | ####################### |
194 | # Demos and batch runs | |
195 | ####################### | |
196 | ||
197 | function demo(experiment; kwargs...) | |
198 | run_experiments(;experiments=(experiment,), | |
199 | save_results=false, | |
200 | save_images=false, | |
36 | 201 | save_prefix=default_save_prefix, |
0 | 202 | visualise=true, |
203 | recalculate=true, | |
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
204 | verbose_iter=50, |
5 | 205 | fullscreen=true, |
0 | 206 | kwargs...) |
207 | end | |
208 | ||
209 | demo_known1 = () -> demo(experiments_pdps_known[3]) | |
210 | demo_known2 = () -> demo(experiments_pdps_known[1]) | |
211 | demo_known3 = () -> demo(experiments_pdps_known[2]) | |
5 | 212 | |
0 | 213 | demo_unknown1 = () -> demo(experiments_pdps_unknown_multi[3], plot_movement=true) |
214 | demo_unknown2 = () -> demo(experiments_pdps_unknown_multi[1], plot_movement=true) | |
215 | demo_unknown3 = () -> demo(experiments_pdps_unknown_multi[2], plot_movement=true) | |
216 | ||
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
217 | 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
|
218 | 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
|
219 | 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
|
220 | 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
|
221 | 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
|
222 | 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
|
223 | demo_denoising7 = () -> demo(denoising_experiments_pdps_known[7]) # Zero dual |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
224 | |
0 | 225 | function batchrun_article(kwargs...) |
226 | run_experiments(;experiments=experiments_all, | |
36 | 227 | save_prefix=default_save_prefix, |
0 | 228 | save_results=true, |
229 | save_images=true, | |
230 | visualise=false, | |
231 | recalculate=false, | |
232 | kwargs...) | |
233 | end | |
234 | ||
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
235 | function batchrun_denoising(;kwargs...) |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
236 | run_experiments(;experiments=denoising_experiments_all, |
36 | 237 | save_prefix=default_save_prefix, |
5 | 238 | save_results=true, |
239 | save_images=true, | |
240 | visualise=false, | |
241 | recalculate=false, | |
242 | kwargs...) | |
243 | end | |
244 | ||
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
245 | |
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
246 | function batchrun_predictors(;kwargs...) |
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
247 | batchrun_denoising(;kwargs...) |
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
248 | batchrun_pet(;kwargs...) |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
249 | end |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
250 | |
23
1c4b7d1f261f
added plotting functions
Neil Dizon <neil.dizon@helsinki.fi>
parents:
22
diff
changeset
|
251 | ######################### |
1c4b7d1f261f
added plotting functions
Neil Dizon <neil.dizon@helsinki.fi>
parents:
22
diff
changeset
|
252 | # Plotting SSIM and PSNR |
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 | |
34
aca9c90f151c
Reduce dependencies; separate Stats from PlotResults (disabled by default to avoid heavy deps)
Tuomo Valkonen <tuomov@iki.fi>
parents:
29
diff
changeset
|
255 | #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
|
256 | # 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
|
257 | # 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
|
258 | # 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
|
259 | #end |
23
1c4b7d1f261f
added plotting functions
Neil Dizon <neil.dizon@helsinki.fi>
parents:
22
diff
changeset
|
260 | |
0 | 261 | end # Module |