Skip to content

Commit

Permalink
Merge pull request #1 from tomography/master
Browse files Browse the repository at this point in the history
resync
  • Loading branch information
decarlof committed Sep 16, 2016
2 parents 774056b + 7df28f4 commit 6181471
Show file tree
Hide file tree
Showing 21 changed files with 2,781 additions and 366 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var/
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
commit_hash.txt

# Unit test / coverage reports
htmlcov/
Expand Down
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ os:

sudo: false

before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start

before_install:
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

267 changes: 267 additions & 0 deletions docs/demos/NEQ.ipynb

Large diffs are not rendered by default.

131 changes: 131 additions & 0 deletions docs/demos/Shepp.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Simple Phantom Construction Demo"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Import tomography/xdesign."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from xdesign import *"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create various `Features` with geometries. Assign attenuation `values` to each of the `Features`. Plot the `Phantom`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"head = Feature(Circle(Point(0.5, 0.5), radius=0.5))\n",
"head.mass_atten = 1\n",
"eyeL = Feature(Circle(Point(0.3, 0.5), radius=0.1))\n",
"eyeL.mass_atten = 1\n",
"eyeR = Feature(Circle(Point(0.7, 0.5), radius=0.1))\n",
"eyeR.mass_atten = 1\n",
"mouth = Feature(Triangle(Point(0.2, 0.7), Point(0.5, 0.8), Point(0.8, 0.7)))\n",
"mouth.mass_atten = -1\n",
"\n",
"Shepp = Phantom()\n",
"Shepp.append(head)\n",
"Shepp.append(eyeL)\n",
"Shepp.append(eyeR)\n",
"Shepp.append(mouth)\n",
"\n",
"sidebyside(Shepp, size=100, labels=True)\n",
"plt.savefig('Shepp_sidebyside.png', dpi=600,\n",
" orientation='landscape', papertype=None, format=None,\n",
" transparent=True, bbox_inches='tight', pad_inches=0.0,\n",
" frameon=False)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Simulate data acquisition for parallel beam around 180 degrees."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"sx, sy = 100, 100\n",
"step = 1. / sy\n",
"prb = Probe(Point(step / 2., -10), Point(step / 2., 10), step)\n",
"theta = np.pi / sx\n",
"sino = np.zeros(sx * sy)\n",
"a = 0\n",
"for m in range(sx):\n",
" for n in range(sy):\n",
" update_progress((m*sy + n)/(sx*sy))\n",
" sino[a] = prb.measure(Shepp)\n",
" a += 1\n",
" prb.translate(step)\n",
" prb.translate(-1)\n",
" prb.rotate(theta, Point(0.5, 0.5))\n",
"update_progress(1)\n",
"\n",
"plt.figure(figsize=(8, 8))\n",
"plt.imshow(np.reshape(sino, (sx, sy)), cmap='inferno', interpolation='nearest')\n",
"plt.savefig('Shepp_sinogram.png', dpi=600,\n",
" orientation='landscape', papertype=None, format=None,\n",
" transparent=True, bbox_inches='tight', pad_inches=0.0,\n",
" frameon=False)\n",
"plt.show()"
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
335 changes: 335 additions & 0 deletions docs/demos/Soil.ipynb

Large diffs are not rendered by default.

263 changes: 263 additions & 0 deletions docs/demos/StandardPatterns.ipynb

Large diffs are not rendered by default.

288 changes: 288 additions & 0 deletions docs/demos/WetCircles.ipynb

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@
# #########################################################################

import setuptools
from version_hashtag import append_dev_info

version_info = (0, 1, 0)
version = '.'.join([str(x) for x in version_info])
version = append_dev_info(version)
with open('VERSION', 'w') as f:
f.write(version)

setuptools.setup(
name='xdesign',
version=open('VERSION').read().strip(),
version=version,
author='Doga Gursoy',
description='Benchmarking and optimization tools for tomography.',
packages=setuptools.find_packages(exclude=['docs']),
Expand All @@ -72,6 +79,6 @@
'Topic :: Software Development :: Libraries',
'Intended Audience :: Science/Research',
'Intended Audience :: Education',
'Intended Audience :: Developers',
],
'Intended Audience :: Developers'
]
)
39 changes: 38 additions & 1 deletion tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from xdesign.geometry import *
from xdesign.geometry import beamcirc
from xdesign.acquisition import *
from numpy.testing import assert_allclose, assert_raises
from numpy.testing import assert_allclose, assert_raises, assert_equal
import numpy as np


Expand Down Expand Up @@ -174,6 +174,43 @@ def test_Circle_area():
assert_allclose(circle.area, 3.14159265359, rtol=1e-6)


def test_Mesh_area():
p5 = Point(0, 0)
p1 = Point(1, 1)
p4 = Point(1, -1)
p3 = Point(-1, -1)
p2 = Point(-1, 1)
m = Mesh()
assert_equal(m.area, 0)
m.append(Triangle(p5, p1, p2))
m.append(Triangle(p5, p2, p3))
m.append(Triangle(p5, p3, p4))
m.append(Triangle(p5, p4, p1))
assert_equal(m.area, 4)


def test_Mesh_center():
p5 = Point(0, 0)
p1 = Point(1, 1)
p4 = Point(1, -1)
p3 = Point(-1, -1)
p2 = Point(-1, 1)
m = Mesh()
assert_equal(m.center, Point(0, 0))

m.append(Triangle(p5, p1, p2))
m.append(Triangle(p5, p2, p3))
m.append(Triangle(p5, p3, p4))
m.append(Triangle(p5, p4, p1))
assert_equal(m.center, Point(0, 0))

m.pop()
m.pop()
m.pop()
m.pop()
assert_equal(m.center, Point(0, 0))


if __name__ == '__main__':
import nose
nose.runmodule(exit=False)
19 changes: 11 additions & 8 deletions tests/test_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import numpy as np
import scipy
import matplotlib.pyplot as plt
import warnings

__author__ = "Daniel Ching"
__copyright__ = "Copyright (c) 2016, UChicago Argonne, LLC."
Expand All @@ -72,11 +73,11 @@ def _plot_both(ref, target):
def test_HyperbolicCocentric():
p0 = Phantom()
p0.load('tests/HyperbolicConcentric.txt')
ref = p0.discrete(200, uniform=False)
ref = discrete_phantom(p0, 200, uniform=False)

np.random.seed(0)
p = HyperbolicConcentric()
target = p.discrete(200, uniform=False)
target = discrete_phantom(p, 200, uniform=False)

# _plot_both(ref, target)
assert_equal(target, ref,
Expand All @@ -87,35 +88,37 @@ def test_DynamicRange():
for i in range(0, 2):
p0 = Phantom()
p0.load('tests/DynamicRange'+str(i)+'.txt')
ref = p0.discrete(100)
ref = discrete_phantom(p0, 100)

np.random.seed(0)
p = DynamicRange(jitter=i)
target = p.discrete(100)
target = discrete_phantom(p, 100)
# _plot_both(ref, target)
assert_equal(target, ref, "Default DynamicRange" + str(i) +
" phantom has changed.")


def test_Soil():
warnings.filterwarnings("ignore", "Reached*", RuntimeWarning)
p0 = Phantom()
p0.load('tests/Soil.txt')
ref = p0.discrete(100)
ref = discrete_phantom(p0, 100)

np.random.seed(0)
p = Soil()
target = p.discrete(100)
target = discrete_phantom(p, 100)
# _plot_both(ref, target)
assert_equal(target, ref, "Default Soil phantom has changed.")


def test_Foam():
warnings.filterwarnings("ignore", "Reached*", RuntimeWarning)
p0 = Phantom()
p0.load('tests/Foam.txt')
ref = p0.discrete(100)
ref = discrete_phantom(p0, 100)

np.random.seed(0)
p = Foam()
target = p.discrete(100)
target = discrete_phantom(p, 100)
# _plot_both(ref, target)
assert_equal(target, ref, "Default Foam phantom has changed.")

0 comments on commit 6181471

Please sign in to comment.