def testPValue(self): """Test the P-value calculation against all the measured data points""" for key, data in PValueResults.items(): ch1 = getChannel(key, 0) ch2 = getChannel(key, 1) coloctest = vtk.vtkImageColocalizationTest() coloctest.AddInput(ch1) coloctest.AddInput(ch2) iterations, method, robs, rrandmean, rrandsd, pvalue, psf = data # Set the PSF radius and # of iterations, if we're using Costes' method if method == "Costes": coloctest.SetManualPSFSize(psf) coloctest.SetNumIterations(iterations) # Set the method (0, 1 or 2 which correspond to Fay, Costes and van Steensel) coloctest.SetMethod(methods.index(method)) coloctest.Update() resultrobs = coloctest.GetRObserved() resultpval = coloctest.GetPValue() self.assert_(abs(resultrobs - robs) < 0.001, "Our R(obs) (%f) differs from ImageJ's (%f)" % (resultrobs, robs)) self.assert_(abs(resultpval - pvalue) < 0.001, "Our P-value (%f) differs from ImageJ's (%f)" % (resultpval, pvalue)) if iterations > 10: resultrrandmean = coloctest.GetRRandMean() self.assert_(abs(resultrrandmean - rrandmean) < 0.1, "Our R(rand) mean (%f) differs from ImageJ's (%f) by more than 0.1" % (resultrrandmean, rrandmean))
def testPValue(self): """Test the P-value calculation against all the measured data points""" for key, data in PValueResults.items(): ch1 = getChannel(key, 0) ch2 = getChannel(key, 1) coloctest = vtk.vtkImageColocalizationTest() coloctest.AddInput(ch1) coloctest.AddInput(ch2) iterations, method, robs, rrandmean, rrandsd, pvalue, psf = data # Set the PSF radius and # of iterations, if we're using Costes' method if method == "Costes": coloctest.SetManualPSFSize(psf) coloctest.SetNumIterations(iterations) # Set the method (0, 1 or 2 which correspond to Fay, Costes and van Steensel) coloctest.SetMethod(methods.index(method)) coloctest.Update() resultrobs = coloctest.GetRObserved() resultpval = coloctest.GetPValue() self.assert_( abs(resultrobs - robs) < 0.001, "Our R(obs) (%f) differs from ImageJ's (%f)" % (resultrobs, robs)) self.assert_( abs(resultpval - pvalue) < 0.001, "Our P-value (%f) differs from ImageJ's (%f)" % (resultpval, pvalue)) if iterations > 10: resultrrandmean = coloctest.GetRRandMean() self.assert_( abs(resultrrandmean - rrandmean) < 0.1, "Our R(rand) mean (%f) differs from ImageJ's (%f) by more than 0.1" % (resultrrandmean, rrandmean))
reader.SetUpdateChannel(0) reader.SetUpdateTimePoint(0) reader.Update() ch1=reader.GetOutput() reader2=vtk.vtkLSMReader() reader2.SetFileName(FILE) reader2.SetUpdateChannel(1) reader2.SetUpdateTimePoint(0) reader2.Update() ch2=reader2.GetOutput() def updateProgress(obj,evt): #print "Progress: ",obj.GetProgressText(),obj.GetProgress() pass print "Now calculating P-value..." coloctest=vtk.vtkImageColocalizationTest() # Use costes method coloctest.SetRandomizeZ(0) coloctest.SetMethod(1); coloctest.SetManualPSFSize(3); coloctest.SetNumIterations(10); coloctest.SetIgnoreZeroPixels(1) coloctest.AddInput(ch1) coloctest.AddInput(ch2) coloctest.AddObserver("ProgressEvent",updateProgress) coloctest.Update() print coloctest data=coloctest.GetOutput()