Import Occiput:


In [1]:
import occiput
occiput.initialise()

from occiput.Reconstruction.PET import PET_Static_Scan, Binning
from occiput.Reconstruction.PET import PET_Interface_mMR
from occiput.DataSources.Synthetic import uniform_sphere, uniform_spheres_ring

import numpy


Define scanner geometry:


In [8]:
# Geometry of the scanner: 

N_axial                = 252                 # number of axial projections 
N_azimuthal            = 1                   # number of azimuthal projections
angular_step_axial     = numpy.pi/N_axial    # radians
angular_step_azimuthal = 0.0                 # radians
N_u                    = 200                 # voxels
N_v                    = 128                 # voxels
size_u                 = 200                 # [mm]
size_v                 = 128                 # [mm]
interface              = PET_Interface_mMR()
binning                = Binning([N_axial, N_azimuthal, angular_step_axial, angular_step_azimuthal, size_u, size_v, N_u, N_v]) 


# Static acquisition: 

SCAN    = PET_Static_Scan()
SCAN.set_interface(interface) 
SCAN.set_binning(binning) 


# Full sampling (all detector pixels are active): 

SCAN.set_full_sampling() 


# Parameters of the projection and backprojection algorithms: 

SCAN.projection_parameters.sample_step     = 0.8
SCAN.projection_parameters.N_samples       = 256
SCAN.backprojection_parameters.sample_step = 0.8
SCAN.backprojection_parameters.N_samples   = 256
SCAN.projection_parameters.direction       = 7

Generate synthetic data:


In [9]:
# Number of voxels of the synthetic activity volume: 

phantom_voxels_x       = 128                       # voxels
phantom_voxels_y       = 128                       # voxels
phantom_voxels_z       = 128                       # voxels


# Size of the synthetic activity volume in [mm] 

phantom_size_x         = 128                       # [mm]
phantom_size_y         = 128                       # [mm]
phantom_size_z         = 128                       # [mm]


# Center of the synthetic activity volume in [mm]

phantom_center_x       = 0.5  * phantom_size_x     # [mm]
phantom_center_y       = 0.5  * phantom_size_y     # [mm]
phantom_center_z       = 0.5  * phantom_size_z     # [mm]


# Synthetic activity parameters: 

phantom_n_spheres      = 6                         # number of spheres
phantom_ring_radius    = 0.4  * phantom_size_x     # radius of the ring of spheres  [mm]
phantom_small_radius   = 0.04 * phantom_size_z     # radius of the smallest spheres [mm]
phantom_large_radius   = 0.10 * phantom_size_z     # radius of the largest sphere   [mm]
phantom_value          = 10.0                      # activity inside the spheres
phantom_background     = 0.25                      # activity outside the spheres 
phantom_ring_axis      = 2                         # axis of the ring of spheres : 0 for X, 1 for Y, 2 for Z 
phantom_extrusion      = 0.6  * phantom_size_z     # extrusion along axis           [mm] 


# Make the synthetic activity volume: 

#phantom = occiput.DataSources.Synthetic.uniform_sphere([128,128,128],[128,128,128],[64,64,64],20,2,0)

phantom = uniform_spheres_ring(  [phantom_voxels_x, phantom_voxels_y, phantom_voxels_z], 
                                 [phantom_size_x,   phantom_size_y,   phantom_size_z  ], 
                                 [phantom_center_x, phantom_center_y, phantom_center_z], 
                                  phantom_ring_radius, phantom_small_radius, phantom_large_radius, 
                                  phantom_n_spheres, phantom_value, phantom_background, phantom_extrusion, phantom_ring_axis)

In [10]:
phantom


Out[10]:

Projection:


In [11]:
# Compute projection: 
SCAN.activity_shape = [phantom_voxels_x,phantom_voxels_y,phantom_voxels_z]
SCAN.activity_size  = [phantom_size_x,phantom_size_y,phantom_size_z]

proj = SCAN.project(phantom.data); 


# Uncompress the projection data and visualize it: 

SCAN.uncompress(proj)


Out[11]:

In [11]:


In [11]:


In [11]:


In [11]:

Backprojection:


In [12]:
SCAN.volume_render(phantom,scale=1)


Out[12]:

In [13]:
# Backproject: 
SCAN.backprojection_parameters.direction=7

bkpr = SCAN.backproject(proj)

In [14]:
# Visualise the back-projection and the synthetic activity: 

occiput.Visualization.MultipleVolumes([phantom,bkpr],axis=0)


Out[14]:

In [15]:
SCAN.set_measurement_data(proj)

In [29]:
A = SCAN.estimate_activity(iterations=20, subset_size=16)


Iteration: 0    max act: 1.771270    min act: 0.000000    max proj: 0.871094    min proj: 0.000000    max norm: 16.000000    min norm: 7.066406
Iteration: 1    max act: 8353.044922    min act: 0.000000    max proj: 0.463008    min proj: 0.000000    max norm: 16.000000    min norm: 6.750000
Iteration: 2    max act: 37797772.000000    min act: 0.000000    max proj: 655.650208    min proj: 0.000000    max norm: 16.000000    min norm: 6.312500
Iteration: 3    max act: 349963354112.000000    min act: 0.000000    max proj: 953844.312500    min proj: 0.000000    max norm: 16.000000    min norm: 7.656250
Iteration: 4    max act: 1316840462614528.000000    min act: 0.000000    max proj: 3637050624.000000    min proj: 0.000000    max norm: 16.000000    min norm: 7.074219
Iteration: 5    max act: 10034298146223292416.000000    min act: 0.000000    max proj: 12483428352000.000000    min proj: 0.000000    max norm: 16.000000    min norm: 6.691406
Iteration: 6    max act: 67698546447797150810112.000000    min act: 0.000000    max proj: 76762765070434304.000000    min proj: 0.000000    max norm: 16.000000    min norm: 6.527344
Iteration: 7    max act: 206649484465034588592275456.000000    min act: 0.000000    max proj: 343101706246012534784.000000    min proj: 0.000000    max norm: 16.000000    min norm: 6.394531
Iteration: 8    max act: 820169957086014626795119181824.000000    min act: 0.000000    max proj: 1344615024989253981437952.000000    min proj: 0.000000    max norm: 16.000000    min norm: 6.562500
Iteration: 9    max act: 2349180938855029556148216505827328.000000    min act: 0.000000    max proj: 6407529385478039857973428224.000000    min proj: 0.000000    max norm: 16.000000    min norm: 7.218750
Iteration: 10    max act: 15080757483687158462433709287140229120.000000    min act: 0.000000    max proj: 12947559260298090022227903774720.000000    min proj: 0.000000    max norm: 16.000000    min norm: 6.601562
/Users/spedemon/.virtualenvs/ipy/lib/python2.7/site-packages/occiput-0.1.0-py2.7.egg/occiput/Reconstruction/PET/PET.py:713: RuntimeWarning: overflow encountered in multiply
  activity = activity * update * self.get_mask().data
Iteration: 11    max act: inf    min act: 0.000000    max proj: 99181903989245896696026583737040896.000000    min proj: 0.000000    max norm: 16.000000    min norm: 6.863281
Iteration: 12    max act: inf    min act: 0.000000    max proj: inf    min proj: 0.000000    max norm: 16.000000    min norm: 6.550781
Iteration: 13    max act: inf    min act: 0.000000    max proj: inf    min proj: 0.000000    max norm: 16.000000    min norm: 6.832031
Iteration: 14    max act: inf    min act: 0.000000    max proj: inf    min proj: 0.000000    max norm: 16.000000    min norm: 7.226562
Iteration: 15    max act: inf    min act: 0.000000    max proj: inf    min proj: 0.000000    max norm: 16.000000    min norm: 6.757812
Iteration: 16    max act: inf    min act: 0.000000    max proj: inf    min proj: 0.000000    max norm: 16.000000    min norm: 5.707031
Iteration: 17    max act: inf    min act: 0.000000    max proj: inf    min proj: 0.000000    max norm: 16.000000    min norm: 7.226562
Iteration: 18    max act: inf    min act: 0.000000    max proj: inf    min proj: 0.000000    max norm: 16.000000    min norm: 4.062500
Iteration: 19    max act: inf    min act: 0.000000    max proj: inf    min proj: 0.000000    max norm: 16.000000    min norm: 6.382812

In [30]:
SCAN.volume_render(A,scale=0.5)


/Users/spedemon/.virtualenvs/ipy/lib/python2.7/site-packages/mMR-0.1.0-py2.7-macosx-10.9-intel.egg/mMR/mMR.py:461: RuntimeWarning: invalid value encountered in multiply
  a = scale*(a)
Out[30]:

In [11]:


In [11]:


In [11]:


In [24]:


In [31]:
bkpr.shape


Out[31]:
(128, 128, 128)

In [11]:


In [12]:


In [ ]:


In [ ]:


In [12]:


In [16]:


In [16]:


In [16]:


In [16]:


In [16]:


In [16]:


In [16]:


In [16]:


In [ ]: