def plot_region(self, mlpoly): poly = Polygon(mlpoly) # reset coords self.roilist = [] tplot = ContourPlot() sname = '1' for co in self.coordlist: for myco in self.coordlist[co]: if poly.contains(Point(myco.x, myco.y)): sname = str(int(myco.x)) + '_' + str(int(myco.y)) self.roilist.append(myco) tplot.loadrow(myco.x, myco.y, myco.rho, myco.frame) msg = 'Total ROI points=' + str(len(self.roilist)) print(msg) fname = self.outputdir + 'ROI_' + sname + '.csv' msg = msg + ": " + self.print_region(fname) tplot.contour_region('ROI_' + sname) return msg