From 5dd99ea14fc1bd2b81770a8e605e6e988fc68b27 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Tue, 17 Apr 2018 15:35:20 +0100 Subject: few fixes cleaning the simple_demo_ccpi --- Wrappers/Python/ccpi/framework.py | 11 +++++++++-- Wrappers/Python/ccpi/optimisation/ops.py | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'Wrappers/Python') diff --git a/Wrappers/Python/ccpi/framework.py b/Wrappers/Python/ccpi/framework.py index ed8bac6..9ccc22d 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: @@ -168,7 +175,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 -- cgit v1.2.3 From c43373c119d620853378a0379327510b048778a1 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Tue, 17 Apr 2018 18:05:14 +0100 Subject: added angle_unit to AcquisitionGeometry --- Wrappers/Python/ccpi/framework.py | 1 + 1 file changed, 1 insertion(+) (limited to 'Wrappers/Python') diff --git a/Wrappers/Python/ccpi/framework.py b/Wrappers/Python/ccpi/framework.py index 9ccc22d..799497e 100644 --- a/Wrappers/Python/ccpi/framework.py +++ b/Wrappers/Python/ccpi/framework.py @@ -118,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 -- cgit v1.2.3