Skip to content

Commit

Permalink
NaN warnings activated in the Spectrum Viewer (#2186)
Browse files Browse the repository at this point in the history
  • Loading branch information
samtygier-stfc committed Jun 7, 2024
2 parents 937bb36 + dcd3ffa commit f482056
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/release_notes/next/fix-2185-spectrum-nan-warning
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#2185: NaN warning icon now appears in the Spectrum Viewer when NaN are in averaged image
16 changes: 12 additions & 4 deletions mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from mantidimaging.core.utility.sensible_roi import SensibleROI
from mantidimaging.gui.widgets.mi_mini_image_view.view import MIMiniImageView

if TYPE_CHECKING:
from mantidimaging.gui.windows.main import MainWindowView # noqa:F401 # pragma: no cover

if TYPE_CHECKING:
import numpy as np

Expand Down Expand Up @@ -113,12 +116,12 @@ class SpectrumWidget(QWidget):
spectrum_plot_widget: SpectrumPlotWidget
image_widget: SpectrumProjectionWidget

def __init__(self) -> None:
def __init__(self, main_window: MainWindowView) -> None:
super().__init__()

self.vbox = QVBoxLayout(self)

self.image_widget = SpectrumProjectionWidget()
self.image_widget = SpectrumProjectionWidget(main_window)
self.image = self.image_widget.image
self.spectrum_plot_widget = SpectrumPlotWidget()
self.spectrum = self.spectrum_plot_widget.spectrum
Expand Down Expand Up @@ -351,8 +354,13 @@ def set_tof_axis_label(self, tof_axis_label: str) -> None:
class SpectrumProjectionWidget(GraphicsLayoutWidget):
image: MIMiniImageView

def __init__(self) -> None:
super().__init__()
def __init__(self, parent: MainWindowView) -> None:
super().__init__(parent)
self._main_window = parent
self.image = MIMiniImageView(name="Projection", view_box_type=CustomViewBox)
self.addItem(self.image, 0, 0)
self.ci.layout.setRowStretchFactor(0, 3)

nan_check_menu = [("Crop Coordinates", lambda: self._main_window.presenter.show_operation("Crop Coordinates")),
("NaN Removal", lambda: self._main_window.presenter.show_operation("NaN Removal"))]
self.image.enable_nan_check(actions=nan_check_menu)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setUp(self) -> None:
self.view = mock.create_autospec(SpectrumViewerWindowView)
self.view.current_dataset_id = uuid.uuid4()
self.view.parent = mock.create_autospec(SpectrumViewerWindowPresenter)
self.spectrum_widget = SpectrumWidget()
self.spectrum_widget = SpectrumWidget(self.main_window)
self.spectrum_plot_widget = SpectrumPlotWidget()
self.sensible_roi = SensibleROI.from_list([0, 0, 0, 0])

Expand Down
2 changes: 1 addition & 1 deletion mantidimaging/gui/windows/spectrum_viewer/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, main_window: MainWindowView):

self.presenter = SpectrumViewerWindowPresenter(self, main_window)

self.spectrum_widget = SpectrumWidget()
self.spectrum_widget = SpectrumWidget(main_window)
self.spectrum = self.spectrum_widget.spectrum_plot_widget

self.imageLayout.addWidget(self.spectrum_widget)
Expand Down

0 comments on commit f482056

Please sign in to comment.