Master | Development | Experimental | Anaconda binaries |
---|---|---|---|
The Astra-Toolbox plugin for CIL.
This repository is no longer under development. The relevant code has been absorbed directly in to the CIL repository and package as of CIL V22.0.0
License: Apache License 2.0
Master | Development | Experimental | Anaconda binaries |
---|---|---|---|
The Astra-Toolbox plugin for CIL.
This repository is no longer under development. The relevant code has been absorbed directly in to the CIL repository and package as of CIL V22.0.0
Need to force the upgrade to expose vector geometry. This will mean we have to remove the current scaling fixes applied so will not be backward compatible.
The current method used to detect CUDA availability fails miserably
import astra
use_cuda = True
try:
astra.test_CUDA()
except RuntimeError as re:
print (re)
use_cuda = False
except:
print ("Crash!")
use_cuda = False
The error is the following and is not properly handled in Python, I suppose
Error: CUDA error 35: CUDA driver version is insufficient for CUDA runtime version.
Error: Failed to allocate 32x2 GPU buffer
python: ./../../src/CudaForwardProjectionAlgorithm.cpp:276: virtual void astra::CCudaForwardProjectionAlgorithm::run(int): Assertion `ok' failed.
The operator norm should be computed on one channel only. An easy (hack) solution atm would be
igtmp = ImageGeometry(voxel_num_x = N, voxel_num_y = N)
agtmp = AcquisitionGeometry('parallel','2D', angles, detectors) # No channels
Atmp = AstraProjectorSimple(igtmp, agtmp, dev)
and then use power method.
Version 2.0.0 of ASTRA has been released. We should update this repo to use that.
According to the release details this should not be different from the 1.9.9 dev we are using.
In the future we should use the available astra machinery to reuse a numpy array.
Originally posted by @paskino in https://github.com/vais-ral/CCPi-astra/pull/68#discussion_r503819799
Add check that data is in astra accepted order
Why do we have get_min, etc for the 'image geometry'
convert_geometry_to_astra
currently blindly takes the data in the angles
field of the AcquisitionGeometry
and passes it to astra.
Since in AcquisitionGeometry
we have a field angle_unit
by default set to DEGREE
we should make use of that.
Also Astra wants a numpy.ndarray
of type numpy.float32
, so that could be rightly and easily created by the convert_geometry_to_astra
function
The FBP
class has no information about the filter_type
. To select different filters
need to use FBP_simple
.
Some tests are now in the CIL-Demos but not as unit test.
FBP 3D keeps allocating memory on the device leading to CUDA memory errors.
These lines should be in the loop.
Notice that astra returns to python some reference to the data that it's allocated on GPU. However, deleting the reference in python wouldn't delete the allocated memory on the GPU.
Infrastructure to pass memory to astra is not working:
Isn't a method in this class.
But the code can never take this route as out
is not passed by the wrapping operator:
The current processors work only on the old 'simple' geometry. They will have to me implemented for the new geometry for all datatypes including multi-channel.
In parallel geometry, if we setup the image geometry then
acqusition_geometry should have as detector_pixel_size the voxel_size
The appears to be an issue copying CIL-ASTRA files to the correct location in the build step. This is causing the builds to currently fail on jenkins.
When built with conda-build
the tests fail with:
ModuleNotFoundError: No module named 'cil.plugins.astra'
The issue appears to be with setup.py
not copying the files as expected. It moves the .egg
to the correct place, but this isn't extracted into cil/plugins
To recreate, create a new environment with CIL
only
conda create -n test cil -c conda-forge -c intel -c ccpi
conda activate test
cd Wrappers/Python
python setup.py install
(test) tpc56154@reconvm1:~/GitHub/CIL-ASTRA/Wrappers/Python$ python setup.py install
/home/tpc56154/miniconda3/envs/test/lib/python3.9/site-packages/setuptools/dist.py:519: UserWarning: The version specified ('v21.3.0-2-g1e83d48') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
warnings.warn(
running install
/home/tpc56154/miniconda3/envs/test/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
/home/tpc56154/miniconda3/envs/test/lib/python3.9/site-packages/setuptools/command/easy_install.py:160: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running bdist_egg
/home/tpc56154/miniconda3/envs/test/lib/python3.9/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: v21.3.0-2-g1e83d48 is an invalid version and will not be supported in a future release
warnings.warn(
running egg_info
creating cil_astra.egg-info
writing cil_astra.egg-info/PKG-INFO
writing dependency_links to cil_astra.egg-info/dependency_links.txt
writing top-level names to cil_astra.egg-info/top_level.txt
writing manifest file 'cil_astra.egg-info/SOURCES.txt'
reading manifest file 'cil_astra.egg-info/SOURCES.txt'
writing manifest file 'cil_astra.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/cil
creating build/lib/cil/plugins
creating build/lib/cil/plugins/astra
copying cil/plugins/astra/version.py -> build/lib/cil/plugins/astra
copying cil/plugins/astra/__init__.py -> build/lib/cil/plugins/astra
creating build/lib/cil/plugins/astra/operators
copying cil/plugins/astra/operators/AstraProjector3D.py -> build/lib/cil/plugins/astra/operators
copying cil/plugins/astra/operators/AstraProjectorMC.py -> build/lib/cil/plugins/astra/operators
copying cil/plugins/astra/operators/AstraProjector2D.py -> build/lib/cil/plugins/astra/operators
copying cil/plugins/astra/operators/__init__.py -> build/lib/cil/plugins/astra/operators
copying cil/plugins/astra/operators/ProjectionOperator.py -> build/lib/cil/plugins/astra/operators
copying cil/plugins/astra/operators/AstraProjector3DMC.py -> build/lib/cil/plugins/astra/operators
creating build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/AstraBackProjector3D.py -> build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/AstraForwardProjector2D.py -> build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/AstraForwardProjectorMC.py -> build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/FBP_Simple.py -> build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/AstraBackProjectorMC.py -> build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/AstraBackProjector2D.py -> build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/FBP_Flexible.py -> build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/__init__.py -> build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/AstraForwardProjector3D.py -> build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/FDK_Flexible.py -> build/lib/cil/plugins/astra/processors
copying cil/plugins/astra/processors/FBP.py -> build/lib/cil/plugins/astra/processors
creating build/lib/cil/plugins/astra/utilities
copying cil/plugins/astra/utilities/convert_geometry_to_astra_vec_2D.py -> build/lib/cil/plugins/astra/utilities
copying cil/plugins/astra/utilities/convert_geometry_to_astra.py -> build/lib/cil/plugins/astra/utilities
copying cil/plugins/astra/utilities/__init__.py -> build/lib/cil/plugins/astra/utilities
copying cil/plugins/astra/utilities/convert_geometry_to_astra_vec_3D.py -> build/lib/cil/plugins/astra/utilities
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/cil
creating build/bdist.linux-x86_64/egg/cil/plugins
creating build/bdist.linux-x86_64/egg/cil/plugins/astra
copying build/lib/cil/plugins/astra/version.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra
creating build/bdist.linux-x86_64/egg/cil/plugins/astra/operators
copying build/lib/cil/plugins/astra/operators/AstraProjector3D.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/operators
copying build/lib/cil/plugins/astra/operators/AstraProjectorMC.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/operators
copying build/lib/cil/plugins/astra/operators/AstraProjector2D.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/operators
copying build/lib/cil/plugins/astra/operators/__init__.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/operators
copying build/lib/cil/plugins/astra/operators/ProjectionOperator.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/operators
copying build/lib/cil/plugins/astra/operators/AstraProjector3DMC.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/operators
creating build/bdist.linux-x86_64/egg/cil/plugins/astra/utilities
copying build/lib/cil/plugins/astra/utilities/convert_geometry_to_astra_vec_2D.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/utilities
copying build/lib/cil/plugins/astra/utilities/convert_geometry_to_astra.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/utilities
copying build/lib/cil/plugins/astra/utilities/__init__.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/utilities
copying build/lib/cil/plugins/astra/utilities/convert_geometry_to_astra_vec_3D.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/utilities
copying build/lib/cil/plugins/astra/__init__.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra
creating build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/AstraBackProjector3D.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/AstraForwardProjector2D.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/AstraForwardProjectorMC.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/FBP_Simple.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/AstraBackProjectorMC.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/AstraBackProjector2D.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/FBP_Flexible.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/__init__.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/AstraForwardProjector3D.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/FDK_Flexible.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
copying build/lib/cil/plugins/astra/processors/FBP.py -> build/bdist.linux-x86_64/egg/cil/plugins/astra/processors
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/version.py to version.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/operators/AstraProjector3D.py to AstraProjector3D.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/operators/AstraProjectorMC.py to AstraProjectorMC.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/operators/AstraProjector2D.py to AstraProjector2D.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/operators/__init__.py to __init__.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/operators/ProjectionOperator.py to ProjectionOperator.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/operators/AstraProjector3DMC.py to AstraProjector3DMC.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/utilities/convert_geometry_to_astra_vec_2D.py to convert_geometry_to_astra_vec_2D.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/utilities/convert_geometry_to_astra.py to convert_geometry_to_astra.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/utilities/__init__.py to __init__.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/utilities/convert_geometry_to_astra_vec_3D.py to convert_geometry_to_astra_vec_3D.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/__init__.py to __init__.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/AstraBackProjector3D.py to AstraBackProjector3D.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/AstraForwardProjector2D.py to AstraForwardProjector2D.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/AstraForwardProjectorMC.py to AstraForwardProjectorMC.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/FBP_Simple.py to FBP_Simple.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/AstraBackProjectorMC.py to AstraBackProjectorMC.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/AstraBackProjector2D.py to AstraBackProjector2D.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/FBP_Flexible.py to FBP_Flexible.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/__init__.py to __init__.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/AstraForwardProjector3D.py to AstraForwardProjector3D.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/FDK_Flexible.py to FDK_Flexible.cpython-39.pyc
byte-compiling build/bdist.linux-x86_64/egg/cil/plugins/astra/processors/FBP.py to FBP.cpython-39.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying cil_astra.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying cil_astra.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying cil_astra.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying cil_astra.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/cil_astra-v21.3.0_2_g1e83d48-py3.9.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing cil_astra-v21.3.0_2_g1e83d48-py3.9.egg
Copying cil_astra-v21.3.0_2_g1e83d48-py3.9.egg to /home/tpc56154/miniconda3/envs/test/lib/python3.9/site-packages
Adding cil-astra v21.3.0-2-g1e83d48 to easy-install.pth file
Installed /home/tpc56154/miniconda3/envs/test/lib/python3.9/site-packages/cil_astra-v21.3.0_2_g1e83d48-py3.9.egg
Processing dependencies for cil-astra===v21.3.0-2-g1e83d48
Finished processing dependencies for cil-astra===v21.3.0-2-g1e83d48
(test) tpc56154@reconvm1:~/GitHub/CIL-ASTRA/Wrappers/Python$ ls ~/miniconda3/envs/test/lib/python3.9/site-packages/cil/plugins/
TomoPhantom.py __init__.py __pycache__ ccpi_regularisation tigre
There is no cil-astra package:
ls ~/miniconda3/envs/test/lib/python3.9/site-packages/cil/plugins/
TomoPhantom.py __init__.py __pycache__ ccpi_regularisation tigre
(test) tpc56154@reconvm1:~/GitHub/CIL-ASTRA/Wrappers/Python$ python
Python 3.9.10 | packaged by conda-forge | (main, Feb 1 2022, 21:24:11)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cil.plugins.astra.version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cil.plugins.astra'
running norm
on a AstraProjector3DSimple
results in the following exception
======================================================================
ERROR: test_norm_simple3D (test_AstraOperators.TestAstraSimple)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/edo/GitHub/CCPi-Astra/Wrappers/Python/test/test_AstraOperators.py", line 86, in test_norm_simple3D
n = self.A3.norm()
File "/home/edo/miniconda3/envs/astra/lib/python3.6/site-packages/ccpi/astra/operators/AstraProjector3DSimple.py", line 75, in norm
self.s1, sall, svec = LinearOperator.PowerMethod(self, 50, x0)
File "/home/edo/miniconda3/envs/astra/lib/python3.6/site-packages/ccpi/optimisation/operators/LinearOperator.py", line 56, in PowerMethod
operator.direct(x0,out=y_tmp)
File "/home/edo/miniconda3/envs/astra/lib/python3.6/site-packages/ccpi/astra/operators/AstraProjector3DSimple.py", line 57, in direct
out.fill(self.fp.get_output())
File "/home/edo/miniconda3/envs/astra/lib/python3.6/site-packages/ccpi/framework/framework.py", line 1349, in get_output
self.output = self.process(out=out)
File "/home/edo/miniconda3/envs/astra/lib/python3.6/site-packages/ccpi/astra/processors/AstraForwardProjector3D.py", line 66, in process
self.vol_geom)
File "/home/edo/miniconda3/envs/astra/lib/python3.6/site-packages/astra/creators.py", line 421, in create_sino3d_gpu
volume_id = data3d.create('-vol', vol_geom, data)
File "/home/edo/miniconda3/envs/astra/lib/python3.6/site-packages/astra/data3d.py", line 43, in create
return d.create(datatype,geometry,data)
File "astra/data3d_c.pyx", line 102, in astra.data3d_c.create
RuntimeError: Geometry class not initialized.
----------------------------------------------------------------------
See #50
We need to add here
if self.filter_type !='ram-lak' and self.device == 'cpu':
raise NotImplementedError('Currently in astra, FDK has only ram-lak available')
Add AstraOperator(ig, ag, device) as a single wrapper for the user. It needs to handle all datatypes including multi-channel.
def compute_norm(self, **kwargs):
igtmp = self.volume_geometry.clone()
igtmp.channels = 1
agtmp = self.sinogram_geometry.clone()
agtmp.channels = 1
Atmp = AstraProjectorSimple(igtmp, agtmp, self.fp.device)
return Atmp.norm()
FBP uses dimension
parameter of AcquisitionGeometry
to set up.
https://github.com/vais-ral/CCPi-astra/blob/master/Wrappers/Python/ccpi/astra/processors/FBP.py#L36
it should not.
As default ASTRA seems to only use one GPU. Multiple can be set using:
astra.astra.set_gpu_index([0,1])
But it may be worth adding in some logic to our wrappers to query the available devices and make use of them.
The conversion from ImageGeometry
and AcquisitionGeometry
to astra geometry uses the parameter dimension
of the ImageGeometry
and AcquisitionGeometry
instances. However, it should better infer if it's 2D
or 3D
(+channel) by reading the rest of the geometry members.
Also, the member dimension
has been used loosely and without any checks. Currently it could contain anything and it would only break the conversion of the geometry here and here.
See here for further considerations: https://github.com/vais-ral/CCPi-Framework/issues/408
I am trying to do FBP for 3D+channel data and get this error
70 if sinogram_geometry.channels > 1:
---> 71 raise NotImplementedError("Cannot process multi-channel data")
72 #processor_full = ChannelwiseProcessor(processor, self.sinogram_geometry.channels, dimension='prepend')
73 #self.processor = operator_full
NotImplementedError: Cannot process multi-channel data
See here.
in create_image_data
which will change name, the operators should create ImageData
or AcquisitionData
define the DEFAULT_ASTRA_ACQUISITION_DATA_DIMENSION_LABELS
and DEFAULT_ASTRA_IMAGE_DATA_DIMENSION_LABELS
as package variables (well, constant!) so that it is impossible to get wrong.
ig = ImageGeometry(voxel_num_x = 256, voxel_num_y = 256, voxel_num_z = 256, \
channels = 80, \
dimension_labels=ccpi.astra.DEFAULT_ASTRA_IMAGE_DATA_DIMENSION_LABELS)
Astra projectors are needed to make use of the vector geometry. This requires an Operator, forward and back projector processors and a new utility to calculate the new geometry.
In AstraForwardProjector3D.py
and AstraBackwardProjector3D.py
we create the output array and then delete it at the following lines:
Same happens for the other processors, except possibly the Multi-Channel one.
Currently using old functions and algorithms.
Currently, norm for the AstraMC 2D operator is not working
see here.The reason is because in the master the lines are commented out.
Did we decide, how we want to treat this case?
I get the following error when I do conda-build:
conda_build.exceptions.DependencyNeedsBuildingError: Unsatisfiable dependencies for platform linux-64: ['astra-toolbox']
I do conda build conda-recipe --numpy 1.12 --python 3.5 and astra 1.8.3 is installed in environment.
Many of the files in this repo have the Apache-2 license header rather than the General Public License v3.0 license applied to all the code.
In order to setup correct (astra) geometries we need to convert our physical info to no unit parameters that astra likes.
So, we have to do sth like
https://github.com/vais-ral/CCPi-astra/blob/ADD_FBP/Wrappers/Python/ccpi/astra/test_AstraFBP3D_FDK.py#L169
And there are two options,
If we build with numpy 1.11 there is no flip
module in numpy. Flip needs to be replace in FBP.py
here
Below a comparison between AstraMC and Channelwise.
Channelwise is 1-2 sec slower.
Computing norm using MC operator: 0.0814945170423016sec
Computing norm using ChanWise operator: 0.08279416302684695sec
Computing direct out using MC operator: 7.874376090010628sec
Computing direct out using ChanWise operator: 8.888477805012371sec
Computing adjoint out using MC operator: 7.901970839011483sec
Computing adjoint out using ChanWise operator: 8.783782225975301sec
Computing direct (no out) using MC operator: 7.892078642034903sec
Computing direct (no out) using ChanWise operator: 8.707080838037655sec
Computing adjoint (no out) using MC operator: 7.789297449984588sec
Computing adjoint (no out) using ChanWise operator: 9.125933162984438sec
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 10:01:00 2020
@author: evangelos
"""
from ccpi.framework import ImageGeometry, AcquisitionGeometry
from ccpi.optimisation.operators import ChannelwiseOperator
from ccpi.astra.operators import AstraProjectorMC, AstraProjectorSimple
from timeit import default_timer as timer
import numpy as np
chan = 50
#ig = ImageGeometry(voxel_num_x = 150,
# voxel_num_y = 150,
# voxel_size_x = 1.,
# voxel_size_y = 1.,
# channels = chan,
# dimension_labels = ['channel','horizontal_y','horizontal_x'])
#
#ag = AcquisitionGeometry('cone',
# '2D',
# np.linspace(0,np.pi,150),
# pixel_num_h = 150,
# pixel_size_h = 1,
# dist_source_center = 10,
# dist_center_detector = 10,
# channels = chan,
# dimension_labels = ['channel', 'angle', 'horizontal'])
ig = ImageGeometry(voxel_num_x = 50,
voxel_num_y = 50,
voxel_size_x = 1.,
voxel_size_y = 1.,
channels = chan,
dimension_labels = ['channel','horizontal_y','horizontal_x'])
ag = AcquisitionGeometry('parallel',
'2D',
np.linspace(0,np.pi,50),
pixel_num_h = 50,
pixel_size_h = 1,
channels = chan,
dimension_labels = ['channel', 'angle', 'horizontal'])
Aop1 = AstraProjectorMC(ig, ag, 'cpu')
igtmp = ig.clone()
igtmp.shape = ig.shape[1:]
igtmp.dimension_labels = ['horizontal_y', 'horizontal_x']
igtmp.channels = 1
agtmp = ag.clone()
agtmp.shape = ag.shape[1:]
agtmp.dimension_labels = ['angle', 'horizontal']
agtmp.channels = 1
tmp_op = AstraProjectorSimple(igtmp, agtmp, 'cpu')
Aop2 = ChannelwiseOperator(tmp_op, chan)
x1 = ig.allocate('random')
tmp_x1a = ig.allocate()
tmp_x1b = ig.allocate()
x2 = ag.allocate('random')
tmp_x2a = ag.allocate()
tmp_x2b = ag.allocate()
t1 = timer()
a1 = Aop1.norm()
t2 = timer()
t3 = timer()
a2 = Aop2.norm()
t4 = timer()
np.testing.assert_almost_equal(a1, a2, decimal = 1)
print(" Computing norm using MC operator: {}sec ".format(t2 - t1))
print(" Computing norm using ChanWise operator: {}sec ".format(t4 - t3))
#%%
t5 = timer()
for i in range(100):
Aop1.direct(x1, out = tmp_x1a)
t6 = timer()
print(" Computing direct out using MC operator: {}sec ".format(t6 - t5))
t7 = timer()
for i in range(100):
Aop2.direct(x1, out = tmp_x1b)
t8 = timer()
#np.testing.assert_array_almost_equal(a1.as_array(), a2.as_array())
print(" Computing direct out using ChanWise operator: {}sec ".format(t8 - t7))
#%%
t9 = timer()
for i in range(100):
# a1 = Aop1.adjoint(x2)
Aop1.adjoint(x2, out = tmp_x2a)
t10 = timer()
print(" Computing adjoint out using MC operator: {}sec ".format(t10 - t9))
t11 = timer()
for i in range(100):
# a2 = Aop2.adjoint(x2)
Aop2.adjoint(x2, out = tmp_x2b)
t12 = timer()
#np.testing.assert_array_almost_equal(a1.as_array(), a2.as_array())
print(" Computing adjoint out using ChanWise operator: {}sec ".format(t12 - t11))
#%%
t13 = timer()
for i in range(100):
a1 = Aop1.direct(x1)
t14 = timer()
print(" Computing direct (no out) using MC operator: {}sec ".format(t14 - t13))
t15 = timer()
for i in range(100):
a2 = Aop2.direct(x1)
t16 = timer()
#np.testing.assert_array_almost_equal(a1.as_array(), a2.as_array())
print(" Computing direct (no out) using ChanWise operator: {}sec ".format(t16 - t15))
t17 = timer()
for i in range(100):
a1 = Aop1.adjoint(x2)
t18 = timer()
print(" Computing adjoint (no out) using MC operator: {}sec ".format(t18 - t17))
t19 = timer()
for i in range(100):
a2 = Aop2.adjoint(x2)
t20 = timer()
#np.testing.assert_array_almost_equal(a1.as_array(), a2.as_array())
print(" Computing adjoint (no out) using ChanWise operator: {}sec ".format(t20 - t19))
Operator norm for the Astra3DMC is not working. Because these lines are commented out.
See in the build matrix:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.