Skip to content

Commit

Permalink
Refactor add_log_to_sample, now checks if logs are suitable before se…
Browse files Browse the repository at this point in the history
…tting

Also small refactor in add_180_deg to handle the case where a stack with the name is not found
  • Loading branch information
Dimitar Tasev committed Dec 1, 2020
1 parent 432dfc9 commit dd46fc6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions mantidimaging/gui/windows/main/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,21 @@ def have_active_stacks(self) -> bool:
return len(self.active_stacks) > 0

def add_log_to_sample(self, stack_name: str, log_file: str):
stack = self.get_stack_by_name(stack_name).widget() # type: ignore
stack.presenter.images.log_file = loader.load_log(log_file)
stack.presenter.images.log_file.raise_if_angle_missing(stack.presenter.images.filenames)
stack_dock = self.get_stack_by_name(stack_name)
if stack_dock is None:
raise RuntimeError(f"Failed to get stack with name {stack_name}")

stack: StackVisualiserView = stack_dock.widget() # type: ignore
log = loader.load_log(log_file)
log.raise_if_angle_missing(stack.presenter.images.filenames)
stack.presenter.images.log_file = log

def add_180_deg_to_stack(self, stack_name, _180_deg_file):
stack = self.get_stack_by_name(stack_name).widget() # type: ignore
stack_dock = self.get_stack_by_name(stack_name)
if stack_dock is None:
raise RuntimeError(f"Failed to get stack with name {stack_name}")

stack: StackVisualiserView = stack_dock.widget() # type: ignore
_180_deg = loader.load(file_names=[_180_deg_file])
stack.presenter.images.proj180deg = _180_deg.sample
return _180_deg

0 comments on commit dd46fc6

Please sign in to comment.