def drawVdData(self, voiName = None): '''Displays Vd Data in the pyplot figure. :praram voiName None by default in order to display DVH for all VOIs. If not none it should contain the name of the VOI to display.\ If the name is unknown it will display the DVH for all the VOIs. ''' if self._dictVd is None: print "Nothing to draw for Vd data" else: if self._figure is None or self._subplot is None: print "No dvh has been drawn yet. No Vd data will be displayed." else: pltGraph.displayPlot() allVOIs = True if voiName is not None and voiName not in self._dictVd.keys(): print "VOI %s not found in : %s.\n All Dv data will be plotted."%(str(voiName),str(self._dictVd.keys())) elif voiName in self._dictVd.keys(): allVOIs = False for voi in self._dictVd: for vdData in self._dictVd[voi]: pltGraph.plotHorizontalLine(self._subplot, vdData[1] , xEnd = vdData[0] ,color = 'r',label = r'$V_{%i}$'%int(vdData[0]), font = globalFont) pltGraph.plotVerticalLine(self._subplot, vdData[0], yEnd = vdData[1] , color = 'r' ) pltGraph.displayPlot() if not allVOIs and voiName == voi: break
def drawDVHs(self, voiName = None): '''Draws the DVH in a pyplot figure. :praram voiName: None by default in order to display DVH for all VOIs. If not none it should contain the name of the VOI to display.\ If the name is unknown it will display the DVH for all the VOIs. ''' if self._dictDVH is None: print "DVH: nothing to draw..." return else: self._figure = pltGraph.getCurrentFigure() allVOIs = True if voiName is not None and voiName not in self._dictDVH.keys(): print "VOI %s not found in : %s.\n All the DVHs will be plotted."%(str(voiName),str(self._dictDVH.keys())) elif voiName in self._dictDVH.keys(): allVOIs = False supTitle = 'DVH for volumes' count = 0 self._subplot = pltGraph.newSubplot(self._figure ) xMax = None for voi in self._dictDVH: if voi != 'relativeVolume': dvhData = self._dictDVH[voi] maxi = np.max(dvhData[0]) if xMax is None or maxi > xMax: xMax = maxi for voi in self._dictDVH: if voi != 'relativeVolume': if not allVOIs and voiName == voi: pltGraph.clearSubplot(self._subplot) supTitle = 'DVH '+ str(voi) dvhData = self._dictDVH[voi] if self._dictDVH['relativeVolume']: yMax = 100 yLabel = 'Relative Volume %' else: yMax = np.max( dvhData[1]) + 10 yLabel = 'Volume (cm3)' pltGraph.drawPlot(self._subplot , dvhData[0], dvhData[1],xmin = 0, xmax = xMax, ymin = 0, ymax =yMax,xlabel = 'Dose (cGy)', ylabel=yLabel, titlePlot = 'DVH '+ str(voi), singlePlot = True, nameSinglePlot = supTitle, grid = True) supTitle = None pltGraph.displayPlot() if not allVOIs and voiName == voi: break pltGraph.makePlotLegend(self._figure,self._subplot) pltGraph.displayPlot()