Commit 1d9b1167 authored by payno's avatar payno

Merge branch 'orange_addon' into 'master'

Orange addon

See merge request !11
parents 7b6b5b83 2cf64b7e
Pipeline #6692 passed with stage
in 2 minutes and 20 seconds
......@@ -483,3 +483,38 @@ class Dim(object):
def __str__(self):
return " ".join((str(self.kind), str(self.name), 'size:', str(self.size)))
def to_dict(self):
"""translate the current Dim to a dictionary"""
return {
'name': self.name,
'kind': self.kind,
'size': self.size,
'relative_prev_val': self.relative_prev_val,
}
@staticmethod
def from_dict(_dict):
"""
:param dict _dict: dict defining the dimension. Should contains the
following keys: name, kind, size, relative_prev_val
unique values are not stored into it because it
depends on the metadata and should be obtain from a
fit / set_dims
:return: Dim corresponding to the dict given
:rtype: :class:`Dim`
"""
assert type(_dict) is dict
missing_keys = []
for _key in ('name', 'kind', 'size', 'relative_prev_val'):
if _key not in _dict:
missing_keys.append(missing_keys)
if len(missing_keys) > 0:
raise ValueError('There is some missing keys (%s), unable to create'
'a valid Dim')
else:
return Dim(name=_dict['name'],
kind=_dict['kind'],
size=_dict['size'],
relative_prev_val=_dict['relative_prev_val'])
......@@ -108,6 +108,7 @@ class DimensionMapping(qt.QWidget):
:return:
"""
self.clear()
assert type(dims) is dict
for axis, dim in dims.items():
assert type(axis) is int
assert isinstance(dim, Dim)
......
......@@ -31,9 +31,9 @@ __date__ = "02/10/2018"
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from Orange.canvas.registry.description import OutputSignal
from Orange.widgets.settings import Setting
from id06workflow.gui.datasetselection import DatasetSelection
from id06workflow.core.experiment import Experiment
from Orange.widgets.settings import Setting
from silx.gui import qt
import os
import logging
......@@ -85,12 +85,18 @@ class DataSelectionOW(OWWidget):
if os.path.isfile(self._data_file_pattern):
self._widget.setDataFilesPattern(self._data_file_pattern)
elif self._data_file_pattern != '':
_logger.info('%s is not recognized as an existing file pattern' % self._data_file_pattern)
for _file in self._flat_field_files:
if os.path.isfile(_file):
self._widget.addFlatFieldFile(_file)
else:
_logger.info('%s is not a valid file path')
for _file in self._dark_files:
if os.path.isfile(_file):
self._widget.addDarkFile(_file)
else:
_logger.info('%s is not a valid file path')
def _process(self):
"""
......@@ -106,3 +112,8 @@ class DataSelectionOW(OWWidget):
def sizeHint(self):
return qt.QSize(400, 400)
def updateProperties(self):
self._data_file_pattern = self._widget.getDataFilesPattern()
self._flat_field_files = self._widget.getFlatFieldFiles()
self._dark_files = self._widget.getDarkFiles()
......@@ -32,8 +32,9 @@ 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 Orange.widgets.settings import Setting
from id06workflow.gui.dimensions import DimensionWidget
from id06workflow.core.experiment import Experiment
from id06workflow.core.experiment import Experiment, Dim
from functools import partial
import logging
......@@ -61,6 +62,8 @@ class DimensionOW(OWWidget):
resizing_enabled = True
compress_signal = False
_dims = Setting(dict())
def __init__(self):
super().__init__()
layout = gui.vBox(self.mainArea, 'dimensions').layout()
......@@ -85,6 +88,10 @@ class DimensionOW(OWWidget):
# expose API
self.setDims = self._widget.setDims
# load properties
_dims = self._convertDictToDim(self._dims)
self._widget.setDims(_dims)
@property
def _ndim(self):
return self._widget.ndim
......@@ -112,3 +119,24 @@ class DimensionOW(OWWidget):
else:
self.send("data", self._widget.experiment)
OWWidget.accept(self)
def updateProperties(self):
# as dim are named tuple we have to cast them to dict
self._dims = {}
if self._widget.ndim is 0:
return
else:
for _axis, _dim in self._widget.dims.items():
assert isinstance(_dim, Dim)
self._dims[_axis] = _dim.to_dict()
def _convertDictToDim(self, _dict):
if len(_dict) > 0:
_dims = {}
for _axis, _dim in _dict.items():
assert type(_dim) is dict
_dims[_axis] = Dim.from_dict(_dim)
return _dims
else:
return {}
......@@ -33,7 +33,7 @@ from silx.gui import qt
from Orange.canvas.registry.description import InputSignal, OutputSignal
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from Orange.widgets.settings import Setting
from id06workflow.core.experiment import Experiment
from id06workflow.core.operation.roi import RoiOperation
from id06workflow.gui.roiselection import ROIOnStackView
......@@ -63,6 +63,9 @@ class RoiSelectionOW(OWWidget):
resizing_enabled = True
compress_signal = False
_roi_origin = Setting(tuple())
_roi_size = Setting(tuple())
def __init__(self):
super().__init__()
......@@ -83,6 +86,11 @@ class RoiSelectionOW(OWWidget):
# expose API
self.setROI = self._widget.setROI
if len(self._roi_size) is 2:
self._widget.getROI().setSize(size=self._roi_size)
if len(self._roi_origin) is 2:
self._widget.getROI().setOrigin(self._roi_origin)
def _process(self, experiment):
if experiment.dataset is None or experiment.dataset.is_valid() is False:
_logger.warning('cannot process roi selection, need a valid dataset for this')
......@@ -116,3 +124,11 @@ class RoiSelectionOW(OWWidget):
else:
OWWidget.accept(self)
# TODO: what can be the image to send to show roi selection (z sum ?)
def updateProperties(self):
# as dim are named tuple we have to cast them to dict
self._roi_origin = tuple(self._widget.getROI().getOrigin())
self._roi_size = tuple(self._widget.getROI().getSize())
print(self._roi_origin)
print(self._roi_size)
......@@ -33,7 +33,7 @@ from silx.gui import qt
from Orange.canvas.registry.description import InputSignal, OutputSignal
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from Orange.widgets.settings import Setting
from id06workflow.core.experiment import Experiment
from id06workflow.core.types import _Image
from id06workflow.gui.shifcorrection import ShiftCorrectionWidget
......@@ -64,6 +64,10 @@ class ShiftCorrectionOW(OWWidget):
resizing_enabled = True
compress_signal = False
_dx = Setting(int())
_dy = Setting(int())
_dz = Setting(int())
def __init__(self):
super().__init__()
self._editedExperiment = None
......@@ -90,6 +94,8 @@ class ShiftCorrectionOW(OWWidget):
# expose API
self.setShift = self._widget.setShift
self._widget.setShift(dx=self._dx, dy=self._dy, dz=self._dz)
def _setProgressValue(self, value):
self._progress.widget.progressBarSet(value)
......@@ -122,3 +128,6 @@ class ShiftCorrectionOW(OWWidget):
image)
# TODO: clear widget to avoid reprocessing ?
OWWidget.accept(self)
def updateProperties(self):
self._dx, self._dy, self._dz = self._widget.getShift()
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