-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
938923b
commit ae77094
Showing
25 changed files
with
1,866 additions
and
1,865 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
rm -r build dist tigre.egg-info .idea | ||
rm _Ax.so _Atb.so _tvdenoising.so _minTV.so _AwminTV.so | ||
rm tigre/Source/_Ax.cpp tigre/Source/_Atb.cpp tigre/Source/_tvdenoising.cpp tigre/Source/_minTV.cpp tigre/Source/_AwminTV.cpp | ||
#!/bin/bash | ||
|
||
rm -r build dist tigre.egg-info .idea | ||
rm _Ax.so _Atb.so _tvdenoising.so _minTV.so _AwminTV.so | ||
rm tigre/Source/_Ax.cpp tigre/Source/_Atb.cpp tigre/Source/_tvdenoising.cpp tigre/Source/_minTV.cpp tigre/Source/_AwminTV.cpp | ||
pip uninstall tigre |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
import os | ||
import subprocess | ||
import tempfile | ||
|
||
import nbformat | ||
|
||
|
||
def _notebook_run(path): | ||
"""Execute a notebook via nbconvert and collect output. | ||
:returns (parsed nb object, execution errors) | ||
""" | ||
dirname, __ = os.path.split(path) | ||
os.chdir(dirname) | ||
with tempfile.NamedTemporaryFile(suffix=".ipynb") as fout: | ||
args = ["nbconvert", "--to", "notebook", "--execute", | ||
"--ExecutePreprocessor.timeout=60", | ||
"--output", fout.name, path] | ||
subprocess.check_call(args) | ||
|
||
fout.seek(0) | ||
nb = nbformat.read(fout, nbformat.current_nbformat) | ||
|
||
errors = [output for cell in nb.cells if "outputs" in cell | ||
for output in cell["outputs"] \ | ||
if output.output_type == "error"] | ||
|
||
return nb, errors | ||
|
||
|
||
def test_ipynb(): | ||
nb, errors = _notebook_run('../tigre/demos/d01_create_geometry.ipynb') | ||
assert errors == [] | ||
|
||
|
||
if __name__ == '__main__': | ||
test_ipynb() | ||
import os | ||
import subprocess | ||
import tempfile | ||
|
||
import nbformat | ||
|
||
|
||
def _notebook_run(path): | ||
"""Execute a notebook via nbconvert and collect output. | ||
:returns (parsed nb object, execution errors) | ||
""" | ||
dirname, __ = os.path.split(path) | ||
os.chdir(dirname) | ||
with tempfile.NamedTemporaryFile(suffix=".ipynb") as fout: | ||
args = ["nbconvert", "--to", "notebook", "--execute", | ||
"--ExecutePreprocessor.timeout=60", | ||
"--output", fout.name, path] | ||
subprocess.check_call(args) | ||
|
||
fout.seek(0) | ||
nb = nbformat.read(fout, nbformat.current_nbformat) | ||
|
||
errors = [output for cell in nb.cells if "outputs" in cell | ||
for output in cell["outputs"] \ | ||
if output.output_type == "error"] | ||
|
||
return nb, errors | ||
|
||
|
||
def test_ipynb(): | ||
nb, errors = _notebook_run('../tigre/demos/d01_create_geometry.ipynb') | ||
assert errors == [] | ||
|
||
|
||
if __name__ == '__main__': | ||
test_ipynb() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
from __future__ import division | ||
import unittest | ||
import tigre | ||
from tigre.utilities.Ax import Ax | ||
import numpy as np | ||
from tigre.algorithms.iterative_recon_alg import IterativeReconAlg | ||
import tigre.algorithms as algs | ||
class AlgorithmsTestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
geo = tigre.geometry() | ||
geo.DSD = 1536 | ||
geo.DSO = 1000 | ||
geo.nDetector = np.array((128, 127)) | ||
geo.dDetector = np.array((0.8, 0.8)) * 4. | ||
geo.sDetector = geo.nDetector * geo.dDetector | ||
geo.nVoxel = np.array((63, 62, 61)) | ||
geo.sVoxel = np.array((256, 256, 256)) | ||
geo.dVoxel = geo.sVoxel / geo.nVoxel | ||
geo.offOrigin = np.array((0, 0, 0)) | ||
geo.offDetector = np.array((0, 0)) | ||
geo.accuracy = 0.5 | ||
geo.mode = 'cone' | ||
self.angles = np.linspace(0, 2 * np.pi, 100, dtype=np.float32) | ||
self.geo = geo | ||
self.img = np.ones((63, 62, 61), dtype=np.float32) | ||
self.proj = Ax(self.img,self.geo,self.angles) | ||
self.niter=2 | ||
def test_mainiter_itrecalg(self): | ||
alg = IterativeReconAlg(self.proj,self.geo,self.angles,self.niter,**dict(verbose=False)) | ||
self.assertIsNone(alg.run_main_iter()) | ||
|
||
def test_shape_sart(self): | ||
self.assertTupleEqual(tigre.algorithms.sart(self.proj,self.geo,self.angles,niter=1).shape, | ||
tuple(self.geo.nVoxel)) | ||
def test_shape_sirt(self): | ||
self.assertTupleEqual(tigre.algorithms.sirt(self.proj,self.geo,self.angles,niter=1).shape, | ||
tuple(self.geo.nVoxel)) | ||
def test_shape_ossart(self): | ||
self.assertTupleEqual(tigre.algorithms.sirt(self.proj,self.geo,self.angles,niter=1).shape, | ||
tuple(self.geo.nVoxel)) | ||
def test_shape_asdpocs(self): | ||
self.assertTupleEqual(algs.asd_pocs(self.proj,self.geo,self.angles,niter=1).shape, | ||
tuple(self.geo.nVoxel)) | ||
def test_shape_awasdpocs(self): | ||
self.assertTupleEqual(algs.awasd_pocs(self.proj,self.geo,self.angles,niter=1).shape, | ||
tuple(self.geo.nVoxel)) | ||
if __name__=='__main__': | ||
from __future__ import division | ||
import unittest | ||
import tigre | ||
from tigre.utilities.Ax import Ax | ||
import numpy as np | ||
from tigre.algorithms.iterative_recon_alg import IterativeReconAlg | ||
import tigre.algorithms as algs | ||
class AlgorithmsTestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
geo = tigre.geometry() | ||
geo.DSD = 1536 | ||
geo.DSO = 1000 | ||
geo.nDetector = np.array((128, 127)) | ||
geo.dDetector = np.array((0.8, 0.8)) * 4. | ||
geo.sDetector = geo.nDetector * geo.dDetector | ||
geo.nVoxel = np.array((63, 62, 61)) | ||
geo.sVoxel = np.array((256, 256, 256)) | ||
geo.dVoxel = geo.sVoxel / geo.nVoxel | ||
geo.offOrigin = np.array((0, 0, 0)) | ||
geo.offDetector = np.array((0, 0)) | ||
geo.accuracy = 0.5 | ||
geo.mode = 'cone' | ||
self.angles = np.linspace(0, 2 * np.pi, 100, dtype=np.float32) | ||
self.geo = geo | ||
self.img = np.ones((63, 62, 61), dtype=np.float32) | ||
self.proj = Ax(self.img,self.geo,self.angles) | ||
self.niter=2 | ||
def test_mainiter_itrecalg(self): | ||
alg = IterativeReconAlg(self.proj,self.geo,self.angles,self.niter,**dict(verbose=False)) | ||
self.assertIsNone(alg.run_main_iter()) | ||
|
||
def test_shape_sart(self): | ||
self.assertTupleEqual(tigre.algorithms.sart(self.proj,self.geo,self.angles,niter=1).shape, | ||
tuple(self.geo.nVoxel)) | ||
def test_shape_sirt(self): | ||
self.assertTupleEqual(tigre.algorithms.sirt(self.proj,self.geo,self.angles,niter=1).shape, | ||
tuple(self.geo.nVoxel)) | ||
def test_shape_ossart(self): | ||
self.assertTupleEqual(tigre.algorithms.sirt(self.proj,self.geo,self.angles,niter=1).shape, | ||
tuple(self.geo.nVoxel)) | ||
def test_shape_asdpocs(self): | ||
self.assertTupleEqual(algs.asd_pocs(self.proj,self.geo,self.angles,niter=1).shape, | ||
tuple(self.geo.nVoxel)) | ||
def test_shape_awasdpocs(self): | ||
self.assertTupleEqual(algs.awasd_pocs(self.proj,self.geo,self.angles,niter=1).shape, | ||
tuple(self.geo.nVoxel)) | ||
if __name__=='__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,82 @@ | ||
import unittest | ||
from tigre.utilities.geometry import geometry | ||
from tigre.utilities.Ax import Ax | ||
from tigre.utilities.Atb import Atb | ||
import numpy as np | ||
|
||
class ProjectionTestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
geo = geometry() | ||
geo.DSD = 1536 | ||
geo.DSO = 1000 | ||
geo.nDetector = np.array((128, 127)) | ||
geo.dDetector = np.array((0.8, 0.8)) * 4 | ||
geo.sDetector = geo.nDetector * geo.dDetector | ||
geo.nVoxel = np.array((63, 62, 61)) | ||
geo.sVoxel = np.array((256, 256, 256)) | ||
geo.dVoxel = geo.sVoxel / geo.nVoxel | ||
geo.offOrigin = np.array((0, 0, 0)) | ||
geo.offDetector = np.array((0, 0)) | ||
geo.accuracy = 0.5 | ||
geo.mode = 'cone' | ||
self.angles = np.linspace(0, 2 * np.pi, 100, dtype=np.float32) | ||
self.geo = geo | ||
self.img = np.ones((63, 62, 61), dtype=np.float32) | ||
self.proj = Ax(self.img,self.geo,self.angles) | ||
def test_geo(self): | ||
self.assertIsNone(self.geo.check_geo(self.angles)) | ||
|
||
def test_proj_interpolated_shape(self): | ||
img = self.img | ||
self.assertTupleEqual(Ax(img,self.geo,self.angles,'interpolated').shape,(100,128,127)) | ||
|
||
def test_proj_ray_voxel_shape(self): | ||
self.assertTupleEqual(Ax(self.img,self.geo,self.angles,'ray-voxel').shape,(100,128,127)) | ||
|
||
def test_proj_parallel_interpolated_shape(self): | ||
setattr(self.geo,'mode','parallel') | ||
self.assertTupleEqual(Ax(self.img,self.geo,self.angles,'interpolated').shape,(100,128,127)) | ||
|
||
def test_proj_parallel_ray_voxel_shape(self): | ||
setattr(self.geo,'mode','parallel') | ||
self.assertTupleEqual(Ax(self.img,self.geo,self.angles,'ray-voxel').shape,(100,128,127)) | ||
|
||
def test_backproj_matched_cone_shape(self): | ||
setattr(self.geo,'mode','cone') | ||
self.assertTupleEqual(Atb(self.proj,self.geo,self.angles,'matched').shape,(63,62,61)) | ||
|
||
def test_backproj_FDK_cone_shape(self): | ||
setattr(self.geo,'mode','cone') | ||
self.assertTupleEqual(Atb(self.proj, self.geo, self.angles, 'FDK').shape, (63, 62, 61)) | ||
|
||
def test_backproj_parallel_shape(self): | ||
setattr(self.geo,'mode','parallel') | ||
self.assertTupleEqual(Atb(self.proj, self.geo, self.angles,'matched').shape, (63, 62, 61)) | ||
|
||
def test_backproj_matched_cone_spherical_shape(self): | ||
setattr(self.geo,'mode','cone') | ||
angles_1 = self.angles | ||
angles_2 = np.ones((len(angles_1)),dtype=np.float32)*np.array([np.pi/4],dtype=np.float32) | ||
angles_3 = np.zeros((len(angles_1)),dtype=np.float32) | ||
new_angles = np.vstack((angles_1,angles_2,angles_3)).T | ||
self.assertTupleEqual(Atb(self.proj, self.geo, new_angles,'matched').shape, (63, 62, 61)) | ||
|
||
def test_backproj_FDK_cone_spherical_shape(self): | ||
setattr(self.geo,'mode','cone') | ||
angles_1 = self.angles | ||
angles_2 = np.ones((len(angles_1)), dtype=np.float32) * np.array([np.pi / 4], dtype=np.float32) | ||
angles_3 = np.zeros((len(angles_1)), dtype=np.float32) | ||
new_angles = np.vstack((angles_1, angles_2, angles_3)).T | ||
self.assertTupleEqual(Atb(self.proj, self.geo, new_angles,'FDK').shape, (63, 62, 61)) | ||
|
||
def test_backproj_parallel_spherical_shape(self): | ||
setattr(self.geo,'mode','parallel') | ||
angles_1 = self.angles | ||
angles_2 = np.ones((len(angles_1)), dtype=np.float32) * np.array([np.pi / 4], dtype=np.float32) | ||
angles_3 = np.zeros((len(angles_1)), dtype=np.float32) | ||
new_angles = np.vstack((angles_1, angles_2, angles_3)).T | ||
self.assertTupleEqual(Atb(self.proj, self.geo, new_angles).shape, (63, 62, 61)) | ||
|
||
if __name__=='__main__': | ||
unittest.main() | ||
import unittest | ||
from tigre.utilities.geometry import geometry | ||
from tigre.utilities.Ax import Ax | ||
from tigre.utilities.Atb import Atb | ||
import numpy as np | ||
|
||
class ProjectionTestCase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
geo = geometry() | ||
geo.DSD = 1536 | ||
geo.DSO = 1000 | ||
geo.nDetector = np.array((128, 127)) | ||
geo.dDetector = np.array((0.8, 0.8)) * 4 | ||
geo.sDetector = geo.nDetector * geo.dDetector | ||
geo.nVoxel = np.array((63, 62, 61)) | ||
geo.sVoxel = np.array((256, 256, 256)) | ||
geo.dVoxel = geo.sVoxel / geo.nVoxel | ||
geo.offOrigin = np.array((0, 0, 0)) | ||
geo.offDetector = np.array((0, 0)) | ||
geo.accuracy = 0.5 | ||
geo.mode = 'cone' | ||
self.angles = np.linspace(0, 2 * np.pi, 100, dtype=np.float32) | ||
self.geo = geo | ||
self.img = np.ones((63, 62, 61), dtype=np.float32) | ||
self.proj = Ax(self.img,self.geo,self.angles) | ||
def test_geo(self): | ||
self.assertIsNone(self.geo.check_geo(self.angles)) | ||
|
||
def test_proj_interpolated_shape(self): | ||
img = self.img | ||
self.assertTupleEqual(Ax(img,self.geo,self.angles,'interpolated').shape,(100,128,127)) | ||
|
||
def test_proj_ray_voxel_shape(self): | ||
self.assertTupleEqual(Ax(self.img,self.geo,self.angles,'ray-voxel').shape,(100,128,127)) | ||
|
||
def test_proj_parallel_interpolated_shape(self): | ||
setattr(self.geo,'mode','parallel') | ||
self.assertTupleEqual(Ax(self.img,self.geo,self.angles,'interpolated').shape,(100,128,127)) | ||
|
||
def test_proj_parallel_ray_voxel_shape(self): | ||
setattr(self.geo,'mode','parallel') | ||
self.assertTupleEqual(Ax(self.img,self.geo,self.angles,'ray-voxel').shape,(100,128,127)) | ||
|
||
def test_backproj_matched_cone_shape(self): | ||
setattr(self.geo,'mode','cone') | ||
self.assertTupleEqual(Atb(self.proj,self.geo,self.angles,'matched').shape,(63,62,61)) | ||
|
||
def test_backproj_FDK_cone_shape(self): | ||
setattr(self.geo,'mode','cone') | ||
self.assertTupleEqual(Atb(self.proj, self.geo, self.angles, 'FDK').shape, (63, 62, 61)) | ||
|
||
def test_backproj_parallel_shape(self): | ||
setattr(self.geo,'mode','parallel') | ||
self.assertTupleEqual(Atb(self.proj, self.geo, self.angles,'matched').shape, (63, 62, 61)) | ||
|
||
def test_backproj_matched_cone_spherical_shape(self): | ||
setattr(self.geo,'mode','cone') | ||
angles_1 = self.angles | ||
angles_2 = np.ones((len(angles_1)),dtype=np.float32)*np.array([np.pi/4],dtype=np.float32) | ||
angles_3 = np.zeros((len(angles_1)),dtype=np.float32) | ||
new_angles = np.vstack((angles_1,angles_2,angles_3)).T | ||
self.assertTupleEqual(Atb(self.proj, self.geo, new_angles,'matched').shape, (63, 62, 61)) | ||
|
||
def test_backproj_FDK_cone_spherical_shape(self): | ||
setattr(self.geo,'mode','cone') | ||
angles_1 = self.angles | ||
angles_2 = np.ones((len(angles_1)), dtype=np.float32) * np.array([np.pi / 4], dtype=np.float32) | ||
angles_3 = np.zeros((len(angles_1)), dtype=np.float32) | ||
new_angles = np.vstack((angles_1, angles_2, angles_3)).T | ||
self.assertTupleEqual(Atb(self.proj, self.geo, new_angles,'FDK').shape, (63, 62, 61)) | ||
|
||
def test_backproj_parallel_spherical_shape(self): | ||
setattr(self.geo,'mode','parallel') | ||
angles_1 = self.angles | ||
angles_2 = np.ones((len(angles_1)), dtype=np.float32) * np.array([np.pi / 4], dtype=np.float32) | ||
angles_3 = np.zeros((len(angles_1)), dtype=np.float32) | ||
new_angles = np.vstack((angles_1, angles_2, angles_3)).T | ||
self.assertTupleEqual(Atb(self.proj, self.geo, new_angles).shape, (63, 62, 61)) | ||
|
||
if __name__=='__main__': | ||
unittest.main() |
Oops, something went wrong.