Commit 7b20711b authored by Pierre Paleo's avatar Pierre Paleo

Use a margin when using unsharp and no phase

parent b94a7613
......@@ -141,7 +141,7 @@ class FullFieldPipeline:
we need to load extra data around the edges of each image. Otherwise,
a default padding type is applied.
"""
if "phase" not in self.processing_steps:
if not(self.use_radio_processing_margin):
self._phase_margin = None
return
up_margin = self._phase_margin_up
......@@ -151,8 +151,13 @@ class FullFieldPipeline:
self._phase_margin = ((up_margin, down_margin), (left_margin, right_margin))
@property
def use_radio_processing_margin(self):
return ("phase" in self.processing_steps) or ("unsharp_mask" in self.processing_steps)
def _get_phase_margin(self):
if "phase" not in self.processing_steps:
if not(self.use_radio_processing_margin):
return ((0, 0), (0, 0))
return self._phase_margin
......@@ -263,7 +268,7 @@ class FullFieldPipeline:
return shape
def _get_phase_output_shape(self):
if "phase" not in self.processing_steps:
if not(self.use_radio_processing_margin):
self._radios_cropped_shape = self.radios.shape
return
((up_margin, down_margin), (left_margin, right_margin)) = self._phase_margin
......@@ -281,7 +286,7 @@ class FullFieldPipeline:
def _allocate_recs(self, ny, nx):
self.n_slices = self.radios.shape[1] # TODO modify with vertical shifts
if "phase" in self.processing_steps:
if self.use_radio_processing_margin:
self.n_slices -= sum(self.phase_margin[0])
self.recs = self._allocate_array((self.n_slices, ny, nx), "f", name="recs")
......
......@@ -235,7 +235,7 @@ class CudaFullFieldPipelineLimitedMemory(CudaFullFieldPipeline):
return shape
def _get_phase_output_shape(self):
if "phase" not in self.processing_steps:
if not(self.use_radio_processing_margin):
self._radios_cropped_shape = self.radios_group_shape
return
((up_margin, down_margin), (left_margin, right_margin)) = self._phase_margin
......
......@@ -106,8 +106,9 @@ class LocalReconstruction:
def _compute_phase_margin(self):
unsharp_margin = self._compute_unsharp_margin()
if "phase" not in self.process_config.processing_steps:
self._phase_margin = (0, 0)
self._phase_margin = unsharp_margin
self._margin_v = self._phase_margin[0]
return
radio_shape = self.process_config.dataset_infos.radio_dims[::-1]
......@@ -124,11 +125,24 @@ class LocalReconstruction:
pixel_size=opts["pixel_size_microns"],
padding=opts["padding_type"]
)
margin_v = max(margin_v, unsharp_margin[0])
self._phase_margin = (margin_v, margin_h)
self._margin_v = self._phase_margin[0]
self.logger.info("Estimated phase margin: %d pixels" % self._margin_v)
def _compute_unsharp_margin(self):
if "unsharp_mask" not in self.process_config.processing_steps:
return (0, 0)
opts = self.process_config.processing_options["unsharp_mask"]
sigma = opts["unsharp_sigma"]
# nabu uses cutoff = 4
cutoff = 4
gaussian_kernel_size = int(ceil(2 * cutoff * sigma + 1))
self.logger.debug("Unsharp mask margin: %d pixels" % gaussian_kernel_size)
return (gaussian_kernel_size, gaussian_kernel_size)
def _get_pipeline_class(self):
self._limited_mem = False
# Actually less in some cases (margin_far_up + margin_far_down instead of 2*margin_v).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment