Example #1
0
    def OnStructureCheck(self, msg):
        """When a structure changes, update the interface and plot."""

        # Make sure that the volume has been calculated for each structure
        # before setting it
        self.checkedstructures = msg.data
        for id, structure in self.checkedstructures.iteritems():
            if not self.structures[id].has_key('volume'):
                self.structures[id]['volume'] = structure['volume']

            # make sure that the dvh has been calculated for each structure
            # before setting it
            if self.dvhs.has_key(id):
                self.EnableConstraints(True)
                # Create an instance of the dvhdata class to can access its functions
                self.dvhdata[id] = dvhdata.DVH(self.dvhs[id])
                # Create an instance of the dvh arrays so that guidvh can plot it
                self.dvharray[id] = dvhdata.DVH(self.dvhs[id]).dvh
                # Create an instance of the dvh scaling data for guidvh
                self.dvhscaling[id] = self.dvhs[id]['scaling']
                # 'Toggle' the choice box to refresh the dose data
                self.OnToggleConstraints(None)
        if not len(self.checkedstructures):
            self.EnableConstraints(False)
            # Make an empty plot on the DVH
            self.guiDVH.Replot()
Example #2
0
    def FindOrganPlan(self, id, organName):
        LimitObject = getattr(self, 'limit' + organName)
        PlanObject = getattr(self, 'plan' + organName)
        ImgObject = getattr(self, 'img' + organName)
        self.dvhdata[id] = dvhdata.DVH(self.dvhs[id])
        total_vol = dvhdata.CalculateVolume(self.structures[id])
        if hasattr(self, 'vol' + organName) == True:  # exclude statictext
            VolObject = getattr(self, 'vol' + organName)
            if '%' in VolObject.GetValue():  #hilum
                s = VolObject.GetValue()
                s = s.rstrip('%')
                formatted_vol = s
        if '> ' in LimitObject.GetValue():  #hilum and lung
            s = LimitObject.GetValue()
            s = s.lstrip('> ')
            formatted_limit = s
        if 'Max' not in organName:
            if 'formatted_vol' in locals():
                Vol = float(formatted_vol) * 100 / total_vol
            else:
                Vol = float(VolObject.GetValue()) * 100 / total_vol
            dose = self.dvhdata[id].GetDoseConstraint(Vol)
            dose = str(dose / 100)  # Dose from DVH is in cGy
            if 'formatted_limit' in locals():
                crit_vol = total_vol - float(formatted_limit)
                crit_vol = str(round(crit_vol, 1))
                PlanObject.SetValue(crit_vol)
                if float(PlanObject.GetValue()) > float(formatted_limit):
                    ImgObject.SetBitmap(self.imgCheck)
                else:
                    ImgObject.SetBitmap(self.imgFlag)
            else:
                PlanObject.SetValue(dose)
                if float(PlanObject.GetValue()) < float(
                        LimitObject.GetValue()):
                    ImgObject.SetBitmap(self.imgCheck)
                else:
                    ImgObject.SetBitmap(self.imgFlag)

        else:  # dose max
            voxelPointVol = 0.035 * 100 / total_vol  # 0.035 cc is "voxel"
            dose = self.dvhdata[id].GetDoseConstraint(
                voxelPointVol)  #dose at DVH tail
            dose = str(dose / 100)
            PlanObject.SetValue(dose)
            if float(PlanObject.GetValue()) < float(LimitObject.GetValue()):
                ImgObject.SetBitmap(self.imgCheck)
            else:
                ImgObject.SetBitmap(self.imgFlag)
    def GetConformality(self, isodose):
        #set thresholds for conformality
        lowerlimit = isodose * self.rxdose / 100

        id = self.structureid
        PITV, CV = CalculateCI(self, self.structures[id], lowerlimit)
        self.dvhdata[id] = dvhdata.DVH(self.dvhs[id])
        TV = dvhdata.CalculateVolume(self.structures[id])

        self.lblConformalityIndex.SetLabel(
            str(CV * CV / (TV * PITV) * 100)[0:5])
        self.lblUnderdoseRatio.SetLabel(str(CV / (TV) * 100)[0:5])
        self.lblOverdoseRatio.SetLabel(str(CV / (PITV) * 100)[0:5])
        self.lblTargetVolume.SetLabel(str(TV)[0:6])
        self.lblIsodoseVolume.SetLabel(str(PITV)[0:6])
        self.lblCoverageVolume.SetLabel(str(CV)[0:6])
Example #4
0
    def OnStructureSelect(self, msg):
        """Load the constraints for the currently selected structure."""

        if (msg.data['id'] == None):
            self.EnableConstraints(False)
        else:
            self.structureid = msg.data['id']
            if self.dvhs.has_key(self.structureid):
                # Create an instance of the dvhdata class to can access its functions
                self.dvhdata[self.structureid] = dvhdata.DVH(
                    self.dvhs[self.structureid])
                # Create an instance of the dvh scaling data for guidvh
                self.dvhscaling[self.structureid] = self.dvhs[
                    self.structureid]['scaling']
                # 'Toggle' the choice box to refresh the dose data
                self.OnToggleConstraints(None)
            else:
                self.EnableConstraints(False)
                self.guiDVH.Replot([self.dvharray], [self.dvhscaling],
                                   self.checkedstructures)