Skip to content

Commit

Permalink
place recon out name in method
Browse files Browse the repository at this point in the history
  • Loading branch information
JackEAllen committed May 30, 2024
1 parent 3fdede3 commit ff51a9e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions mantidimaging/gui/windows/recon/presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,7 @@ def _on_stack_reconstruct_slice_done(self, task: TaskWorkerThread):
slice_idx = self._get_slice_index(None)
if images is not None:
assert self.model.images is not None
algorithm_name = self.view.recon_params().algorithm
filter_name = self.view.recon_params(
).filter_name if "filter_name" in self.allowed_recon_kwargs[algorithm_name] else None

images.name = f"Recon_Slice_{algorithm_name}"
images.name = f"{images.name}_{filter_name}" if filter_name else images.name
images.name = self.create_recon_output_filename("Recon_Slice")
self._replace_inf_nan(images) # pyqtgraph workaround
self.view.show_recon_volume(images, self.model.stack_id)
images.record_operation('AstraRecon.single_sino',
Expand Down Expand Up @@ -354,11 +349,7 @@ def _on_volume_recon_done(self, task) -> None:
try:
self._replace_inf_nan(task.result) # pyqtgraph workaround
assert self.model.images is not None
algorithm_name = self.view.recon_params().algorithm
filter_name = self.view.recon_params(
).filter_name if "filter_name" in self.allowed_recon_kwargs[algorithm_name] else None
task.result.name = f"Recon_Vol{self.view.recon_params().algorithm}"
task.result.name = f"{task.result.name}_{filter_name}" if filter_name else task.result.name
task.result.name = self.create_recon_output_filename("Recon_Vol")
self.view.show_recon_volume(task.result, self.model.stack_id)
finally:
self.view.set_recon_buttons_enabled(True)
Expand Down Expand Up @@ -477,3 +468,15 @@ def _replace_inf_nan(images: ImageStack) -> None:
:param images: The ImageStack object.
"""
images.data[np.isinf(images.data)] = np.nan

def create_recon_output_filename(self, prefix: str) -> str:
"""
Takes a naming prefix and creates a descriptive recon output
filename based on algorithm and filter if filter kward used in recon
"""
recon_name = self.view.recon_params().algorithm
filter_name = self.view.recon_params(
).filter_name if "filter_name" in self.allowed_recon_kwargs[recon_name] else None

algorithm_name = f"{prefix}_{recon_name}"
return f"{algorithm_name}_{filter_name}" if filter_name else algorithm_name

0 comments on commit ff51a9e

Please sign in to comment.