Commit 16235cfe authored by payno's avatar payno
Browse files

Merge branch 'normalization_image_intensities' into 'master'

start adding intensity normalization

See merge request tomotools/tomwer!335
parents 17b89537 bd2e9668
......@@ -16,3 +16,7 @@ omit =
*benchmark.py
# tomwer main
tomwer/__main__.py
# utils for test
tomwer/test/utils/utilstest.py
# some files no more tested
orangecontrib/tomwer/widgets/control/OldDataValidatorOW.py
......@@ -72,6 +72,7 @@ tomwer:
- python -m pip install .[full_no_cuda]
- python -m pip install PyQt5==5.11.3
- python -m pip install pyqtgraph==0.11.0
- python -m pip install git+https://gitlab.esrf.fr/tomotools/tomoscan
- python -m pip install pytest-cov
- python -m pip install git+https://gitlab.esrf.fr/tomotools/nabu
- python -m tomwer --help
......@@ -93,6 +94,7 @@ test:test-tomwer-tutorials:
- python -m pip install fabio --upgrade --pre
- python -m pip install silx --upgrade --pre
- python -m pip install .[full_no_cuda]
- python -m pip install git+https://gitlab.esrf.fr/tomotools/tomoscan
- mkdir tmp_dir
- cd tmp_dir
script:
......
......@@ -126,6 +126,7 @@ Reconstruction
widgets/reconstruction/sadeltabetawidget.rst
widgets/reconstruction/tofuwidget.rst
widgets/reconstruction/castvolumewidget.rst
widgets/reconstruction/intensitynormalization.rst
Cluster
......
.. _sinogram normalization:
sino normalization
``````````````````
.. image:: img/sino_normalization/main_screen.png
Behavior
''''''''
The goal of this widget is to let the user define some normalization to be applied to sinograms.
This normalization can be one of the following:
* None: no extra normalization will be applied to the sinogram
* chebyshev: chebyshev normalization will be applied to sinograms
* division: a value or an array of value will divide the sinogram (during nabu preprocessing step)
* subtraction: a value or an array of value will subtract the sinogram (during nabu preprocessing step)
For **division** and **subtraction** the user can either provide:
* a scalar value which will be constant
* a roi to compute one scalar value *per projections* in order to be applied on the sinogram.
* an URL to be provided directly to nabu. In this case the dataset can be provided locally or globally.
If provided locally then the path will be updated for each scan. If provided globally then it will be constant.
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2016-2020 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__ = "19/07/2021"
import logging
from silx.gui import qt
from tomwer.core.scan.scanbase import TomwerScanBase
from orangecontrib.tomwer.widgets.utils import WidgetLongProcessing
from orangewidget.settings import Setting
from orangewidget import gui
from orangewidget.widget import Input, Output
from ...orange.managedprocess import SuperviseOW
from tomwer.gui.reconstruction.normalization.intensity import (
SinoNormWindow as _SinoNormWindow,
)
from tomwer.synctools.stacks.reconstruction.normalization import (
INormalizationProcessStack,
)
from processview.core.manager import ProcessManager
from processview.core.manager import DatasetState
from tomwer.core.process.reconstruction.normalization import (
SinoNormalizationTask,
)
from tomwer.core import settings
from tomwer.core import utils
from tomoscan.normalization import Method as NormMethod
from tomwer.core.process.reconstruction.normalization.params import _ValueSource
import functools
_logger = logging.getLogger(__name__)
class SinoNormWindow(_SinoNormWindow):
"""
implementation of NormIntensityWindow for orange. Add a lock processing
and a processing stack
"""
sigValidate = qt.Signal()
def __init__(self, parent, process_id=None):
assert isinstance(parent, SinoNormOW)
super().__init__(parent)
self._parentValidate = self.parent()._validate
self._processing_stack = INormalizationProcessStack(process_id=process_id)
# connect signal / slot
self._optsWidget.sigProcessingRequested.connect(self._processCurrentScan)
def _validated(self):
scan = self.getScan()
self._parentValidate(scan)
def _processCurrentScan(self):
scan = self.getScan()
if scan is None:
return
self._processScan(scan)
def _processScan(self, scan):
self._processing_stack.add(
scan=scan,
configuration=self.getConfiguration(),
callback=functools.partial(
self._mightUpdateResult,
scan,
self.isLocked(),
),
)
def _mightUpdateResult(self, scan, validate):
extra_info = scan.intensity_normalization.get_extra_infos()
if "value" in extra_info:
self.setResult(result=extra_info["value"])
else:
self.setResult(None)
if validate is True:
self._parentValidate(scan)
class SinoNormOW(WidgetLongProcessing, SuperviseOW):
"""
A simple widget managing the copy of an incoming folder to an other one
:param parent: the parent widget
"""
# note of this widget should be the one registered on the documentation
name = "sino normalization"
id = "orange.widgets.tomwer.reconstruction.SinoNormOW.SinoNormOW"
description = "Define normalization on intensity to be applied on projections"
icon = "icons/norm_I.svg"
priority = 28
keywords = [
"tomography",
"normalization",
"norm",
"I",
"intensity",
"projections",
"radios",
]
want_main_area = True
resizing_enabled = True
compress_signal = False
allows_cycle = True
_rpSetting = Setting(dict())
sigScanReady = qt.Signal(TomwerScanBase)
"Signal emitted when a scan is ended"
class Inputs:
data_in = Input(name="data", type=TomwerScanBase)
class Outputs:
data_out = Output(name="data", type=TomwerScanBase)
def __init__(self, parent=None):
"""
Widget allowing the user to define the normalization to be applied on
projections. This can be a scalar or an array.
"""
SuperviseOW.__init__(self, parent)
WidgetLongProcessing.__init__(self)
self._window = SinoNormWindow(self, process_id=self.process_id)
self._layout = gui.vBox(self.mainArea, self.name).layout()
self._layout.setContentsMargins(0, 0, 0, 0)
self._layout.addWidget(self._window)
try:
self.loadSettings()
except Exception as e:
_logger.warning(f"Failed to load settings: {e}")
# connect signal / slot
self._window.sigConfigurationChanged.connect(self._updateSettings)
self.destroyed.connect(self._window.stop)
self._window._processing_stack.sigComputationStarted.connect(
self._startProcessing
)
self._window._processing_stack.sigComputationEnded.connect(self._endProcessing)
def isLocked(self):
return self._window.isLocked()
def setLocked(self, locked):
self._window.setLocked(locked)
def setCurrentMethod(self, mode):
self._window.setCurrentMethod(mode)
def getCurrentMethod(self):
return self._window.getCurrentMethod()
def setCurrentSource(self, source):
self._window.setCurrentSource(source)
def getCurrentSource(self):
return self._window.getCurrentSource()
@Inputs.data_in
def process(self, scan: TomwerScanBase):
if not isinstance(scan, (TomwerScanBase, type(None))):
raise TypeError(
"scan should be None or an instance of "
"TomwerScanBase. Not {}".format(type(scan))
)
if scan is None:
return
self._skipCurrentScan(new_scan=scan)
if settings.isOnLbsram(scan) and utils.isLowOnMemory(
settings.get_lbsram_path()
):
details = "skip {} because low memory on lbsram".format(str(scan))
self.notify_skip(scan=scan, details=details)
self.Outputs.data_out.send(scan)
else:
self._window.setScan(scan=scan)
if self.isLocked():
self._window._processScan(scan=scan)
def _validate(self, scan):
if scan is None:
return
# save processing result for the one with interaction. Otherwise
# this will be saved in the processing thread
extra_infos = scan.intensity_normalization.get_extra_infos()
tomwer_processing_res_code = extra_infos.pop(
"tomwer_processing_res_code", "unprocessed"
)
SinoNormalizationTask._register_process(
process_file=scan.process_file,
process=SinoNormalizationTask,
entry=scan.entry,
configuration=self.getConfiguration(),
results={
"method": scan.intensity_normalization.method.value,
"extra_infos": extra_infos,
},
process_index=scan.pop_process_index(),
)
if tomwer_processing_res_code is True:
# if defined by manual scalar we need to set the value
if extra_infos.get("source", None) == _ValueSource.MANUAL_SCALAR.value:
extra_infos["value"] = self.getCurrentlyDefinedValues()
self.notify_succeed(scan=scan)
elif tomwer_processing_res_code is False:
self.notify_failed(scan=scan)
elif tomwer_processing_res_code is None:
self.notify_skip(scan=scan)
elif tomwer_processing_res_code == "unprocessed":
# if validate manually we must set current method + value
scan.intensity_normalization = self.getCurrentMethod()
if self.getCurrentMethod() in (
NormMethod.NONE,
NormMethod.CHEBYSHEV,
NormMethod.LSQR_SPLINE,
):
extra_infos = {}
elif self.getCurrentSource() is _ValueSource.DATASET:
extra_infos = {
"dataset_url": self._window._optsWidget._datasetWidget.getDatasetUrl().path(),
}
else:
extra_infos = {
"value": self.getCurrentlyDefinedValues(),
"source": self.getCurrentSource(),
}
self.notify_succeed(scan=scan)
# clear flag
scan.intensity_normalization.set_extra_infos(extra_infos)
self.Outputs.data_out.send(scan)
def _skipCurrentScan(self, new_scan):
scan = self._window.getScan()
# if the same scan has been run several scan
if scan is None or str(scan) == str(new_scan):
return
current_scan_state = ProcessManager().get_dataset_state(
dataset_id=scan.get_dataset_identifier(), process=self
)
if current_scan_state in (
DatasetState.PENDING,
DatasetState.WAIT_USER_VALIDATION,
):
details = "Was pending and has been replaced by another scan."
self.notify_skip(scan=scan, details=details)
self.Outputs.data_out.send(scan)
def getCurrentlyDefinedValues(self):
return self._window._crtWidget.getResult()
def validateCurrentScan(self):
scan = self._window.getScan()
self._validate(scan)
def clear(self):
self._window.clear()
def getConfiguration(self):
return self._window.getConfiguration()
def stop(self):
self._window.stop()
def _updateSettings(self):
self._rpSetting = self._window.getConfiguration()
self._rpSetting["__lock__"] = self.isLocked()
def loadSettings(self):
self._window.setConfiguration(self._rpSetting)
if "__lock__" in self._rpSetting:
self.setLocked(self._rpSetting["__lock__"])
<?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="48"
height="48"
viewBox="0 0 12.7 12.7"
version="1.1"
id="svg8"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
sodipodi:docname="norm_I.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11.2"
inkscape:cx="31.937527"
inkscape:cy="31.052611"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1043"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<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 />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-284.3)">
<g
aria-label="norm(I)"
transform="matrix(0.93370219,0,0,1.0710053,-0.1889881,0.80319941)"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.83768845px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.2209422"
id="text819">
<path
d="m 2.3378999,273.14913 c 0,-0.39137 -0.2131229,-0.61612 -0.5696194,-0.61612 -0.2867472,0 -0.4649955,0.1395 -0.7052431,0.2945 l -0.05425,-0.2945 -0.57736934,0.0969 v 0.0969 l 0.14724856,0.0194 c 0.10074901,0.0155 0.12399878,0.0349 0.12399878,0.17438 v 1.22061 c 0,0.19762 -0.0116249,0.20537 -0.29062215,0.22475 v 0.11237 H 1.3575345 v -0.11237 c -0.2751223,-0.0194 -0.2906222,-0.0271 -0.2906222,-0.22475 v -0.90674 c 0,-0.0969 0.00775,-0.15113 0.03875,-0.21312 0.081374,-0.15113 0.2557475,-0.279 0.4611204,-0.279 0.2634975,0 0.4068711,0.14725 0.4068711,0.48437 v 0.91449 c 0,0.19762 -0.011625,0.20537 -0.2906222,0.22475 v 0.11237 h 0.9454908 v -0.11237 c -0.2751223,-0.0194 -0.2906222,-0.0271 -0.2906222,-0.22475 z"
style="font-size:3.87496209px;stroke-width:0.2209422"
id="path897"
inkscape:connector-curvature="0" />
<path
d="m 3.8031806,272.53301 c -0.6199939,0 -0.9261159,0.36812 -0.9261159,0.99587 0,0.62774 0.306122,0.99586 0.9261159,0.99586 0.6277439,0 0.9299909,-0.36812 0.9299909,-0.99586 0,-0.62775 -0.302247,-0.99587 -0.9299909,-0.99587 z m -0.5231199,0.99587 c 0,-0.53475 0.1704983,-0.86025 0.5231199,-0.86025 0.3603715,0 0.5269948,0.3255 0.5269948,0.86025 0,0.53474 -0.1666233,0.86024 -0.5269948,0.86024 -0.3526216,0 -0.5231199,-0.3255 -0.5231199,-0.86024 z"
style="font-size:3.87496209px;stroke-width:0.2209422"
id="path899"
inkscape:connector-curvature="0" />
<path
d="m 5.6522034,272.53301 -0.5889942,0.0969 v 0.0969 l 0.1472486,0.0194 c 0.100749,0.0155 0.1239987,0.0349 0.1239987,0.17438 v 1.22061 c 0,0.19762 -0.019375,0.20537 -0.2906221,0.22475 v 0.11237 h 1.02299 v -0.11237 C 5.7219528,274.34655 5.698703,274.33885 5.698703,274.1412 v -0.90674 c 0,-0.29837 0.1317487,-0.39912 0.2208728,-0.39912 0.061999,0 0.1278738,0.0233 0.2402477,0.0852 0.027125,0.0155 0.058124,0.0194 0.077499,0.0194 0.092999,0 0.1782483,-0.0969 0.1782483,-0.217 0,-0.0852 -0.05425,-0.18987 -0.205373,-0.18987 -0.1394987,0 -0.2557475,0.0853 -0.511495,0.31 z"
style="font-size:3.87496209px;stroke-width:0.2209422"
id="path901"
inkscape:connector-curvature="0" />
<path
d="m 6.5692979,272.62988 v 0.0969 l 0.1472486,0.0194 c 0.100749,0.0155 0.1239988,0.0349 0.1239988,0.17438 v 1.22061 c 0,0.19762 -0.011625,0.20537 -0.2906222,0.22475 v 0.11237 h 0.9454908 v -0.11237 c -0.2751223,-0.0194 -0.2906222,-0.0271 -0.2906222,-0.22475 v -0.90674 c 0,-0.0969 0.00387,-0.15113 0.031,-0.20537 0.073624,-0.155 0.2441226,-0.28675 0.4572455,-0.28675 0.3332468,0 0.3719964,0.24412 0.3719964,0.48437 v 0.91449 c 0,0.19762 -0.011625,0.20537 -0.2906222,0.22475 v 0.11237 h 0.9454908 v -0.11237 C 8.4447799,274.34652 8.42928,274.33882 8.42928,274.14117 v -0.90674 c 0,-0.0969 0.00387,-0.15113 0.027125,-0.21312 0.058124,-0.155 0.2247478,-0.279 0.4417456,-0.279 0.2441227,-0.008 0.3913712,0.14725 0.3913712,0.48437 v 0.91449 c 0,0.19762 -0.011625,0.20537 -0.2906221,0.22475 v 0.11237 h 0.9454907 v -0.11237 c -0.2751223,-0.0194 -0.2906221,-0.0271 -0.2906221,-0.22475 v -0.99199 c 0,-0.39137 -0.209248,-0.61612 -0.5773694,-0.61612 -0.3177469,0 -0.5463697,0.21312 -0.6819933,0.29837 -0.092999,-0.18212 -0.2402477,-0.29837 -0.511495,-0.29837 -0.2983721,0 -0.5424947,0.19375 -0.6781184,0.2945 l -0.034875,-0.2945 z"
style="font-size:3.87496209px;stroke-width:0.2209422"
id="path903"
inkscape:connector-curvature="0" />
<path
d="m 10.683841,273.3855 c 0,-1.10824 0.337122,-1.44148 0.581245,-1.49186 v -0.0969 c -0.678119,0.0271 -0.852492,0.86799 -0.852492,1.58873 0,0.72074 0.174373,1.56161 0.852492,1.58874 v -0.0969 c -0.224748,-0.0465 -0.581245,-0.37587 -0.581245,-1.49186 z"
style="font-size:3.87496209px;stroke-width:0.2209422"
id="path905"
inkscape:connector-curvature="0" />
<path
d="m 12.228438,272.15714 c 0,-0.217 0.01162,-0.22475 0.348746,-0.248 v -0.11237 H 11.49607 v 0.11237 c 0.340996,0.0233 0.348746,0.031 0.348746,0.248 v 1.96073 c 0,0.217 -0.0077,0.22475 -0.348746,0.248 v 0.11237 h 1.081114 v -0.11237 c -0.337122,-0.0232 -0.348746,-0.031 -0.348746,-0.248 z"
style="font-size:3.87496209px;stroke-width:0.2209422"
id="path907"
inkscape:connector-curvature="0" />
<path
d="m 13.393287,273.3855 c 0,1.11599 -0.356496,1.44536 -0.581244,1.49186 v 0.0969 c 0.678118,-0.0271 0.852492,-0.868 0.852492,-1.58874 0,-0.72074 -0.174374,-1.56161 -0.852492,-1.58873 v 0.0969 c 0.244123,0.0504 0.581244,0.38362 0.581244,1.49186 z"
style="font-size:3.87496209px;stroke-width:0.2209422"
id="path909"
inkscape:connector-curvature="0" />
</g>
<path
style="fill:#769393;fill-opacity:1;stroke:none;stroke-width:0.30338553px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 0.40159968,286.54441 c 1.33676052,0.9304 2.55579302,2.09298 4.37034962,2.08106 l -0.023623,-2.23636 c 0.9965319,0.9002 1.5863804,1.85216 4.4412199,2.5159 l 0.047247,-2.79544 c 0.9412648,1.21735 1.8967988,2.38465 3.0238088,2.95075 v 2.08105 H 2.4095983 0.35435267 Z"
id="path895"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccc" />
</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__ = "09/06/2021"
from silx.gui.utils.testutils import TestCaseQt
from silx.gui import qt
from tomwer.core.utils.scanutils import MockHDF5
from orangecontrib.tomwer.widgets.reconstruction.SinoNormOW import (
SinoNormOW as _NormIOW,
)
from processview.core.manager import ProcessManager, DatasetState
from tomwer.io.utils.h5pyutils import EntryReader
from tomwer.core.process.reconstruction.normalization import (
SinoNormalizationTask,
)
from silx.io.utils import h5py_read_dataset
import tempfile
import shutil
import logging
import os
from tomwer.core import utils, settings
logger = logging.getLogger(__name__)
class NormIOW(_NormIOW):
def __init__(self, parent=None):
self._scans_finished = []
super().__init__(parent)
def processing_finished(self, scan):
self._scans_finished.append(scan)
def wait_processing(self, wait_time):
self._window._processing_stack._computationThread.wait(wait_time)
@property
def scans_finished(self):
return self._scans_finished
def compute(self):
self._window._processCurrentScan()
def setROI(self, start_x, end_x, start_y, end_y):
self._window.setROI(start_x=start_x, end_x=end_x, start_y=start_y, end_y=end_y)
def close(self):
self._scans_finished = {}
super().close()
class TestProcessing(TestCaseQt):
DIM = 100
def setUp(self):
super().setUp()
utils.mockLowMemory(False)
settings.mock_lsbram(False)
self._source_dir = tempfile.mkdtemp()
def create_scan(folder_name):
_dir = os.path.join(self._source_dir, folder_name)
return MockHDF5(
scan_path=_dir,
n_ini_proj=20,
n_proj=20,
n_alignement_proj=2,
create_final_ref=False,
create_ini_dark=True,
create_ini_ref=True,
n_refs=1,
dim=self.DIM,
).scan
# create scans
self.scan_1 = create_scan("scan_1")
self.scan_2 = create_scan("scan_2")
self.scan_3 = create_scan("scan_3")
self._process_manager = ProcessManager()
self.widget = NormIOW()
self.widget.show()
def tearDown(self):
self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
self.widget.stop()
self.widget.close()