Mon, 06 May 2024 20:05:06 -0500
Added tag v2.0.1 for changeset 910a99e4c099
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, |
52
cb029cdb141a
activation function for dual scscaling
Neil Dizon <neil.dizon@helsinki.fi>
parents:
50
diff
changeset
|
173 | p_known₀_denoising ⬿ (predictor=DualScaling(x -> (-abs(x-1)^1/5 + 1),0.75,1e-12),)), |
36 | 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(),)), | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
186 | ) |
5 | 187 | |
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
188 | const denoising_experiments_all = Iterators.flatten(( |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
189 | denoising_experiments_pdps_known, |
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
190 | )) |
5 | 191 | |
0 | 192 | ####################### |
193 | # Demos and batch runs | |
194 | ####################### | |
195 | ||
196 | function demo(experiment; kwargs...) | |
197 | run_experiments(;experiments=(experiment,), | |
198 | save_results=false, | |
199 | save_images=false, | |
36 | 200 | save_prefix=default_save_prefix, |
0 | 201 | visualise=true, |
202 | recalculate=true, | |
28
f7c1007f0127
added function to generate table
Neil Dizon <neil.dizon@helsinki.fi>
parents:
27
diff
changeset
|
203 | verbose_iter=50, |
5 | 204 | fullscreen=true, |
0 | 205 | kwargs...) |
206 | end | |
207 | ||
208 | demo_known1 = () -> demo(experiments_pdps_known[3]) | |
209 | demo_known2 = () -> demo(experiments_pdps_known[1]) | |
210 | demo_known3 = () -> demo(experiments_pdps_known[2]) | |
5 | 211 | |
0 | 212 | demo_unknown1 = () -> demo(experiments_pdps_unknown_multi[3], plot_movement=true) |
213 | demo_unknown2 = () -> demo(experiments_pdps_unknown_multi[1], plot_movement=true) | |
214 | demo_unknown3 = () -> demo(experiments_pdps_unknown_multi[2], plot_movement=true) | |
215 | ||
8
e4ad8f7ce671
Added PET and updated README
Neil Dizon <neil.dizon@helsinki.fi>
parents:
6
diff
changeset
|
216 | 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
|
217 | 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
|
218 | 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
|
219 | 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
|
220 | 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
|
221 | 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
|
222 | demo_denoising7 = () -> demo(denoising_experiments_pdps_known[7]) # Zero dual |
50 | 223 | |
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 |