From d9432bccf982ca06e987edf4cfc0a7db9b495f94 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Thu, 9 May 2024 13:42:27 +0100 Subject: [PATCH 1/8] Create ShutterCount File Selection to Load Dialog --- mantidimaging/gui/ui/image_load_dialog.ui | 38 +++++++++++++---------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/mantidimaging/gui/ui/image_load_dialog.ui b/mantidimaging/gui/ui/image_load_dialog.ui index b69e0a920d8..ca5a21a32fd 100644 --- a/mantidimaging/gui/ui/image_load_dialog.ui +++ b/mantidimaging/gui/ui/image_load_dialog.ui @@ -7,7 +7,7 @@ 0 0 690 - 497 + 530 @@ -129,24 +129,30 @@ - - Flat Before Log - - - - - - - - - - + + Sample Shutter Counts + - - Flat After Log - + + Flat Before Shutter Counts + + + + + Flat After Shutter Counts + + + + Flat Before Log + + + + + Flat After Log + + From 207fc63dbc81123279e086d4594fe0412be19bc2 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Thu, 9 May 2024 13:44:16 +0100 Subject: [PATCH 2/8] Create Load ShutterCount File for Stack Option Post-Load --- mantidimaging/gui/ui/main_window.ui | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mantidimaging/gui/ui/main_window.ui b/mantidimaging/gui/ui/main_window.ui index e9e5f67babb..3d2b555b043 100644 --- a/mantidimaging/gui/ui/main_window.ui +++ b/mantidimaging/gui/ui/main_window.ui @@ -38,6 +38,7 @@ + @@ -189,6 +190,14 @@ Load log for stack... + + + false + + + Load ShutterCounts file for stack... + + false From 77feb9b684cce56a7869da359030943c5354249a Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Thu, 9 May 2024 13:55:48 +0100 Subject: [PATCH 3/8] Re-enable Load Parameter ShutterCount References Re-enable ShutterCount load parameter references to enable selection of ShutterCount files within loading dialog window. --- mantidimaging/gui/windows/image_load_dialog/presenter.py | 3 +-- mantidimaging/gui/windows/image_load_dialog/view.py | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/mantidimaging/gui/windows/image_load_dialog/presenter.py b/mantidimaging/gui/windows/image_load_dialog/presenter.py index 154b98a62ef..8c96206e569 100644 --- a/mantidimaging/gui/windows/image_load_dialog/presenter.py +++ b/mantidimaging/gui/windows/image_load_dialog/presenter.py @@ -164,8 +164,7 @@ def _update_loading_param(self, file_type: FILE_TYPES, loading_param: LoadingPar if file_type in log_for_file_type: self._update_image_param(file_type, image_param, log_for_file_type, 'log_file') if file_type in shuttercounts_for_file_type: - # self._update_image_param(file_type, image_param, shuttercounts_for_file_type, 'shutter_count_file') - pass + self._update_image_param(file_type, image_param, shuttercounts_for_file_type, 'shutter_count_file') if file_type == FILE_TYPES.SAMPLE: image_param.indices = field.indices diff --git a/mantidimaging/gui/windows/image_load_dialog/view.py b/mantidimaging/gui/windows/image_load_dialog/view.py index dae32a67636..d23267ac97f 100644 --- a/mantidimaging/gui/windows/image_load_dialog/view.py +++ b/mantidimaging/gui/windows/image_load_dialog/view.py @@ -39,8 +39,6 @@ def __init__(self, parent: QWidget) -> None: self.tree.setTabKeyNavigation(True) for n, file_info in enumerate(FILE_TYPES): - if file_info.fname in ["Sample Shutter Counts", "Flat Before Shutter Counts", "Flat After Shutter Counts"]: - continue self.fields[file_info.fname] = self.create_file_input(n, file_info) self.sample = self.fields["Sample"] From 08ca9623d8b0e7a2be4b59d955fb926a09516624 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Thu, 9 May 2024 14:08:08 +0100 Subject: [PATCH 4/8] Connect Main View to ShutterCount Load Dialog Selection Actions --- mantidimaging/gui/windows/main/view.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mantidimaging/gui/windows/main/view.py b/mantidimaging/gui/windows/main/view.py index 6b4f5011c79..b05d79b903d 100644 --- a/mantidimaging/gui/windows/main/view.py +++ b/mantidimaging/gui/windows/main/view.py @@ -88,6 +88,7 @@ class MainWindowView(BaseMainWindowView): actionSpectrumViewer: QAction actionLiveViewer: QAction actionSampleLoadLog: QAction + actionShutterCounts: QAction actionLoadProjectionAngles: QAction actionLoad180deg: QAction actionLoadDataset: QAction @@ -184,6 +185,7 @@ def setup_shortcuts(self): self.actionLoadImages.triggered.connect(self.load_image_stack) self.actionLoadNeXusFile.triggered.connect(self.show_nexus_load_dialog) self.actionSampleLoadLog.triggered.connect(self.load_sample_log_dialog) + self.actionShutterCounts.triggered.connect(self.load_shuttercounts_dialog) self.actionLoad180deg.triggered.connect(self.load_180_deg_dialog) self.actionLoadProjectionAngles.triggered.connect(self.load_projection_angles) self.actionSaveImages.triggered.connect(self.show_image_save_dialog) @@ -227,6 +229,7 @@ def update_shortcuts(self): self.actionSaveImages.setEnabled(has_datasets) self.actionSaveNeXusFile.setEnabled(has_strict_datasets) self.actionSampleLoadLog.setEnabled(has_datasets) + self.actionShutterCounts.setEnabled(has_datasets) self.actionLoad180deg.setEnabled(has_strict_datasets) self.actionLoadProjectionAngles.setEnabled(has_datasets) self.menuWorkflow.setEnabled(has_datasets) From b3c4ac4f085eb8dbb4bbe3c60f091c17b001b8f5 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Thu, 9 May 2024 14:12:53 +0100 Subject: [PATCH 5/8] Re-order FILE_TYPES --- mantidimaging/core/utility/data_containers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mantidimaging/core/utility/data_containers.py b/mantidimaging/core/utility/data_containers.py index 872bc4e5787..8be4df8040f 100644 --- a/mantidimaging/core/utility/data_containers.py +++ b/mantidimaging/core/utility/data_containers.py @@ -143,11 +143,11 @@ class FILE_TYPES(Enum): DARK_AFTER = ("Dark", "After", "images") PROJ_180 = ("180 degree", "", "180") SAMPLE_LOG = ("Sample Log", "", "log") - FLAT_BEFORE_LOG = ("Flat Before Log", "", "log") - FLAT_AFTER_LOG = ("Flat After Log", "", "log") SHUTTER_COUNTS = ("Sample Shutter Counts", "", "ShutterCount") FLAT_BEFORE_SHUTTER_COUNTS = ("Flat Before Shutter Counts", "", "ShutterCount") FLAT_AFTER_SHUTTER_COUNTS = ("Flat After Shutter Counts", "", "ShutterCount") + FLAT_BEFORE_LOG = ("Flat Before Log", "", "log") + FLAT_AFTER_LOG = ("Flat After Log", "", "log") def __init__(self, tname: str, suffix: str, mode: str) -> None: self.tname = tname From a737984224bb04050a52cd9349fdd253157b5ae3 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Mon, 13 May 2024 10:42:56 +0100 Subject: [PATCH 6/8] Loading Dialog ShutterCount File Format Validation --- .../gui/windows/image_load_dialog/presenter.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mantidimaging/gui/windows/image_load_dialog/presenter.py b/mantidimaging/gui/windows/image_load_dialog/presenter.py index 8c96206e569..b1a2883f831 100644 --- a/mantidimaging/gui/windows/image_load_dialog/presenter.py +++ b/mantidimaging/gui/windows/image_load_dialog/presenter.py @@ -7,7 +7,7 @@ from typing import TYPE_CHECKING from mantidimaging.core.io.filenames import FilenameGroup -from mantidimaging.core.io.loader import load_log +from mantidimaging.core.io.loader import load_log, load_shutter_counts from mantidimaging.core.io.loader.loader import LoadingParameters, ImageParameters, read_image_dimensions from mantidimaging.core.utility.data_containers import FILE_TYPES, log_for_file_type, shuttercounts_for_file_type from mantidimaging.gui.windows.image_load_dialog.field import Field @@ -111,6 +111,16 @@ def do_update_shutter_counts(self, field: Field, selected_file: str) -> None: filename_group.find_shutter_count_file() field.set_images(list(filename_group.all_files())) self._update_field_action(field, selected_file) + shuttercount_names = [p.name for p in filename_group.all_files()] + self.ensure_sample_shuttercount_consistency(field, selected_file, shuttercount_names) + + def ensure_sample_shuttercount_consistency(self, field: Field, file_name: str, image_filenames: list[str]) -> None: + if file_name is None or file_name == "": + return + + shutter_count = load_shutter_counts(Path(file_name)) + shutter_count.raise_if_counts_missing() + self._update_field_action(field, file_name) def do_update_flat_or_dark(self, field: Field, selected_file: str) -> None: """ From 520a5649035771da50166203eccb258d7017a9d1 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Tue, 14 May 2024 18:55:49 +0100 Subject: [PATCH 7/8] Remove Counts Check Method --- mantidimaging/core/io/instrument_log.py | 3 --- .../gui/windows/image_load_dialog/presenter.py | 10 +++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/mantidimaging/core/io/instrument_log.py b/mantidimaging/core/io/instrument_log.py index bec1786537e..5fb642ca994 100644 --- a/mantidimaging/core/io/instrument_log.py +++ b/mantidimaging/core/io/instrument_log.py @@ -246,6 +246,3 @@ def pulse_per_shutter_range_numbers(self) -> np.ndarray[Any, Any]: def has_Pulse(self) -> bool: return ShutterCountColumn.PULSE in self.data - - def raise_if_counts_missing(self): - pass diff --git a/mantidimaging/gui/windows/image_load_dialog/presenter.py b/mantidimaging/gui/windows/image_load_dialog/presenter.py index b1a2883f831..bc43029b2df 100644 --- a/mantidimaging/gui/windows/image_load_dialog/presenter.py +++ b/mantidimaging/gui/windows/image_load_dialog/presenter.py @@ -7,7 +7,7 @@ from typing import TYPE_CHECKING from mantidimaging.core.io.filenames import FilenameGroup -from mantidimaging.core.io.loader import load_log, load_shutter_counts +from mantidimaging.core.io.loader import load_log from mantidimaging.core.io.loader.loader import LoadingParameters, ImageParameters, read_image_dimensions from mantidimaging.core.utility.data_containers import FILE_TYPES, log_for_file_type, shuttercounts_for_file_type from mantidimaging.gui.windows.image_load_dialog.field import Field @@ -111,15 +111,11 @@ def do_update_shutter_counts(self, field: Field, selected_file: str) -> None: filename_group.find_shutter_count_file() field.set_images(list(filename_group.all_files())) self._update_field_action(field, selected_file) - shuttercount_names = [p.name for p in filename_group.all_files()] - self.ensure_sample_shuttercount_consistency(field, selected_file, shuttercount_names) + self.ensure_sample_shuttercount_consistency(field, selected_file) - def ensure_sample_shuttercount_consistency(self, field: Field, file_name: str, image_filenames: list[str]) -> None: + def ensure_sample_shuttercount_consistency(self, field: Field, file_name: str) -> None: if file_name is None or file_name == "": return - - shutter_count = load_shutter_counts(Path(file_name)) - shutter_count.raise_if_counts_missing() self._update_field_action(field, file_name) def do_update_flat_or_dark(self, field: Field, selected_file: str) -> None: From bb2e2f4db20d3b5c53af717141f29997e6923588 Mon Sep 17 00:00:00 2001 From: JackEAllen Date: Mon, 13 May 2024 09:24:18 +0100 Subject: [PATCH 8/8] Release Notes --- .../next/feature-2094-Load_ShutterCount_files_front-end | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/release_notes/next/feature-2094-Load_ShutterCount_files_front-end diff --git a/docs/release_notes/next/feature-2094-Load_ShutterCount_files_front-end b/docs/release_notes/next/feature-2094-Load_ShutterCount_files_front-end new file mode 100644 index 00000000000..897d04ff2ae --- /dev/null +++ b/docs/release_notes/next/feature-2094-Load_ShutterCount_files_front-end @@ -0,0 +1 @@ +#2094: Front-end for loading ShutterCount files into Mantid Imaging. \ No newline at end of file