Ejemplo n.º 1
0
    def __init__(self, filename=None):
        self.debug_p = False

        self.phantfilename = filename

        # all measurements are in cm
        self.height = 5.
        self.radius = 10.
        self.width = 2. * self.radius
        self.depth = 30.

        # voxel size
        self.dx = 0.05
        self.dy = 0.05
        self.dz = 0.25

        # compute dimensions of phantom, i.e. number of
        # voxels in each direction
        self.dimensions = (int(self.width / self.dx), \
            int((self.height + self.radius) / self.dy), \
            int(self.depth / self.dz))

        # print self.dimensions

        # make a blank phantom
        self.phantom = EGSPhant.EGSPhant(None, self.dimensions[0],
                                         self.dimensions[1],
                                         self.dimensions[2])

        self.phantom.phantfilename = self.phantfilename

        # phantom is just air and water
        self.phantom.nmaterials = 2
        self.phantom.materials = ('AIR700ICRU', 'H2O700ICRU')

        self.phantom.estepe = ones(self.phantom.nmaterials, type=Float32)

        # set the voxel edges
        self.phantom.xedges = zeros(self.phantom.dimensions[0] + 1,
                                    type=Float32)
        self.phantom.yedges = zeros(self.phantom.dimensions[1] + 1,
                                    type=Float32)
        self.phantom.zedges = zeros(self.phantom.dimensions[2] + 1,
                                    type=Float32)

        for i in range(self.phantom.dimensions[0] + 1):
            self.phantom.xedges[i] = -10. + i * self.dx

        for i in range(self.phantom.dimensions[1] + 1):
            self.phantom.yedges[i] = -10. + i * self.dy

        for i in range(self.phantom.dimensions[2] + 1):
            self.phantom.zedges[i] = -15. + i * self.dz

        self.phantom.edges_to_centers()
Ejemplo n.º 2
0
#!/usr/bin/env python2.4

import sys

from egsnrc import EGSPhant

if len(sys.argv) == 1:
    print "Need one argument, name of phantom file to fix"
else:
    try:
        phant = EGSPhant(sys.argv[1])
    except IOError:
        raise

    suffix = '.egsphant'
    phant.fix_density()
    basename = sys.argv[1].split(suffix)[0]
    newname = basename + '_fixed' + suffix
    phant.save(newname)
Ejemplo n.º 3
0
#!/usr/bin/env python
# encoding: utf-8
"""
phant_info.py

Created by David Chin on 2006-07-11.
Copyright (c) 2006 Brigham & Women's Hospital. All rights reserved.
"""

import sys
from egsnrc.EGSPhant import *

if len(sys.argv) == 1:
    print "Need one argument, name of phantom file to fix"
else:
    try:
        phant = EGSPhant(sys.argv[1])
    except IOError:
        raise

    phant.print_info()
Ejemplo n.º 4
0
#!/usr/bin/env python2.4

# $Id: fix_phantom_tissue.py 86 2007-11-12 22:11:40Z dwchin $

from egsnrc.EGSPhant import *

if len(sys.argv) == 1:
    print 'Need name of egsphant file'
    sys.exit(1)

p = EGSPhant(sys.argv[1])

# set the density for tissue and bone voxels 
for k in range(p.dimensions[2]):
    for j in range(p.dimensions[1]):
        for i in range(p.dimensions[0]):
            mat = p.material(p.materialscan[k,j,i])
            if mat == 'ICRUTISSUE700ICRU':
                proper_dens = 1.0
                p.densityscan[k,j,i] = proper_dens
            elif mat == 'ICRPBONE700ICRU': # set to mid-range value
                proper_dens = 0.5 * (p.density[mat][0] + p.density[mat][1])
                p.densityscan[k,j,i] = proper_dens

new_filename = p.phantfilename.split('.egsphant')[0] + '_fixed.egsphant'
p.save(new_filename)

Ejemplo n.º 5
0
#!/usr/bin/env python2.4

import sys

from egsnrc import EGSPhant


if len(sys.argv) == 1:
    print "Need one argument, name of phantom file to fix"
else:
    try:
        phant = EGSPhant(sys.argv[1])
    except IOError:
        raise

    suffix = ".egsphant"
    phant.fix_density()
    basename = sys.argv[1].split(suffix)[0]
    newname = basename + "_fixed" + suffix
    phant.save(newname)
Ejemplo n.º 6
0
#!/usr/bin/env python2.4

# $Id: fix_phantom_tissue.py 86 2007-11-12 22:11:40Z dwchin $

from egsnrc.EGSPhant import *

if len(sys.argv) == 1:
    print 'Need name of egsphant file'
    sys.exit(1)

p = EGSPhant(sys.argv[1])

# set the density for tissue and bone voxels
for k in range(p.dimensions[2]):
    for j in range(p.dimensions[1]):
        for i in range(p.dimensions[0]):
            mat = p.material(p.materialscan[k, j, i])
            if mat == 'ICRUTISSUE700ICRU':
                proper_dens = 1.0
                p.densityscan[k, j, i] = proper_dens
            elif mat == 'ICRPBONE700ICRU':  # set to mid-range value
                proper_dens = 0.5 * (p.density[mat][0] + p.density[mat][1])
                p.densityscan[k, j, i] = proper_dens

new_filename = p.phantfilename.split('.egsphant')[0] + '_fixed.egsphant'
p.save(new_filename)