Commit 8efc4f8d authored by payno's avatar payno

Merge branch 'fix_8' into 'master'

Fix 8

Closes #8

See merge request !6
parents cd0c230f 1414ac32
......@@ -146,5 +146,9 @@ class Dataset(object):
# TODO: add information if the number of frame is fixed...
if len(files_list) is 0:
return None
series = FileSeries(files_list)
return self._loadSeries(series)
res = []
series = FileSeries(filenames=files_list, single_frame=True)
for iframe in range(series.nframes):
res.append(series.getframe(iframe).data)
return numpy.asarray(res)
......@@ -93,6 +93,10 @@ class Experiment(object):
assert geometry is None or isinstance(geometry, GeometryBase)
self._geometry = geometry
@property
def metadata(self):
return self.__metadata
@property
def roi(self):
# TODO: manage several rois
......@@ -205,18 +209,22 @@ class Experiment(object):
steps = (1, 1, 1)
else:
if len(reductionStep) is 1:
steps = reductionStep[0]
steps = reductionStep[0].steps
else:
raise NotImplementedError(
'cannot manage several reduction steps for the moment')
# first apply data reduction because roi is applied after data
# reduction
background_img = numpy.median(background, axis=0)
background_img = background_img[::steps[1], ::steps[0]]
if self.roi is None:
return background_img[::steps[1], ::steps[2]]
return background_img
else:
origin, size = self.roi
ymin, ymax = int(origin[1]), int(origin[1] + size[1])
xmin, xmax = int(origin[0]), int(origin[0] + size[0])
return background_img[ymin:ymax:steps[1], xmin:xmax:steps[2]]
return background_img[ymin:ymax, xmin:xmax]
def addOperation(self, operation):
"""Add the operation to the stack of operations"""
......@@ -246,9 +254,19 @@ class Experiment(object):
def _getDataReductionOperations(self):
"""
:return: the list of roi operation
:return: the list of roi operation.
..note: reduction steps are defined as tuple(x, y, z)
"""
return self._data_reduction_operations
def hasOperation(self, operationID):
raise NotImplementedError('Not implemented yet')
@property
def nslices(self):
if self.data is None:
return 0
else:
assert self.data.ndim is 3
return self.data.shape[0]
......@@ -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):
"""
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="48px"
height="48px"
id="svg2985"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="New document 2">
<defs
id="defs2987" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7"
inkscape:cx="0.14285714"
inkscape:cy="24"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="1920"
inkscape:window-height="1098"
inkscape:window-x="0"
inkscape:window-y="31"
inkscape:window-maximized="1" />
<metadata
id="metadata2990">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<rect
style="fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2993"
width="36.42857"
height="32.57143"
x="6.2857141"
y="8.7142859" />
<rect
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect3797"
width="13"
height="32.714287"
x="6.1428571"
y="8.5714283" />
<rect
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect3799"
width="9.8571434"
height="32.571426"
x="32.857143"
y="8.7142859" />
<rect
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect3801"
width="7.1428571"
height="32.42857"
x="25.714285"
y="8.7142859" />
<rect
style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect3803"
width="36.714287"
height="6.8571429"
x="6.1428571"
y="8.4285717" />
</g>
</svg>
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
__authors__ = ["H. Payno"]
__license__ = "MIT"
__date__ = "16/10/2018"
from silx.gui import qt
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from Orange.canvas.registry.description import InputSignal, OutputSignal
from id06workflow.gui.mapping import MappingPlot
from id06workflow.core.experiment import Experiment
from id06workflow.core.experiment.operation.mapping import GradientRemoval
from id06workflow.core.types import _Image
class MetadataTableOW(OWWidget):
"""
"""
name = "Metadata table"
id = "orange.widgets.id06workflow.metadatatable"
description = "Display "
icon = "icons/metadata.svg"
priority = 4
category = "esrfWidgets"
keywords = ["metadata", "experiment", "motors"]
inputs = [InputSignal(name="data", type=Experiment, handler='_process')]
outputs = [OutputSignal(name="data", type=Experiment)]
want_main_area = True
resizing_enabled = True
compress_signal = False
def __init__(self):
super().__init__()
layout = gui.vBox(self.mainArea, 'metadata table').layout()
self._table = qt.QTableWidget(parent=self)
layout.addWidget(self._table)
def _process(self, experiment):
if experiment is None:
return
self._table.clear()
v_header = []
[v_header.append(str(i)) for i in range(experiment.nslices)]
self._table.setRowCount(len(v_header))
self._table.setVerticalHeaderLabels(v_header)
columnCount = None
for row, metadata_slice in enumerate(experiment.metadata):
if columnCount is None:
columnCount = len(metadata_slice)
self._table.setColumnCount(columnCount)
self._table.setHorizontalHeaderLabels(metadata_slice.keys())
elif columnCount != len(metadata_slice):
raise ValueError('Metadata keys are incoherent')
for column, info in enumerate(metadata_slice):
_item = qt.QTableWidgetItem()
_item.setText(metadata_slice[info])
# _item.setFlags(qt.Qt.ItemIsEnabled | qt.Qt.ItemIsSelectable)
self._table.setItem(row, column, _item)
self.send("data", experiment)
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