Commit 1414ac32 authored by payno's avatar payno

[shift] fix shift correction and add button estimate shift

parent 07b80b3b
......@@ -86,16 +86,17 @@ class Shift(OverwritingOperation):
self._dz = dz
def compute(self):
if self._compute(self.data) is not None:
self.registerOperation()
return self.data
self.data = self._compute(self.data)
self.registerOperation()
return self.data
def dry_run(self, cache_data=None):
if cache_data is None:
self._cache_data = self.data[...]
else:
self._cache_data = cache_data
return self._compute(self._cache_data)
self._cache_data = self._compute(self._cache_data)
return self._cache_data
def apply(self):
if self._cache_data is None:
......@@ -110,8 +111,7 @@ class Shift(OverwritingOperation):
def _compute(self, data):
res = []
nImg = self.data.shape[0]
print(nImg)
nImg = data.shape[0]
for iImg, img in enumerate(self.data[:]):
self.updateProgress(int(iImg / nImg * 100.0))
_dx = self.dx * iImg
......
......@@ -54,12 +54,7 @@ class ShiftCorrectionWidget(qt.QWidget):
qt.QWidget.__init__(self, parent)
self.setLayout(qt.QVBoxLayout())
self.layout().addWidget(
qt.QLabel('In the future move the dxm2d_findregistration '
'to python and/or add th eoption to select pixels \n'
'on plot to define two positions and make the '
'interpolation from it',
parent=self))
self._control = _DxDyDzWidget(parent=self)
self.layout().addWidget(self._control)
self._displayTab = qt.QTabWidget(parent=self)
......@@ -74,7 +69,6 @@ class ShiftCorrectionWidget(qt.QWidget):
self._displayTab.addTab(self._sumPlot, 'images sum')
self._rawData = None
self._shiftedData = None
self._lastShift = (0, 0, 0)
# expose API
......@@ -114,8 +108,9 @@ class ShiftCorrectionWidget(qt.QWidget):
def _update_post_processing(self, _shift):
self._operation_thread.finished.disconnect(self._callback)
self._stack.setStack(self._shiftedData)
self._sumPlot.addImage(self._shiftedData.sum(axis=0))
assert self._operation._cache_data is not None
self._stack.setStack(self._operation._cache_data)
self._sumPlot.addImage(self._operation._cache_data.sum(axis=0))
self._lastShift = _shift
self.setProgress(100)
......@@ -127,7 +122,6 @@ class ShiftCorrectionWidget(qt.QWidget):
self._operation = ShiftOperation(experiment=self._experiment)
self._rawData = self._operation.data
self._shiftedData = self._operation.data
self._lastShift = (0, 0, 0)
self._stack.setStack(self._operation.data)
self._sumPlot.addImage(self._operation.data.sum(axis=0))
......@@ -165,6 +159,17 @@ class _DxDyDzWidget(qt.QWidget):
self._dzLE.setValidator(qt.QDoubleValidator(self._dzLE))
self.layout().addWidget(self._dzLE, 3, 1)
self._estimate_button = qt.QPushButton('estimate', parent=self)
self._estimate_button.pressed.connect(self._make_estimation)
self.layout().addWidget(self._estimate_button, 0, 0, 1, 2)
def _make_estimation(self):
msg = qt.QMessageBox(self)
msg.setIcon(qt.QMessageBox.Information)
text = "algorithm of the shift estimation has not been implemented yet"
msg.setText(text)
msg.exec_()
def getDx(self):
"""
......
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