diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2017-09-15 16:38:08 +0200 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2017-09-15 16:38:08 +0200 |
commit | aa31a06235496c0d808e57c8ce914cb4b640bc6e (patch) | |
tree | 33385e828ddca0b2857bac9e3dac4dd3723a3eee /python/astra | |
parent | f6aa2db83dfea89f9d2cfc6fcbd3da141ee77e02 (diff) | |
parent | 00a1c6118b2d64b867c8e640c295462bcccfc7c9 (diff) | |
download | astra-aa31a06235496c0d808e57c8ce914cb4b640bc6e.tar.gz astra-aa31a06235496c0d808e57c8ce914cb4b640bc6e.tar.bz2 astra-aa31a06235496c0d808e57c8ce914cb4b640bc6e.tar.xz astra-aa31a06235496c0d808e57c8ce914cb4b640bc6e.zip |
Merge branch 'master' into parallel_vec
Diffstat (limited to 'python/astra')
45 files changed, 1070 insertions, 793 deletions
diff --git a/python/astra/PyAlgorithmFactory.pxd b/python/astra/PyAlgorithmFactory.pxd index 256d7b2..5e335e4 100644 --- a/python/astra/PyAlgorithmFactory.pxd +++ b/python/astra/PyAlgorithmFactory.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from libcpp.string cimport string from libcpp cimport bool from .PyIncludes cimport * diff --git a/python/astra/PyAlgorithmManager.pxd b/python/astra/PyAlgorithmManager.pxd index a99a807..dfc7961 100644 --- a/python/astra/PyAlgorithmManager.pxd +++ b/python/astra/PyAlgorithmManager.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# -------------------------------------------------------------------- + from libcpp.string cimport string from libcpp cimport bool from .PyIncludes cimport * diff --git a/python/astra/PyData2DManager.pxd b/python/astra/PyData2DManager.pxd index db8ec84..7cf60c7 100644 --- a/python/astra/PyData2DManager.pxd +++ b/python/astra/PyData2DManager.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from libcpp.string cimport string from .PyIncludes cimport * diff --git a/python/astra/PyData3DManager.pxd b/python/astra/PyData3DManager.pxd index 9264a82..250147e 100644 --- a/python/astra/PyData3DManager.pxd +++ b/python/astra/PyData3DManager.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from libcpp.string cimport string from .PyIncludes cimport * diff --git a/python/astra/PyIncludes.pxd b/python/astra/PyIncludes.pxd index 61425c9..1c7973a 100644 --- a/python/astra/PyIncludes.pxd +++ b/python/astra/PyIncludes.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from libcpp cimport bool from libcpp.string cimport string from .PyXMLDocument cimport XMLNode @@ -30,246 +30,266 @@ from .PyXMLDocument cimport XMLNode include "config.pxi" cdef extern from "astra/Globals.h" namespace "astra": - ctypedef float float32 - ctypedef double float64 - ctypedef unsigned short int uint16 - ctypedef signed short int sint16 - ctypedef unsigned char uchar8 - ctypedef signed char schar8 - ctypedef int int32 - ctypedef short int int16 + ctypedef float float32 + ctypedef double float64 + ctypedef unsigned short int uint16 + ctypedef signed short int sint16 + ctypedef unsigned char uchar8 + ctypedef signed char schar8 + ctypedef int int32 + ctypedef short int int16 cdef extern from "astra/Config.h" namespace "astra": - cdef cppclass Config: - Config() - void initialize(string rootname) - XMLNode self + cdef cppclass Config: + Config() + void initialize(string rootname) + XMLNode self cdef extern from "astra/VolumeGeometry2D.h" namespace "astra": - cdef cppclass CVolumeGeometry2D: - bool initialize(Config) - int getGridColCount() - int getGridRowCount() - int getGridTotCount() - float32 getWindowLengthX() - float32 getWindowLengthY() - float32 getWindowArea() - float32 getPixelLengthX() - float32 getPixelLengthY() - float32 getPixelArea() - float32 getWindowMinX() - float32 getWindowMinY() - float32 getWindowMaxX() - float32 getWindowMaxY() - Config* getConfiguration() - bool isEqual(CVolumeGeometry2D*) + cdef cppclass CVolumeGeometry2D: + bool initialize(Config) + int getGridColCount() + int getGridRowCount() + int getGridTotCount() + float32 getWindowLengthX() + float32 getWindowLengthY() + float32 getWindowArea() + float32 getPixelLengthX() + float32 getPixelLengthY() + float32 getPixelArea() + float32 getWindowMinX() + float32 getWindowMinY() + float32 getWindowMaxX() + float32 getWindowMaxY() + Config* getConfiguration() + bool isEqual(CVolumeGeometry2D*) cdef extern from "astra/Float32Data2D.h" namespace "astra": - cdef cppclass CFloat32CustomMemory: - pass + cdef cppclass CFloat32CustomMemory: + pass cdef extern from "astra/Float32VolumeData2D.h" namespace "astra": - cdef cppclass CFloat32VolumeData2D: - CFloat32VolumeData2D(CVolumeGeometry2D*) - CFloat32VolumeData2D(CVolumeGeometry2D*, CFloat32CustomMemory*) - CVolumeGeometry2D * getGeometry() - int getWidth() - int getHeight() - void changeGeometry(CVolumeGeometry2D*) - Config* getConfiguration() + cdef cppclass CFloat32VolumeData2D: + CFloat32VolumeData2D(CVolumeGeometry2D*) + CFloat32VolumeData2D(CVolumeGeometry2D*, CFloat32CustomMemory*) + CVolumeGeometry2D * getGeometry() + int getWidth() + int getHeight() + void changeGeometry(CVolumeGeometry2D*) + Config* getConfiguration() cdef extern from "astra/ProjectionGeometry2D.h" namespace "astra": - cdef cppclass CProjectionGeometry2D: - CProjectionGeometry2D() - bool initialize(Config) - int getDetectorCount() - int getProjectionAngleCount() - bool isOfType(string) - float32 getProjectionAngle(int) - float32 getDetectorWidth() - Config* getConfiguration() - bool isEqual(CProjectionGeometry2D*) + cdef cppclass CProjectionGeometry2D: + CProjectionGeometry2D() + bool initialize(Config) + int getDetectorCount() + int getProjectionAngleCount() + bool isOfType(string) + float32 getProjectionAngle(int) + float32 getDetectorWidth() + Config* getConfiguration() + bool isEqual(CProjectionGeometry2D*) cdef extern from "astra/Float32Data2D.h" namespace "astra::CFloat32Data2D": - cdef enum TWOEDataType "astra::CFloat32Data2D::EDataType": - TWOPROJECTION "astra::CFloat32Data2D::PROJECTION" - TWOVOLUME "astra::CFloat32Data2D::VOLUME" + cdef enum TWOEDataType "astra::CFloat32Data2D::EDataType": + TWOPROJECTION "astra::CFloat32Data2D::PROJECTION" + TWOVOLUME "astra::CFloat32Data2D::VOLUME" cdef extern from "astra/Float32Data3D.h" namespace "astra::CFloat32Data3D": - cdef enum THREEEDataType "astra::CFloat32Data3D::EDataType": - THREEPROJECTION "astra::CFloat32Data3D::PROJECTION" - THREEVOLUME "astra::CFloat32Data3D::VOLUME" + cdef enum THREEEDataType "astra::CFloat32Data3D::EDataType": + THREEPROJECTION "astra::CFloat32Data3D::PROJECTION" + THREEVOLUME "astra::CFloat32Data3D::VOLUME" cdef extern from "astra/Float32Data2D.h" namespace "astra": - cdef cppclass CFloat32Data2D: - bool isInitialized() - int getSize() - float32 *getData() - float32 **getData2D() - int getWidth() - int getHeight() - TWOEDataType getType() + cdef cppclass CFloat32Data2D: + bool isInitialized() + int getSize() + float32 *getData() + float32 **getData2D() + int getWidth() + int getHeight() + TWOEDataType getType() cdef extern from "astra/SparseMatrixProjectionGeometry2D.h" namespace "astra": - cdef cppclass CSparseMatrixProjectionGeometry2D: - CSparseMatrixProjectionGeometry2D() + cdef cppclass CSparseMatrixProjectionGeometry2D: + CSparseMatrixProjectionGeometry2D() cdef extern from "astra/FanFlatProjectionGeometry2D.h" namespace "astra": - cdef cppclass CFanFlatProjectionGeometry2D: - CFanFlatProjectionGeometry2D() + cdef cppclass CFanFlatProjectionGeometry2D: + CFanFlatProjectionGeometry2D() cdef extern from "astra/FanFlatVecProjectionGeometry2D.h" namespace "astra": - cdef cppclass CFanFlatVecProjectionGeometry2D: - CFanFlatVecProjectionGeometry2D() + cdef cppclass CFanFlatVecProjectionGeometry2D: + CFanFlatVecProjectionGeometry2D() cdef extern from "astra/ParallelVecProjectionGeometry2D.h" namespace "astra": cdef cppclass CParallelVecProjectionGeometry2D: CParallelVecProjectionGeometry2D() cdef extern from "astra/ParallelProjectionGeometry2D.h" namespace "astra": - cdef cppclass CParallelProjectionGeometry2D: - CParallelProjectionGeometry2D() + cdef cppclass CParallelProjectionGeometry2D: + CParallelProjectionGeometry2D() cdef extern from "astra/Float32ProjectionData2D.h" namespace "astra": - cdef cppclass CFloat32ProjectionData2D: - CFloat32ProjectionData2D(CProjectionGeometry2D*) - CFloat32ProjectionData2D(CProjectionGeometry2D*, CFloat32CustomMemory*) - CProjectionGeometry2D * getGeometry() - void changeGeometry(CProjectionGeometry2D*) - int getDetectorCount() - int getAngleCount() + cdef cppclass CFloat32ProjectionData2D: + CFloat32ProjectionData2D(CProjectionGeometry2D*) + CFloat32ProjectionData2D(CProjectionGeometry2D*, CFloat32CustomMemory*) + CProjectionGeometry2D * getGeometry() + void changeGeometry(CProjectionGeometry2D*) + int getDetectorCount() + int getAngleCount() cdef extern from "astra/Algorithm.h" namespace "astra": - cdef cppclass CAlgorithm: - bool initialize(Config) - void run(int) nogil - bool isInitialized() + cdef cppclass CAlgorithm: + bool initialize(Config) + void run(int) nogil + bool isInitialized() cdef extern from "astra/ReconstructionAlgorithm2D.h" namespace "astra": - cdef cppclass CReconstructionAlgorithm2D: - bool getResidualNorm(float32&) + cdef cppclass CReconstructionAlgorithm2D: + bool getResidualNorm(float32&) cdef extern from "astra/Projector2D.h" namespace "astra": - cdef cppclass CProjector2D: - bool isInitialized() - CProjectionGeometry2D* getProjectionGeometry() - CVolumeGeometry2D* getVolumeGeometry() - CSparseMatrix* getMatrix() + cdef cppclass CProjector2D: + bool isInitialized() + CProjectionGeometry2D* getProjectionGeometry() + CVolumeGeometry2D* getVolumeGeometry() + CSparseMatrix* getMatrix() cdef extern from "astra/Projector3D.h" namespace "astra": - cdef cppclass CProjector3D: - bool isInitialized() - CProjectionGeometry3D* getProjectionGeometry() - CVolumeGeometry3D* getVolumeGeometry() + cdef cppclass CProjector3D: + bool isInitialized() + CProjectionGeometry3D* getProjectionGeometry() + CVolumeGeometry3D* getVolumeGeometry() IF HAVE_CUDA==True: - cdef extern from "astra/CudaProjector3D.h" namespace "astra": - cdef cppclass CCudaProjector3D + cdef extern from "astra/CudaProjector3D.h" namespace "astra": + cdef cppclass CCudaProjector3D + + cdef extern from "astra/CudaProjector2D.h" namespace "astra": + cdef cppclass CCudaProjector2D + + cdef extern from "astra/Float32Data3DGPU.h" namespace "astraCUDA3d": + cdef cppclass MemHandle3D: + pass - cdef extern from "astra/CudaProjector2D.h" namespace "astra": - cdef cppclass CCudaProjector2D + cdef extern from "astra/Float32Data3DGPU.h" namespace "astraCUDA3d": + cdef MemHandle3D wrapHandle(float *D_ptr, unsigned int x, unsigned int y, unsigned int z, unsigned int pitch) cdef extern from "astra/SparseMatrix.h" namespace "astra": - cdef cppclass CSparseMatrix: - CSparseMatrix(unsigned int,unsigned int,unsigned long) - unsigned int m_iWidth - unsigned int m_iHeight - unsigned long m_lSize - bool isInitialized() - float32* m_pfValues - unsigned int* m_piColIndices - unsigned long* m_plRowStarts + cdef cppclass CSparseMatrix: + CSparseMatrix(unsigned int,unsigned int,unsigned long) + unsigned int m_iWidth + unsigned int m_iHeight + unsigned long m_lSize + bool isInitialized() + float32* m_pfValues + unsigned int* m_piColIndices + unsigned long* m_plRowStarts + +cdef extern from "astra/Float32Data3D.h" namespace "astra": + cdef cppclass CFloat32Data3D: + bool isInitialized() + int getSize() + int getWidth() + int getHeight() + int getDepth() + cdef extern from "astra/Float32Data3DMemory.h" namespace "astra": - cdef cppclass CFloat32Data3DMemory: - CFloat32Data3DMemory() - bool isInitialized() - int getSize() - int getWidth() - int getHeight() - int getDepth() - void updateStatistics() - float32 *getData() - float32 ***getData3D() - THREEEDataType getType() + cdef cppclass CFloat32Data3DMemory(CFloat32Data3D): + CFloat32Data3DMemory() + void updateStatistics() + float32 *getData() + float32 ***getData3D() + THREEEDataType getType() cdef extern from "astra/VolumeGeometry3D.h" namespace "astra": - cdef cppclass CVolumeGeometry3D: - CVolumeGeometry3D() - bool initialize(Config) - Config * getConfiguration() - int getGridColCount() - int getGridRowCount() - int getGridSliceCount() + cdef cppclass CVolumeGeometry3D: + CVolumeGeometry3D() + bool initialize(Config) + Config * getConfiguration() + int getGridColCount() + int getGridRowCount() + int getGridSliceCount() cdef extern from "astra/ProjectionGeometry3D.h" namespace "astra": - cdef cppclass CProjectionGeometry3D: - CProjectionGeometry3D() - bool initialize(Config) - Config * getConfiguration() - int getProjectionCount() - int getDetectorColCount() - int getDetectorRowCount() + cdef cppclass CProjectionGeometry3D: + CProjectionGeometry3D() + bool initialize(Config) + Config * getConfiguration() + int getProjectionCount() + int getDetectorColCount() + int getDetectorRowCount() cdef extern from "astra/Float32VolumeData3DMemory.h" namespace "astra": - cdef cppclass CFloat32VolumeData3DMemory: - CFloat32VolumeData3DMemory(CVolumeGeometry3D*) - CFloat32VolumeData3DMemory(CVolumeGeometry3D*, CFloat32CustomMemory*) - CVolumeGeometry3D* getGeometry() - void changeGeometry(CVolumeGeometry3D*) - int getRowCount() - int getColCount() - int getSliceCount() - bool isInitialized() - - + cdef cppclass CFloat32VolumeData3DMemory: + CFloat32VolumeData3DMemory(CVolumeGeometry3D*) + CFloat32VolumeData3DMemory(CVolumeGeometry3D*, CFloat32CustomMemory*) + CVolumeGeometry3D* getGeometry() + void changeGeometry(CVolumeGeometry3D*) + int getRowCount() + int getColCount() + int getSliceCount() + bool isInitialized() cdef extern from "astra/ParallelProjectionGeometry3D.h" namespace "astra": - cdef cppclass CParallelProjectionGeometry3D: - CParallelProjectionGeometry3D() + cdef cppclass CParallelProjectionGeometry3D: + CParallelProjectionGeometry3D() cdef extern from "astra/ParallelVecProjectionGeometry3D.h" namespace "astra": - cdef cppclass CParallelVecProjectionGeometry3D: - CParallelVecProjectionGeometry3D() + cdef cppclass CParallelVecProjectionGeometry3D: + CParallelVecProjectionGeometry3D() cdef extern from "astra/ConeProjectionGeometry3D.h" namespace "astra": - cdef cppclass CConeProjectionGeometry3D: - CConeProjectionGeometry3D() - bool initialize(Config) + cdef cppclass CConeProjectionGeometry3D: + CConeProjectionGeometry3D() + bool initialize(Config) cdef extern from "astra/ConeVecProjectionGeometry3D.h" namespace "astra": - cdef cppclass CConeVecProjectionGeometry3D: - CConeVecProjectionGeometry3D() + cdef cppclass CConeVecProjectionGeometry3D: + CConeVecProjectionGeometry3D() cdef extern from "astra/Float32ProjectionData3DMemory.h" namespace "astra": - cdef cppclass CFloat32ProjectionData3DMemory: - CFloat32ProjectionData3DMemory(CProjectionGeometry3D*) - CFloat32ProjectionData3DMemory(CConeProjectionGeometry3D*) - CFloat32ProjectionData3DMemory(CProjectionGeometry3D*, CFloat32CustomMemory*) - CFloat32ProjectionData3DMemory(CConeProjectionGeometry3D*, CFloat32CustomMemory*) - CProjectionGeometry3D* getGeometry() - void changeGeometry(CProjectionGeometry3D*) - int getDetectorColCount() - int getDetectorRowCount() - int getAngleCount() - bool isInitialized() + cdef cppclass CFloat32ProjectionData3DMemory: + CFloat32ProjectionData3DMemory(CProjectionGeometry3D*) + CFloat32ProjectionData3DMemory(CConeProjectionGeometry3D*) + CFloat32ProjectionData3DMemory(CProjectionGeometry3D*, CFloat32CustomMemory*) + CFloat32ProjectionData3DMemory(CConeProjectionGeometry3D*, CFloat32CustomMemory*) + CProjectionGeometry3D* getGeometry() + void changeGeometry(CProjectionGeometry3D*) + int getDetectorColCount() + int getDetectorRowCount() + int getAngleCount() + bool isInitialized() -cdef extern from "astra/Float32Data3D.h" namespace "astra": - cdef cppclass CFloat32Data3D: - CFloat32Data3D() - bool isInitialized() - int getSize() - int getWidth() - int getHeight() - int getDepth() - void updateStatistics() +IF HAVE_CUDA==True: + cdef extern from "astra/Float32VolumeData3DGPU.h" namespace "astra": + cdef cppclass CFloat32VolumeData3DGPU: + CFloat32VolumeData3DGPU(CVolumeGeometry3D*, MemHandle3D) + CVolumeGeometry3D* getGeometry() + void changeGeometry(CVolumeGeometry3D*) + int getRowCount() + int getColCount() + int getSliceCount() + bool isInitialized() + + cdef extern from "astra/Float32ProjectionData3DGPU.h" namespace "astra": + cdef cppclass CFloat32ProjectionData3DGPU: + CFloat32ProjectionData3DGPU(CProjectionGeometry3D*, MemHandle3D) + CProjectionGeometry3D* getGeometry() + void changeGeometry(CProjectionGeometry3D*) + int getRowCount() + int getColCount() + int getSliceCount() + bool isInitialized() diff --git a/python/astra/PyIndexManager.pxd b/python/astra/PyIndexManager.pxd index c1ad502..5eeff02 100644 --- a/python/astra/PyIndexManager.pxd +++ b/python/astra/PyIndexManager.pxd @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # diff --git a/python/astra/PyMatrixManager.pxd b/python/astra/PyMatrixManager.pxd index b2b84c4..38ad7f1 100644 --- a/python/astra/PyMatrixManager.pxd +++ b/python/astra/PyMatrixManager.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from libcpp.string cimport string from .PyIncludes cimport * diff --git a/python/astra/PyProjector2DFactory.pxd b/python/astra/PyProjector2DFactory.pxd index 3314544..8c751fc 100644 --- a/python/astra/PyProjector2DFactory.pxd +++ b/python/astra/PyProjector2DFactory.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from libcpp.string cimport string from libcpp cimport bool from .PyIncludes cimport * diff --git a/python/astra/PyProjector2DManager.pxd b/python/astra/PyProjector2DManager.pxd index 92176ba..86bd3cf 100644 --- a/python/astra/PyProjector2DManager.pxd +++ b/python/astra/PyProjector2DManager.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from libcpp.string cimport string from .PyIncludes cimport * diff --git a/python/astra/PyProjector3DFactory.pxd b/python/astra/PyProjector3DFactory.pxd index bcbce94..345678b 100644 --- a/python/astra/PyProjector3DFactory.pxd +++ b/python/astra/PyProjector3DFactory.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from libcpp.string cimport string from libcpp cimport bool from .PyIncludes cimport * diff --git a/python/astra/PyProjector3DManager.pxd b/python/astra/PyProjector3DManager.pxd index b1eac6b..cdd739a 100644 --- a/python/astra/PyProjector3DManager.pxd +++ b/python/astra/PyProjector3DManager.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from libcpp.string cimport string from .PyIncludes cimport * diff --git a/python/astra/PyXMLDocument.pxd b/python/astra/PyXMLDocument.pxd index 033b8ef..dbd84d5 100644 --- a/python/astra/PyXMLDocument.pxd +++ b/python/astra/PyXMLDocument.pxd @@ -1,28 +1,27 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- # distutils: language = c++ # distutils: libraries = astra diff --git a/python/astra/__init__.py b/python/astra/__init__.py index 515d9a2..b73fff5 100644 --- a/python/astra/__init__.py +++ b/python/astra/__init__.py @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from . import matlab as m from .creators import astra_dict,create_vol_geom, create_proj_geom, create_backprojection, create_sino, create_reconstruction, create_projector,create_sino3d_gpu, create_backprojection3d_gpu from .functions import data_op, add_noise_to_sino, clear, move_vol_geom @@ -35,9 +35,12 @@ from . import projector from . import projector3d from . import matrix from . import plugin +from . import plugins from . import log from .optomo import OpTomo +__version__ = '1.8' + import os if 'ASTRA_GPU_INDEX' in os.environ: diff --git a/python/astra/algorithm.py b/python/astra/algorithm.py index 46cfccc..b6dfb95 100644 --- a/python/astra/algorithm.py +++ b/python/astra/algorithm.py @@ -1,28 +1,27 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- from . import algorithm_c as a diff --git a/python/astra/algorithm_c.pyx b/python/astra/algorithm_c.pyx index 4e96578..0a48de8 100644 --- a/python/astra/algorithm_c.pyx +++ b/python/astra/algorithm_c.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # @@ -44,7 +44,7 @@ from .utils import wrap_from_bytes cdef CAlgorithmManager * manAlg = <CAlgorithmManager * >PyAlgorithmManager.getSingletonPtr() cdef extern from *: - CReconstructionAlgorithm2D * dynamic_cast_recAlg "dynamic_cast<CReconstructionAlgorithm2D*>" (CAlgorithm * ) except NULL + CReconstructionAlgorithm2D * dynamic_cast_recAlg "dynamic_cast<astra::CReconstructionAlgorithm2D*>" (CAlgorithm * ) except NULL def create(config): diff --git a/python/astra/astra.py b/python/astra/astra.py index 61c26ee..3804d51 100644 --- a/python/astra/astra.py +++ b/python/astra/astra.py @@ -1,28 +1,27 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- from . import astra_c as a @@ -38,17 +37,6 @@ def use_cuda(): """ return a.use_cuda() - -def version(printToScreen=False): - """Check version of the ASTRA Toolbox. - - :param printToScreen: If ``True``, print version string. If ``False``, return version integer. - :type printToScreen: :class:`bool` - :returns: :class:`string` or :class:`int` -- The version string or integer. - - """ - return a.version(printToScreen) - def set_gpu_index(idx, memory=0): """Set default GPU index to use. diff --git a/python/astra/astra_c.pyx b/python/astra/astra_c.pyx index 8e30e69..6de10da 100644 --- a/python/astra/astra_c.pyx +++ b/python/astra/astra_c.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # @@ -37,8 +37,6 @@ cimport PyIndexManager from .PyIndexManager cimport CAstraObjectManagerBase cdef extern from "astra/Globals.h" namespace "astra": - int getVersion() - string getVersionString() bool cudaEnabled() IF HAVE_CUDA==True: @@ -74,13 +72,6 @@ def credits(): def use_cuda(): return cudaEnabled() - -def version(printToScreen=False): - if printToScreen: - six.print_(wrap_from_bytes(getVersionString())) - else: - return getVersion() - IF HAVE_CUDA==True: def set_gpu_index(idx, memory=0): import collections diff --git a/python/astra/creators.py b/python/astra/creators.py index 82fd9d1..4ddaf0c 100644 --- a/python/astra/creators.py +++ b/python/astra/creators.py @@ -1,28 +1,27 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- import six import numpy as np @@ -272,7 +271,7 @@ This method can be called in a number of ways: elif intype == 'cone': if len(args) < 7: raise Exception('not enough variables: astra_create_proj_geom(cone, detector_spacing_x, detector_spacing_y, det_row_count, det_col_count, angles, source_origin, origin_det)') - return {'type': 'cone','DetectorSpacingX':args[0], 'DetectorSpacingY':args[1], 'DetectorRowCount':args[2],'DetectorColCount':args[3],'ProjectionAngles':args[4],'DistanceOriginSource': args[5],'DistanceOriginDetector':args[6]} + return {'type': 'cone','DetectorSpacingX':args[0], 'DetectorSpacingY':args[1], 'DetectorRowCount':args[2],'DetectorColCount':args[3],'ProjectionAngles':args[4],'DistanceOriginSource': args[5],'DistanceOriginDetector':args[6]} elif intype == 'cone_vec': if len(args) < 3: raise Exception('not enough variables: astra_create_proj_geom(cone_vec, det_row_count, det_col_count, V)') @@ -547,8 +546,8 @@ def create_reconstruction(rec_type, proj_id, sinogram, iterations=1, use_mask='n return recon_id -def create_projector(proj_type, proj_geom, vol_geom): - """Create a 2D projector. +def create_projector(proj_type, proj_geom, vol_geom, options=None): + """Create a 2D or 3D projector. :param proj_type: Projector type, such as ``'line'``, ``'linear'``, ... :type proj_type: :class:`string` @@ -556,6 +555,8 @@ def create_projector(proj_type, proj_geom, vol_geom): :type proj_geom: :class:`dict` :param vol_geom: Volume geometry. :type vol_geom: :class:`dict` +:param options: Projector options structure defining ``'VoxelSuperSampling'``, ``'DetectorSuperSampling'``. +:type options: :class:`dict` :returns: :class:`int` -- The ID of the projector. """ @@ -564,6 +565,8 @@ def create_projector(proj_type, proj_geom, vol_geom): cfg = astra_dict(proj_type) cfg['ProjectionGeometry'] = proj_geom cfg['VolumeGeometry'] = vol_geom + if options is not None: + cfg['options'] = options types3d = ['linear3d', 'linearcone', 'cuda3d'] if proj_type in types3d: return projector3d.create(cfg) diff --git a/python/astra/data2d.py b/python/astra/data2d.py index f119f05..674161d 100644 --- a/python/astra/data2d.py +++ b/python/astra/data2d.py @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from . import data2d_c as d import numpy as np diff --git a/python/astra/data2d_c.pyx b/python/astra/data2d_c.pyx index 2242d3b..1b1125d 100644 --- a/python/astra/data2d_c.pyx +++ b/python/astra/data2d_c.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # @@ -83,8 +83,10 @@ def create(datatype, geometry, data=None, link=False): cdef CFloat32Data2D * pDataObject2D cdef CFloat32CustomMemory * pCustom - if link and data.shape!=geom_size(geometry): - raise Exception("The dimensions of the data do not match those specified in the geometry.") + if link: + geom_shape = geom_size(geometry) + if data.shape != geom_shape: + raise ValueError("The dimensions of the data do not match those specified in the geometry: {} != {}".format(data.shape, geom_shape)) if datatype == '-vol': cfg = utils.dictToConfig(six.b('VolumeGeometry'), geometry) @@ -92,7 +94,7 @@ def create(datatype, geometry, data=None, link=False): if not pGeometry.initialize(cfg[0]): del cfg del pGeometry - raise Exception('Geometry class not initialized.') + raise RuntimeError('Geometry class not initialized.') if link: pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data) pDataObject2D = <CFloat32Data2D * > new CFloat32VolumeData2D(pGeometry, pCustom) @@ -116,7 +118,7 @@ def create(datatype, geometry, data=None, link=False): if not ppGeometry.initialize(cfg[0]): del cfg del ppGeometry - raise Exception('Geometry class not initialized.') + raise RuntimeError('Geometry class not initialized.') if link: pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data) pDataObject2D = <CFloat32Data2D * > new CFloat32ProjectionData2D(ppGeometry, pCustom) @@ -125,11 +127,11 @@ def create(datatype, geometry, data=None, link=False): del ppGeometry del cfg else: - raise Exception("Invalid datatype. Please specify '-vol' or '-sino'.") + raise ValueError("Invalid datatype. Please specify '-vol' or '-sino'.") if not pDataObject2D.isInitialized(): del pDataObject2D - raise Exception("Couldn't initialize data object.") + raise RuntimeError("Couldn't initialize data object.") if not link: fillDataObject(pDataObject2D, data) @@ -140,6 +142,10 @@ cdef fillDataObject(CFloat32Data2D * obj, data): fillDataObjectScalar(obj, 0) else: if isinstance(data, np.ndarray): + obj_shape = (obj.getHeight(), obj.getWidth()) + if data.shape != obj_shape: + raise ValueError( + "The dimensions of the data do not match those specified in the geometry: {} != {}".format(data.shape, obj_shape)) fillDataObjectArray(obj, np.ascontiguousarray(data,dtype=np.float32)) else: fillDataObjectScalar(obj, np.float32(data)) @@ -152,18 +158,15 @@ cdef fillDataObjectScalar(CFloat32Data2D * obj, float s): @cython.boundscheck(False) @cython.wraparound(False) cdef fillDataObjectArray(CFloat32Data2D * obj, float [:,::1] data): - if (not data.shape[0] == obj.getHeight()) or (not data.shape[1] == obj.getWidth()): - raise Exception( - "The dimensions of the data do not match those specified in the geometry.") cdef float [:,::1] cView = <float[:data.shape[0],:data.shape[1]]> obj.getData2D()[0] cView[:] = data cdef CFloat32Data2D * getObject(i) except NULL: cdef CFloat32Data2D * pDataObject = man2d.get(i) if pDataObject == NULL: - raise Exception("Data object not found") + raise ValueError("Data object not found") if not pDataObject.isInitialized(): - raise Exception("Data object not initialized properly.") + raise RuntimeError("Data object not initialized properly.") return pDataObject @@ -182,15 +185,15 @@ def get_geometry(i): pDataObject3 = <CFloat32VolumeData2D * >pDataObject geom = utils.configToDict(pDataObject3.getGeometry().getConfiguration()) else: - raise Exception("Not a known data object") + raise RuntimeError("Not a known data object") return geom cdef CProjector2D * getProjector(i) except NULL: cdef CProjector2D * proj = manProj.get(i) if proj == NULL: - raise Exception("Projector not initialized.") + raise RuntimeError("Projector not initialized.") if not proj.isInitialized(): - raise Exception("Projector not initialized.") + raise RuntimeError("Projector not initialized.") return proj def check_compatible(i, proj_id): @@ -205,7 +208,7 @@ def check_compatible(i, proj_id): pDataObject3 = <CFloat32VolumeData2D * >pDataObject return pDataObject3.getGeometry().isEqual(proj.getVolumeGeometry()) else: - raise Exception("Not a known data object") + raise RuntimeError("Not a known data object") def change_geometry(i, geom): cdef Config *cfg @@ -231,12 +234,14 @@ def change_geometry(i, geom): if not ppGeometry.initialize(cfg[0]): del cfg del ppGeometry - raise Exception('Geometry class not initialized.') - if (ppGeometry.getDetectorCount() != pDataObject2.getDetectorCount() or ppGeometry.getProjectionAngleCount() != pDataObject2.getAngleCount()): + raise RuntimeError('Geometry class not initialized.') + geom_shape = (ppGeometry.getProjectionAngleCount(), ppGeometry.getDetectorCount()) + obj_shape = (pDataObject2.getAngleCount(), pDataObject2.getDetectorCount()) + if geom_shape != obj_shape: del ppGeometry del cfg - raise Exception( - "The dimensions of the data do not match those specified in the geometry.") + raise ValueError( + "The dimensions of the data do not match those specified in the geometry: {} != {}", obj_shape, geom_shape) pDataObject2.changeGeometry(ppGeometry) del ppGeometry del cfg @@ -247,17 +252,19 @@ def change_geometry(i, geom): if not pGeometry.initialize(cfg[0]): del cfg del pGeometry - raise Exception('Geometry class not initialized.') - if (pGeometry.getGridColCount() != pDataObject3.getWidth() or pGeometry.getGridRowCount() != pDataObject3.getHeight()): + raise RuntimeError('Geometry class not initialized.') + geom_shape = (pGeometry.getGridRowCount(), pGeometry.getGridColCount()) + obj_shape = (pDataObject3.getHeight(), pDataObject3.getWidth()) + if geom_shape != obj_shape: del cfg del pGeometry - raise Exception( - 'The dimensions of the data do not match those specified in the geometry.') + raise ValueError( + "The dimensions of the data do not match those specified in the geometry: {} != {}", obj_shape, geom_shape) pDataObject3.changeGeometry(pGeometry) del cfg del pGeometry else: - raise Exception("Not a known data object") + raise RuntimeError("Not a known data object") @cython.boundscheck(False) @cython.wraparound(False) @@ -278,7 +285,7 @@ def get_shared(i): def get_single(i): - raise Exception("Not yet implemented") + raise NotImplementedError("Not yet implemented") def info(): diff --git a/python/astra/data3d.py b/python/astra/data3d.py index f143659..ecb99d0 100644 --- a/python/astra/data3d.py +++ b/python/astra/data3d.py @@ -1,31 +1,33 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from . import data3d_c as d import numpy as np +from .pythonutils import GPULink + def create(datatype,geometry,data=None): """Create a 3D object. @@ -52,12 +54,13 @@ def link(datatype, geometry, data): :returns: :class:`int` -- the ID of the constructed object. """ - if not isinstance(data,np.ndarray): - raise ValueError("Input should be a numpy array") - if not data.dtype==np.float32: - raise ValueError("Numpy array should be float32") - if not (data.flags['C_CONTIGUOUS'] and data.flags['ALIGNED']): - raise ValueError("Numpy array should be C_CONTIGUOUS and ALIGNED") + if not isinstance(data,np.ndarray) and not isinstance(data,GPULink): + raise TypeError("Input should be a numpy ndarray or GPULink object") + if isinstance(data, np.ndarray): + if data.dtype != np.float32: + raise ValueError("Numpy array should be float32") + if not (data.flags['C_CONTIGUOUS'] and data.flags['ALIGNED']): + raise ValueError("Numpy array should be C_CONTIGUOUS and ALIGNED") return d.create(datatype,geometry,data,True) diff --git a/python/astra/data3d_c.pyx b/python/astra/data3d_c.pyx index 811d1e4..78ed620 100644 --- a/python/astra/data3d_c.pyx +++ b/python/astra/data3d_c.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # @@ -45,12 +45,17 @@ from .PyXMLDocument cimport XMLDocument cimport utils from .utils import wrap_from_bytes -from .pythonutils import geom_size +from .pythonutils import geom_size, GPULink import operator from six.moves import reduce +include "config.pxi" + +cdef extern from "Python.h": + void* PyLong_AsVoidPtr(object) + cdef CData3DManager * man3d = <CData3DManager * >PyData3DManager.getSingletonPtr() @@ -65,12 +70,22 @@ def create(datatype,geometry,data=None, link=False): cdef Config *cfg cdef CVolumeGeometry3D * pGeometry cdef CProjectionGeometry3D * ppGeometry - cdef CFloat32Data3DMemory * pDataObject3D + cdef CFloat32Data3D * pDataObject3D cdef CConeProjectionGeometry3D* pppGeometry - cdef CFloat32CustomMemory * pCustom + cdef CFloat32CustomMemory * pCustom = NULL + IF HAVE_CUDA==True: + cdef MemHandle3D hnd - if link and data.shape!=geom_size(geometry): - raise Exception("The dimensions of the data do not match those specified in the geometry.") + if link: + geom_shape = geom_size(geometry) + if isinstance(data, np.ndarray): + data_shape = data.shape + elif isinstance(data, GPULink): + data_shape = ( data.z, data.y, data.x ) + else: + raise TypeError("data should be a numpy.ndarray or a GPULink object") + if geom_shape != data_shape: + raise ValueError("The dimensions of the data do not match those specified in the geometry: {} != {}".format(data_shape, geom_shape)) if datatype == '-vol': cfg = utils.dictToConfig(six.b('VolumeGeometry'), geometry) @@ -78,15 +93,25 @@ def create(datatype,geometry,data=None, link=False): if not pGeometry.initialize(cfg[0]): del cfg del pGeometry - raise Exception('Geometry class not initialized.') + raise RuntimeError('Geometry class not initialized.') if link: - pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data) - pDataObject3D = <CFloat32Data3DMemory * > new CFloat32VolumeData3DMemory(pGeometry, pCustom) + if isinstance(data, np.ndarray): + pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data) + pDataObject3D = <CFloat32Data3D * > new CFloat32VolumeData3DMemory(pGeometry, pCustom) + elif isinstance(data, GPULink): + IF HAVE_CUDA==True: + s = geom_size(geometry) + hnd = wrapHandle(<float*>PyLong_AsVoidPtr(data.ptr), data.x, data.y, data.z, data.pitch/4) + pDataObject3D = <CFloat32Data3D * > new CFloat32VolumeData3DGPU(pGeometry, hnd) + ELSE: + raise NotImplementedError("CUDA support is not enabled in ASTRA") + else: + raise TypeError("data should be a numpy.ndarray or a GPULink object") else: - pDataObject3D = <CFloat32Data3DMemory * > new CFloat32VolumeData3DMemory(pGeometry) + pDataObject3D = <CFloat32Data3D * > new CFloat32VolumeData3DMemory(pGeometry) del cfg del pGeometry - elif datatype == '-sino' or datatype == '-proj3d': + elif datatype == '-sino' or datatype == '-proj3d' or datatype == '-sinocone': cfg = utils.dictToConfig(six.b('ProjectionGeometry'), geometry) tpe = wrap_from_bytes(cfg.self.getAttribute(six.b('type'))) if (tpe == "parallel3d"): @@ -98,41 +123,38 @@ def create(datatype,geometry,data=None, link=False): elif (tpe == "cone_vec"): ppGeometry = <CProjectionGeometry3D*> new CConeVecProjectionGeometry3D(); else: - raise Exception("Invalid geometry type.") + raise ValueError("Invalid geometry type.") if not ppGeometry.initialize(cfg[0]): del cfg del ppGeometry - raise Exception('Geometry class not initialized.') + raise RuntimeError('Geometry class not initialized.') if link: - pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data) - pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(ppGeometry, pCustom) + if isinstance(data, np.ndarray): + pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data) + pDataObject3D = <CFloat32Data3D * > new CFloat32ProjectionData3DMemory(ppGeometry, pCustom) + elif isinstance(data, GPULink): + IF HAVE_CUDA==True: + s = geom_size(geometry) + hnd = wrapHandle(<float*>PyLong_AsVoidPtr(data.ptr), data.x, data.y, data.z, data.pitch/4) + pDataObject3D = <CFloat32Data3D * > new CFloat32ProjectionData3DGPU(ppGeometry, hnd) + ELSE: + raise NotImplementedError("CUDA support is not enabled in ASTRA") + else: + raise TypeError("data should be a numpy.ndarray or a GPULink object") else: pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(ppGeometry) del ppGeometry del cfg - elif datatype == "-sinocone": - cfg = utils.dictToConfig(six.b('ProjectionGeometry'), geometry) - pppGeometry = new CConeProjectionGeometry3D() - if not pppGeometry.initialize(cfg[0]): - del cfg - del pppGeometry - raise Exception('Geometry class not initialized.') - if link: - pCustom = <CFloat32CustomMemory*> new CFloat32CustomPython(data) - pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(pppGeometry, pCustom) - else: - pDataObject3D = <CFloat32Data3DMemory * > new CFloat32ProjectionData3DMemory(pppGeometry) else: - raise Exception("Invalid datatype. Please specify '-vol' or '-proj3d'.") + raise ValueError("Invalid datatype. Please specify '-vol' or '-proj3d'.") if not pDataObject3D.isInitialized(): del pDataObject3D - raise Exception("Couldn't initialize data object.") - - if not link: fillDataObject(pDataObject3D, data) + raise RuntimeError("Couldn't initialize data object.") - pDataObject3D.updateStatistics() + if not link: + fillDataObject(dynamic_cast_mem(pDataObject3D), data) return man3d.store(<CFloat32Data3D*>pDataObject3D) @@ -147,7 +169,7 @@ def get_geometry(i): pDataObject3 = <CFloat32VolumeData3DMemory * >pDataObject geom = utils.configToDict(pDataObject3.getGeometry().getConfiguration()) else: - raise Exception("Not a known data object") + raise RuntimeError("Not a known data object") return geom def change_geometry(i, geom): @@ -168,18 +190,18 @@ def change_geometry(i, geom): elif (tpe == "cone_vec"): ppGeometry = <CProjectionGeometry3D*> new CConeVecProjectionGeometry3D(); else: - raise Exception("Invalid geometry type.") + raise ValueError("Invalid geometry type.") if not ppGeometry.initialize(cfg[0]): del cfg del ppGeometry - raise Exception('Geometry class not initialized.') + raise RuntimeError('Geometry class not initialized.') del cfg - if (ppGeometry.getDetectorColCount() != pDataObject2.getDetectorColCount() or \ - ppGeometry.getProjectionCount() != pDataObject2.getAngleCount() or \ - ppGeometry.getDetectorRowCount() != pDataObject2.getDetectorRowCount()): + geom_shape = (ppGeometry.getDetectorRowCount(), ppGeometry.getProjectionCount(), ppGeometry.getDetectorColCount()) + obj_shape = (pDataObject2.getDetectorRowCount(), pDataObject2.getAngleCount(), pDataObject2.getDetectorColCount()) + if geom_shape != obj_shape: del ppGeometry - raise Exception( - "The dimensions of the data do not match those specified in the geometry.") + raise ValueError( + "The dimensions of the data do not match those specified in the geometry: {} != {}".format(obj_shape, geom_shape)) pDataObject2.changeGeometry(ppGeometry) del ppGeometry @@ -190,19 +212,19 @@ def change_geometry(i, geom): if not pGeometry.initialize(cfg[0]): del cfg del pGeometry - raise Exception('Geometry class not initialized.') + raise RuntimeError('Geometry class not initialized.') del cfg - if (pGeometry.getGridColCount() != pDataObject3.getColCount() or \ - pGeometry.getGridRowCount() != pDataObject3.getRowCount() or \ - pGeometry.getGridSliceCount() != pDataObject3.getSliceCount()): + geom_shape = (pGeometry.getGridSliceCount(), pGeometry.getGridRowCount(), pGeometry.getGridColCount()) + obj_shape = (pDataObject3.getSliceCount(), pDataObject3.getRowCount(), pDataObject3.getColCount()) + if geom_shape != obj_shape: del pGeometry - raise Exception( - "The dimensions of the data do not match those specified in the geometry.") + raise ValueError( + "The dimensions of the data do not match those specified in the geometry.".format(obj_shape, geom_shape)) pDataObject3.changeGeometry(pGeometry) del pGeometry else: - raise Exception("Not a known data object") + raise RuntimeError("Not a known data object") cdef fillDataObject(CFloat32Data3DMemory * obj, data): @@ -210,6 +232,10 @@ cdef fillDataObject(CFloat32Data3DMemory * obj, data): fillDataObjectScalar(obj, 0) else: if isinstance(data, np.ndarray): + obj_shape = (obj.getDepth(), obj.getHeight(), obj.getWidth()) + if data.shape != obj_shape: + raise ValueError( + "The dimensions of the data do not match those specified in the geometry: {} != {}".format(data.shape, obj_shape)) fillDataObjectArray(obj, np.ascontiguousarray(data,dtype=np.float32)) else: fillDataObjectScalar(obj, np.float32(data)) @@ -222,18 +248,15 @@ cdef fillDataObjectScalar(CFloat32Data3DMemory * obj, float s): @cython.boundscheck(False) @cython.wraparound(False) cdef fillDataObjectArray(CFloat32Data3DMemory * obj, float [:,:,::1] data): - if (not data.shape[0] == obj.getDepth()) or (not data.shape[1] == obj.getHeight()) or (not data.shape[2] == obj.getWidth()): - raise Exception( - "The dimensions of the data do not match those specified in the geometry.") cdef float [:,:,::1] cView = <float[:data.shape[0],:data.shape[1],:data.shape[2]]> obj.getData3D()[0][0] cView[:] = data cdef CFloat32Data3D * getObject(i) except NULL: cdef CFloat32Data3D * pDataObject = man3d.get(i) if pDataObject == NULL: - raise Exception("Data object not found") + raise ValueError("Data object not found") if not pDataObject.isInitialized(): - raise Exception("Data object not initialized properly.") + raise RuntimeError("Data object not initialized properly.") return pDataObject @cython.boundscheck(False) @@ -256,7 +279,7 @@ def get_shared(i): return np.PyArray_SimpleNewFromData(3,shape,np.NPY_FLOAT32,<void *>pDataObject.getData3D()[0][0]) def get_single(i): - raise Exception("Not yet implemented") + raise NotImplementedError("Not yet implemented") def store(i,data): cdef CFloat32Data3D * pDataObject = getObject(i) diff --git a/python/astra/experimental.pyx b/python/astra/experimental.pyx index 9bb73a2..0af3118 100644 --- a/python/astra/experimental.pyx +++ b/python/astra/experimental.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # @@ -36,12 +36,20 @@ IF HAVE_CUDA==True: cdef extern from "astra/CompositeGeometryManager.h" namespace "astra": cdef cppclass CCompositeGeometryManager: - bool doFP(CProjector3D *, vector[CFloat32VolumeData3DMemory *], vector[CFloat32ProjectionData3DMemory *]) - bool doBP(CProjector3D *, vector[CFloat32VolumeData3DMemory *], vector[CFloat32ProjectionData3DMemory *]) + bool doFP(CProjector3D *, vector[CFloat32VolumeData3D *], vector[CFloat32ProjectionData3D *]) + bool doBP(CProjector3D *, vector[CFloat32VolumeData3D *], vector[CFloat32ProjectionData3D *]) cdef extern from *: - CFloat32VolumeData3DMemory * dynamic_cast_vol_mem "dynamic_cast<astra::CFloat32VolumeData3DMemory*>" (CFloat32Data3D * ) except NULL - CFloat32ProjectionData3DMemory * dynamic_cast_proj_mem "dynamic_cast<astra::CFloat32ProjectionData3DMemory*>" (CFloat32Data3D * ) except NULL + CFloat32VolumeData3D * dynamic_cast_vol_mem "dynamic_cast<astra::CFloat32VolumeData3D*>" (CFloat32Data3D * ) except NULL + CFloat32ProjectionData3D * dynamic_cast_proj_mem "dynamic_cast<astra::CFloat32ProjectionData3D*>" (CFloat32Data3D * ) except NULL + + cdef extern from "astra/Float32ProjectionData3D.h" namespace "astra": + cdef cppclass CFloat32ProjectionData3D: + bool isInitialized() + cdef extern from "astra/Float32VolumeData3D.h" namespace "astra": + cdef cppclass CFloat32VolumeData3D: + bool isInitialized() + cimport PyProjector3DManager from .PyProjector3DManager cimport CProjector3DManager @@ -52,9 +60,9 @@ IF HAVE_CUDA==True: cdef CData3DManager * man3d = <CData3DManager * >PyData3DManager.getSingletonPtr() def do_composite(projector_id, vol_ids, proj_ids, t): - cdef vector[CFloat32VolumeData3DMemory *] vol - cdef CFloat32VolumeData3DMemory * pVolObject - cdef CFloat32ProjectionData3DMemory * pProjObject + cdef vector[CFloat32VolumeData3D *] vol + cdef CFloat32VolumeData3D * pVolObject + cdef CFloat32ProjectionData3D * pProjObject for v in vol_ids: pVolObject = dynamic_cast_vol_mem(man3d.get(v)) if pVolObject == NULL: @@ -62,7 +70,7 @@ IF HAVE_CUDA==True: if not pVolObject.isInitialized(): raise Exception("Data object not initialized properly") vol.push_back(pVolObject) - cdef vector[CFloat32ProjectionData3DMemory *] proj + cdef vector[CFloat32ProjectionData3D *] proj for v in proj_ids: pProjObject = dynamic_cast_proj_mem(man3d.get(v)) if pProjObject == NULL: diff --git a/python/astra/extrautils.pyx b/python/astra/extrautils.pyx index 2c7771e..248c6ee 100644 --- a/python/astra/extrautils.pyx +++ b/python/astra/extrautils.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # @@ -26,19 +26,19 @@ def clipCircle(img): - cdef int i,j - cdef double x2,y2,mid,bnd - cdef long sz,sz2 - sz = img.shape[0] - sz2 = sz*sz - bnd = sz2/4. - mid = (sz-1.)/2. - nDel=0 - for i in range(sz): - for j in range(sz): - x2 = (i-mid)*(i-mid) - y2 = (j-mid)*(j-mid) - if x2+y2>bnd: - img[i,j]=0 - nDel=nDel+1 - return nDel + cdef int i,j + cdef double x2,y2,mid,bnd + cdef long sz,sz2 + sz = img.shape[0] + sz2 = sz*sz + bnd = sz2/4. + mid = (sz-1.)/2. + nDel=0 + for i in range(sz): + for j in range(sz): + x2 = (i-mid)*(i-mid) + y2 = (j-mid)*(j-mid) + if x2+y2>bnd: + img[i,j]=0 + nDel=nDel+1 + return nDel diff --git a/python/astra/functions.py b/python/astra/functions.py index 9927eee..b3a470d 100644 --- a/python/astra/functions.py +++ b/python/astra/functions.py @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -# Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -# Author: Daniel M. Pelt -# Contact: D.M.Pelt@cwi.nl -# Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -# This file is part of the Python interface to the -# All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -# The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify +# The ASTRA Toolbox is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# (at your option) any later version. # -# The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, +# The ASTRA Toolbox is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + """Additional functions for PyAstraToolbox. .. moduleauthor:: Daniel M. Pelt <D.M.Pelt@cwi.nl> diff --git a/python/astra/log.py b/python/astra/log.py index 3ec0df5..a54ed08 100644 --- a/python/astra/log.py +++ b/python/astra/log.py @@ -1,28 +1,27 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- from . import log_c as l @@ -150,4 +149,4 @@ def setOutputFile(filename, level): :param level: Logging level to use (DEBUG, INFO, WARN, or ERROR). :type level: :class:`int` """ - l.log_setOutputFile(filename, level)
\ No newline at end of file + l.log_setOutputFile(filename, level) diff --git a/python/astra/log_c.pyx b/python/astra/log_c.pyx index 0d187e9..0757d0c 100644 --- a/python/astra/log_c.pyx +++ b/python/astra/log_c.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # diff --git a/python/astra/matlab.py b/python/astra/matlab.py index 83b345d..c96931e 100644 --- a/python/astra/matlab.py +++ b/python/astra/matlab.py @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + """This module implements a MATLAB-like interface to the ASTRA Toolbox. Note that all functions are called with a :class:`string` as the first diff --git a/python/astra/matrix.py b/python/astra/matrix.py index 27e4823..eeb873c 100644 --- a/python/astra/matrix.py +++ b/python/astra/matrix.py @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from . import matrix_c as m def delete(ids): diff --git a/python/astra/matrix_c.pyx b/python/astra/matrix_c.pyx index f5c0938..ba20b10 100644 --- a/python/astra/matrix_c.pyx +++ b/python/astra/matrix_c.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # diff --git a/python/astra/optomo.py b/python/astra/optomo.py index dde719e..74f34e5 100644 --- a/python/astra/optomo.py +++ b/python/astra/optomo.py @@ -1,28 +1,27 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- from . import data2d from . import data3d diff --git a/python/astra/plugin.py b/python/astra/plugin.py index 3e3528d..56c2761 100644 --- a/python/astra/plugin.py +++ b/python/astra/plugin.py @@ -1,28 +1,27 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- from . import plugin_c as p from . import log @@ -118,4 +117,4 @@ def get_help(name): :returns: :class:`str` -- Help string (docstring). """ - return p.get_help(name)
\ No newline at end of file + return p.get_help(name) diff --git a/python/astra/plugin_c.pyx b/python/astra/plugin_c.pyx index ee04853..3853cec 100644 --- a/python/astra/plugin_c.pyx +++ b/python/astra/plugin_c.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # diff --git a/python/astra/plugins/__init__.py b/python/astra/plugins/__init__.py new file mode 100644 index 0000000..88a68cb --- /dev/null +++ b/python/astra/plugins/__init__.py @@ -0,0 +1,29 @@ +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam +# +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ +# +# This file is part of the ASTRA Toolbox. +# +# +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# +# ----------------------------------------------------------------------- + + +from .sirt import SIRTPlugin +from .cgls import CGLSPlugin + diff --git a/python/astra/plugins/cgls.py b/python/astra/plugins/cgls.py new file mode 100644 index 0000000..5268f51 --- /dev/null +++ b/python/astra/plugins/cgls.py @@ -0,0 +1,99 @@ +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam +# +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ +# +# This file is part of the ASTRA Toolbox. +# +# +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# +# ----------------------------------------------------------------------- + + +import astra +import numpy as np +import six + +class CGLSPlugin(astra.plugin.base): + """CGLS.""" + + astra_name = "CGLS-PLUGIN" + + def initialize(self,cfg): + self.W = astra.OpTomo(cfg['ProjectorId']) + self.vid = cfg['ReconstructionDataId'] + self.sid = cfg['ProjectionDataId'] + + try: + v = astra.data2d.get_shared(self.vid) + s = astra.data2d.get_shared(self.sid) + self.data_mod = astra.data2d + except Exception: + v = astra.data3d.get_shared(self.vid) + s = astra.data3d.get_shared(self.sid) + self.data_mod = astra.data3d + + def run(self, its): + v = self.data_mod.get_shared(self.vid) + s = self.data_mod.get_shared(self.sid) + z = np.zeros(v.shape, dtype=np.float32) + p = np.zeros(v.shape, dtype=np.float32) + r = np.zeros(s.shape, dtype=np.float32) + w = np.zeros(s.shape, dtype=np.float32) + W = self.W + + # r = s - W*v + W.FP(v, out=w) + r[:] = s + r -= w + + # p = W'*r + W.BP(r, out=p) + + # gamma = <p,p> + gamma = np.dot(p.ravel(), p.ravel()) + + for i in range(its): + # w = W * p + W.FP(p, out=w) + + # alpha = gamma / <w,w> + alpha = gamma / np.dot(w.ravel(), w.ravel()) + + # v += alpha * p + z[:] = p + z *= alpha + v += z + + # r -= alpha * w + w *= -alpha; + r += w + + # z = W' * r + W.BP(r, out=z) + + # beta = <z,z> / gamma + newgamma = np.dot(z.ravel(), z.ravel()) + beta = newgamma / gamma + + # gamma = <z,z> + gamma = newgamma + + # p = z + beta * p + p *= beta + p += z + diff --git a/python/astra/plugins/sirt.py b/python/astra/plugins/sirt.py new file mode 100644 index 0000000..5238399 --- /dev/null +++ b/python/astra/plugins/sirt.py @@ -0,0 +1,90 @@ +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam +# +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ +# +# This file is part of the ASTRA Toolbox. +# +# +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# +# ----------------------------------------------------------------------- + + +import astra +import numpy as np +import six + +class SIRTPlugin(astra.plugin.base): + """SIRT. + + Options: + + 'Relaxation': relaxation factor (optional) + 'MinConstraint': constrain values to at least this (optional) + 'MaxConstraint': constrain values to at most this (optional) + """ + + astra_name = "SIRT-PLUGIN" + + def initialize(self,cfg, Relaxation = 1, MinConstraint = None, MaxConstraint = None): + self.W = astra.OpTomo(cfg['ProjectorId']) + self.vid = cfg['ReconstructionDataId'] + self.sid = cfg['ProjectionDataId'] + self.min_constraint = MinConstraint + self.max_constraint = MaxConstraint + + try: + v = astra.data2d.get_shared(self.vid) + s = astra.data2d.get_shared(self.sid) + self.data_mod = astra.data2d + except Exception: + v = astra.data3d.get_shared(self.vid) + s = astra.data3d.get_shared(self.sid) + self.data_mod = astra.data3d + + self.R = self.W * np.ones(v.shape,dtype=np.float32).ravel(); + self.R[self.R < 0.000001] = np.Inf + self.R = 1 / self.R + self.R = self.R.reshape(s.shape) + + self.mrC = self.W.T * np.ones(s.shape,dtype=np.float32).ravel(); + self.mrC[self.mrC < 0.000001] = np.Inf + self.mrC = -Relaxation / self.mrC + self.mrC = self.mrC.reshape(v.shape) + + + def run(self, its): + v = self.data_mod.get_shared(self.vid) + s = self.data_mod.get_shared(self.sid) + tv = np.zeros(v.shape, dtype=np.float32) + ts = np.zeros(s.shape, dtype=np.float32) + W = self.W + mrC = self.mrC + R = self.R + for i in range(its): + W.FP(v,out=ts) + ts -= s + ts *= R # ts = R * (W*v - s) + + W.BP(ts,out=tv) + tv *= mrC + + v += tv # v = v - rel * C * W' * ts + + if self.min_constraint is not None or self.max_constraint is not None: + v.clip(min=self.min_constraint, max=self.max_constraint, out=v) + diff --git a/python/astra/projector.py b/python/astra/projector.py index e370e5a..878e011 100644 --- a/python/astra/projector.py +++ b/python/astra/projector.py @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from . import projector_c as p def create(config): diff --git a/python/astra/projector3d.py b/python/astra/projector3d.py index d1086b9..9befa3f 100644 --- a/python/astra/projector3d.py +++ b/python/astra/projector3d.py @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from . import projector3d_c as p def create(config): diff --git a/python/astra/projector3d_c.pyx b/python/astra/projector3d_c.pyx index e355e38..98eccc1 100644 --- a/python/astra/projector3d_c.pyx +++ b/python/astra/projector3d_c.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # diff --git a/python/astra/projector_c.pyx b/python/astra/projector_c.pyx index 53d38c3..be529da 100644 --- a/python/astra/projector_c.pyx +++ b/python/astra/projector_c.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # diff --git a/python/astra/pythonutils.py b/python/astra/pythonutils.py index 8ea4af5..27fa8fd 100644 --- a/python/astra/pythonutils.py +++ b/python/astra/pythonutils.py @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -# Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -# Author: Daniel M. Pelt -# Contact: D.M.Pelt@cwi.nl -# Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -# This file is part of the Python interface to the -# All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -# The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify +# The ASTRA Toolbox is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# (at your option) any later version. # -# The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, +# The ASTRA Toolbox is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + """Additional purely Python functions for PyAstraToolbox. .. moduleauthor:: Daniel M. Pelt <D.M.Pelt@cwi.nl> @@ -61,3 +61,21 @@ def geom_size(geom, dim=None): s = s[dim] return s + +class GPULink(object): + """Utility class for astra.data3d.link with a CUDA pointer + + The CUDA pointer ptr must point to an array of floats. + + x is the fastest-changing coordinate, z the slowest-changing. + + pitch is the width in bytes of the memory block. For a contiguous + memory block, pitch is equal to sizeof(float) * x. For a memory block + allocated by cudaMalloc3D, pitch is the pitch as returned by cudaMalloc3D. + """ + def __init__(self, ptr, x, y, z, pitch): + self.ptr = ptr + self.x = x + self.y = y + self.z = z + self.pitch = pitch diff --git a/python/astra/src/PythonPluginAlgorithm.cpp b/python/astra/src/PythonPluginAlgorithm.cpp index 893db94..69b3d06 100644 --- a/python/astra/src/PythonPluginAlgorithm.cpp +++ b/python/astra/src/PythonPluginAlgorithm.cpp @@ -4,7 +4,7 @@ Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp 2014-2016, CWI, Amsterdam Contact: astra@uantwerpen.be -Website: http://sf.net/projects/astra-toolbox +Website: http://www.astra-toolbox.com/ This file is part of the ASTRA Toolbox. diff --git a/python/astra/src/PythonPluginAlgorithm.h b/python/astra/src/PythonPluginAlgorithm.h index ea4c6fb..dacd0e4 100644 --- a/python/astra/src/PythonPluginAlgorithm.h +++ b/python/astra/src/PythonPluginAlgorithm.h @@ -4,7 +4,7 @@ Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp 2014-2016, CWI, Amsterdam Contact: astra@uantwerpen.be -Website: http://sf.net/projects/astra-toolbox +Website: http://www.astra-toolbox.com/ This file is part of the ASTRA Toolbox. diff --git a/python/astra/utils.pxd b/python/astra/utils.pxd index ca84836..695081f 100644 --- a/python/astra/utils.pxd +++ b/python/astra/utils.pxd @@ -1,28 +1,28 @@ -#----------------------------------------------------------------------- -#Copyright 2013 Centrum Wiskunde & Informatica, Amsterdam +# ----------------------------------------------------------------------- +# Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp +# 2013-2016, CWI, Amsterdam # -#Author: Daniel M. Pelt -#Contact: D.M.Pelt@cwi.nl -#Website: http://dmpelt.github.io/pyastratoolbox/ +# Contact: astra@uantwerpen.be +# Website: http://www.astra-toolbox.com/ # +# This file is part of the ASTRA Toolbox. # -#This file is part of the Python interface to the -#All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). # -#The Python interface to the ASTRA Toolbox is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. +# The ASTRA Toolbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. # -#The Python interface to the ASTRA Toolbox is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. +# The ASTRA Toolbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public License -#along with the Python interface to the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. +# You should have received a copy of the GNU General Public License +# along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. # -#----------------------------------------------------------------------- +# ----------------------------------------------------------------------- + from libcpp.string cimport string cimport PyXMLDocument diff --git a/python/astra/utils.pyx b/python/astra/utils.pyx index 34d1902..a40916b 100644 --- a/python/astra/utils.pyx +++ b/python/astra/utils.pyx @@ -3,7 +3,7 @@ # 2013-2016, CWI, Amsterdam # # Contact: astra@uantwerpen.be -# Website: http://sf.net/projects/astra-toolbox +# Website: http://www.astra-toolbox.com/ # # This file is part of the ASTRA Toolbox. # |