From 2d3a8b6badd8c4acc273ada9dff25b172aa7ea2e Mon Sep 17 00:00:00 2001 From: Daniil Kazantsev Date: Sun, 14 Feb 2021 23:17:28 +0000 Subject: [PATCH] demos updates to new artefacts module tomophantom --- Demos/Python/DemoADMM_2D.py | 8 +++---- Demos/Python/DemoADMM_3D.py | 11 +++++----- Demos/Python/DemoFISTA_2D.py | 8 +++---- Demos/Python/DemoFISTA_3D.py | 9 ++++---- Demos/Python/DemoFISTA_NLTV_2D.py | 14 ++++++------ Demos/Python/DemoFISTA_artifacts2D.py | 26 +++++++++++----------- Demos/Python/DemoFISTA_artifacts3D.py | 31 +++++++++++++-------------- 7 files changed, 52 insertions(+), 55 deletions(-) diff --git a/Demos/Python/DemoADMM_2D.py b/Demos/Python/DemoADMM_2D.py index 352d28d63..e998fba57 100644 --- a/Demos/Python/DemoADMM_2D.py +++ b/Demos/Python/DemoADMM_2D.py @@ -56,11 +56,11 @@ from tomophantom.supp.artifacts import _Artifacts_ # forming dictionaries with artifact types -_noise_ = {'type' : 'Poisson', - 'sigma' : 8000, # noise amplitude - 'seed' : 0} +_noise_ = {'noise_type' : 'Poisson', + 'noise_sigma' : 8000, # noise amplitude + 'noise_seed' : 0} -noisy_sino = _Artifacts_(sino_an, _noise_, {}, {}, {}) +noisy_sino = _Artifacts_(sino_an, **_noise_) plt.figure() plt.rcParams.update({'font.size': 21}) diff --git a/Demos/Python/DemoADMM_3D.py b/Demos/Python/DemoADMM_3D.py index e9f70d561..6684ec038 100644 --- a/Demos/Python/DemoADMM_3D.py +++ b/Demos/Python/DemoADMM_3D.py @@ -62,13 +62,12 @@ print ("Generate 3D analytical projection data with TomoPhantom") projData3D_analyt= TomoP3D.ModelSino(model, N_size, Horiz_det, Vert_det, angles, path_library3D) -# adding noise -# forming dictionaries with artifact types -_noise_ = {'type' : 'Poisson', - 'sigma' : 8000, # noise amplitude - 'seed' : 0} +# adding a noise dictionary +_noise_ = {'noise_type' : 'Poisson', + 'noise_sigma' : 8000, # noise amplitude + 'noise_seed' : 0} -projData3D_analyt_noise = _Artifacts_(projData3D_analyt, _noise_, {}, {}, {}) +projData3D_analyt_noise = _Artifacts_(projData3D_analyt, **_noise_) intens_max = 45 diff --git a/Demos/Python/DemoFISTA_2D.py b/Demos/Python/DemoFISTA_2D.py index 741362275..dfeba8395 100644 --- a/Demos/Python/DemoFISTA_2D.py +++ b/Demos/Python/DemoFISTA_2D.py @@ -59,11 +59,11 @@ from tomophantom.supp.artifacts import _Artifacts_ # forming dictionaries with artifact types -_noise_ = {'type' : 'Poisson', - 'sigma' : 10000, # noise amplitude - 'seed' : 0} +_noise_ = {'noise_type' : 'Poisson', + 'noise_sigma' : 10000, # noise amplitude + 'noise_seed' : 0} -noisy_sino = _Artifacts_(sino_an, _noise_, {}, {}, {}) +noisy_sino = _Artifacts_(sino_an, **_noise_) plt.figure() plt.rcParams.update({'font.size': 21}) diff --git a/Demos/Python/DemoFISTA_3D.py b/Demos/Python/DemoFISTA_3D.py index 7756a9703..e775c4fa6 100644 --- a/Demos/Python/DemoFISTA_3D.py +++ b/Demos/Python/DemoFISTA_3D.py @@ -63,11 +63,12 @@ projData3D_analyt= TomoP3D.ModelSino(model, N_size, Horiz_det, Vert_det, angles, path_library3D) # adding noise -_noise_ = {'type' : 'Poisson', - 'sigma' : 8000, # noise amplitude - 'seed' : 0} +_noise_ = {'noise_type' : 'Poisson', + 'noise_sigma' : 8000, # noise amplitude + 'noise_seed' : 0} -projData3D_analyt_noise = _Artifacts_(projData3D_analyt, _noise_, {}, {}, {}) + +projData3D_analyt_noise = _Artifacts_(projData3D_analyt, **_noise_) intens_max = 45 diff --git a/Demos/Python/DemoFISTA_NLTV_2D.py b/Demos/Python/DemoFISTA_NLTV_2D.py index 8201ae619..4e8633192 100644 --- a/Demos/Python/DemoFISTA_NLTV_2D.py +++ b/Demos/Python/DemoFISTA_NLTV_2D.py @@ -25,7 +25,7 @@ import os import tomophantom from tomophantom.supp.qualitymetrics import QualityTools - +from tomophantom.supp.artifacts import _Artifacts_ model = 13 # select a model N_size = 512 # set dimension of the phantom @@ -57,14 +57,12 @@ plt.title('{}''{}'.format('Analytical sinogram of model no.',model)) #%% # Adding noise -from tomophantom.supp.artifacts import _Artifacts_ - # forming dictionaries with artifact types -_noise_ = {'type' : 'Poisson', - 'sigma' : 5000, # noise amplitude - 'seed' : 0} +_noise_ = {'noise_type' : 'Poisson', + 'noise_sigma' : 5000, # noise amplitude + 'noise_seed' : 0} -noisy_sino = _Artifacts_(sino_an, _noise_, {}, {}, {}) +noisy_sino = _Artifacts_(sino_an, **_noise_) plt.figure() plt.rcParams.update({'font.size': 21}) @@ -110,7 +108,7 @@ 'patchwindow': 2,\ 'neighbours' : 15 ,\ 'edge_parameter':0.9} -H_i, H_j, Weights = PatchSelect(pars['input'], pars['searchwindow'], pars['patchwindow'], pars['neighbours'], +H_i, H_j, Weights = PatchSelect(pars['input'], pars['searchwindow'], pars['patchwindow'], pars['neighbours'], pars['edge_parameter'],'gpu') """ plt.figure() diff --git a/Demos/Python/DemoFISTA_artifacts2D.py b/Demos/Python/DemoFISTA_artifacts2D.py index 6c6ad5f13..7cb71ff91 100755 --- a/Demos/Python/DemoFISTA_artifacts2D.py +++ b/Demos/Python/DemoFISTA_artifacts2D.py @@ -56,25 +56,25 @@ from tomophantom.supp.artifacts import _Artifacts_ # forming dictionaries with artifact types -_noise_ = {'type' : 'Poisson', - 'sigma' : 5000, # noise amplitude - 'seed' : 0, - 'prelog' : True} +_noise_ = {'noise_type' : 'Poisson', + 'noise_sigma' : 5000, # noise amplitude + 'noise_seed' : 0, + 'noise_prelog': True} # misalignment dictionary -_sinoshifts_ = {'maxamplitude' : 10} -[[sino_misalign, sino_misalign_raw], shifts] = _Artifacts_(sino_an, _noise_, {}, {}, _sinoshifts_) +_sinoshifts_ = {'sinoshifts_maxamplitude' : 10} +[[sino_misalign, sino_misalign_raw], shifts] = _Artifacts_(sino_an, **_noise_, **_sinoshifts_) # adding zingers and stripes -_zingers_ = {'percentage' : 0.25, - 'modulus' : 10} +_zingers_ = {'zingers_percentage' : 0.25, + 'zingers_modulus' : 10} -_stripes_ = {'percentage' : 1.2, - 'maxthickness' : 3.0, - 'intensity' : 0.3, - 'type' : 'full'} +_stripes_ = {'stripes_percentage' : 1.2, + 'stripes_maxthickness' : 3.0, + 'stripes_intensity' : 0.3, + 'stripes_type' : 'full'} -[sino_artifacts, sino_artifacts_raw] = _Artifacts_(sino_an, _noise_, _zingers_, _stripes_, _sinoshifts_= {}) +[sino_artifacts, sino_artifacts_raw] = _Artifacts_(sino_an, **_noise_, **_zingers_, **_stripes_) plt.figure() plt.rcParams.update({'font.size': 21}) diff --git a/Demos/Python/DemoFISTA_artifacts3D.py b/Demos/Python/DemoFISTA_artifacts3D.py index a8bcdafb4..e7e04cac2 100644 --- a/Demos/Python/DemoFISTA_artifacts3D.py +++ b/Demos/Python/DemoFISTA_artifacts3D.py @@ -19,6 +19,7 @@ import tomophantom from tomophantom import TomoP3D from tomophantom.supp.qualitymetrics import QualityTools +from tomophantom.supp.artifacts import _Artifacts_ print ("Building 3D phantom using TomoPhantom software") tic=timeit.default_timer() @@ -73,29 +74,27 @@ plt.show() # Adding artifacts and noise -from tomophantom.supp.artifacts import _Artifacts_ - # forming dictionaries with artifact types -_noise_ = {'type' : 'Poisson', - 'sigma' : 10000, # noise amplitude - 'seed' : 0, - 'prelog' : True} +_noise_ = {'noise_type' : 'Poisson', + 'noise_sigma' : 10000, # noise amplitude + 'noise_seed' : 0, + 'noise_prelog': True} # misalignment dictionary -_sinoshifts_ = {'maxamplitude' : 10} -[[projData3D_analyt_misalign, projData3D_analyt_misalign_raw], shifts2D] = _Artifacts_(projData3D_analyt, _noise_, {}, {}, _sinoshifts_) +_sinoshifts_ = {'sinoshifts_maxamplitude' : 10} +[[projData3D_analyt_misalign, projData3D_analyt_misalign_raw], shifts2D] = _Artifacts_(projData3D_analyt, **_noise_, **_sinoshifts_) # adding zingers and stripes -_zingers_ = {'percentage' : 0.25, - 'modulus' : 10} +_zingers_ = {'zingers_percentage' : 0.25, + 'zingers_modulus' : 10} -_stripes_ = {'percentage' : 1.0, - 'maxthickness' : 3.0, - 'intensity' : 0.3, - 'type' : 'full', - 'variability' : 0.005} +_stripes_ = {'stripes_percentage' : 1.2, + 'stripes_maxthickness' : 3.0, + 'stripes_intensity' : 0.3, + 'stripes_type' : 'full', + 'stripes_variability' : 0.005} -[projData3D_analyt_noisy, projData3D_raw] = _Artifacts_(projData3D_analyt, _noise_, _zingers_, _stripes_, _sinoshifts_= {}) +[projData3D_analyt_noisy, projData3D_raw] = _Artifacts_(projData3D_analyt, **_noise_, **_zingers_, **_stripes_) intens_max = 70 sliceSel = int(0.5*N_size)