Commit d6e79d74 authored by payno's avatar payno

[saveimage] rework save image and mapping to send image of all map created

parent c53682b6
Pipeline #6630 passed with stage
in 2 minutes and 21 seconds
......@@ -33,6 +33,8 @@ from Orange.canvas.registry.description import InputSignal, OutputSignal
from id06workflow.core.experiment import Experiment
from id06workflow.core.experiment.operation.mapping import IntensityMapping, _MappingBase
from id06workflow.core.experiment.operation.ThreadedOperation import ThreadedOperation
from id06workflow.core.mapping import MEAN, VARIANCE, SKEWNESS, KURTOSIS
from id06workflow.core.experiment import _METADATA_TYPES_I
from id06workflow.core.types import _Image
from id06workflow.gui.mapping import MappingPlot
from functools import partial
......@@ -93,18 +95,18 @@ class MappingOW(OWWidget):
self._processing_thread.start()
def _post_processing(self, operation, experiment):
self.send("image",
_Image(img=operation.intensity_map, name='intensity_map'))
self.send("image",
_Image(img=operation.dims[0][:, :, 0], name='mean'))
self.send("image",
_Image(img=operation.dims[0][:, :, 1], name='variance'))
self.send("image",
_Image(img=operation.dims[0][:, :, 2], name='skeness'))
self.send("image",
_Image(img=operation.dims[0][:, :, 3], name='kurtosis'))
self._plot.setOperation(operation)
if operation.intensity_map is not None:
self.send("image",
_Image(img=operation.intensity_map, name='intensity'))
for iDim, dim in operation.dims.items():
name = dim.name
kind = _METADATA_TYPES_I[dim.kind]
for mode in (MEAN, VARIANCE, SKEWNESS, KURTOSIS):
img = getattr(dim, mode)
img_name = '_'.join((kind, name, mode))
self.send("image", _Image(img=img, name=img_name))
self._plot.setOperation(operation)
self.send("data", experiment)
self.send("map", operation)
......
......@@ -73,7 +73,7 @@ class SaveImageOW(OWWidget):
output = '.'
_logger.info('save image to %s' % output)
try:
qimage = convertArrayToQImage(image.data)
qimage = convertArrayToQImage(image.img)
qimage.save(os.path.join(output, image.name), 'PNG')
except Exception as e:
_logger.error(e)
......@@ -35,7 +35,8 @@ from id06workflow.core.experiment import _Dim
from id06workflow.unitsystem import metricsystem
from id06workflow.core.geometry.TwoThetaGeometry import TwoThetaGeometry
import os
import tempfile
import shutil
logging.disable(logging.INFO)
......@@ -67,7 +68,8 @@ class TestTrueData(OrangeWorflowTest):
'orangecontrib.id06workflow.widgets.mapping.MappingOW')
saveNode = self.addWidget(
'orangecontrib.id06workflow.widgets.saveexperiment.SaveExperimentOW')
# TODO: add processing in here
screenshotNode = self.addWidget(
'orangecontrib.id06workflow.widgets.saveimage.SaveImageOW')
self.processOrangeEvents()
......@@ -78,6 +80,7 @@ class TestTrueData(OrangeWorflowTest):
self.link(noiseReductionNode, "data", shiftCorrectionNode, "data")
self.link(shiftCorrectionNode, "data", mappingNode, "data")
self.link(mappingNode, "data", saveNode, "data")
self.link(mappingNode, "image", screenshotNode, "image")
self.processOrangeEvents()
self._selectionWidget = self.getWidgetForNode(dataSelectionNode)
......@@ -99,7 +102,15 @@ class TestTrueData(OrangeWorflowTest):
ypixelsize=1.0*metricsystem.micrometer,
orientation=TwoThetaGeometry.VERTICAL)
self._screenshot_output = tempfile.mkdtemp()
self._previous_workflow_output = os.environ.get('WORKFLOW_OUTPUT')
os.environ['WORKFLOW_OUTPUT'] = self._screenshot_output
def tearDown(self):
if self._previous_workflow_output is not None:
os.environ['WORKFLOW_OUTPUT'] = self._previous_workflow_output
shutil.rmtree(self._screenshot_output)
OrangeWorflowTest.tearDown(self)
def createDataset(self):
......@@ -180,6 +191,16 @@ class TestTrueData(OrangeWorflowTest):
self._shiftCorrectionWidget.hide()
self._moveToNextStep()
# screenshot saving
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'intensity.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_diffry_mean.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_diffry_variance.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_diffry_sckewness.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_diffry_kurtosis.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_obpitch_mean.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_obpitch_variance.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_obpitch_sckewness.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_obpitch_kurtosis.png')))
def suite():
......
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