Skip to content

Commit

Permalink
added load_specific_image_stack function
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmeigh committed May 13, 2024
1 parent f57d46a commit 69f5e70
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions scripts/operations_tests/operations_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import numpy as np
import pandas as pd

from mantidimaging.core.utility.data_containers import FILE_TYPES

try:
from plotly import graph_objs as go
from plotly.subplots import make_subplots
Expand All @@ -34,6 +32,7 @@
from mantidimaging.core.io.filenames import FilenameGroup # noqa: E402
from mantidimaging.core.io.loader import loader # noqa: E402
from mantidimaging.core.operations.loader import load_filter_packages # noqa: E402
from mantidimaging.core.utility.data_containers import FILE_TYPES #

script_dir = Path(__file__).resolve().parent
log_directory = script_dir / "logs"
Expand Down Expand Up @@ -181,9 +180,23 @@ def add_nan(self, image_stack, fraction=0.001):
def add_flats_and_darks(self, params):
for frame_type in ['flat_before', 'dark_before', 'flat_after', 'dark_after']:
if frame_type in params:
file_path = FilenameGroup.from_file(config_manager.load_sample)
file_path.find_related(getattr(FILE_TYPES, frame_type.upper()))
params[frame_type] = self.load_image_stack(file_path.get_path(getattr(FILE_TYPES, frame_type.upper())))
filename_group = FilenameGroup.from_file(config_manager.load_sample)
filename_group.find_all_files()
filename_group.find_related(getattr(FILE_TYPES, frame_type.upper()))

image_stack = self.load_specific_image_stack(filename_group, frame_type)
if image_stack is not None:
params[frame_type] = image_stack
else:
print(f"Failed to load image stack for {frame_type}")

def load_specific_image_stack(self, filename_group, frame_type):
try:
image_stack = loader.load(filename_group=filename_group)
return image_stack
except Exception as e:
print(f"Error loading image stack for {frame_type}: {e}")
return None

def compare_mode(self):
for operation, test_case_info in TEST_CASES.items():
Expand Down

0 comments on commit 69f5e70

Please sign in to comment.