#!/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)
#!/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)
#!/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)
#!/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)