示例#1
0
	def makemask(self):
		for i in range(1,len(self.mask)):
			mask = copy.deepcopy(self.mask)
			mask[i][-1] = "gray=1001"
			#tableio.print2d(mask)
			maskfile = self.maskfile.replace("000",str(i))
			maskimagefile = self.maskimagefile.replace("000",str(i))
			tableio.write(mask,maskfile)
			print "Your maskfile was saved as",maskfile
			call(["rtkdrawgeometricphantom","--phantomfile",maskfile,"--dimension",self.sizeinvox,"--spacing",self.spacingstr,"--output",maskimagefile])
			call(["clitkCropImage","-i",maskimagefile,"-o",maskimagefile,"--BG=-1000"])
			call(["clitkBinarizeImage","-i",maskimagefile,"-o",maskimagefile,"-l","0.5","-u","1.5"]) #the intensity egion that is 1, and not 0
			#call(["clitkImageConvert","-i",maskimagefile,"-o",maskimagefile,"-c"])
			print "Your mask was saved as",maskimagefile
示例#2
0
 def makemask(self):
     for i in range(1, len(self.mask)):
         mask = copy.deepcopy(self.mask)
         mask[i][-1] = "gray=1001"
         #tableio.print2d(mask)
         maskfile = self.maskfile.replace("000", str(i))
         maskimagefile = self.maskimagefile.replace("000", str(i))
         tableio.write(mask, maskfile)
         print "Your maskfile was saved as", maskfile
         call([
             "rtkdrawgeometricphantom", "--phantomfile", maskfile,
             "--dimension", self.sizeinvox, "--spacing", self.spacingstr,
             "--output", maskimagefile
         ])
         call([
             "clitkCropImage", "-i", maskimagefile, "-o", maskimagefile,
             "--BG=-1000"
         ])
         call([
             "clitkBinarizeImage", "-i", maskimagefile, "-o", maskimagefile,
             "-l", "0.5", "-u", "1.5"
         ])  #the intensity egion that is 1, and not 0
         #call(["clitkImageConvert","-i",maskimagefile,"-o",maskimagefile,"-c"])
         print "Your mask was saved as", maskimagefile
        for haha in ['iba', 'ipnl']:
            if (haha + 'lyso' in line
                    or haha + 'bgo' in line) and haha + '-' in typ:
                print(haha, line, typ)
                ctsetsets.append(
                    auger.getctset(numprot,
                                   line[2:10],
                                   line[2:10],
                                   typ,
                                   addnoise=addnoise,
                                   precolli=precolli))
            if haha + 'zinv' in line and haha + '-' in typ:
                print(haha, line, typ)
                ctsetsets.append(
                    auger.getctset(numprot,
                                   line[2:10],
                                   line[2:10],
                                   typ,
                                   addnoise=addnoise,
                                   precolli=precolli))
    assert (len(ctsetsets) == 3)
    megaplot(ctsetsets, 'PMMA_phantom')
    print 'Mean detection yield in', typ, 'study over', sum(
        [ctset['totnprim'] for ctset in ctsetsets]), 'primaries in', sum([
            ctset['nreal'] for ctset in ctsetsets
        ]), 'realisations:', sum([ctset['detyieldmu'] for ctset in ctsetsets])

tableio.print2d(resultstable)
tableio.write(resultstable, 'resultstable.tsv')
示例#4
0
	def writedensityfile(self,filename):
		tableio.write(self.density,filename)
示例#5
0
	def writephantomfile(self,filename):
		tableio.write(self.phantom,filename)
示例#6
0
 def writephantomfile(self, filename):
     tableio.write(self.phantom, filename)
示例#7
0
 def writedensityfile(self, filename):
     tableio.write(self.density, filename)
示例#8
0
parser.add_argument('--dump', action='store_true')
parser.add_argument('--scatter', action='store_true')
parser.add_argument('files', nargs='*')  # This is it!!
args = parser.parse_args()

if len(args.files)<1:
    print "no files given or found. exiting..."
    quit()
print "openening",args.files

rtplan = rtplan.rtplan(args.files,norm2nprim=(not args.nonorm),MSWtoprotons=(not args.nomu),noproc=(args.noproc))

outname = args.files[0][:-4]+('nonorm' if args.nonorm else '')+('nomu' if args.nomu else '')+('noproc' if args.noproc else '')+('scatter' if args.scatter else '')+'-plot.pdf'

if args.dump:
    write(rtplan.spots,outname+'spots.txt')
    write(rtplan.layers,outname+'layers.txt')
    write(rtplan.fields,outname+'fields.txt')

spotdata=rtplan.getspotdata()
layerdata=rtplan.getlayerdata()

MSW=[]
for spot in rtplan.spots:
    MSW.append(spot[-1])

#spot_weight_mean = np.median(MSW)
spot_weight_mean = np.mean(MSW)

nrfields=len(rtplan.fields)
	'ipnl-auger-tof-1.root',
	'iba-auger-tof-1.root',
	'ipnl-auger-notof-1.root',
	'iba-auger-notof-1.root',
	'ipnl-auger-tof-3.root',
	'iba-auger-tof-3.root',
	'ipnl-auger-notof-3.root',
	'iba-auger-notof-3.root']

# typs=['ipnl-auger-tof-1.root','iba-auger-tof-1.root','ipnl-auger-notof-3.root','iba-auger-notof-3.root']
dirs = subprocess.check_output(['find . -iname "*autogen*" | sort -k1.13'],shell=True).split('\n')[:-1]

numprots = [1e9,1e8,1e7,1e6]

for typ in typs:
    ctsetsets = []
    for line,numprot in zip(dirs,[item for item in numprots for i in range(len(typs)/4)]):
        for haha in ['iba','ipnl']:
            if haha+'lyso' in line and haha+'-' in typ:
                print (haha,line,typ)
                ctsetsets.append( auger.getctset(numprot,line[2:10],line[2:10],typ,addnoise=addnoise) )
            if haha+'zinv' in line and haha+'-' in typ:
                print (haha,line,typ)
                ctsetsets.append( auger.getctset(numprot,line[2:10],line[2:10],typ,addnoise=addnoise) )
    assert(len(ctsetsets)==4)
    megaplot(ctsetsets,'PMMA_phantom')
    print 'Mean detection yield in',typ,'study over',sum([ctset['totnprim'] for ctset in ctsetsets]),'primaries in',sum([ctset['nreal'] for ctset in ctsetsets]),'realisations:',sum([ctset['detyieldmu'] for ctset in ctsetsets])

tableio.print2d(resultstable)
tableio.write(resultstable,'resultstable.tsv')