コード例 #1
0
ファイル: NEMASUV_old.py プロジェクト: JaapGroen/WAD_Python
 def check_overlap(self,newsphere):
     a = newsphere.volume
     for key in self.bgspheres.keys():
         b = self.bgspheres[key].volume
         if niq.compare_coordsets(a,b) == True:
             return None
     return newsphere
コード例 #2
0
    def  __init__(self,data,order=['x','y','z'],phantomdim=[20,10],phantomvolume=9500,dose=75,dosecaltime='000000',remdose=0,remdosecaltime='000000'):


        print order
        self.xind = order.index('x')
        self.yind = order.index('y')
        self.zind = order.index('z')
        
        axes = [self.xind,self.yind,self.zind]
        print data
        pixelsize,array,info = niq.loaddata(data)

        print info
        
        self.pixel_size = pixelsize
        print "pixelsize: ", pixelsize

        self.phantomvolume = float(phantomvolume)
        self.dose = float(dose)
        self.dosecaltime = str(dosecaltime)
        self.remdose = float(remdose)
        self.remdosecaltime = str(remdosecaltime)

        
        self.rows = info.info["0028","0010"].value
        self.cols = info.info["0028","0011"].value

        self.vendor = info.info["0008","0070"].value
        
        if self.vendor == 'Philips Medical Systems':
            self.suvfactor = info.info["7053","1009"].value
        else:
            self.suvfactor = 1.0

        self.weight = info.info["0010","1030"].value

        print "Acquisition date",info.info["0008","0022"].value #Date
        acqtime = info.info["0008","0032"].value.split('.')[0] #Acq. Time and we remove the microseconds

        
        
        print "Acquisition time:  ", acqtime
        print "Activity calibrated: %s at %s "%(self.dose,self.dosecaltime)
        print "Remainder activity: %s at %s "%(self.remdose,self.remdosecaltime)

        self.fmt = '%H%M%S'
        self.fmt2 = '%H%M'

        

        t1 = datetime.strptime(acqtime, self.fmt) #acquisition time dcmhdr
        t2 = datetime.strptime(self.dosecaltime, self.fmt) #act. cal time
        t3 = datetime.strptime(self.remdosecaltime, self.fmt)#remaining activity cal time

        # Activity concentration at acquisitiontime:


        deltat0 = float((t1 - t2).seconds/60.) #minutes
        deltatr = float((t2 - t3).seconds/60.) #minutes


        self.currconc = niqlib.calc_act_con(self.phantomvolume,self.dose,deltat0,self.remdose,deltatr)

        print "Net activity at acquisition : %s "%self.currconc
コード例 #3
0
ファイル: NEMASUV_old.py プロジェクト: JaapGroen/WAD_Python
    def  __init__(self,data,order=['x','y','z'],phantomdim=[20,10],phantomvolume=9500,dose=75,dosecaltime='000000',remdose=0,remdosecaltime='000000'):


        print order
        self.xind = order.index('x')
        self.yind = order.index('y')
        self.zind = order.index('z')
        
        axes = [self.xind,self.yind,self.zind]
        print data
        pixelsize,array,info = niq.loaddata(data)

        print info
        
        self.pixel_size = pixelsize
        print "pixelsize: ", pixelsize

        self.phantomvolume = float(phantomvolume)
        self.dose = float(dose)
        self.dosecaltime = str(dosecaltime)
        self.remdose = float(remdose)
        self.remdosecaltime = str(remdosecaltime)

        
        self.rows = info.info["0028","0010"].value
        self.cols = info.info["0028","0011"].value
        
        print "info - date",info.info["0008","0022"].value #Date
        acqtime = info.info["0008","0032"].value.split('.')[0] #Acq. Time and we remove the microseconds

        
        
        print "acquisition time:  ", acqtime
        print "acquisition time:  ", self.dosecaltime
        print "acquisition time:  ", self.remdosecaltime

        self.fmt = '%H%M%S'
        self.fmt2 = '%H%M'

        

        t1 = datetime.strptime(acqtime, self.fmt) #acquisition time dcmhdr
        t2 = datetime.strptime(self.dosecaltime, self.fmt) #act. cal time
        t3 = datetime.strptime(self.remdosecaltime, self.fmt)#remaining activity cal time

        # Activity concentration at acquisitiontime:


        deltat0 = float((t1 - t2).seconds/60.) #minutes
        deltatr = float((t2 - t3).seconds/60.) #minutes


        self.currconc = self.calc_act_con(self.phantomvolume,self.dose,deltat0,self.remdose,deltatr)

        print self.currconc
        


#float(indata.info["0028","0030"].value[0])

        self.bgradius = 4

        



        self.data = np.array(array)

        print type(self.data)
        print type(self.data[0])

        tmpshape  = np.shape(self.data)

        print tmpshape
        
        self.ddimz = tmpshape[self.zind]
        self.ddimy = tmpshape[self.yind]
        self.ddimx = tmpshape[self.xind]

        self.maxdata = self.data.max()
        self.volume = np.zeros(np.shape(data))

#        self.mode = mode
        self.z = self.z_init()


        self.thrdata = copy.deepcopy(self.data)

        lowind = (self.thrdata < np.max(self.thrdata[self.z,:,:])*0.2)
        self.thrdata[lowind] = 0.0
        highind = (self.thrdata >= np.max(self.thrdata[self.z,:,:])*0.2)
        self.thrdata[highind] = 10

        self.bgdata = copy.deepcopy(self.data)

        self.roughcom = ndimage.measurements.center_of_mass(self.data[self.z,:,:])

        print "rough com location:", self.roughcom

        self.cor = self.roughcom
        self.bgspheres = {}

        self.set_bg_spheres()
コード例 #4
0
ファイル: EARLtool.py プロジェクト: wadqc/WAD_Python
    def get_earliq(self, filename, mode, axorder, sporder):
        inputdict = self.get_input_pars()

        self.curr_results = NEMAIQ.update_wad(filename, mode, axorder, sporder,
                                              **inputdict)
コード例 #5
0
ファイル: EARLtool_old.py プロジェクト: JaapGroen/WAD_Python
    def get_earliq(self):

        print '-'*20
        print 'The following earl results have been found:'

        results = {}
        

        for row in ['NM_EARL_SUV','NM_EARL_IQ']:
            
            results[row] = []

            tmpresults = []
            for elem in self.analyseoutput:
                if row in elem[1]:
                    tmpresults.append(elem)

            #print 'Aanwezige resultaten:',tmpresults

            datelist = []
            for elem in tmpresults:
                datelist.append([int(elem[1].split('/')[1]),int(elem[0])])

            #print "datelist: ", sorted(datelist) #.sort(key=itemgetter(0))
                
            for elem in sorted(datelist):
                tmppk =  elem[1]
                self.cur.execute("SELECT * from gewenste_processen where analysemodule_output_fk = %s"%tmppk)
                output = self.cur.fetchall()[0]
                


                self.cur.execute("SELECT * from resultaten_char where gewenste_processen_fk = %s"%output[0])
                limits = self.cur.fetchall()

                
                for subelem in limits:
                    if subelem[2] == 'status':
                        results[row].append([output[5],subelem[2],subelem[5],subelem[1]])

        print '--RESULTATEN--:'
        for key in results.keys():
            print key
            for nr, subresult in enumerate(results[key]):
                 print '\t',nr, subresult

        selection = {}

        


        # we select a result
        #print 'selecting 2014-7-5 15:48:47 gewenste_pk = 30'
        print 'Voer het gewenste procesnr in:'
        gewenste_pk = raw_input()
        print 'Je voerde in %s, indien correct voer 0 in'%gewenste_pk

        tmpstatus = raw_input()
        if tmpstatus == '0':
            pass
        else:
            sys.exit()

        
        selection['gewenste_pk'] = gewenste_pk
        selection['type'] = 'NM_EARL_SUV'

        # from the gewenste processen key we obtain the analysemodule_input key
        self.cur.execute("SELECT * from gewenste_processen where pk = %s"%str(gewenste_pk))
        tmpoutkey = self.cur.fetchall()[0][8]
        print 'tmpselectorkey',tmpoutkey
        #from the analyse_output key we obtain the file

        self.cur.execute("SELECT * from analysemodule_input where pk = %s"%str(tmpoutkey))
        tmpoutput = self.cur.fetchall()[0]

        #set the base dir

        tmpxml = os.path.join('D:\WAD-software',tmpoutput[2],tmpoutput[1])
        import xml.etree.ElementTree as ET

        tree = ET.parse(tmpxml)
        root = tree.getroot()

        pat = tree.findall('patient')[0]
        stud = pat.findall('study')[0]
        ser = stud.findall('series')[0]
        ins = ser.findall('instance')[0]
        fil = ins.getchildren()[1].text
            


#,self.cur.fetchall()[0][2])
        print 'resultaat voor keuze', fil

        seriesdir = os.path.split(fil)[0]

        #now that we have the series we can launch the tool
        #first we ask the necessary pars

        m = 'max'
        order = 'zxy'
        ort =  'acw'
        bga = 10.0
        spa = 1.0

            
        if selection['type'] == 'NM_EARL_IQ':
                results['EARL IQ'] = NEMAIQ.update_wad(filename = seriesdir, mode = m, axorder = order, sporder = ort,bgac = bga, sphereac = spa)
        elif selection['type'] == 'NM_EARL_SUV':
                results['EARL SUV'] = NEMASUV.update_wad(filename = seriesdir, mode = m, axorder = order, sporder = ort,bgac = bga, dimensions = [15,5], volume = '9200', caltime=120000 , remainder=0, remtime= 120000)

        print "write to database"                
        for key in results.keys():
            print key, results[key]

        print "updating float results"
        self.cur.execute("SELECT * from resultaten_floating where gewenste_processen_fk = %s"%str(selection['gewenste_pk']))
        tmpfloats = self.cur.fetchall()
        for elem in tmpfloats:
            print 'parameter',elem[2],'value', elem[7], 'updating to' , results[elem[2]]


        print "updating char results"
        self.cur.execute("SELECT * from resultaten_char where gewenste_processen_fk = %s"%str(selection['gewenste_pk']))
        tmpchar = self.cur.fetchall()
        for elem in tmpchar:
            print 'parameter',elem[2],'value', elem[5], 'updating to' , results[elem[2]]


        print "updating image results"
        self.cur.execute("SELECT * from resultaten_object where gewenste_processen_fk = %s"%str(selection['gewenste_pk']))
        tmpfig = self.cur.fetchall()
        
        for elem in tmpfig:
            print 'parameter',elem[2],'value', elem[5], 'updating to', results[elem[2]]


        print "setting status to processed"
        self.cur.execute("update resultaten_char set waarde='processed' where gewenste_processen_fk=%s"%str(gewenste_pk))
        self.db.commit()