src/PET/PET.jl

changeset 28
f7c1007f0127
parent 27
515a89cf2178
child 34
aca9c90f151c
child 38
75116ad1d2e6
equal deleted inserted replaced
27:515a89cf2178 28:f7c1007f0127
20 using AlgTools.Comms 20 using AlgTools.Comms
21 using ImageTools.Visualise: secs_ns, grayimg, do_visualise 21 using ImageTools.Visualise: secs_ns, grayimg, do_visualise
22 using ImageTools.ImFilter: gaussian 22 using ImageTools.ImFilter: gaussian
23 23
24 # For PET 24 # For PET
25 #using Colors
26 #using ColorTypes
27 using ColorSchemes 25 using ColorSchemes
28 #using PerceptualColourMaps
29 26
30 ##################### 27 #####################
31 # Load local modules 28 # Load local modules
32 ##################### 29 #####################
33 include("OpticalFlow.jl") 30 include("OpticalFlow.jl")
105 dual_flow = true, 102 dual_flow = true,
106 prox_predict = true, 103 prox_predict = true,
107 handle_interrupt = true, 104 handle_interrupt = true,
108 init = :zero, 105 init = :zero,
109 plot_movement = false, 106 plot_movement = false,
107 stable_interval = Set(0),
110 ) 108 )
111 109
112 const p_known₀_pet = ( 110 const p_known₀_pet = (
113 noise_level = 0.5, 111 noise_level = 0.5,
114 shake_noise_level = 0.1, 112 shake_noise_level = 0.1,
115 shake = 1.0, 113 shake = 1.0,
116 rotation_factor = 0.075, 114 rotation_factor = 0.075,
117 rotation_noise_level = 0.0075, 115 rotation_noise_level = 0.0075,
118 α = 1.0, 116 α = 0.15,
119 ρ̃₀ = 1.0, 117 ρ̃₀ = 1.0,
120 σ̃₀ = 1.0, 118 σ̃₀ = 1.0,
121 δ = 0.9, 119 δ = 0.9,
122 σ₀ = 0.5, 120 σ₀ = 1.0,
123 τ₀ = 0.9, 121 τ₀ = 0.9,
124 λ = 1, 122 λ = 1,
125 radondims = [128,64], 123 radondims = [128,64],
126 sz = (256,256), 124 sz = (256,256),
127 scale = 1, 125 scale = 1,
128 c = 1.0, 126 c = 1.0,
129 sino_sparsity = 0.5, # Percentage of zero parts in the mask 127 sino_sparsity = 0.5,
130 L = 300.0, 128 L = 300.0,
131 L_experiment = false, 129 L_experiment = false,
132 stable_interval = Set(0), 130 #stable_interval = Set(0),
133 # stable_interval = union(Set(1:1000),Set(2500:3000)), 131 stable_interval = union(Set(1000:2000),Set(3500:4000)),
134 # stable_interval = union(Set(1000:2000),Set(3000:4000)),
135 ) 132 )
136 133
137 const shepplogan = imgen_shepplogan_radon(p_known₀_pet.sz) 134 const shepplogan = imgen_shepplogan_radon(p_known₀_pet.sz)
138 135
139 const brainphantom = imgen_brainphantom_radon(p_known₀_pet.sz) 136 const brainphantom = imgen_brainphantom_radon(p_known₀_pet.sz)
219 end 216 end
220 217
221 function name(e::Experiment, p) 218 function name(e::Experiment, p)
222 ig = e.imgen 219 ig = e.imgen
223 # return "$(ig.name)_$(e.mod.identifier)_$(@sprintf "%x" hash(p))" 220 # return "$(ig.name)_$(e.mod.identifier)_$(@sprintf "%x" hash(p))"
224 return "$(ig.name)_$(e.mod.identifier)_$(Int64(10000*p.σ₀))_$(Int64(10000*p.τ₀))" 221 return "$(ig.name)_$(e.mod.identifier)_$(Int64(100*p.α))_$(Int64(10000*p.σ₀))_$(Int64(10000*p.τ₀))"
225 end 222 end
226 223
227 function write_tex(texfile, e_params) 224 function write_tex(texfile, e_params)
228 open(texfile, "w") do io 225 open(texfile, "w") do io
229 wp = (n, v) -> println(io, "\\def\\EXPPARAM$(n){$(v)}") 226 wp = (n, v) -> println(io, "\\def\\EXPPARAM$(n){$(v)}")
306 hififile = e_params.save_prefix * "_hifi.txt" 303 hififile = e_params.save_prefix * "_hifi.txt"
307 texfile = e_params.save_prefix * "_params.tex" 304 texfile = e_params.save_prefix * "_params.tex"
308 # datafile = e_params.save_prefix * ".jld2" 305 # datafile = e_params.save_prefix * ".jld2"
309 306
310 write_log(perffile, st.log, "# params = $(e_params)\n") 307 write_log(perffile, st.log, "# params = $(e_params)\n")
311 write_log(hififile, st.log_hifi, "# params = $(e_params)\n") 308 #write_log(hififile, st.log_hifi, "# params = $(e_params)\n")
312 write_tex(texfile, e_params) 309 #write_tex(texfile, e_params)
313 # @save datafile x y st params 310 # @save datafile x y st params
314 end 311 end
315 312
316 close(datachannel) 313 close(datachannel)
317 wait(gentask) 314 wait(gentask)
344 run_experiments(;experiments=(experiment,), 341 run_experiments(;experiments=(experiment,),
345 save_results=false, 342 save_results=false,
346 save_images=false, 343 save_images=false,
347 visualise=true, 344 visualise=true,
348 recalculate=true, 345 recalculate=true,
349 verbose_iter=1, 346 verbose_iter=50,
350 fullscreen=true, 347 fullscreen=true,
351 kwargs...) 348 kwargs...)
352 end 349 end
353 350
354 demo_petS1 = () -> demo(shepplogan_experiments_pdps_known[1]) # Dual scaling 351 demo_petS1 = () -> demo(shepplogan_experiments_pdps_known[1]) # Dual scaling
366 demo_petB5 = () -> demo(brainphantom_experiments_pdps_known[5]) # Proximal (old) 363 demo_petB5 = () -> demo(brainphantom_experiments_pdps_known[5]) # Proximal (old)
367 demo_petB6 = () -> demo(brainphantom_experiments_pdps_known[6]) # Rotation 364 demo_petB6 = () -> demo(brainphantom_experiments_pdps_known[6]) # Rotation
368 demo_petB7 = () -> demo(brainphantom_experiments_pdps_known[7]) # Zero dual 365 demo_petB7 = () -> demo(brainphantom_experiments_pdps_known[7]) # Zero dual
369 366
370 367
371 function batchrun_shepplogan(kwargs...) 368 function batchrun_shepplogan(;kwargs...)
372 run_experiments(;experiments=shepplogan_experiments_all, 369 run_experiments(;experiments=shepplogan_experiments_all,
373 save_results=true, 370 save_results=true,
374 save_images=true, 371 save_images=true,
375 visualise=false, 372 visualise=false,
376 recalculate=false, 373 recalculate=false,
377 kwargs...) 374 kwargs...)
378 end 375 end
379 376
380 function batchrun_brainphantom(kwargs...) 377 function batchrun_brainphantom(;kwargs...)
381 run_experiments(;experiments=brainphantom_experiments_all, 378 run_experiments(;experiments=brainphantom_experiments_all,
382 save_results=true, 379 save_results=true,
383 save_images=true, 380 save_images=true,
384 visualise=false, 381 visualise=false,
385 recalculate=false, 382 recalculate=false,
386 kwargs...) 383 kwargs...)
387 end 384 end
388 385
389 function batchrun_pet(kwargs...) 386 function batchrun_pet(;kwargs...)
390 batchrun_shepplogan() 387 batchrun_shepplogan(;kwargs...)
391 batchrun_brainphantom() 388 batchrun_brainphantom(;kwargs...)
392 end 389 end
393 390
394 ###################################################### 391 ######################################################
395 # Iterator that does visualisation and log collection 392 # Iterator that does visualisation and log collection
396 ###################################################### 393 ######################################################

mercurial