summaryrefslogtreecommitdiffstats
path: root/Wrappers/Python
diff options
context:
space:
mode:
authorjakobsj <jakobsj@users.noreply.github.com>2018-04-19 22:22:46 +0100
committerGitHub <noreply@github.com>2018-04-19 22:22:46 +0100
commitab1280f5c09a60a3c59b53f426a465e1f9753a30 (patch)
tree9597343041288a5e59efed1509ecaa556a342d2e /Wrappers/Python
parent4503519488fd7ac23aaaa4e4198d97a141a458f6 (diff)
parentc43373c119d620853378a0379327510b048778a1 (diff)
downloadframework-ab1280f5c09a60a3c59b53f426a465e1f9753a30.tar.gz
framework-ab1280f5c09a60a3c59b53f426a465e1f9753a30.tar.bz2
framework-ab1280f5c09a60a3c59b53f426a465e1f9753a30.tar.xz
framework-ab1280f5c09a60a3c59b53f426a465e1f9753a30.zip
Merge pull request #105 from vais-ral/demo_cleanup
Demo cleanup
Diffstat (limited to 'Wrappers/Python')
-rw-r--r--Wrappers/Python/ccpi/framework.py12
-rwxr-xr-xWrappers/Python/ccpi/optimisation/ops.py23
2 files changed, 33 insertions, 2 deletions
diff --git a/Wrappers/Python/ccpi/framework.py b/Wrappers/Python/ccpi/framework.py
index ed8bac6..799497e 100644
--- a/Wrappers/Python/ccpi/framework.py
+++ b/Wrappers/Python/ccpi/framework.py
@@ -96,7 +96,14 @@ class ImageGeometry:
self.center_y,
self.center_z,
self.channels)
-
+ def __str__ (self):
+ repres = ""
+ repres += "Number of channels: {0}\n".format(self.channels)
+ repres += "voxel_num : x{0},y{1},z{2}\n".format(self.voxel_num_x, self.voxel_num_y, self.voxel_num_z)
+ repres += "voxel_size : x{0},y{1},z{2}\n".format(self.voxel_size_x, self.voxel_size_y, self.voxel_size_z)
+ repres += "center : x{0},y{1},z{2}\n".format(self.center_x, self.center_y, self.center_z)
+ return repres
+
class AcquisitionGeometry:
@@ -111,6 +118,7 @@ class AcquisitionGeometry:
dist_source_center=None,
dist_center_detector=None,
channels=1
+ angle_unit='degree'
):
"""
General inputs for standard type projection geometries
@@ -168,7 +176,7 @@ class AcquisitionGeometry:
def __str__ (self):
repres = ""
repres += "Number of dimensions: {0}\n".format(self.dimension)
- repres += "angles: {0}\n".format(len(self.angles))
+ repres += "angles: {0}\n".format(self.angles)
repres += "voxel_num : h{0},v{1}\n".format(self.pixel_num_h, self.pixel_num_v)
repres += "voxel size: h{0},v{1}\n".format(self.pixel_size_h, self.pixel_size_v)
repres += "geometry type: {0}\n".format(self.geom_type)
diff --git a/Wrappers/Python/ccpi/optimisation/ops.py b/Wrappers/Python/ccpi/optimisation/ops.py
index 6460986..993f2de 100755
--- a/Wrappers/Python/ccpi/optimisation/ops.py
+++ b/Wrappers/Python/ccpi/optimisation/ops.py
@@ -157,3 +157,26 @@ def PowerMethodNonsquare(op,numiters):
s[it] = (x1*x0).sum() / (x0*x0).sum()
x0 = (1.0/x1norm)*x1
return numpy.sqrt(s[-1]), numpy.sqrt(s), x0
+
+class LinearOperatorMatrix(Operator):
+ def __init__(self,A):
+ self.A = A
+ self.s1 = None # Largest singular value, initially unknown
+ super(LinearOperatorMatrix, self).__init__()
+
+ def direct(self,x):
+ return DataContainer(numpy.dot(self.A,x.as_array()))
+
+ def adjoint(self,x):
+ return DataContainer(numpy.dot(self.A.transpose(),x.as_array()))
+
+ def size(self):
+ return self.A.shape
+
+ def get_max_sing_val(self):
+ # If unknown, compute and store. If known, simply return it.
+ if self.s1 is None:
+ self.s1 = svds(self.A,1,return_singular_vectors=False)[0]
+ return self.s1
+ else:
+ return self.s1