Commit 7c71a7eb authored by Julia Garriga Ferrer's avatar Julia Garriga Ferrer
Browse files

[orangecontrib][zsum] Change origin and scale of image if transformation

parent 05091086
Pipeline #50624 passed with stage
in 2 minutes and 23 seconds
......@@ -26,7 +26,7 @@
__authors__ = ["J. Garriga"]
__license__ = "MIT"
__date__ = "11/12/2020"
__date__ = "15/12/2020"
from silx.gui.colors import Colormap
......@@ -59,6 +59,7 @@ class ZSumWidgetOW(OWWidget):
self._chooseDimensionDock = ChooseDimensionDock(self)
self._chooseDimensionDock.hide()
self.controlArea.layout().addWidget(self._chooseDimensionDock)
self.origin, self.scale = None, None
self._chooseDimensionDock.widget.filterChanged.connect(self._filterStack)
self._chooseDimensionDock.widget.stateDisabled.connect(self._wholeStack)
......@@ -72,6 +73,16 @@ class ZSumWidgetOW(OWWidget):
self._chooseDimensionDock.show()
self._chooseDimensionDock.widget.setDimensions(self.dataset.dims)
image = self.dataset.zsum(indices=self.indices)
if self.dataset.transformation:
px = self.dataset.transformation[0][0][0]
py = self.dataset.transformation[1][0][0]
xscale = (self.dataset.transformation[0][-1][-1] - px) / len(self.dataset.transformation[0][0])
yscale = (self.dataset.transformation[1][-1][-1] - py) / len(self.dataset.transformation[1][0])
self.origin = (px, py)
self.scale = (xscale, yscale)
self._plot.addImage(image, origin=self.origin, scale=self.scale, xlabel='µm', ylabel='µm')
else:
self._plot.addImage(image, xlabel='pixels', ylabel='pixels')
self._plot.addImage(image)
self.open()
else:
......@@ -84,9 +95,15 @@ class ZSumWidgetOW(OWWidget):
def _filterStack(self, dim=0, val=0):
image = self.dataset.zsum(indices=self.indices, dimension=[dim, val])
if image.shape[0]:
self._plot.addImage(image)
if self.origin:
self._plot.addImage(image, origin=self.origin, scale=self.scale, xlabel='µm', ylabel='µm')
else:
self._plot.addImage(image, xlabel='pixels', ylabel='pixels')
else:
self._plot.clear()
def _wholeStack(self):
self._plot.addImage(self.dataset.zsum())
if self.origin:
self._plot.addImage(self.dataset.zsum(), origin=self.origin, scale=self.scale, xlabel='µm', ylabel='µm')
else:
self._plot.addImage(self.dataset.zsum(), xlabel='pixels', ylabel='pixels')
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