Skip to content

Commit 5eff60a

Browse files
committed
Fix preview value of VoCentering's input data not persisting across iterations
One of the things that occurs after a plugin finishes running is that it resets the preview value for all of its datasets: https://github.com/DiamondLightSource/Savu/blob/df7418a8189a54d13d8cddfd0a17f6295611cd1a/savu/plugins/driver/plugin_driver.py#L67. If there is a non-empty preview value set in VoCentering and it is in an iterative loop, the above results in VoCentering ignoring its preview value on iterations after the 0th one, and instead calculating the centre of rotation on however many sinograms were provided by the previewed data outputted by the loader plugin. For example, when using VoCentering in an iterative loop, if: - the loader has a non-empty preview value of [:, 200:800, :] - VoCentering has a non-empty preview value of [:, mid, :] this then causes VoCentering on iteration 0 to calculate the centre of rotation of 1 sinogram (expected behaviour), but on iteration 1 (and onwards) to calculate the centre of rotation of 600 sinograms (unexpected behaviour). In this example, on all iterations it's expected that only a single sinogram is processed, which corresponds to the middle slice of the previewed data outputted by the loader. This happens on iteration 0, but does not happen on subsequent iterations. Instead, what happens on iteration 1 and onwards is that 600 sinograms are processed by VoCentering, which correspond to the entire previewed data outputted by the loader. This change: - updates the preview value in the `Preview` object associated with the input dataset of VoCentering on every iteration after the 0th one - subsequetly updates the `PluginData` object associated to the input dataset of VoCentering on every iteration after the 0th one (this is so then the transport layer is made aware of the preview value being reset) and thus preserves the VoCentering plugin's preview value across all iterations, allowing VoCentering to process the expected number of sinograms on every iteration.
1 parent 732c6e4 commit 5eff60a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

savu/plugins/centering/vo_centering.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ def pre_process(self):
179179
self.broadcast_method = 'median'
180180
in_pData = self.get_plugin_in_datasets()[0]
181181
data = self.get_in_datasets()[0]
182+
183+
iterate_group = check_if_in_iterative_loop(self.exp)
184+
if iterate_group is not None and iterate_group._ip_iteration > 0:
185+
# reset the preview value of the input dataset (since in
186+
# PluginDriver._run_plugin_instances() the value is changed after
187+
# the VoCentering plugin runs on the previous iteration)
188+
in_dataset, out_dataset = self.get_datasets()
189+
self.set_preview(in_dataset[0], self.parameters['preview'])
190+
self._finalise_plugin_datasets()
191+
182192
# the preview parameters from the centering plugin (calculated as absolute values - not related to the loader preview values)
183193
starts, stops, steps = data.get_preview().get_starts_stops_steps()[0:3]
184194
start_ind = starts[1]

0 commit comments

Comments
 (0)