From c6e1e8bf9a4cd716848fa469e18fb8e50eaf869a Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Wed, 6 Mar 2024 19:05:25 +0000 Subject: [PATCH 1/3] changing to static method --- .../remove_dead_stripe/remove_dead_stripe.py | 11 ++++++----- .../remove_large_stripe/remove_large_stripe.py | 11 ++++++----- .../remove_stripe_filtering.py | 12 ++++++------ .../remove_stripe_sorting_fitting.py | 8 ++++---- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py b/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py index 96bd40e6390..5d76b4b32f2 100644 --- a/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py +++ b/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py @@ -35,8 +35,8 @@ class RemoveDeadStripesFilter(BaseFilter): link_histograms = True operate_on_sinograms = True - @classmethod - def filter_func(cls, images: ImageStack, snr=3, size=61, progress=None): + @staticmethod + def filter_func(images: ImageStack, snr=3, size=61, progress=None): """ :param snr: The ratio value. :param size: The window size of the median filter to remove dead stripes. @@ -47,10 +47,11 @@ def filter_func(cls, images: ImageStack, snr=3, size=61, progress=None): return images params = {"snr": snr, "size": size, "residual": False} if images.is_sinograms: - compute_func = cls.compute_function_sino + ps.run_compute_func(RemoveDeadStripesFilter.compute_function_sino, images.num_sinograms, + images.shared_array, params, progress) else: - compute_func = cls.compute_function - ps.run_compute_func(compute_func, images.num_sinograms, images.shared_array, params, progress) + ps.run_compute_func(RemoveDeadStripesFilter.compute_function, images.num_projections, images.shared_array, + params, progress) return images @staticmethod diff --git a/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py b/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py index 1f035f95616..7a136340df6 100644 --- a/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py +++ b/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py @@ -35,8 +35,8 @@ class RemoveLargeStripesFilter(BaseFilter): link_histograms = True operate_on_sinograms = True - @classmethod - def filter_func(cls, images: 'ImageStack', snr=3, la_size=61, progress=None): + @staticmethod + def filter_func(images: 'ImageStack', snr=3, la_size=61, progress=None): """ :param snr: The ratio value. :param size: The window size of the median filter to remove large stripes. @@ -45,10 +45,11 @@ def filter_func(cls, images: 'ImageStack', snr=3, la_size=61, progress=None): """ params = {"snr": snr, "size": la_size} if images.is_sinograms: - compute_func = cls.compute_function_sino + ps.run_compute_func(RemoveLargeStripesFilter.compute_function_sino, images.num_sinograms, + images.shared_array, params, progress) else: - compute_func = cls.compute_function - ps.run_compute_func(compute_func, images.num_sinograms, images.shared_array, params, progress) + ps.run_compute_func(RemoveLargeStripesFilter.compute_function, images.num_projections, images.shared_array, + params, progress) return images @staticmethod diff --git a/mantidimaging/core/operations/remove_stripe_filtering/remove_stripe_filtering.py b/mantidimaging/core/operations/remove_stripe_filtering/remove_stripe_filtering.py index 9cc8e469ae2..a888ad6f28f 100644 --- a/mantidimaging/core/operations/remove_stripe_filtering/remove_stripe_filtering.py +++ b/mantidimaging/core/operations/remove_stripe_filtering/remove_stripe_filtering.py @@ -35,8 +35,8 @@ class RemoveStripeFilteringFilter(BaseFilter): link_histograms = True operate_on_sinograms = True - @classmethod - def filter_func(cls, images: ImageStack, sigma=3, size=21, window_dim=1, filtering_dim=1, progress=None): + @staticmethod + def filter_func(images: ImageStack, sigma=3, size=21, window_dim=1, filtering_dim=1, progress=None): """ :param sigma: The sigma of the Gaussian window used to separate the low-pass and high-pass components of the intensity profile @@ -55,15 +55,15 @@ def filter_func(cls, images: ImageStack, sigma=3, size=21, window_dim=1, filteri if images.is_sinograms: if filtering_dim == 1: params["sort"] = True - compute_func = cls.compute_function_sino + compute_func = RemoveStripeFilteringFilter.compute_function_sino else: - compute_func = cls.compute_function_2d_sino + compute_func = RemoveStripeFilteringFilter.compute_function_2d_sino else: if filtering_dim == 1: params["sort"] = True - compute_func = cls.compute_function + compute_func = RemoveStripeFilteringFilter.compute_function else: - compute_func = cls.compute_function_2d + compute_func = RemoveStripeFilteringFilter.compute_function_2d ps.run_compute_func(compute_func, images.num_sinograms, images.shared_array, params, progress) return images diff --git a/mantidimaging/core/operations/remove_stripe_sorting_fitting/remove_stripe_sorting_fitting.py b/mantidimaging/core/operations/remove_stripe_sorting_fitting/remove_stripe_sorting_fitting.py index ab56c55fc6b..9fd88c1d925 100644 --- a/mantidimaging/core/operations/remove_stripe_sorting_fitting/remove_stripe_sorting_fitting.py +++ b/mantidimaging/core/operations/remove_stripe_sorting_fitting/remove_stripe_sorting_fitting.py @@ -35,8 +35,8 @@ class RemoveStripeSortingFittingFilter(BaseFilter): link_histograms = True operate_on_sinograms = True - @classmethod - def filter_func(cls, images: ImageStack, order=1, sigma=3, progress=None): + @staticmethod + def filter_func(images: ImageStack, order=1, sigma=3, progress=None): """ :param order: The polynomial fit order. Check algotom docs for more information. @@ -49,9 +49,9 @@ def filter_func(cls, images: ImageStack, order=1, sigma=3, progress=None): return images params = {'order': order, 'sigma': sigma, 'sort': True} if images.is_sinograms: - compute_func = cls.compute_function_sino + compute_func = RemoveStripeSortingFittingFilter.compute_function_sino else: - compute_func = cls.compute_function + compute_func = RemoveStripeSortingFittingFilter.compute_function ps.run_compute_func(compute_func, images.num_sinograms, images.shared_array, params, progress) return images From 1f9e98c89d518767471ed83f92283b7621619ccc Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Wed, 6 Mar 2024 19:25:49 +0000 Subject: [PATCH 2/3] changing to static method --- .../operations/remove_dead_stripe/remove_dead_stripe.py | 8 ++++---- .../operations/remove_large_stripe/remove_large_stripe.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py b/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py index 5d76b4b32f2..a926ba06c80 100644 --- a/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py +++ b/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py @@ -47,11 +47,11 @@ def filter_func(images: ImageStack, snr=3, size=61, progress=None): return images params = {"snr": snr, "size": size, "residual": False} if images.is_sinograms: - ps.run_compute_func(RemoveDeadStripesFilter.compute_function_sino, images.num_sinograms, - images.shared_array, params, progress) + compute_func = RemoveDeadStripesFilter.compute_function_sino else: - ps.run_compute_func(RemoveDeadStripesFilter.compute_function, images.num_projections, images.shared_array, - params, progress) + compute_func = RemoveDeadStripesFilter.compute_function + + ps.run_compute_func(compute_func, images.num_projections, images.shared_array, params, progress) return images @staticmethod diff --git a/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py b/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py index 7a136340df6..378d4edce16 100644 --- a/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py +++ b/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py @@ -45,11 +45,11 @@ def filter_func(images: 'ImageStack', snr=3, la_size=61, progress=None): """ params = {"snr": snr, "size": la_size} if images.is_sinograms: - ps.run_compute_func(RemoveLargeStripesFilter.compute_function_sino, images.num_sinograms, - images.shared_array, params, progress) + compute_func = RemoveLargeStripesFilter.compute_function_sino else: - ps.run_compute_func(RemoveLargeStripesFilter.compute_function, images.num_projections, images.shared_array, - params, progress) + compute_func = RemoveLargeStripesFilter.compute_function + + ps.run_compute_func(compute_func, images.num_projections, images.shared_array, params, progress) return images @staticmethod From 3e5ba4af56ac8c1202164152950d87236946fa62 Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Thu, 7 Mar 2024 12:20:24 +0000 Subject: [PATCH 3/3] changing to static method --- .../core/operations/remove_dead_stripe/remove_dead_stripe.py | 3 +-- .../core/operations/remove_large_stripe/remove_large_stripe.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py b/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py index a926ba06c80..97a5339c922 100644 --- a/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py +++ b/mantidimaging/core/operations/remove_dead_stripe/remove_dead_stripe.py @@ -50,8 +50,7 @@ def filter_func(images: ImageStack, snr=3, size=61, progress=None): compute_func = RemoveDeadStripesFilter.compute_function_sino else: compute_func = RemoveDeadStripesFilter.compute_function - - ps.run_compute_func(compute_func, images.num_projections, images.shared_array, params, progress) + ps.run_compute_func(compute_func, images.num_sinograms, images.shared_array, params, progress) return images @staticmethod diff --git a/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py b/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py index 378d4edce16..0fc53bda153 100644 --- a/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py +++ b/mantidimaging/core/operations/remove_large_stripe/remove_large_stripe.py @@ -48,8 +48,7 @@ def filter_func(images: 'ImageStack', snr=3, la_size=61, progress=None): compute_func = RemoveLargeStripesFilter.compute_function_sino else: compute_func = RemoveLargeStripesFilter.compute_function - - ps.run_compute_func(compute_func, images.num_projections, images.shared_array, params, progress) + ps.run_compute_func(compute_func, images.num_sinograms, images.shared_array, params, progress) return images @staticmethod