Skip to content

Commit

Permalink
Fix error caused by bad revert
Browse files Browse the repository at this point in the history
  • Loading branch information
AnderBiguri committed Jan 2, 2019
1 parent 938923b commit ae77094
Show file tree
Hide file tree
Showing 25 changed files with 1,866 additions and 1,865 deletions.
Binary file modified MATLAB/Mex_files/win64/Atb_mex.mexw64
Binary file not shown.
Binary file modified MATLAB/Mex_files/win64/AwminTV.mexw64
Binary file not shown.
Binary file modified MATLAB/Mex_files/win64/Ax_mex.mexw64
Binary file not shown.
Binary file modified MATLAB/Mex_files/win64/minTV.mexw64
Binary file not shown.
Binary file modified MATLAB/Mex_files/win64/tvDenoise.mexw64
Binary file not shown.
9 changes: 5 additions & 4 deletions MATLAB/Source/Siddon_projection.cu
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ int siddon_ray_projection(float const * const img, Geometry geo, float** result,

// Prepare for MultiGPU
int deviceCount = 0;
gpuErrchk(cudaGetDeviceCount(&deviceCount));
cudaGetDeviceCount(&deviceCount);
cudaCheckErrors("Error checking devices");
if (deviceCount == 0) {
mexErrMsgIdAndTxt("Ax:Siddon_projection:GPUselect","There are no available device(s) that support CUDA\n");
}
Expand Down Expand Up @@ -381,7 +382,7 @@ int siddon_ray_projection(float const * const img, Geometry geo, float** result,
cudaDeviceReset();
return 0;
}
void CreateTexture(int num_devices, float* imagedata,Geo geo, cudaTextureObject_t *texImage)
void CreateTexture(int num_devices, float* imagedata,Geometry geo, cudaTextureObject_t *texImage)
{
size_t size_image=geo.nVoxelX*geo.nVoxelY*geo.nVoxelZ;
for (unsigned int i = 0; i < num_devices; i++){
Expand All @@ -402,7 +403,7 @@ void CreateTexture(int num_devices, float* imagedata,Geo geo, cudaTextureObject_
copyParams.extent = make_cudaExtent(geo.nVoxelX,geo.nVoxelY,geo.nVoxelZ);
copyParams.kind = cudaMemcpyHostToDevice;
cudaMemcpy3D(&copyParams);
checkCudaErrors("Texture memory data copy fail");
cudaCheckErrors("Texture memory data copy fail");
//Array creation End

cudaResourceDesc texRes;
Expand All @@ -418,7 +419,7 @@ void CreateTexture(int num_devices, float* imagedata,Geo geo, cudaTextureObject_
texDescr.addressMode[2] = cudaAddressModeBorder;
texDescr.readMode = cudaReadModeElementType;
cudaCreateTextureObject(&texImage[i], &texRes, &texDescr, NULL);
checkCudaErrors("Texture object creation fail");
cudaCheckErrors("Texture object creation fail");
}
}

Expand Down
10 changes: 5 additions & 5 deletions Python/purge.sh
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
72 changes: 36 additions & 36 deletions Python/tests/ipnbdoctest.py
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()
96 changes: 48 additions & 48 deletions Python/tests/test_algorithms.py
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()
164 changes: 82 additions & 82 deletions Python/tests/test_projections.py
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()
Loading

0 comments on commit ae77094

Please sign in to comment.