AlveolEye 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2022 <>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.1
2
+ Name: AlveolEye
3
+ Version: 0.1.2
4
+ Summary: Reads lung slides with AI-driven and classical methods
5
+ Author: Joseph Hirsh
6
+ Author-email: josephhirsh9@gmail.com
7
+ License: MIT
8
+ Classifier: Development Status :: 2 - Pre-Alpha
9
+ Classifier: Framework :: napari
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy
24
+ Requires-Dist: magicgui
25
+ Requires-Dist: qtpy
26
+ Provides-Extra: testing
27
+ Requires-Dist: pytest ; extra == 'testing'
28
+ Requires-Dist: pytest-cov ; extra == 'testing'
29
+ Requires-Dist: pytest-qt ; extra == 'testing'
30
+ Requires-Dist: napari ; extra == 'testing'
31
+ Requires-Dist: qtpy ; extra == 'testing'
32
+
33
+ <!--
34
+ [![License MIT](https://img.shields.io/pypi/l/automated-lung-morphometry.svg?color=green)](https://github.com/Quooooooookka/automated-lung-morphometry/raw/main/LICENSE)
35
+ [![PyPI](https://img.shields.io/pypi/v/automated-lung-morphometry.svg?color=green)](https://pypi.org/project/automated-lung-morphometry)
36
+ [![Python Version](https://img.shields.io/pypi/pyversions/automated-lung-morphometry.svg?color=green)](https://python.org)
37
+ [![tests](https://github.com/Quooooooookka/automated-lung-morphometry/workflows/tests/badge.svg)](https://github.com/Quooooooookka/automated-lung-morphometry/actions)
38
+ [![codecov](https://codecov.io/gh/Quooooooookka/automated-lung-morphometry/branch/main/graph/badge.svg)](https://codecov.io/gh/Quooooooookka/automated-lung-morphometry)
39
+ [![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/automated-lung-morphometry)](https://napari-hub.org/plugins/automated-lung-morphometry)
40
+ -->
41
+
42
+ # AlveolEye: Automated lung morphometry made easy
43
+
44
+ This repository contains the beta version of AlveolEye, which is created by the Sucre lab.
45
+ This code is authored by Joseph Hirsh, Samuel Hirsh, Nick Negretti, and Shawyon Shirazi.
46
+
47
+ This project is a Napari plugin that uses computer vision tools and classical image processing
48
+ to calculate mean linear intercept (MLI) and airspace volume density (ASVD) from histological images.
49
+
50
+ A primary goal of this tool is to be an aid to the researcher, and not be a complete automated annotation solution.
51
+
52
+ ## Installation
53
+
54
+ The target of this process is to create a conda environment that has both napari, and all of the AlveolEye requirements.
55
+
56
+ If you already have conda setup, you can skip step 1
57
+
58
+ 1. Install miniconda by downlading the appropriate version from [here](https://docs.anaconda.com/free/miniconda/)
59
+
60
+ a. Choose the version that matches your processor
61
+
62
+ b. Download the "pkg" version for easy install
63
+ 2. Open a terminal, or miniconda prompt, and clone this git repository by running:
64
+
65
+ ```git clone https://github.com/SucreLab/AlveolEye```
66
+ 3. Go to the AlveolEye directory
67
+
68
+ ```cd AlveolEye```
69
+ 4. Create the conda environment
70
+
71
+ ```conda env create -f ./environment.yml```
72
+ 5. Activate the new environment
73
+
74
+ ```conda activate AlveolEye```
75
+ 6. Install the plugin
76
+
77
+ ```pip install .```
78
+ 7. Launch napari, followed by locating the plugin in the plugin menu
79
+
80
+ ```napari```
81
+
82
+ ## Running post-installation
83
+
84
+ 1. Open a terminal, or miniconda prompt, activate the environment and run napari
85
+
86
+ ```
87
+ conda activate AlveolEye
88
+ napari
89
+ ```
90
+
91
+
92
+ # AlveolEye Usage Tutorial
93
+
94
+ ## Annotated Diagram
95
+ ![annotated diagram](./docs/Colored_AlveolEye.png)
96
+
97
+ ## Processing: Identify and segment vessel and airway epithelium with an AI computer vision model.
98
+ 1. ![#FF3333](https://placehold.co/15x15/FF3333/FF3333.png) **Select an image**: The remaining steps will concern this image.
99
+
100
+ a. Click the “Import Image” button.
101
+
102
+ b. Use operating system default file dialogue to select an image (*.jpg, *.png, or *.tiff).
103
+
104
+ c. Check the image in the “Image” layer (of the Napari Viewer) and the file name (displayed to the right of the “Import Image” button) to confirm that the image loaded correctly.
105
+ 2. ![#FF9933](https://placehold.co/15x15/FF9933/FF9933.png) **Select a model**</span>: The selected model will run on the image and predict (segment) vessel and airway epithelium.
106
+
107
+ a. To use the default model, skip to step 3; otherwise, proceed to step 2b. Use the provided default model unless you have a specific reason not to.
108
+
109
+ b. Click the “Import Weights” button.
110
+
111
+ c. Use operating system file dialogue to select a model (*.pth).
112
+
113
+ d. Check the file name (displayed to the right of the “Import Weights” button) to confirm that the model loaded correctly.
114
+ 3. ![#FFFF33](https://placehold.co/15x15/FFFF33/FFFF33.png) **Select a confidence level**: Type a percentage and/or click the “-” and “+” buttons in the “Minimum confidence” input box to set the confidence level. Predictions with lower confidence then the set confidence level will not appear.
115
+ 4. ![#f03c15](https://placehold.co/15x15/33FF33/33FF33.png) **Run processing**: Click the “Run Processing” button to run the model and segment vessel and airway epithelium filtered by confidence level. Once completed, manually edit the prediction as necessary with the built-in napari tools to the left of the displayed image layer. See Napari documentation for more information about how to use these tools.
116
+
117
+ ---
118
+
119
+ ## Postprocessing: Identify alveolar tissue, and airwary and vessel lumens with “classical” (non-AI) methods; remove small particles and holes to prepare for assessments.
120
+ 1. ![#FF3333](https://placehold.co/15x15/FF3333/FF3333.png) **Toggle manual thresholding**: To manually set a threshold value, toggle manual threshold; otherwise, a threshold value will be determined with Otsu's method.
121
+
122
+ a. To use manual thresholding, check the “Manual thresholding” box and proceed; to use automatic thresholding, leave the box unchecked and skip to step 2.
123
+
124
+ b. Type a percentage and/or click the “-” and “+” buttons in the “Manual thresholding” input box to set the threshold level.
125
+ 2. ![#FF9933](https://placehold.co/15x15/FF9933/FF9933.png) **Remove small particles**: Type a percentage and/or click the “-” and “+” buttons in the “Remove small particles” input box to set the maximum size cutoff for particles to remove. Particles with fewer pixels than the set number will be removed.
126
+ 3. ![#FFFF33](https://placehold.co/15x15/FFFF33/FFFF33.png) **Remove small holes**: Type a percentage and/or click the “-” and “+” buttons in the “Remove small holes” input box to set the maximum size cutoff for holes to remove. Holes with fewer pixels than the set number will be removed.
127
+ 4. ![#f03c15](https://placehold.co/15x15/33FF33/33FF33.png) **Run postprocessing**: Click “Run Postprocessing” button to identify alveolar tissue, airwary lumens, and vessel lumens, and to remove small particles and holes. Once completed, manually edit the post-processing layer as necessary with the built-in napari tools to the left of the displayed image layer. See Napari documentation for more information about how to use these tools.
128
+
129
+ ---
130
+
131
+ ## Assessments: Calculate morphometry assessments—mean linear intercept (MLI) and airspace volume density (ASVD) on the fully classified image.
132
+ 1. ![#FF3333](https://placehold.co/15x15/FF3333/FF3333.png) **Select ASVD**: To include ASVD calculations in results, check the “ASVD” checkbox; otherwise, leave the box unchecked. Leave the box unchecked to increase the speed of the assessments calculation or to exclude unnecessary data from the final export file.
133
+ 2. ![#FF9933](https://placehold.co/15x15/FF9933/FF9933.png) **Select MLI**: To include MLI calculations in results, check the “MLI” checkbox; otherwise, leave the box unchecked. Leave the box unchecked to increase the speed of the assessments calculation or to exclude unnecessary data from the final export file.
134
+ 3. ![#FFFF33](https://placehold.co/15x15/FFFF33/FFFF33.png) **Set number of lines**: Type a number and/or click the “-” and “+” buttons in the “number of lines” input box to set the number of MLI lines.
135
+ 4. ![#f03c15](https://placehold.co/15x15/33FF33/33FF33.png) **Set minimum length**: Type a number and/or click the “-” and “+” buttons in the “minimum length” input box to set the minimum length required for a chord to be included in the mean calculation.
136
+ 5. ![#f03c15](https://placehold.co/15x15/3359FF/3359FF.png) **Set scale**: Type a number and/or click the “-” and “+” buttons in the “scale” input box to set the scale factor (i.e. a pixel to physical space multiplier).
137
+ 6. ![#f03c15](https://placehold.co/15x15/C433FF/C433FF.png) **Run Assessments**: Click the “Run Assessments” button to calculate the selected assessments. The ASVD and MLI calculation results will display to the right of the assessment checkboxes.
138
+
139
+ ---
140
+
141
+ ## Export Results: Collect assessment results for each image and export all the data into a file when done (*.csv or *.json).
142
+ - **Interpreting Results**
143
+ - **MLI:** Mean Linear Intercept for the given image
144
+ - **Standard deviation:** The standard deviation of the lengths of the chord used to calculate MLI.
145
+ - **Number of chords:** The number of chords used to calculate MLI.
146
+ - **ASVD:** Airspace Volume Density calculation for the given image.
147
+ - **Airspace pixels:** The total number of airspace pixels
148
+ - **Non airspace pixels:** The total number non-airspace pixels.
149
+ 1. ![#FF3333](https://placehold.co/15x15/FF3333/FF3333.png) **Add last result**: Click the “Add” button to add the assessment data to the final export file. Once the results are added, you can return to the "Processing" step and do another image.
150
+ 2. ![#FF9933](https://placehold.co/15x15/FF9933/FF9933.png) **Remove last result**: Click the “Remove” button to remove the last results added to the export file.
151
+ 3. ![#FFFF33](https://placehold.co/15x15/FFFF33/FFFF33.png) **Clear export data**: Click the “Clear” button to clear the export data file.
152
+ 4. ![#f03c15](https://placehold.co/15x15/33FF33/33FF33.png) **Export Results**: Click the “Export Results” button to open a file dialogue for saving the assessments results. Note that the plugin supports two export result file types, *.csv and *.json that you can choose between.
153
+
@@ -0,0 +1,38 @@
1
+ alveoleye/__init__.py,sha256=n4sTm_7myRcG7tZzxVzubSR5eO2Uy0o99zeZm191of0,323
2
+ alveoleye/_action_box.py,sha256=6CuFgpjJQMgE4H2cOGMQHzzD0IwK9xU462_8emuHvs4,4443
3
+ alveoleye/_boxes.py,sha256=rAQwjr-2uby8P-VNqGjITI4xfEutSB_WwJZWcns7umw,28900
4
+ alveoleye/_export_operations.py,sha256=kaRaNTlQV1GylroLbsDP0ELsFOxiNmKZINA0qdgcAp8,2373
5
+ alveoleye/_gui_creator.py,sha256=yYm7fToV3Y_zAeUIAXV-VgjzBvVOlLN1vvqwKE5ecYA,6217
6
+ alveoleye/_layers_editor.py,sha256=_rRHVHE-qKLM9m2o1Nnx54nbI3p_-ppnD2TuJoXtlCE,1248
7
+ alveoleye/_reader.py,sha256=0jmhZXJDGCxDd_DEk-05IQzIZcwHjfZ7tJLGQaPYP3I,603
8
+ alveoleye/_rules.py,sha256=jKrsWxc1FPGp--BWIaeQI5QZFYJFQ9PI9TDM3iHpvQ0,1081
9
+ alveoleye/_sample_data.py,sha256=xH1frjJRRlEdtBxJsebIYJ1FHq1hN53bMlL_--HaYfE,644
10
+ alveoleye/_widget.py,sha256=Y1cFXoQIpPosh6WtSdOO_E2lc8zhIYKUqoP7ei3xA84,2545
11
+ alveoleye/_workers.py,sha256=KWc4zA-tnZI2gj2Ci638qMG53H3C6WLf0js2ag4XoC8,9477
12
+ alveoleye/_writer.py,sha256=iqoyFgN-IWctf3UrLp7RtvA0e9oaHfUNxk16qMuJh_A,923
13
+ alveoleye/config.json,sha256=araY5GyTQ6oqqpeF_LpTVpX64rVhr2bAB6b3J2Ivrcg,4647
14
+ alveoleye/dark_theme.css,sha256=n1OjjauuE834ywYNob9yvbcGbOL4uEQ-jYEN9j2pgfc,1473
15
+ alveoleye/light_theme.css,sha256=gLJ_R831AlebX7DgX8Neyil_xF2umR5ubCqe1PNLD-0,1448
16
+ alveoleye/napari.yaml,sha256=H5d6gcb5_AQ_4obgVqk7OKxZ1ckk4io81Le5un9pIIQ,1294
17
+ alveoleye/_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ alveoleye/_tests/test_lungcv.py,sha256=CrhtbhQkfZMfiQuoyQvF1NDQlCPvxrsCs2rZSbNtjkQ,623
19
+ alveoleye/_tests/test_reader.py,sha256=ssmS6ZO_e39HEBGz3BZfDw6cZGwDlC51F0T-b98fNWQ,219
20
+ alveoleye/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ alveoleye/lungcv/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ alveoleye/lungcv/assessments.py,sha256=1JK248J8SDX_lcWv6AVVVs2-yhZChiWf6PCyTHFJV-I,2286
23
+ alveoleye/lungcv/model_operations.py,sha256=nogggzDn-bWmEByrQ06jNS6bwoNiXiOSe1EThhqsIwo,4241
24
+ alveoleye/lungcv/postprocessor.py,sha256=ukueii0XtW6Tr7whYp_8srgynkPueS8I6Cjf3iyA--c,6357
25
+ alveoleye/lungcv/mrcnn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ alveoleye/lungcv/mrcnn/coco_eval.py,sha256=MUKHllRJL44qYm-cD20OWOtjk0P9WhDAPLhhxt_gvrs,6496
27
+ alveoleye/lungcv/mrcnn/coco_utils.py,sha256=wws9NlCnUgCSV0NgdR2N5KnG6ecUy12fDSvPklzCE9Y,8437
28
+ alveoleye/lungcv/mrcnn/engine.py,sha256=KIJ2vSfy_QMJzEGmrXAxHIlCstjrGDf9FvvoNgq0C-I,4188
29
+ alveoleye/lungcv/mrcnn/group_by_aspect_ratio.py,sha256=TmUxvDCcS8LvyGS5t4WIez0H-JTGnOIK4k_RiCxMss4,7147
30
+ alveoleye/lungcv/mrcnn/train.py,sha256=XacNPR6AZKxaREiYNaTlfLZhJ4p0H00PIuzYTv0JUNY,8409
31
+ alveoleye/lungcv/mrcnn/transforms.py,sha256=lyRR2duoU4D_W5KVMxsmMuu3FY7fZR-3qKnIbE1m0eo,23630
32
+ alveoleye/lungcv/mrcnn/utils.py,sha256=4tmArnpysH5Mjp3V3hAB41at3AtZn6R-48I_vAmOmTo,13587
33
+ AlveolEye-0.1.2.dist-info/LICENSE,sha256=_rmYY1BpzHFTLw0NkYm9KhksluU0ap3_RNc45FMaVao,1070
34
+ AlveolEye-0.1.2.dist-info/METADATA,sha256=k0pCTzaMxYMduVetF9pN-Ts-eHdVM9_j2CYRAeWaR3M,10638
35
+ AlveolEye-0.1.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
36
+ AlveolEye-0.1.2.dist-info/entry_points.txt,sha256=4LaW7WCJHHGCae4CBhct4NKUJpNA6E-1k9z9PBH2gwA,52
37
+ AlveolEye-0.1.2.dist-info/top_level.txt,sha256=lLQjkcOZaZzEG9ECpos8B4ZUYTn6fDiRtO4Tl_tqfAc,10
38
+ AlveolEye-0.1.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.43.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [napari.manifest]
2
+ AlveolEye = alveoleye:napari.yaml
@@ -0,0 +1 @@
1
+ alveoleye
alveoleye/__init__.py ADDED
@@ -0,0 +1,14 @@
1
+ __version__ = "0.1.2"
2
+
3
+ from ._reader import napari_get_reader
4
+ from ._sample_data import make_sample_data
5
+ from ._widget import WidgetMain
6
+ from ._writer import write_multiple, write_single_image
7
+
8
+ __all__ = (
9
+ "napari_get_reader",
10
+ "write_single_image",
11
+ "write_multiple",
12
+ "make_sample_data",
13
+ "WidgetMain",
14
+ )
@@ -0,0 +1,137 @@
1
+ from qtpy.QtCore import Qt, QTimer, QThread
2
+ from qtpy.QtWidgets import QVBoxLayout, QPushButton, QGroupBox
3
+
4
+ import alveoleye._rules as rules
5
+ import alveoleye._gui_creator as gui_creator
6
+ from alveoleye._workers import WorkerParent
7
+
8
+
9
+ class ActionBox(QGroupBox):
10
+ current_results = []
11
+ file_name = None
12
+ all_action_boxes = []
13
+ step = 0
14
+
15
+ def __init__(self, config_data, napari_viewer):
16
+ super().__init__()
17
+
18
+ self.action_box_config_data = config_data["ActionBox"]
19
+ self.layers_config_data = config_data["Layers"]
20
+ self.labels_config_data = config_data["Labels"]
21
+ self.box_config_data = config_data[self.__class__.__name__]
22
+
23
+ ActionBox.all_action_boxes.append(self)
24
+ WorkerParent.layers_config_data = self.layers_config_data
25
+
26
+ self.name = self.box_config_data["TITLE"]
27
+ self.setTitle(self.name)
28
+
29
+ self.state = 0
30
+
31
+ self.layout = QVBoxLayout()
32
+ self.rules_engine = rules.RulesEngine()
33
+
34
+ self.worker = None
35
+ self.thread = None
36
+ self.action_button = None
37
+ self.animation_timer = None
38
+
39
+ self.box_id = None
40
+
41
+ self.napari_viewer = napari_viewer
42
+
43
+ class ActionButton(QPushButton):
44
+ def __init__(self, button_text, tooltip_text, action, *__args):
45
+ super().__init__(*__args)
46
+
47
+ self.button_text = button_text
48
+ self.tooltip_text = tooltip_text
49
+
50
+ self.setText(button_text)
51
+ self.setToolTip(tooltip_text)
52
+ self.clicked.connect(action)
53
+
54
+ self.setCursor(Qt.PointingHandCursor)
55
+
56
+ def set_state(self, state):
57
+ self.setText([self.button_text, "Cancel", "Canceling..."][state])
58
+ self.setToolTip([self.tooltip_text, "Cancel operation", "Operation is canceling"][state])
59
+
60
+ def broadcast_cancel_message(self):
61
+ for box in ActionBox.all_action_boxes:
62
+ if box is not self:
63
+ box.cancel_action()
64
+
65
+ def broadcast_step_change_message(self, box_id=None):
66
+ for box in ActionBox.all_action_boxes:
67
+ if box is not self:
68
+ ActionBox.step = self.box_id if box_id is None else box_id
69
+ box.rules_engine.evaluate_rules()
70
+
71
+ def create_action_box_layout(self, elements, button_text, tooltip_text):
72
+ self.action_button = self.ActionButton(button_text, tooltip_text, self.on_action_button_press)
73
+ elements.append(self.action_button)
74
+ gui_creator.create_sub_layout(self.layout, elements)
75
+ self.setLayout(self.layout)
76
+
77
+ def start_animation(self):
78
+ self.animation_timer = QTimer()
79
+ self.animation_timer.timeout.connect(self.on_animation)
80
+ self.animation_timer.start(self.action_box_config_data["ANIMATION_INTERVAL"])
81
+
82
+ def stop_animation(self):
83
+ self.setTitle(self.name)
84
+ self.animation_timer.stop()
85
+
86
+ def on_animation(self):
87
+ current_dot_count = self.title().count(".") - self.name.count(".")
88
+ new_dot_count = (current_dot_count + 1) % (self.action_box_config_data["ANIMATION_DOTS"] + 1)
89
+ new_title = f"{self.name}{'.' * new_dot_count}"
90
+
91
+ self.setTitle(new_title)
92
+
93
+ def thread_worker(self):
94
+ self.thread = QThread()
95
+ self.worker.moveToThread(self.thread)
96
+
97
+ self.worker.results_ready.connect(self.on_results_ready)
98
+ self.worker.finished.connect(self.thread.quit)
99
+
100
+ self.thread.started.connect(self.worker.run)
101
+ self.thread.finished.connect(self.on_thread_completed)
102
+
103
+ self.thread.start()
104
+
105
+ def set_state(self, state):
106
+ self.state = state
107
+ self.action_button.set_state(state)
108
+ self.rules_engine.evaluate_rules()
109
+
110
+ def cancel_action(self):
111
+ if self.state == 1:
112
+ self.worker.cancel()
113
+ self.set_state(2)
114
+
115
+ def on_action_button_press(self):
116
+ self.broadcast_cancel_message()
117
+
118
+ if self.state:
119
+ self.cancel_action()
120
+ return
121
+
122
+ self.start_animation()
123
+ self.thread_worker()
124
+ self.set_state(1)
125
+
126
+ def on_results_ready(self, *__args):
127
+ self.broadcast_step_change_message()
128
+
129
+ def on_thread_completed(self):
130
+ self.thread.deleteLater()
131
+ self.stop_animation()
132
+ self.set_state(0)
133
+
134
+ def create_ui_rules(self):
135
+ self.rules_engine.add_rule(lambda: self.state == 2, lambda: rules.toggle(False, self.action_button))
136
+
137
+ self.rules_engine.evaluate_rules()