Skip to content

Commit

Permalink
Merge pull request #61 from dkazanc/artefacts
Browse files Browse the repository at this point in the history
demos updates to new artefacts module tomophantom
  • Loading branch information
dkazanc authored Feb 14, 2021
2 parents f96e52c + 2d3a8b6 commit 8de58d1
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 55 deletions.
8 changes: 4 additions & 4 deletions Demos/Python/DemoADMM_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
11 changes: 5 additions & 6 deletions Demos/Python/DemoADMM_3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Demos/Python/DemoFISTA_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
9 changes: 5 additions & 4 deletions Demos/Python/DemoFISTA_3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions Demos/Python/DemoFISTA_NLTV_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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()
Expand Down
26 changes: 13 additions & 13 deletions Demos/Python/DemoFISTA_artifacts2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
31 changes: 15 additions & 16 deletions Demos/Python/DemoFISTA_artifacts3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8de58d1

Please sign in to comment.