def __init__(self):
		"""
		Initialization
		"""
		lib.ProcessingFilter.ProcessingFilter.__init__(self, (2,2), requireWholeDataset = 1)
		for i in range(1, 3):
			self.setInputChannel(i, i)
		self.colocAutoThreshold = vtkbxd.vtkImageAutoThresholdColocalization()
		self.colocAutoThreshold.SetCalculateThreshold(1)
		self.colocAutoThreshold.GetOutput().ReleaseDataFlagOn()
		self.colocAutoThreshold.AddObserver('ProgressEvent', lib.messenger.send)
		lib.messenger.connect(self.colocAutoThreshold, "ProgressEvent", self.updateProgress)
		self.resultVariables = {
							"Ch1ThresholdMax":	"Ch1 Automatic Threshold",
							"Ch2ThresholdMax":	"Ch2 Automatic Threshold",
							"Slope":			"Correlation slope",
							"Intercept":		"Correlation intercept"
							}
		self.filterDesc = "Calculates thresholds for colocalization analysis automatically. Combine with the 'Analyze colocalization' procedure to analyze the results. Intended for use with the Batch Processor only, for other colocalization analyses use the Colocalization task.\nInputs: Grayscale images\nOutput: Thresholds (first input as pipeline output)"
	def reset(self):
		"""
		Resets the module to initial state. This method is
					 used mainly when doing previews, when the parameters
					 that control the colocalization are changed and the
					 preview data becomes invalid.
		"""
		Module.reset(self)
		self.colocFilter = vtkbxd.vtkImageColocalizationFilter()
		self.colocFilter.AddObserver('ProgressEvent', lib.messenger.send)
		lib.messenger.connect(self.colocFilter, "ProgressEvent", self.updateProgress)

		self.colocAutoThreshold = vtkbxd.vtkImageAutoThresholdColocalization()
		self.colocAutoThreshold.GetOutput().ReleaseDataFlagOn()
		self.colocAutoThreshold.AddObserver('ProgressEvent', lib.messenger.send)
		lib.messenger.connect(self.colocAutoThreshold, "ProgressEvent", self.updateProgress)
		self.thresholds = []
		self.settingsLst = []
		self.preview = None
		self.n = -1
	def execute(self, inputs, update = 0, last = 0):
		"""
		Execute the filter with given inputs and return the output
		"""			   
		if not lib.ProcessingFilter.ProcessingFilter.execute(self, inputs):
			return None

		tp1 = self.parameters["Timepoint1"] - 1
		tp2 = self.parameters["Timepoint2"] - 1
		self.vtkfilter = vtkbxd.vtkImageAutoThresholdColocalization()
		units = self.dataUnit.getSourceDataUnits()
		data1 = units[0].getTimepoint(tp1)
		# We need to prepare a copy of the data since when we get the next
		# timepoint, the data we got earlier will reference the new data
		tp = vtk.vtkImageData()
		data1.SetUpdateExtent(data1.GetWholeExtent())
		data1.Update()
		tp.DeepCopy(data1)
		data1 = tp
		data2 = units[0].getTimepoint(tp2)
		data2.SetUpdateExtent(data2.GetWholeExtent())
		data2.Update()
		
		self.vtkfilter.AddInput(data1)
		self.vtkfilter.AddInput(data2)

		# Set the thresholds so they won't be calculated
		self.vtkfilter.SetLowerThresholdCh1(0)
		self.vtkfilter.SetLowerThresholdCh2(0)
		self.vtkfilter.SetUpperThresholdCh1(255)
		self.vtkfilter.SetUpperThresholdCh2(255)
		self.vtkfilter.Update()
		correlation = self.vtkfilter.GetPearsonWholeImage()
		self.setResultVariable("Timepoint1",tp1)
		self.setResultVariable("Timepoint2",tp2)
		self.setResultVariable("Correlation",correlation)
		
		self.corrLbl2.SetLabel("%.5f" % correlation)
		return self.getInput(1)
Example #4
0
    def execute(self, inputs, update=0, last=0):
        """
		Execute the filter with given inputs and return the output
		"""
        if not lib.ProcessingFilter.ProcessingFilter.execute(self, inputs):
            return None

        tp1 = self.parameters["Timepoint1"] - 1
        tp2 = self.parameters["Timepoint2"] - 1
        self.vtkfilter = vtkbxd.vtkImageAutoThresholdColocalization()
        units = self.dataUnit.getSourceDataUnits()
        data1 = units[0].getTimepoint(tp1)
        # We need to prepare a copy of the data since when we get the next
        # timepoint, the data we got earlier will reference the new data
        tp = vtk.vtkImageData()
        data1.SetUpdateExtent(data1.GetWholeExtent())
        data1.Update()
        tp.DeepCopy(data1)
        data1 = tp
        data2 = units[0].getTimepoint(tp2)
        data2.SetUpdateExtent(data2.GetWholeExtent())
        data2.Update()

        self.vtkfilter.AddInput(data1)
        self.vtkfilter.AddInput(data2)

        # Set the thresholds so they won't be calculated
        self.vtkfilter.SetLowerThresholdCh1(0)
        self.vtkfilter.SetLowerThresholdCh2(0)
        self.vtkfilter.SetUpperThresholdCh1(255)
        self.vtkfilter.SetUpperThresholdCh2(255)
        self.vtkfilter.Update()
        correlation = self.vtkfilter.GetPearsonWholeImage()
        self.setResultVariable("Timepoint1", tp1)
        self.setResultVariable("Timepoint2", tp2)
        self.setResultVariable("Correlation", correlation)

        self.corrLbl2.SetLabel("%.5f" % correlation)
        return self.getInput(1)
Example #5
0
    def reset(self):
        """
		Resets the module to initial state. This method is
					 used mainly when doing previews, when the parameters
					 that control the colocalization are changed and the
					 preview data becomes invalid.
		"""
        Module.reset(self)
        self.colocFilter = vtkbxd.vtkImageColocalizationFilter()
        self.colocFilter.AddObserver('ProgressEvent', lib.messenger.send)
        lib.messenger.connect(self.colocFilter, "ProgressEvent",
                              self.updateProgress)

        self.colocAutoThreshold = vtkbxd.vtkImageAutoThresholdColocalization()
        self.colocAutoThreshold.GetOutput().ReleaseDataFlagOn()
        self.colocAutoThreshold.AddObserver('ProgressEvent',
                                            lib.messenger.send)
        lib.messenger.connect(self.colocAutoThreshold, "ProgressEvent",
                              self.updateProgress)
        self.thresholds = []
        self.settingsLst = []
        self.preview = None
        self.n = -1
Example #6
0
    def __init__(self):
        """
		Initialization
		"""
        self.defaultLower = 128
        self.defaultUpper = 255
        self.colocRange = (0, 255)
        self.numericalAperture = 1.4
        self.listctrl = None
        self.emissionWavelength = 520
        self.oldThresholds = None
        lib.ProcessingFilter.ProcessingFilter.__init__(self, (2, 2),
                                                       requireWholeDataset=1)
        for i in range(1, 3):
            self.setInputChannel(i, i)

        self.colocFilter = vtkbxd.vtkImageColocalizationFilter()
        self.colocFilter.AddObserver('ProgressEvent', lib.messenger.send)
        lib.messenger.connect(self.colocFilter, "ProgressEvent",
                              self.updateProgress)

        self.colocAutoThreshold = vtkbxd.vtkImageAutoThresholdColocalization()
        self.colocAutoThreshold.SetCalculateThreshold(0)
        self.colocAutoThreshold.GetOutput().ReleaseDataFlagOn()
        self.colocAutoThreshold.AddObserver('ProgressEvent',
                                            lib.messenger.send)
        lib.messenger.connect(self.colocAutoThreshold, "ProgressEvent",
                              self.updateProgress)
        self.descs = {
            "LowerThresholdCh1": "Lower Threshold (Ch1)",
            "UpperThresholdCh1": "Upper threshold (Ch1)",
            "LowerThresholdCh2": "Lower Threshold (Ch2)",
            "UpperThresholdCh2": "Upper threshold (Ch2)",
            "PValue": "Calculate P-value",
            "None": "None",
            "Costes": "Costes",
            "Fay": "Fay",
            "Steensel": "van Steensel",
            "Iterations": "Iterations",
            "PSF": "PSF radius (px)",
            "Lambda": u"Ch2 \u03BB (nm)",
            "NA": "Numerical aperture",
            "Palette": "",
            "OneBit": "Use single value for colocalization",
            "ColocValue": "Coloc. value"
        }
        self.resultVariables = {
            "Ch1ThresholdMax": "Ch1 Upper Threshold",
            "Ch2ThresholdMax": "Ch2 Upper Threshold",
            "PearsonImageAbove": "Correlation (voxels > threshold)",
            "PearsonImageBelow": "Correlation (voxels < threshold)",
            "PearsonWholeImage": "Correlation",
            "M1": "M1",
            "M2": "M2",
            "K1": "K1",
            "K2": "K2",
            "DiffStainIntCh1": "Diff.stain ch1/ch2 (intensity)",
            "DiffStainIntCh2": "Diff.stain ch2/ch1 (intensity)",
            "DiffStainVoxelsCh1": "Diff.stain of ch1/ch2 (# of voxels)",
            "DiffStainVoxelsCh2": "Diff.stain of ch2/ch1 (# of voxels)",
            "ThresholdM1": "M1 (colocalized voxels)",
            "ThresholdM2": "M2 (colocalized voxels)",
            "ColocAmount": "# of coloc. voxels",
            "ColocPercent": "% of colocalization",
            "PercentageVolumeCh1": "% of ch1 coloc. (voxels)",
            "PercentageTotalCh1": "% of ch1 coloc. (tot.intensity)",
            "PercentageTotalCh2": "% of ch2 coloc. (tot.intensity)",
            "PercentageVolumeCh2": "% of ch2 coloc. (voxels)",
            "PercentageMaterialCh1": "% of ch1 coloc. (intensity)",
            "PercentageMaterialCh2": "% of ch2 coloc. (intensity)",
            "SumOverThresholdCh1": "Sum of ch1 (over threshold)",
            "SumOverThresholdCh2": "Sum of ch2 (over threshold)",
            "SumCh1": "Sum of ch1 (total)",
            "SumCh2": "Sum of ch2 (total)",
            "NonZeroCh1": "# of non-zero voxels (Ch1)",
            "NonZeroCh2": "# of non-zero voxels (Ch2)",
            "OverThresholdCh2": "# of voxels > threshold (Ch2)",
            "OverThresholdCh1": "# of voxels > threshold (Ch1)",
            "Slope": "Slope",
            "Intercept": "Intercept",
            "PValue": "P-Value",
            "RObserved": "R(obs)",
            "RRandMean": "R(rand) mean",
            "RRandSD": "R(rand) sd",
            "NumIterations": "Iterations",
            "Method": "Method",
            "ColocCount": "Amount of coloc",
            "LowerThresholdCh1": "",
            "UpperThresholdCh1": "",
            "LowerThresholdCh2": "",
            "UpperThresholdCh2": ""
        }
        self.filterDesc = "Analyzes colocalization using manually specified thresholds, or automatically calculated thresholds if preceded by the procedure 'Calculate thresholds for colocalization'. Intended for use with the Batch Processor only, for other colocalization analyses use the Colocalization task.\nInputs: Grayscale images\nOutput: Results (Colocalization map as grayscale image)"
	def __init__(self):
		"""
		Initialization
		"""
		self.defaultLower = 128
		self.defaultUpper = 255
		self.colocRange = (0,255)
		self.numericalAperture = 1.4
		self.listctrl = None
		self.emissionWavelength = 520
		self.oldThresholds = None
		lib.ProcessingFilter.ProcessingFilter.__init__(self, (2,2), requireWholeDataset = 1)
		for i in range(1, 3):
			self.setInputChannel(i, i)

		self.colocFilter = vtkbxd.vtkImageColocalizationFilter()
		self.colocFilter.AddObserver('ProgressEvent', lib.messenger.send)
		lib.messenger.connect(self.colocFilter, "ProgressEvent", self.updateProgress)

		self.colocAutoThreshold = vtkbxd.vtkImageAutoThresholdColocalization()
		self.colocAutoThreshold.SetCalculateThreshold(0)
		self.colocAutoThreshold.GetOutput().ReleaseDataFlagOn()
		self.colocAutoThreshold.AddObserver('ProgressEvent', lib.messenger.send)
		lib.messenger.connect(self.colocAutoThreshold, "ProgressEvent", self.updateProgress)
		self.descs = {"LowerThresholdCh1": "Lower Threshold (Ch1)", "UpperThresholdCh1": "Upper threshold (Ch1)",
		"LowerThresholdCh2": "Lower Threshold (Ch2)", "UpperThresholdCh2": "Upper threshold (Ch2)",
		"PValue":"Calculate P-value","None":"None", "Costes":"Costes", "Fay":"Fay",
		"Steensel":"van Steensel","Iterations":"Iterations","PSF":"PSF radius (px)","Lambda":u"Ch2 \u03BB (nm)",
		"NA":"Numerical aperture", "Palette":"","OneBit":"Use single value for colocalization","ColocValue":"Coloc. value"
		}
		self.resultVariables = {
							"Ch1ThresholdMax":		"Ch1 Upper Threshold",
							"Ch2ThresholdMax":		"Ch2 Upper Threshold",
							"PearsonImageAbove":	"Correlation (voxels > threshold)",
							"PearsonImageBelow":	"Correlation (voxels < threshold)",
							"PearsonWholeImage":	"Correlation",
							"M1":					"M1",
							"M2":					"M2",
							"K1":					"K1",
							"K2":					"K2",
							"DiffStainIntCh1":		"Diff.stain ch1/ch2 (intensity)",
							"DiffStainIntCh2":		"Diff.stain ch2/ch1 (intensity)",
							"DiffStainVoxelsCh1":	"Diff.stain of ch1/ch2 (# of voxels)",
							"DiffStainVoxelsCh2":	"Diff.stain of ch2/ch1 (# of voxels)",
							"ThresholdM1":			"M1 (colocalized voxels)",
							"ThresholdM2":			"M2 (colocalized voxels)",
							"ColocAmount":			"# of coloc. voxels",
							"ColocPercent":			"% of colocalization",
							"PercentageVolumeCh1":	"% of ch1 coloc. (voxels)",
							"PercentageTotalCh1":	"% of ch1 coloc. (tot.intensity)",
							"PercentageTotalCh2":	"% of ch2 coloc. (tot.intensity)",
							"PercentageVolumeCh2":	"% of ch2 coloc. (voxels)",
							"PercentageMaterialCh1":"% of ch1 coloc. (intensity)",
							"PercentageMaterialCh2":"% of ch2 coloc. (intensity)",
							"SumOverThresholdCh1":	"Sum of ch1 (over threshold)",
							"SumOverThresholdCh2":	"Sum of ch2 (over threshold)",
							"SumCh1":				"Sum of ch1 (total)",
							"SumCh2":				"Sum of ch2 (total)",
							"NonZeroCh1":			"# of non-zero voxels (Ch1)",
							"NonZeroCh2":			"# of non-zero voxels (Ch2)",
							"OverThresholdCh2":		"# of voxels > threshold (Ch2)",
							"OverThresholdCh1":		"# of voxels > threshold (Ch1)",
							"Slope":				"Slope",
							"Intercept":			"Intercept",
							"PValue":				"P-Value",
							"RObserved":			"R(obs)",
							"RRandMean":			"R(rand) mean",
							"RRandSD":				"R(rand) sd",
							"NumIterations":		"Iterations",
							"Method":				"Method",
							"ColocCount":			"Amount of coloc",
							"LowerThresholdCh1":"",
							"UpperThresholdCh1":"",
							"LowerThresholdCh2":"",
							"UpperThresholdCh2":""
							}
		self.filterDesc = "Analyzes colocalization using manually specified thresholds, or automatically calculated thresholds if preceded by the procedure 'Calculate thresholds for colocalization'. Intended for use with the Batch Processor only, for other colocalization analyses use the Colocalization task.\nInputs: Grayscale images\nOutput: Results (Colocalization map as grayscale image)"