Ejemplo n.º 1
0
    def ExecuteCurves(self, origInVolumeNode, inVolumeNode, numberOfIterations,
                      propagationScaling, curvatureScaling, advectionScaling,
                      calculateFeatureImage):

        self._helper.debug("Starting execution of Curves..")

        if not inVolumeNode or not origInVolumeNode:
            slicer.Application.ErrorMessage(
                "Not enough information!!! Aborting Geodesic..\n")
            return
        else:

            cast = slicer.vtkImageCast()
            cast.SetInput(origInVolumeNode.GetImageData())
            cast.SetOutputScalarTypeToFloat()
            cast.Update()

            origImage = cast.GetOutput()
            image = inVolumeNode.GetImageData()

            levelSets = slicer.vtkvmtkCurvesLevelSetImageFilter()
            self._helper.debug("FeatureImageCalc: " +
                               str(calculateFeatureImage))
            if calculateFeatureImage == 1:
                levelSets.SetFeatureImage(
                    self.BuildGradientBasedFeatureImage(origImage))
            else:
                levelSets.SetFeatureImage(origImage)
            levelSets.SetDerivativeSigma(self.FeatureDerivativeSigma)
            levelSets.SetAutoGenerateSpeedAdvection(1)
            levelSets.SetPropagationScaling(propagationScaling)
            levelSets.SetCurvatureScaling(curvatureScaling)
            levelSets.SetAdvectionScaling(advectionScaling)

            levelSets.SetInput(image)
            levelSets.SetNumberOfIterations(numberOfIterations)
            levelSets.SetIsoSurfaceValue(self.IsoSurfaceValue)
            levelSets.SetMaximumRMSError(self.MaximumRMSError)
            levelSets.SetInterpolateSurfaceLocation(1)
            levelSets.SetUseImageSpacing(1)
            levelSets.Update()

            matrix = slicer.vtkMatrix4x4()
            inVolumeNode.GetIJKToRASMatrix(matrix)

            outVolumeData = slicer.vtkImageData()
            outVolumeData.DeepCopy(levelSets.GetOutput())
            outVolumeData.Update()

            outVolumeNode = slicer.vtkMRMLScalarVolumeNode()
            outVolumeNode.SetAndObserveImageData(outVolumeData)
            outVolumeNode.SetIJKToRASMatrix(matrix)

            outputContainer = SlicerVMTKLevelSetContainer(outVolumeNode, 0.0)

            return outputContainer
    def ExecuteCurves(self,origInVolumeNode,inVolumeNode,numberOfIterations,propagationScaling,curvatureScaling,advectionScaling,calculateFeatureImage):

        self._helper.debug("Starting execution of Curves..")

        if not inVolumeNode or not origInVolumeNode:
            slicer.Application.ErrorMessage("Not enough information!!! Aborting Geodesic..\n")
            return
        else:

            cast = slicer.vtkImageCast()
            cast.SetInput(origInVolumeNode.GetImageData())
            cast.SetOutputScalarTypeToFloat()
            cast.Update()

            origImage = cast.GetOutput()
            image = inVolumeNode.GetImageData()

            levelSets = slicer.vtkvmtkCurvesLevelSetImageFilter()
            self._helper.debug("FeatureImageCalc: " + str(calculateFeatureImage))
            if calculateFeatureImage==1:
                levelSets.SetFeatureImage(self.BuildGradientBasedFeatureImage(origImage))
            else:
                levelSets.SetFeatureImage(origImage)
            levelSets.SetDerivativeSigma(self.FeatureDerivativeSigma)
            levelSets.SetAutoGenerateSpeedAdvection(1)
            levelSets.SetPropagationScaling(propagationScaling)
            levelSets.SetCurvatureScaling(curvatureScaling)
            levelSets.SetAdvectionScaling(advectionScaling)


            levelSets.SetInput(image)
            levelSets.SetNumberOfIterations(numberOfIterations)
            levelSets.SetIsoSurfaceValue(self.IsoSurfaceValue)
            levelSets.SetMaximumRMSError(self.MaximumRMSError)
            levelSets.SetInterpolateSurfaceLocation(1)
            levelSets.SetUseImageSpacing(1)
            levelSets.Update()


            matrix = slicer.vtkMatrix4x4()
            inVolumeNode.GetIJKToRASMatrix(matrix)

            outVolumeData = slicer.vtkImageData()
            outVolumeData.DeepCopy(levelSets.GetOutput())
            outVolumeData.Update()

            outVolumeNode = slicer.vtkMRMLScalarVolumeNode()
            outVolumeNode.SetAndObserveImageData(outVolumeData)
            outVolumeNode.SetIJKToRASMatrix(matrix)

            outputContainer = SlicerVMTKLevelSetContainer(outVolumeNode,0.0)

            return outputContainer
    def ExecuteGAC(self, origImage, segmentationImage, numberOfIterations,
                   propagationScaling, curvatureScaling, advectionScaling,
                   method):

        self._parentClass.GetHelper().debug("Starting GAC..")

        calculateFeatureImage = 1

        cast = slicer.vtkImageCast()
        cast.SetInput(origImage)
        cast.SetOutputScalarTypeToFloat()
        cast.Update()

        if method == 'curves':
            levelSets = slicer.vtkvmtkCurvesLevelSetImageFilter()
        else:
            levelSets = slicer.vtkvmtkGeodesicActiveContourLevelSetImageFilter(
            )

        if calculateFeatureImage == 1:
            levelSets.SetFeatureImage(
                self.BuildGradientBasedFeatureImage(origImage))
        else:
            levelSets.SetFeatureImage(origImage)
        levelSets.SetDerivativeSigma(self._featureDerivativeSigma)
        levelSets.SetAutoGenerateSpeedAdvection(1)
        levelSets.SetPropagationScaling(propagationScaling)
        levelSets.SetCurvatureScaling(curvatureScaling)
        levelSets.SetAdvectionScaling(advectionScaling)
        levelSets.SetInput(segmentationImage)
        levelSets.SetNumberOfIterations(numberOfIterations)
        levelSets.SetIsoSurfaceValue(self._isoSurfaceValue)
        levelSets.SetMaximumRMSError(self._maximumRMSError)
        levelSets.SetInterpolateSurfaceLocation(1)
        levelSets.SetUseImageSpacing(1)
        levelSets.Update()

        outVolumeData = slicer.vtkImageData()
        outVolumeData.DeepCopy(levelSets.GetOutput())
        outVolumeData.Update()

        self._parentClass.GetHelper().debug("End of GAC..")

        return outVolumeData
    def ExecuteGAC(self,origImage,segmentationImage,numberOfIterations,propagationScaling,curvatureScaling,advectionScaling,method):

        self._parentClass.GetHelper().debug("Starting GAC..")

        calculateFeatureImage = 1

        cast = slicer.vtkImageCast()
        cast.SetInput(origImage)
        cast.SetOutputScalarTypeToFloat()
        cast.Update()

        if method=='curves':
            levelSets = slicer.vtkvmtkCurvesLevelSetImageFilter()
        else:
            levelSets = slicer.vtkvmtkGeodesicActiveContourLevelSetImageFilter()

        if calculateFeatureImage==1:
            levelSets.SetFeatureImage(self.BuildGradientBasedFeatureImage(origImage))
        else:
            levelSets.SetFeatureImage(origImage)
        levelSets.SetDerivativeSigma(self._featureDerivativeSigma)
        levelSets.SetAutoGenerateSpeedAdvection(1)
        levelSets.SetPropagationScaling(propagationScaling)
        levelSets.SetCurvatureScaling(curvatureScaling)
        levelSets.SetAdvectionScaling(advectionScaling)
        levelSets.SetInput(segmentationImage)
        levelSets.SetNumberOfIterations(numberOfIterations)
        levelSets.SetIsoSurfaceValue(self._isoSurfaceValue)
        levelSets.SetMaximumRMSError(self._maximumRMSError)
        levelSets.SetInterpolateSurfaceLocation(1)
        levelSets.SetUseImageSpacing(1)
        levelSets.Update()

        outVolumeData = slicer.vtkImageData()
        outVolumeData.DeepCopy(levelSets.GetOutput())
        outVolumeData.Update()

        self._parentClass.GetHelper().debug("End of GAC..")

        return outVolumeData