<commit_before>import tomviz.operators


class UnsharpMask(tomviz.operators.CancelableOperator):

    def transform_scalars(self, dataset, amount=0.5, threshold=0.0,
                          sigma=1.0):
        """This filter performs anisotropic diffusion on an image using
        the classic Perona-Malik, gradient magnitude-based equation.
        """

        # Initial progress
        self.progress.value = 0
        self.progress.maximum = 100

        # Approximate percentage of work completed after each step in the
        # transform
        step_pct = iter([10, 20, 90, 100])

        try:
            import itk
            import itkTypes
            from tomviz import itkutils
        except Exception as exc:
            print("Could not import necessary module(s)")
            raise exc

        try:
            self.progress.message = "Converting data to ITK image"
            self.progress.value = 0

            # Get the ITK image. The itk.GradientAnisotropicDiffusionImageFilter
            # is templated over float pixel types only, so explicitly request a
            # float ITK image type.
            itk_image = itkutils.convert_vtk_to_itk_image(dataset)
            self.progress.value = next(step_pct)
            itk_image_type = type(itk_image)


            self.progress.message = "Running filter"
            self.progress.value = next(step_pct)

            unsharp_mask = \
                itk.UnsharpMaskImageFilter.New(Input=itk_image)
            unsharp_mask.SetAmount(amount)
            unsharp_mask.SetThreshold(threshold)
            unsharp_mask.SetSigma(sigma)
            itkutils.observe_filter_progress(self, unsharp_mask, self.progress.value,
                    next(step_pct))

            try:
                unsharp_mask.Update()
            except RuntimeError:
                return
            print('update succeeded')
            print(itk_image)
            print(unsharp_mask.GetOutput())

            self.progress.message = "Saving results"
            self.progress.value = next(step_pct)

            enhanced = unsharp_mask.GetOutput()
            itkutils.set_array_from_itk_image(dataset,
                                              enhanced)

            self.progress.value = next(step_pct)
            print(self.progress.value)
        except Exception as exc:
            print("Problem encountered while running %s" %
                  self.__class__.__name__)
            raise exc<commit_msg>Remove debug statements from UnsharpMask<commit_after>import tomviz.operators


class UnsharpMask(tomviz.operators.CancelableOperator):

    def transform_scalars(self, dataset, amount=0.5, threshold=0.0,
                          sigma=1.0):
        """This filter performs anisotropic diffusion on an image using
        the classic Perona-Malik, gradient magnitude-based equation.
        """

        # Initial progress
        self.progress.value = 0
        self.progress.maximum = 100

        # Approximate percentage of work completed after each step in the
        # transform
        step_pct = iter([10, 20, 90, 100])

        try:
            import itk
            import itkTypes
            from tomviz import itkutils
        except Exception as exc:
            print("Could not import necessary module(s)")
            raise exc

        try:
            self.progress.message = "Converting data to ITK image"
            self.progress.value = 0

            # Get the ITK image. The itk.GradientAnisotropicDiffusionImageFilter
            # is templated over float pixel types only, so explicitly request a
            # float ITK image type.
            itk_image = itkutils.convert_vtk_to_itk_image(dataset)
            self.progress.value = next(step_pct)
            itk_image_type = type(itk_image)


            self.progress.message = "Running filter"
            self.progress.value = next(step_pct)

            unsharp_mask = \
                itk.UnsharpMaskImageFilter.New(Input=itk_image)
            unsharp_mask.SetAmount(amount)
            unsharp_mask.SetThreshold(threshold)
            unsharp_mask.SetSigma(sigma)
            itkutils.observe_filter_progress(self, unsharp_mask, self.progress.value,
                    next(step_pct))

            try:
                unsharp_mask.Update()
            except RuntimeError:
                return

            self.progress.message = "Saving results"

            enhanced = unsharp_mask.GetOutput()
            itkutils.set_array_from_itk_image(dataset,
                                              enhanced)

            self.progress.value = next(step_pct)
        except Exception as exc:
            print("Problem encountered while running %s" %
                  self.__class__.__name__)
            raise exc
{'fraction_non_alphanumeric': 0.06805845511482254, 'fraction_numerical': 0.008350730688935281, 'mean_word_length': 1.7661662817551964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2334906', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1217, 'n_words': 296}