diff options
author | Jakob Jorgensen, WS at HMXIF <jakob.jorgensen@manchester.ac.uk> | 2019-04-26 17:06:35 +0100 |
---|---|---|
committer | Jakob Jorgensen, WS at HMXIF <jakob.jorgensen@manchester.ac.uk> | 2019-04-26 17:06:35 +0100 |
commit | 3dd7810b24962999c1a80c72e1dfa411543e4c52 (patch) | |
tree | 026942281f65d8bae7f850bae2af3702b21c9550 /Wrappers | |
parent | 493d4fe58d74c8027213ec1f409bc853d90a3282 (diff) | |
download | astra-wrapper-3dd7810b24962999c1a80c72e1dfa411543e4c52.tar.gz astra-wrapper-3dd7810b24962999c1a80c72e1dfa411543e4c52.tar.bz2 astra-wrapper-3dd7810b24962999c1a80c72e1dfa411543e4c52.tar.xz astra-wrapper-3dd7810b24962999c1a80c72e1dfa411543e4c52.zip |
Add out argument in dataprocessor process method
Diffstat (limited to 'Wrappers')
6 files changed, 50 insertions, 25 deletions
diff --git a/Wrappers/Python/ccpi/astra/processors/AstraBackProjector.py b/Wrappers/Python/ccpi/astra/processors/AstraBackProjector.py index 476523a..d094e79 100644 --- a/Wrappers/Python/ccpi/astra/processors/AstraBackProjector.py +++ b/Wrappers/Python/ccpi/astra/processors/AstraBackProjector.py @@ -65,7 +65,7 @@ class AstraBackProjector(DataProcessor): def set_AcquisitionGeometry(self, sinogram_geometry): self.sinogram_geometry = sinogram_geometry - def process(self): + def process(self, out=None): DATA = self.get_input() IM = ImageData(geometry=self.volume_geometry) rec_id, IM.array = astra.create_backprojection(DATA.as_array(), @@ -73,8 +73,12 @@ class AstraBackProjector(DataProcessor): astra.data2d.delete(rec_id) if self.device == 'cpu': - return IM + ret = IM else: scaling = self.volume_geometry.voxel_size_x**3 - return scaling*IM -
\ No newline at end of file + ret = scaling*IM + + if out is None: + return ret + else: + out.fill(ret)
\ No newline at end of file diff --git a/Wrappers/Python/ccpi/astra/processors/AstraBackProjector3D.py b/Wrappers/Python/ccpi/astra/processors/AstraBackProjector3D.py index b1d139e..26a549a 100644 --- a/Wrappers/Python/ccpi/astra/processors/AstraBackProjector3D.py +++ b/Wrappers/Python/ccpi/astra/processors/AstraBackProjector3D.py @@ -53,7 +53,7 @@ class AstraBackProjector3D(DataProcessor): def set_AcquisitionGeometry(self, sinogram_geometry): self.sinogram_geometry = sinogram_geometry - def process(self): + def process(self, out=None): DATA = self.get_input() IM = ImageData(geometry=self.volume_geometry, dimension_labels=self.output_axes_order) @@ -64,4 +64,9 @@ class AstraBackProjector3D(DataProcessor): # Scaling of 3D ASTRA backprojector, works both parallel and cone. scaling = 1/self.volume_geometry.voxel_size_x**2 - return scaling*IM + ret = scaling*IM + + if out is None: + return ret + else: + out.fill(ret) diff --git a/Wrappers/Python/ccpi/astra/processors/AstraBackProjectorMC.py b/Wrappers/Python/ccpi/astra/processors/AstraBackProjectorMC.py index d48fb80..84932b6 100644 --- a/Wrappers/Python/ccpi/astra/processors/AstraBackProjectorMC.py +++ b/Wrappers/Python/ccpi/astra/processors/AstraBackProjectorMC.py @@ -22,7 +22,8 @@ class AstraBackProjectorMC(AstraBackProjector): else: raise ValueError("Expected input dimensions is 2 or 3, got {0}"\ .format(dataset.number_of_dimensions)) - def process(self): + + def process(self, out): DATA = self.get_input() IM = ImageData(geometry=self.volume_geometry) @@ -34,7 +35,12 @@ class AstraBackProjectorMC(AstraBackProjector): astra.data2d.delete(rec_id) if self.device == 'cpu': - return IM + ret = IM else: scaling = self.volume_geometry.voxel_size_x**3 - return scaling*IM
\ No newline at end of file + ret = scaling*IM + + if out is None: + return ret + else: + out.fill(ret)
\ No newline at end of file diff --git a/Wrappers/Python/ccpi/astra/processors/AstraForwardProjector.py b/Wrappers/Python/ccpi/astra/processors/AstraForwardProjector.py index dd5bab4..2cf5716 100644 --- a/Wrappers/Python/ccpi/astra/processors/AstraForwardProjector.py +++ b/Wrappers/Python/ccpi/astra/processors/AstraForwardProjector.py @@ -65,21 +65,24 @@ class AstraForwardProjector(DataProcessor): def set_AcquisitionGeometry(self, sinogram_geometry): self.sinogram_geometry = sinogram_geometry - - def process(self): + + def process(self, out=None): IM = self.get_input() DATA = AcquisitionData(geometry=self.sinogram_geometry) - #sinogram_id, DATA = astra.create_sino( IM.as_array(), - # self.proj_id) sinogram_id, DATA.array = astra.create_sino(IM.as_array(), self.proj_id) astra.data2d.delete(sinogram_id) if self.device == 'cpu': - return DATA + ret = DATA else: if self.sinogram_geometry.geom_type == 'cone': - return DATA + ret = DATA else: scaling = 1.0/self.volume_geometry.voxel_size_x - return scaling*DATA
\ No newline at end of file + ret = scaling*DATA + + if out is None: + return ret + else: + out.fill(ret)
\ No newline at end of file diff --git a/Wrappers/Python/ccpi/astra/processors/AstraForwardProjector3D.py b/Wrappers/Python/ccpi/astra/processors/AstraForwardProjector3D.py index d18b43e..18b4078 100644 --- a/Wrappers/Python/ccpi/astra/processors/AstraForwardProjector3D.py +++ b/Wrappers/Python/ccpi/astra/processors/AstraForwardProjector3D.py @@ -57,10 +57,7 @@ class AstraForwardProjector3D(DataProcessor): def set_vol_geom(self, vol_geom): self.vol_geom = vol_geom - def set_AcquisitionGeometry(self, sinogram_geometry): - self.sinogram_geometry = sinogram_geometry - - def process(self): + def process(self, out=None): IM = self.get_input() DATA = AcquisitionData(geometry=self.sinogram_geometry, dimension_labels=self.output_axes_order) @@ -69,4 +66,8 @@ class AstraForwardProjector3D(DataProcessor): self.vol_geom) astra.data3d.delete(sinogram_id) # 3D CUDA FP does not need scaling - return DATA
\ No newline at end of file + + if out is None: + return DATA + else: + out.fill(DATA)
\ No newline at end of file diff --git a/Wrappers/Python/ccpi/astra/processors/AstraForwardProjectorMC.py b/Wrappers/Python/ccpi/astra/processors/AstraForwardProjectorMC.py index 5a697ca..34f4222 100644 --- a/Wrappers/Python/ccpi/astra/processors/AstraForwardProjectorMC.py +++ b/Wrappers/Python/ccpi/astra/processors/AstraForwardProjectorMC.py @@ -22,7 +22,8 @@ class AstraForwardProjectorMC(AstraForwardProjector): else: raise ValueError("Expected input dimensions is 2 or 3, got {0}"\ .format(dataset.number_of_dimensions)) - def process(self): + + def process(self, out=None): IM = self.get_input() #create the output AcquisitionData DATA = AcquisitionData(geometry=self.sinogram_geometry) @@ -33,10 +34,15 @@ class AstraForwardProjectorMC(AstraForwardProjector): astra.data2d.delete(sinogram_id) if self.device == 'cpu': - return DATA + ret = DATA else: if self.sinogram_geometry.geom_type == 'cone': - return DATA + ret = DATA else: scaling = (1.0/self.volume_geometry.voxel_size_x) - return scaling*DATA
\ No newline at end of file + ret = scaling*DATA + + if out is None: + return ret + else: + out.fill(ret)
\ No newline at end of file |