summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Jorgensen, WS at HMXIF <jakob.jorgensen@manchester.ac.uk>2019-04-16 16:19:39 +0100
committerJakob Jorgensen, WS at HMXIF <jakob.jorgensen@manchester.ac.uk>2019-04-16 16:19:39 +0100
commitfdc6c564722d6b93f62310d5ba57f03173028b7e (patch)
tree5e5f569845da90e691d008eefbcdda4a78f379e4
parent490aedb50630a162b7914e27917c074c10bada8e (diff)
downloadframework-fdc6c564722d6b93f62310d5ba57f03173028b7e.tar.gz
framework-fdc6c564722d6b93f62310d5ba57f03173028b7e.tar.bz2
framework-fdc6c564722d6b93f62310d5ba57f03173028b7e.tar.xz
framework-fdc6c564722d6b93f62310d5ba57f03173028b7e.zip
Copied SIRT manually
-rw-r--r--Wrappers/Python/ccpi/optimisation/algorithms/SIRT.py58
1 files changed, 30 insertions, 28 deletions
diff --git a/Wrappers/Python/ccpi/optimisation/algorithms/SIRT.py b/Wrappers/Python/ccpi/optimisation/algorithms/SIRT.py
index 9fc3b8e..cb8b731 100644
--- a/Wrappers/Python/ccpi/optimisation/algorithms/SIRT.py
+++ b/Wrappers/Python/ccpi/optimisation/algorithms/SIRT.py
@@ -2,41 +2,44 @@
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 10 13:39:35 2019
- @author: jakob
+
+@author: jakob
"""
- # -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
# This work is part of the Core Imaging Library developed by
# Visual Analytics and Imaging System Group of the Science Technology
# Facilities Council, STFC
- # Copyright 2018 Edoardo Pasca
+# Copyright 2018 Edoardo Pasca
- # Licensed under the Apache License, Version 2.0 (the "License");
+# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
- # http://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
- # Unless required by applicable law or agreed to in writing, software
+# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Created on Thu Feb 21 11:11:23 2019
- @author: ofn77899
+
+@author: ofn77899
"""
from ccpi.optimisation.algorithms import Algorithm
from ccpi.framework import ImageData, AcquisitionData
- #from collections.abc import Iterable
+#from collections.abc import Iterable
class SIRT(Algorithm):
'''Simultaneous Iterative Reconstruction Technique
+
Parameters:
- x_init: initial guess
+ x_init: initial guess
operator: operator for forward/backward projections
data: data to operate on
constraint: Function with prox-method, for example IndicatorBox to
@@ -55,18 +58,18 @@ class SIRT(Algorithm):
operator=kwargs['operator'],
data =kwargs['data'])
- def set_up(self, x_init, operator , data, constraint=None ):
-
- self.x = x_init.copy()
+ def set_up(self, x_init, operator , data, constraint=None ):
+
+ self.x = x_init.copy()
self.operator = operator
self.data = data
self.constraint = constraint
-
- self.r = data.copy()
-
- self.relax_par = 1.0
-
- # Set up scaling matrices D and M.
+
+ self.r = data.copy()
+
+ self.relax_par = 1.0
+
+ # Set up scaling matrices D and M.
im1 = ImageData(geometry=self.x.geometry)
im1.array[:] = 1.0
self.M = 1/operator.direct(im1)
@@ -75,15 +78,14 @@ class SIRT(Algorithm):
self.D = 1/operator.adjoint(aq1)
- def update(self):
-
- self.r = self.data - self.operator.direct(self.x)
-
- self.x += self.relax_par * (self.D*self.operator.adjoint(self.M*self.r))
-
- if self.constraint != None:
+ def update(self):
+
+ self.r = self.data - self.operator.direct(self.x)
+
+ self.x += self.relax_par * (self.D*self.operator.adjoint(self.M*self.r))
+
+ if self.constraint != None:
self.x = self.constraint.prox(self.x,None)
- def update_objective(self):
- self.loss.append(self.r.squared_norm())
- \ No newline at end of file
+ def update_objective(self):
+ self.loss.append(self.r.squared_norm()) \ No newline at end of file