def calculatePValue(self, images): """ Calculate the P-value """ coloctest = vtkbxd.vtkImageColocalizationTest() self.eventDesc = "Calculating P-Value" method = 2 if self.parameters["Costes"]: method = 1 if self.parameters["Fay"]: method = 0 coloctest.SetMethod(method) Logging.info("Calculating P-value, method = %d"%method) if self.parameters["PSF"]: Logging.info("Using manual PSF size %d"%int(self.parameters["PSF"])) coloctest.SetManualPSFSize(int(self.parameters["PSF"])) coloctest.SetNumIterations(self.parameters["Iterations"]) images[0].SetUpdateExtent(images[0].GetWholeExtent()) images[1].SetUpdateExtent(images[1].GetWholeExtent()) images[0].Update() images[1].Update() for data in images: coloctest.AddInput(data) coloctest.AddObserver('ProgressEvent', lib.messenger.send) lib.messenger.connect(coloctest, "ProgressEvent", self.updateProgress) coloctest.Update() for i in ["PValue", "RObserved", "RRandMean", "RRandSD", "NumIterations", "ColocCount", "Method"]: val = eval("coloctest.Get%s()" % i) self.setResultVariable(i, val) lib.messenger.send(None, "update_progress", 100, "Done.")
def getPValue(self, method = 1, iterations = 100): """ Method: getPValue Get the P value for colocalization """ try: n = int(self.iterations.GetValue()) if n != iterations: self.iterations.SetValue("%d" % iterations) except: pass coloctest = vtkbxd.vtkImageColocalizationTest() #coloctest.SetRandomizeZ(1) sources = self.dataUnit.getSourceDataUnits() self.eventDesc = "Calculating P-Value" methods = ["Fay", "Costes", "van Steensel"] if type(method) == types.StringType: method = methods.index(method) Logging.info("Using %s method (%d)" % (methods[method], method), kw = "processing") t = time.time() coloctest.SetMethod(method) try: n = float(self.fixedPSF.GetValue()) except: lib.messenger.send(None, "show_error", "Bad PSF width", \ "The given width for point spread function is invalid.") return print "Setting PSF width", int(n) coloctest.SetManualPSFSize(int(n)) coloctest.SetNumIterations(iterations) for i in sources: data = i.getTimepoint(self.timePoint) coloctest.AddInput(data) coloctest.AddObserver('ProgressEvent', lib.messenger.send) lib.messenger.connect(coloctest, "ProgressEvent", self.updateProgress) coloctest.Update() print "It took ", time.time() - t, "seconds to calculate p-value" set = sources[0].getSettings().set for i in ["PValue", "RObserved", "RRandMean", "RRandSD", "NumIterations", "ColocCount", "Method"]: val = eval("coloctest.Get%s()" % i) set(i, val) lib.messenger.send(None, "update_progress", 100, "Done.") self.listctrl.updateListCtrl(self.getVariables())
def calculatePValue(self, images): """ Calculate the P-value """ coloctest = vtkbxd.vtkImageColocalizationTest() self.eventDesc = "Calculating P-Value" method = 2 if self.parameters["Costes"]: method = 1 if self.parameters["Fay"]: method = 0 coloctest.SetMethod(method) Logging.info("Calculating P-value, method = %d" % method) if self.parameters["PSF"]: Logging.info("Using manual PSF size %d" % int(self.parameters["PSF"])) coloctest.SetManualPSFSize(int(self.parameters["PSF"])) coloctest.SetNumIterations(self.parameters["Iterations"]) images[0].SetUpdateExtent(images[0].GetWholeExtent()) images[1].SetUpdateExtent(images[1].GetWholeExtent()) images[0].Update() images[1].Update() for data in images: coloctest.AddInput(data) coloctest.AddObserver('ProgressEvent', lib.messenger.send) lib.messenger.connect(coloctest, "ProgressEvent", self.updateProgress) coloctest.Update() for i in [ "PValue", "RObserved", "RRandMean", "RRandSD", "NumIterations", "ColocCount", "Method" ]: val = eval("coloctest.Get%s()" % i) self.setResultVariable(i, val) lib.messenger.send(None, "update_progress", 100, "Done.")