Iterative Reconstruction Result
We can now use the iterative algorithms to reconstruct the first three images of our time series. We first prepare our parameters. For this example we will use the Conjugate Gradient Normal Residual solver with 20 iterations and a L2 regularization of 0.001. Furthermore, we will project the final result to positive values:
pre = RadonPreprocessingParameters(frames = collect(1:3))
iter_reco = IterativeRadonReconstructionParameters(; shape = size(images)[1:3], angles = angles, iterations = 20, reg = [L2Regularization(0.001), PositiveRegularization()], solver = CGNR);
Again we can construct the algorithm with our parameters:
algo_iter = IterativeRadonAlgorithm(IterativeRadonParameters(pre, iter_reco));
And apply it to our sinograms:
imag_iter = reconstruct(algo_iter, sinograms);
Finally we can visualize the results:
fig = Figure()
for i = 1:3
plot_image(fig[i,1], reverse(images[:, :, 24, i]))
plot_image(fig[i,2], sinograms[:, :, 24, i])
plot_image(fig[i,3], reverse(imag_iter[:, :, 24, i]))
end
resize_to_layout!(fig)
fig

As was already mentioned for the direct reconstruction, the iterative algorithm also needs to be recreated for any parameter change. This can already be quite tedious with the number of parameters we have here. To make this process easier, we can use the RecoPlan
feature of AbstractImageReconstruction
. This allows us to define a plan for the reconstruction, which can then be used to easily reconstruct the images.
RecoPlan
A RecoPlan
is a thin-wrapper around nested key-value pairs that represent the same tree structure of our algorithm and parameters. The plan can be fully parametertized and then used to create the algorithm. But it can also miss parameters and describe the structure of the algorithm only. This can be useful to create a template for the reconstruction, which can be filled with parameters later on.
We can create a plan from our algorithm:
plan = toPlan(algo_iter)
RecoPlan{Main.OurRadonReco.IterativeRadonAlgorithm}
└─ parameter::RecoPlan{Main.OurRadonReco.IterativeRadonParameters}
├─ reco::RecoPlan{Main.OurRadonReco.IterativeRadonReconstructionParameters}
│ ├─ iterations = 20
│ ├─ solver = CGNR
│ ├─ reg = AbstractRegularization[L2Regularization{Float64}(0.001), PositiveRegularization()]
│ ├─ angles = [0.0, 0.01232, 0.0246399, 0.0369599, 0.0492799, 0.0615999, 0.0739198, 0.0862398, 0.0985598, 0.11088 … 3.03071, 3.04303, 3.05535, 3.06767, 3.07999, 3.09231, 3.10463, 3.11695, 3.12927, 3.14159]
│ └─ shape = (64, 64, 64)
└─ pre::RecoPlan{Main.OurRadonReco.RadonPreprocessingParameters}
├─ numAverages = 1
└─ frames = [1, 2, 3]
The parameters of our plan can be accessed/traversed the same way as the algorithm:
plan.parameter.pre.frames == algo_iter.parameter.pre.frames
true
And each nested algorithm and parameter struct was converted to a plan:
typeof(plan.parameter.pre)
RecoPlan{Main.OurRadonReco.RadonPreprocessingParameters}
Unlike the algorithm, we can easily change the parameters of the plan:
plan.parameter.reco.iterations = 30
plan.parameter.pre.frames = collect(1:5)
5-element Vector{Int64}:
1
2
3
4
5
Instead of traversing the properties of the plan/algorithm, we can also use the setAll!
function to set all parameters of the same of the plan at once:
setAll!(plan, :solver, FISTA);
This also works with dictionaries of symbols and values:
dict = Dict{Symbol, Any}(:reg => [L1Regularization(0.001)])
setAll!(plan, dict);
Once we have parametertized our plan, we can build the algorithm from it:
algo_iter = build(plan)
imag_iter = reconstruct(algo_iter, sinograms)
fig = Figure()
for i = 1:5
plot_image(fig[i,1], reverse(images[:, :, 24, i]))
plot_image(fig[i,2], sinograms[:, :, 24, i])
plot_image(fig[i,3], reverse(imag_iter[:, :, 24, i]))
end
resize_to_layout!(fig)
fig

It's also possible to clear the plan and remove all set parameters. By default this preserves the structure of the plan. Such a plan can be used as a template for further reconstructions and stored as a TOML file:
toTOML(stdout, plan) # to save to file use `savePlan("path/to/file.toml", plan)`
_module = "Main.OurRadonReco"
_type = "RecoPlan{Main.OurRadonReco.IterativeRadonAlgorithm}"
[parameter]
_module = "Main.OurRadonReco"
_type = "RecoPlan{Main.OurRadonReco.IterativeRadonParameters}"
[parameter.reco]
iterations = 30
_module = "Main.OurRadonReco"
_type = "RecoPlan{Main.OurRadonReco.IterativeRadonReconstructionParameters}"
angles = [0.0, 0.012319971190548208, 0.024639942381096416, 0.036959913571644624, 0.04927988476219283, 0.06159985595274104, 0.07391982714328925, 0.08623979833383746, 0.09855976952438567, 0.11087974071493388, 0.12319971190548208, 0.1355196830960303, 0.1478396542865785, 0.1601596254771267, 0.17247959666767493, 0.18479956785822313, 0.19711953904877133, 0.20943951023931953, 0.22175948142986776, 0.23407945262041596, 0.24639942381096416, 0.25871939500151236, 0.2710393661920606, 0.28335933738260877, 0.295679308573157, 0.3079992797637052, 0.3203192509542534, 0.3326392221448016, 0.34495919333534986, 0.35727916452589803, 0.36959913571644626, 0.38191910690699443, 0.39423907809754266, 0.4065590492880909, 0.41887902047863906, 0.4311989916691873, 0.4435189628597355, 0.4558389340502837, 0.4681589052408319, 0.4804788764313801, 0.4927988476219283, 0.5051188188124766, 0.5174387900030247, 0.5297587611935729, 0.5420787323841212, 0.5543987035746694, 0.5667186747652175, 0.5790386459557658, 0.591358617146314, 0.6036785883368622, 0.6159985595274104, 0.6283185307179586, 0.6406385019085068, 0.6529584730990551, 0.6652784442896033, 0.6775984154801514, 0.6899183866706997, 0.7022383578612479, 0.7145583290517961, 0.7268783002423443, 0.7391982714328925, 0.7515182426234407, 0.7638382138139889, 0.7761581850045371, 0.7884781561950853, 0.8007981273856335, 0.8131180985761818, 0.82543806976673, 0.8377580409572781, 0.8500780121478264, 0.8623979833383746, 0.8747179545289228, 0.887037925719471, 0.8993578969100192, 0.9116778681005674, 0.9239978392911157, 0.9363178104816638, 0.948637781672212, 0.9609577528627602, 0.9732777240533085, 0.9855976952438567, 0.9979176664344048, 1.010237637624953, 1.0225576088155013, 1.0348775800060495, 1.0471975511965976, 1.0595175223871458, 1.0718374935776942, 1.0841574647682424, 1.0964774359587905, 1.1087974071493387, 1.121117378339887, 1.133437349530435, 1.1457573207209835, 1.1580772919115316, 1.1703972631020798, 1.182717234292628, 1.1950372054831762, 1.2073571766737243, 1.2196771478642727, 1.231997119054821, 1.244317090245369, 1.2566370614359172, 1.2689570326264654, 1.2812770038170136, 1.2935969750075618, 1.3059169461981102, 1.3182369173886583, 1.3305568885792065, 1.3428768597697547, 1.3551968309603029, 1.367516802150851, 1.3798367733413994, 1.3921567445319476, 1.4044767157224958, 1.416796686913044, 1.4291166581035921, 1.4414366292941403, 1.4537566004846887, 1.4660765716752369, 1.478396542865785, 1.4907165140563332, 1.5030364852468814, 1.5153564564374296, 1.5276764276279777, 1.5399963988185261, 1.5523163700090743, 1.5646363411996225, 1.5769563123901706, 1.5892762835807188, 1.601596254771267, 1.6139162259618154, 1.6262361971523636, 1.6385561683429117, 1.65087613953346, 1.663196110724008, 1.6755160819145563, 1.6878360531051044, 1.7001560242956528, 1.712475995486201, 1.7247959666767492, 1.7371159378672973, 1.7494359090578455, 1.7617558802483937, 1.774075851438942, 1.7863958226294903, 1.7987157938200384, 1.8110357650105866, 1.8233557362011348, 1.835675707391683, 1.8479956785822313, 1.8603156497727795, 1.8726356209633277, 1.8849555921538759, 1.897275563344424, 1.9095955345349722, 1.9219155057255204, 1.9342354769160688, 1.946555448106617, 1.9588754192971651, 1.9711953904877133, 1.9835153616782615, 1.9958353328688097, 2.008155304059358, 2.020475275249906, 2.0327952464404544, 2.0451152176310026, 2.0574351888215507, 2.069755160012099, 2.082075131202647, 2.0943951023931953, 2.1067150735837434, 2.1190350447742916, 2.1313550159648402, 2.1436749871553884, 2.1559949583459366, 2.1683149295364847, 2.180634900727033, 2.192954871917581, 2.2052748431081293, 2.2175948142986774, 2.2299147854892256, 2.242234756679774, 2.254554727870322, 2.26687469906087, 2.2791946702514188, 2.291514641441967, 2.303834612632515, 2.3161545838230633, 2.3284745550136114, 2.3407945262041596, 2.353114497394708, 2.365434468585256, 2.377754439775804, 2.3900744109663523, 2.4023943821569005, 2.4147143533474487, 2.427034324537997, 2.4393542957285455, 2.4516742669190936, 2.463994238109642, 2.47631420930019, 2.488634180490738, 2.5009541516812863, 2.5132741228718345, 2.5255940940623827, 2.537914065252931, 2.550234036443479, 2.562554007634027, 2.5748739788245754, 2.5871939500151235, 2.599513921205672, 2.6118338923962203, 2.6241538635867685, 2.6364738347773167, 2.648793805967865, 2.661113777158413, 2.673433748348961, 2.6857537195395094, 2.6980736907300575, 2.7103936619206057, 2.722713633111154, 2.735033604301702, 2.7473535754922502, 2.759673546682799, 2.771993517873347, 2.784313489063895, 2.7966334602544434, 2.8089534314449915, 2.8212734026355397, 2.833593373826088, 2.845913345016636, 2.8582333162071842, 2.8705532873977324, 2.8828732585882806, 2.8951932297788288, 2.9075132009693774, 2.9198331721599255, 2.9321531433504737, 2.944473114541022, 2.95679308573157, 2.9691130569221182, 2.9814330281126664, 2.9937529993032146, 3.0060729704937628, 3.018392941684311, 3.030712912874859, 3.0430328840654073, 3.0553528552559555, 3.067672826446504, 3.0799927976370522, 3.0923127688276004, 3.1046327400181486, 3.1169527112086968, 3.129272682399245, 3.141592653589793]
[parameter.reco.shape]
1 = 64
2 = 64
_module = "Core"
_type = "Tuple"
3 = 64
[[parameter.reco.reg]]
"λ" = 0.001
_module = "RegularizedLeastSquares"
_type = "L1Regularization"
[parameter.reco.solver]
_module = "RegularizedLeastSquares"
_type = "Type"
_value = "RegularizedLeastSquares.FISTA"
[parameter.pre]
frames = [1, 2, 3, 4, 5]
numAverages = 1
_module = "Main.OurRadonReco"
_type = "RecoPlan{Main.OurRadonReco.RadonPreprocessingParameters}"
After clearing we just have the structure of the plan left:
clear!(plan)
toTOML(stdout, plan) # to save to file use `savePlan("path/to/file.toml", plan)`
_module = "Main.OurRadonReco"
_type = "RecoPlan{Main.OurRadonReco.IterativeRadonAlgorithm}"
[parameter]
_module = "Main.OurRadonReco"
_type = "RecoPlan{Main.OurRadonReco.IterativeRadonParameters}"
[parameter.reco]
_module = "Main.OurRadonReco"
_type = "RecoPlan{Main.OurRadonReco.IterativeRadonReconstructionParameters}"
[parameter.pre]
_module = "Main.OurRadonReco"
_type = "RecoPlan{Main.OurRadonReco.RadonPreprocessingParameters}"
Note that the serialization here is not the same as storing the binary representation of the algorithm or the RecoPlan. We essentially store key-value pairs which can be used in keyword-argument constructors to recreate the algorithm, however depending on the version of our Reco package, the underlying structs might change. It is also possible to define custom serialization and deserialization functions for a plan's parameters.
For more information on RecoPlan
, see the how-to guides in the documentation.
This page was generated using Literate.jl.