Skip to content

Commit

Permalink
Merge pull request #1149 from mantidproject/1023-algotom
Browse files Browse the repository at this point in the history
Switch from sarepy to algotom
  • Loading branch information
samtygier-stfc authored Sep 24, 2021
2 parents 0ebc361 + b3d0ba0 commit b547c6e
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 53 deletions.
1 change: 1 addition & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ requirements:
- cil-astra=21.2.*
- ccpi-regulariser=20.9
- tomophantom=1.4.*
- algotom=1.0.*

build:
number: 1
Expand Down
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Overview

Mantid Imaging contains tools for loading data from neutron imaging experiments, preprocessing to enhance images and tomographic reconstruction into 3 dimensional data that can be output for further analysis.

Mantid Imaging makes use of a range of algorithms, some from external tools including `Astra <http://www.astra-toolbox.com/>`_ and `Tomopy <https://tomopy.readthedocs.io/en/latest/>`_. Many of these are optimised for multithreading and GPU computing.
Mantid Imaging makes use of a range of algorithms, some from external tools including `Astra <http://www.astra-toolbox.com/>`_, `Tomopy <https://tomopy.readthedocs.io/en/latest/>`_, `Algotom <https://github.com/algotom/algotom>`_ and the `Core Imaging Library <https://github.com/TomographicImaging/CIL>`_. Many of these are optimised for multithreading and GPU computing.

Mantid Imaging is written in Python and requires a CUDA capable GPU for full functionality. It runs on Linux. See :ref:`Installation` for more details.

Expand Down
1 change: 1 addition & 0 deletions docs/release_notes/next.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ New Features
------------

- #1044 : Command line argument to load a dataset
- #1023 : Switch from Sarepy to Algotom

Fixes
-----
Expand Down
1 change: 1 addition & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ channels:
- astra-toolbox/label/dev
- conda-forge
- ccpi
- algotom
dependencies:
- mantidimaging
- pip
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ channels:
- astra-toolbox/label/dev
- conda-forge
- ccpi
- algotom
# Dependencies that can be installed with conda should be in conda/meta.yaml
dependencies:
- mantidimaging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from mantidimaging.core.data.images import Images

from PyQt5.QtWidgets import QSpinBox, QDoubleSpinBox
from sarepy.prep.stripe_removal_original import remove_all_stripe
from algotom.prep.removal import remove_all_stripe

from mantidimaging.core.operations.base_filter import BaseFilter, FilterGroup
from mantidimaging.core.parallel import shared as ps
Expand All @@ -16,7 +16,7 @@ class RemoveAllStripesFilter(BaseFilter):
"""Stripe and ring artifact removal. Remove all types of stripe artifacts by
combining algorithm 6, 5, and 3 in Vo et al., Optics Express 28396 (2018).
Source: https://github.com/nghia-vo/sarepy
Source: https://github.com/algotom/algotom
Intended to be used on: Sinograms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from mantidimaging.core.data.images import Images

from PyQt5.QtWidgets import QDoubleSpinBox, QSpinBox
from sarepy.prep.stripe_removal_original import remove_unresponsive_and_fluctuating_stripe
from algotom.prep.removal import remove_dead_stripe

from mantidimaging.core.operations.base_filter import BaseFilter, FilterGroup
from mantidimaging.core.parallel import shared as ps
Expand All @@ -16,7 +16,7 @@ class RemoveDeadStripesFilter(BaseFilter):
"""Stripe and ring artifact removal. Algorithm 6 in Vo et al., Optics Express 28396 (2018).
Remove unresponsive or fluctuating stripes by: locating stripes, correction by interpolation.
Source: https://github.com/nghia-vo/sarepy
Source: https://github.com/algotom/algotom
Intended to be used on: Sinograms
Expand All @@ -31,12 +31,7 @@ class RemoveDeadStripesFilter(BaseFilter):

@staticmethod
def filter_func(images: Images, snr=3, size=61, cores=None, chunksize=None, progress=None):
f = ps.create_partial(
remove_unresponsive_and_fluctuating_stripe,
ps.return_to_self,
snr=snr,
size=size,
)
f = ps.create_partial(remove_dead_stripe, ps.return_to_self, snr=snr, size=size, residual=False)
ps.shared_list = [images.data]
ps.execute(f, images.num_projections, progress, cores=cores)
return images
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from functools import partial

from PyQt5.QtWidgets import QSpinBox, QDoubleSpinBox
from sarepy.prep.stripe_removal_original import remove_large_stripe
from algotom.prep.removal import remove_large_stripe

from mantidimaging.core.operations.base_filter import BaseFilter, FilterGroup
from mantidimaging.core.parallel import shared as ps
Expand All @@ -16,7 +16,7 @@ class RemoveLargeStripesFilter(BaseFilter):
Remove large stripes by: locating stripes, normalizing them to remove full stripes, using
the sorting technique to remove partial stripes.
Source: https://github.com/nghia-vo/sarepy
Source: https://github.com/algotom/algotom
Intended to be used on: Sinograms
When: If stripes artifacts are present that have not been
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from mantidimaging.core.data.images import Images

from PyQt5.QtWidgets import QSpinBox
from sarepy.prep.stripe_removal_improved import remove_stripe_based_filtering_sorting, \
remove_stripe_based_2d_filtering_sorting
from algotom.prep.removal import remove_stripe_based_filtering, remove_stripe_based_2d_filtering_sorting

from mantidimaging.core.operations.base_filter import BaseFilter, FilterGroup
from mantidimaging.core.parallel import shared as ps
Expand All @@ -17,7 +16,7 @@ class RemoveStripeFilteringFilter(BaseFilter):
"""Stripe and ring artifact removal. Combination of algorithm 2 and algorithm 3 in Vo et al.,
Optics Express 28396 (2018). Removing stripes using the filtering and sorting technique.
Source: https://github.com/nghia-vo/sarepy
Source: https://github.com/algotom/algotom
Intended to be used on: Sinograms
Expand All @@ -40,11 +39,12 @@ def filter_func(images: Images,
chunksize=None,
progress=None):
if filtering_dim == 1:
f = ps.create_partial(remove_stripe_based_filtering_sorting,
f = ps.create_partial(remove_stripe_based_filtering,
ps.return_to_self,
sigma=sigma,
size=size,
dim=window_dim)
dim=window_dim,
sort=True)
else:
f = ps.create_partial(remove_stripe_based_2d_filtering_sorting,
ps.return_to_self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from mantidimaging.core.data.images import Images

from PyQt5.QtWidgets import QSpinBox
from sarepy.prep.stripe_removal_improved import remove_stripe_based_sorting_fitting
from algotom.prep.removal import remove_stripe_based_fitting

from mantidimaging.core.operations.base_filter import BaseFilter, FilterGroup
from mantidimaging.core.parallel import shared as ps
Expand All @@ -16,7 +16,7 @@ class RemoveStripeSortingFittingFilter(BaseFilter):
"""Stripe and ring artifact removal. Combination of algorithm 3 and 1 in Vo et al.,
Optics Express 28396 (2018). Remove stripes using the sorting and fitting technique.
Source: https://github.com/nghia-vo/sarepy
Source: https://github.com/algotom/algotom
Intended to be used on: Sinograms
Expand All @@ -30,12 +30,8 @@ class RemoveStripeSortingFittingFilter(BaseFilter):
link_histograms = True

@staticmethod
def filter_func(images: Images, order=1, sigmax=3, sigmay=3, cores=None, chunksize=None, progress=None):
f = ps.create_partial(remove_stripe_based_sorting_fitting,
ps.return_to_self,
order=order,
sigmax=sigmax,
sigmay=sigmay)
def filter_func(images: Images, order=1, sigma=3, cores=None, chunksize=None, progress=None):
f = ps.create_partial(remove_stripe_based_fitting, ps.return_to_self, order=order, sigma=sigma, sort=True)

ps.shared_list = [images.data]
ps.execute(f, images.num_projections, progress, cores=cores)
Expand All @@ -54,28 +50,19 @@ def register_gui(form, on_change, view):
default_value=1,
form=form,
on_change=on_change,
tooltip="Polynomial fit order. Check sarepy for more information")
_, sigmax = add_property_to_form('Sigma X',
Type.INT,
default_value=3,
form=form,
on_change=on_change,
tooltip="Sigma of the Gaussian window in the x-direction")
_, sigmay = add_property_to_form('Sigma Y',
Type.INT,
default_value=3,
form=form,
on_change=on_change,
tooltip="Sigma of the Gaussian window in the y-direction")

return {'order': order, 'sigmax': sigmax, 'sigmay': sigmay}
tooltip="Polynomial fit order. Check algotom docs for more information")
_, sigma = add_property_to_form('Sigma',
Type.INT,
default_value=3,
form=form,
on_change=on_change,
tooltip="Sigma of the Gaussian window in the x-direction")

return {'order': order, 'sigma': sigma}

@staticmethod
def execute_wrapper(order: QSpinBox, sigmax: QSpinBox, sigmay: QSpinBox): # type: ignore
return partial(RemoveStripeSortingFittingFilter.filter_func,
order=order.value(),
sigmax=sigmax.value(),
sigmay=sigmay.value())
def execute_wrapper(order: QSpinBox, sigma: QSpinBox): # type: ignore
return partial(RemoveStripeSortingFittingFilter.filter_func, order=order.value(), sigma=sigma.value())

@staticmethod
def group_name() -> FilterGroup:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,16 @@ def test_execute_wrapper_return_is_runnable(self):
"""
order = mock.Mock()
order.value = mock.Mock(return_value=1)
sigmax = mock.Mock()
sigmax.value = mock.Mock(return_value=2)
sigmay = mock.Mock()
sigmay.value = mock.Mock(return_value=2)
sigma = mock.Mock()
sigma.value = mock.Mock(return_value=2)

execute_func = RemoveStripeSortingFittingFilter.execute_wrapper(order, sigmax, sigmay)
execute_func = RemoveStripeSortingFittingFilter.execute_wrapper(order, sigma)

images = th.generate_images()
execute_func(images)

self.assertEqual(order.value.call_count, 1)
self.assertEqual(sigmax.value.call_count, 1)
self.assertEqual(sigmay.value.call_count, 1)
self.assertEqual(sigma.value.call_count, 1)


if __name__ == '__main__':
Expand Down

0 comments on commit b547c6e

Please sign in to comment.