mosamatic2 2.0.24__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.
- models.py +259 -0
- mosamatic2/__init__.py +0 -0
- mosamatic2/app.py +32 -0
- mosamatic2/cli.py +50 -0
- mosamatic2/commands/__init__.py +0 -0
- mosamatic2/commands/boadockerpipeline.py +48 -0
- mosamatic2/commands/calculatemaskstatistics.py +59 -0
- mosamatic2/commands/calculatescores.py +73 -0
- mosamatic2/commands/createdicomsummary.py +61 -0
- mosamatic2/commands/createpngsfromsegmentations.py +65 -0
- mosamatic2/commands/defaultdockerpipeline.py +84 -0
- mosamatic2/commands/defaultpipeline.py +70 -0
- mosamatic2/commands/dicom2nifti.py +55 -0
- mosamatic2/commands/liveranalysispipeline.py +61 -0
- mosamatic2/commands/rescaledicomimages.py +54 -0
- mosamatic2/commands/segmentmusclefatl3tensorflow.py +55 -0
- mosamatic2/commands/selectslicefromscans.py +66 -0
- mosamatic2/commands/totalsegmentator.py +77 -0
- mosamatic2/constants.py +27 -0
- mosamatic2/core/__init__.py +0 -0
- mosamatic2/core/data/__init__.py +5 -0
- mosamatic2/core/data/dicomimage.py +27 -0
- mosamatic2/core/data/dicomimageseries.py +26 -0
- mosamatic2/core/data/dixonseries.py +22 -0
- mosamatic2/core/data/filedata.py +26 -0
- mosamatic2/core/data/multidicomimage.py +30 -0
- mosamatic2/core/data/multiniftiimage.py +26 -0
- mosamatic2/core/data/multinumpyimage.py +26 -0
- mosamatic2/core/data/niftiimage.py +13 -0
- mosamatic2/core/data/numpyimage.py +13 -0
- mosamatic2/core/managers/__init__.py +0 -0
- mosamatic2/core/managers/logmanager.py +45 -0
- mosamatic2/core/managers/logmanagerlistener.py +3 -0
- mosamatic2/core/pipelines/__init__.py +4 -0
- mosamatic2/core/pipelines/boadockerpipeline/__init__.py +0 -0
- mosamatic2/core/pipelines/boadockerpipeline/boadockerpipeline.py +70 -0
- mosamatic2/core/pipelines/defaultdockerpipeline/__init__.py +0 -0
- mosamatic2/core/pipelines/defaultdockerpipeline/defaultdockerpipeline.py +28 -0
- mosamatic2/core/pipelines/defaultpipeline/__init__.py +0 -0
- mosamatic2/core/pipelines/defaultpipeline/defaultpipeline.py +90 -0
- mosamatic2/core/pipelines/liveranalysispipeline/__init__.py +0 -0
- mosamatic2/core/pipelines/liveranalysispipeline/liveranalysispipeline.py +48 -0
- mosamatic2/core/pipelines/pipeline.py +14 -0
- mosamatic2/core/singleton.py +9 -0
- mosamatic2/core/tasks/__init__.py +13 -0
- mosamatic2/core/tasks/applythresholdtosegmentationstask/__init__.py +0 -0
- mosamatic2/core/tasks/applythresholdtosegmentationstask/applythresholdtosegmentationstask.py +117 -0
- mosamatic2/core/tasks/calculatemaskstatisticstask/__init__.py +0 -0
- mosamatic2/core/tasks/calculatemaskstatisticstask/calculatemaskstatisticstask.py +104 -0
- mosamatic2/core/tasks/calculatescorestask/__init__.py +0 -0
- mosamatic2/core/tasks/calculatescorestask/calculatescorestask.py +152 -0
- mosamatic2/core/tasks/createdicomsummarytask/__init__.py +0 -0
- mosamatic2/core/tasks/createdicomsummarytask/createdicomsummarytask.py +88 -0
- mosamatic2/core/tasks/createpngsfromsegmentationstask/__init__.py +0 -0
- mosamatic2/core/tasks/createpngsfromsegmentationstask/createpngsfromsegmentationstask.py +101 -0
- mosamatic2/core/tasks/dicom2niftitask/__init__.py +0 -0
- mosamatic2/core/tasks/dicom2niftitask/dicom2niftitask.py +45 -0
- mosamatic2/core/tasks/rescaledicomimagestask/__init__.py +0 -0
- mosamatic2/core/tasks/rescaledicomimagestask/rescaledicomimagestask.py +64 -0
- mosamatic2/core/tasks/segmentationnifti2numpytask/__init__.py +0 -0
- mosamatic2/core/tasks/segmentationnifti2numpytask/segmentationnifti2numpytask.py +57 -0
- mosamatic2/core/tasks/segmentationnumpy2niftitask/__init__.py +0 -0
- mosamatic2/core/tasks/segmentationnumpy2niftitask/segmentationnumpy2niftitask.py +86 -0
- mosamatic2/core/tasks/segmentmusclefatl3tensorflowtask/__init__.py +0 -0
- mosamatic2/core/tasks/segmentmusclefatl3tensorflowtask/paramloader.py +39 -0
- mosamatic2/core/tasks/segmentmusclefatl3tensorflowtask/segmentmusclefatl3tensorflowtask.py +122 -0
- mosamatic2/core/tasks/segmentmusclefatt4pytorchtask/__init__.py +0 -0
- mosamatic2/core/tasks/segmentmusclefatt4pytorchtask/paramloader.py +39 -0
- mosamatic2/core/tasks/segmentmusclefatt4pytorchtask/segmentmusclefatt4pytorchtask.py +128 -0
- mosamatic2/core/tasks/selectslicefromscanstask/__init__.py +0 -0
- mosamatic2/core/tasks/selectslicefromscanstask/selectslicefromscanstask.py +249 -0
- mosamatic2/core/tasks/task.py +50 -0
- mosamatic2/core/tasks/totalsegmentatortask/__init__.py +0 -0
- mosamatic2/core/tasks/totalsegmentatortask/totalsegmentatortask.py +75 -0
- mosamatic2/core/utils.py +405 -0
- mosamatic2/server.py +146 -0
- mosamatic2/ui/__init__.py +0 -0
- mosamatic2/ui/mainwindow.py +426 -0
- mosamatic2/ui/resources/VERSION +1 -0
- mosamatic2/ui/resources/icons/mosamatic2.icns +0 -0
- mosamatic2/ui/resources/icons/mosamatic2.ico +0 -0
- mosamatic2/ui/resources/icons/spinner.gif +0 -0
- mosamatic2/ui/resources/images/body-composition.jpg +0 -0
- mosamatic2/ui/settings.py +62 -0
- mosamatic2/ui/utils.py +36 -0
- mosamatic2/ui/widgets/__init__.py +0 -0
- mosamatic2/ui/widgets/dialogs/__init__.py +0 -0
- mosamatic2/ui/widgets/dialogs/dialog.py +16 -0
- mosamatic2/ui/widgets/dialogs/helpdialog.py +9 -0
- mosamatic2/ui/widgets/panels/__init__.py +0 -0
- mosamatic2/ui/widgets/panels/defaultpanel.py +31 -0
- mosamatic2/ui/widgets/panels/logpanel.py +65 -0
- mosamatic2/ui/widgets/panels/mainpanel.py +82 -0
- mosamatic2/ui/widgets/panels/pipelines/__init__.py +0 -0
- mosamatic2/ui/widgets/panels/pipelines/boadockerpipelinepanel.py +195 -0
- mosamatic2/ui/widgets/panels/pipelines/defaultdockerpipelinepanel.py +314 -0
- mosamatic2/ui/widgets/panels/pipelines/defaultpipelinepanel.py +302 -0
- mosamatic2/ui/widgets/panels/pipelines/liveranalysispipelinepanel.py +187 -0
- mosamatic2/ui/widgets/panels/pipelines/pipelinepanel.py +6 -0
- mosamatic2/ui/widgets/panels/settingspanel.py +16 -0
- mosamatic2/ui/widgets/panels/stackedpanel.py +22 -0
- mosamatic2/ui/widgets/panels/tasks/__init__.py +0 -0
- mosamatic2/ui/widgets/panels/tasks/applythresholdtosegmentationstaskpanel.py +271 -0
- mosamatic2/ui/widgets/panels/tasks/calculatemaskstatisticstaskpanel.py +215 -0
- mosamatic2/ui/widgets/panels/tasks/calculatescorestaskpanel.py +238 -0
- mosamatic2/ui/widgets/panels/tasks/createdicomsummarytaskpanel.py +206 -0
- mosamatic2/ui/widgets/panels/tasks/createpngsfromsegmentationstaskpanel.py +247 -0
- mosamatic2/ui/widgets/panels/tasks/dicom2niftitaskpanel.py +183 -0
- mosamatic2/ui/widgets/panels/tasks/rescaledicomimagestaskpanel.py +184 -0
- mosamatic2/ui/widgets/panels/tasks/segmentationnifti2numpytaskpanel.py +192 -0
- mosamatic2/ui/widgets/panels/tasks/segmentationnumpy2niftitaskpanel.py +213 -0
- mosamatic2/ui/widgets/panels/tasks/segmentmusclefatl3tensorflowtaskpanel.py +216 -0
- mosamatic2/ui/widgets/panels/tasks/segmentmusclefatt4pytorchtaskpanel.py +217 -0
- mosamatic2/ui/widgets/panels/tasks/selectslicefromscanstaskpanel.py +193 -0
- mosamatic2/ui/widgets/panels/tasks/taskpanel.py +6 -0
- mosamatic2/ui/widgets/panels/tasks/totalsegmentatortaskpanel.py +195 -0
- mosamatic2/ui/widgets/panels/visualizations/__init__.py +0 -0
- mosamatic2/ui/widgets/panels/visualizations/liversegmentvisualization/__init__.py +0 -0
- mosamatic2/ui/widgets/panels/visualizations/liversegmentvisualization/liversegmentpicker.py +96 -0
- mosamatic2/ui/widgets/panels/visualizations/liversegmentvisualization/liversegmentviewer.py +130 -0
- mosamatic2/ui/widgets/panels/visualizations/liversegmentvisualization/liversegmentvisualization.py +120 -0
- mosamatic2/ui/widgets/panels/visualizations/sliceselectionvisualization/__init__.py +0 -0
- mosamatic2/ui/widgets/panels/visualizations/sliceselectionvisualization/sliceselectionviewer.py +61 -0
- mosamatic2/ui/widgets/panels/visualizations/sliceselectionvisualization/sliceselectionvisualization.py +133 -0
- mosamatic2/ui/widgets/panels/visualizations/sliceselectionvisualization/slicetile.py +63 -0
- mosamatic2/ui/widgets/panels/visualizations/slicevisualization/__init__.py +0 -0
- mosamatic2/ui/widgets/panels/visualizations/slicevisualization/custominteractorstyle.py +80 -0
- mosamatic2/ui/widgets/panels/visualizations/slicevisualization/sliceviewer.py +116 -0
- mosamatic2/ui/widgets/panels/visualizations/slicevisualization/slicevisualization.py +141 -0
- mosamatic2/ui/widgets/panels/visualizations/visualization.py +6 -0
- mosamatic2/ui/widgets/splashscreen.py +101 -0
- mosamatic2/ui/worker.py +29 -0
- mosamatic2-2.0.24.dist-info/METADATA +43 -0
- mosamatic2-2.0.24.dist-info/RECORD +136 -0
- mosamatic2-2.0.24.dist-info/WHEEL +4 -0
- mosamatic2-2.0.24.dist-info/entry_points.txt +5 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from PySide6.QtWidgets import (
|
|
4
|
+
QLineEdit,
|
|
5
|
+
QSpinBox,
|
|
6
|
+
QComboBox,
|
|
7
|
+
QCheckBox,
|
|
8
|
+
QHBoxLayout,
|
|
9
|
+
QVBoxLayout,
|
|
10
|
+
QFormLayout,
|
|
11
|
+
QPushButton,
|
|
12
|
+
QFileDialog,
|
|
13
|
+
QMessageBox,
|
|
14
|
+
)
|
|
15
|
+
from PySide6.QtCore import (
|
|
16
|
+
QThread,
|
|
17
|
+
Slot,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
from mosamatic2.core.managers.logmanager import LogManager
|
|
21
|
+
from mosamatic2.ui.widgets.panels.pipelines.pipelinepanel import PipelinePanel
|
|
22
|
+
from mosamatic2.ui.settings import Settings
|
|
23
|
+
from mosamatic2.ui.utils import is_macos
|
|
24
|
+
from mosamatic2.ui.worker import Worker
|
|
25
|
+
from mosamatic2.core.pipelines import DefaultPipeline
|
|
26
|
+
|
|
27
|
+
LOG = LogManager()
|
|
28
|
+
|
|
29
|
+
PANEL_TITLE = 'DefaultPipeline'
|
|
30
|
+
PANEL_NAME = 'defaultpipelinepanel'
|
|
31
|
+
MODEL_TYPE_ITEM_NAMES = ['tensorflow', 'pytorch']
|
|
32
|
+
MODEL_VERSION_ITEM_NAMES = ['1.0', '2.2']
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class DefaultPipelinePanel(PipelinePanel):
|
|
36
|
+
def __init__(self):
|
|
37
|
+
super(DefaultPipelinePanel, self).__init__()
|
|
38
|
+
self.set_title(PANEL_TITLE)
|
|
39
|
+
self._images_dir_line_edit = None
|
|
40
|
+
self._images_dir_select_button = None
|
|
41
|
+
self._model_files_dir_line_edit = None
|
|
42
|
+
self._model_files_dir_select_button = None
|
|
43
|
+
self._output_dir_line_edit = None
|
|
44
|
+
self._output_dir_select_button = None
|
|
45
|
+
self._target_size_spinbox = None
|
|
46
|
+
self._model_type_combobox = None
|
|
47
|
+
self._model_version_combobox = None
|
|
48
|
+
self._fig_width_spinbox = None
|
|
49
|
+
self._fig_height_spinbox = None
|
|
50
|
+
self._full_scan_checkbox = None
|
|
51
|
+
self._overwrite_checkbox = None
|
|
52
|
+
self._form_layout = None
|
|
53
|
+
self._run_pipeline_button = None
|
|
54
|
+
self._settings = None
|
|
55
|
+
self._task = None
|
|
56
|
+
self._worker = None
|
|
57
|
+
self._thread = None
|
|
58
|
+
self.init_layout()
|
|
59
|
+
|
|
60
|
+
def images_dir_line_edit(self):
|
|
61
|
+
if not self._images_dir_line_edit:
|
|
62
|
+
self._images_dir_line_edit = QLineEdit()
|
|
63
|
+
self._images_dir_line_edit.setText(self.settings().get(f'{PANEL_NAME}/images_dir'))
|
|
64
|
+
return self._images_dir_line_edit
|
|
65
|
+
|
|
66
|
+
def images_dir_select_button(self):
|
|
67
|
+
if not self._images_dir_select_button:
|
|
68
|
+
self._images_dir_select_button = QPushButton('Select')
|
|
69
|
+
self._images_dir_select_button.clicked.connect(self.handle_images_dir_select_button)
|
|
70
|
+
return self._images_dir_select_button
|
|
71
|
+
|
|
72
|
+
def model_files_dir_line_edit(self):
|
|
73
|
+
if not self._model_files_dir_line_edit:
|
|
74
|
+
self._model_files_dir_line_edit = QLineEdit()
|
|
75
|
+
self._model_files_dir_line_edit.setText(self.settings().get(f'{PANEL_NAME}/model_files_dir'))
|
|
76
|
+
return self._model_files_dir_line_edit
|
|
77
|
+
|
|
78
|
+
def model_files_dir_select_button(self):
|
|
79
|
+
if not self._model_files_dir_select_button:
|
|
80
|
+
self._model_files_dir_select_button = QPushButton('Select')
|
|
81
|
+
self._model_files_dir_select_button.clicked.connect(self.handle_model_files_dir_select_button)
|
|
82
|
+
return self._model_files_dir_select_button
|
|
83
|
+
|
|
84
|
+
def output_dir_line_edit(self):
|
|
85
|
+
if not self._output_dir_line_edit:
|
|
86
|
+
self._output_dir_line_edit = QLineEdit()
|
|
87
|
+
self._output_dir_line_edit.setText(self.settings().get(f'{PANEL_NAME}/output_dir'))
|
|
88
|
+
return self._output_dir_line_edit
|
|
89
|
+
|
|
90
|
+
def output_dir_select_button(self):
|
|
91
|
+
if not self._output_dir_select_button:
|
|
92
|
+
self._output_dir_select_button = QPushButton('Select')
|
|
93
|
+
self._output_dir_select_button.clicked.connect(self.handle_output_dir_select_button)
|
|
94
|
+
return self._output_dir_select_button
|
|
95
|
+
|
|
96
|
+
def target_size_spinbox(self):
|
|
97
|
+
if not self._target_size_spinbox:
|
|
98
|
+
self._target_size_spinbox = QSpinBox()
|
|
99
|
+
self._target_size_spinbox.setMinimum(0)
|
|
100
|
+
self._target_size_spinbox.setMaximum(1024)
|
|
101
|
+
self._target_size_spinbox.setValue(self.settings().get_int(f'{PANEL_NAME}/target_size', 512))
|
|
102
|
+
return self._target_size_spinbox
|
|
103
|
+
|
|
104
|
+
def model_type_combobox(self):
|
|
105
|
+
if not self._model_type_combobox:
|
|
106
|
+
self._model_type_combobox = QComboBox()
|
|
107
|
+
self._model_type_combobox.addItems(MODEL_TYPE_ITEM_NAMES)
|
|
108
|
+
self._model_type_combobox.setCurrentText(self.settings().get(f'{PANEL_NAME}/model_type'))
|
|
109
|
+
self._model_type_combobox.currentTextChanged.connect(self.handle_model_type_combobox)
|
|
110
|
+
return self._model_type_combobox
|
|
111
|
+
|
|
112
|
+
def model_version_combobox(self):
|
|
113
|
+
if not self._model_version_combobox:
|
|
114
|
+
self._model_version_combobox = QComboBox()
|
|
115
|
+
self._model_version_combobox.addItems(MODEL_VERSION_ITEM_NAMES)
|
|
116
|
+
self._model_version_combobox.setCurrentText(self.settings().get(f'{PANEL_NAME}/model_version'))
|
|
117
|
+
self._model_version_combobox.currentTextChanged.connect(self.handle_model_version_combobox)
|
|
118
|
+
return self._model_version_combobox
|
|
119
|
+
|
|
120
|
+
def fig_width_spinbox(self):
|
|
121
|
+
if not self._fig_width_spinbox:
|
|
122
|
+
self._fig_width_spinbox = QSpinBox()
|
|
123
|
+
self._fig_width_spinbox.setValue(self.settings().get_int(f'{PANEL_NAME}/fig_width', default=10))
|
|
124
|
+
return self._fig_width_spinbox
|
|
125
|
+
|
|
126
|
+
def fig_height_spinbox(self):
|
|
127
|
+
if not self._fig_height_spinbox:
|
|
128
|
+
self._fig_height_spinbox = QSpinBox()
|
|
129
|
+
self._fig_height_spinbox.setValue(self.settings().get_int(f'{PANEL_NAME}/fig_height', default=10))
|
|
130
|
+
return self._fig_height_spinbox
|
|
131
|
+
|
|
132
|
+
def full_scan_checkbox(self):
|
|
133
|
+
if not self._full_scan_checkbox:
|
|
134
|
+
self._full_scan_checkbox = QCheckBox('')
|
|
135
|
+
self._full_scan_checkbox.setChecked(self.settings().get_bool(f'{PANEL_NAME}/full_scan', False))
|
|
136
|
+
return self._full_scan_checkbox
|
|
137
|
+
|
|
138
|
+
def overwrite_checkbox(self):
|
|
139
|
+
if not self._overwrite_checkbox:
|
|
140
|
+
self._overwrite_checkbox = QCheckBox('')
|
|
141
|
+
self._overwrite_checkbox.setChecked(self.settings().get_bool(f'{PANEL_NAME}/overwrite', True))
|
|
142
|
+
return self._overwrite_checkbox
|
|
143
|
+
|
|
144
|
+
def form_layout(self):
|
|
145
|
+
if not self._form_layout:
|
|
146
|
+
self._form_layout = QFormLayout()
|
|
147
|
+
if is_macos():
|
|
148
|
+
self._form_layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
|
|
149
|
+
return self._form_layout
|
|
150
|
+
|
|
151
|
+
def run_pipeline_button(self):
|
|
152
|
+
if not self._run_pipeline_button:
|
|
153
|
+
self._run_pipeline_button = QPushButton('Run pipeline')
|
|
154
|
+
self._run_pipeline_button.clicked.connect(self.handle_run_pipeline_button)
|
|
155
|
+
return self._run_pipeline_button
|
|
156
|
+
|
|
157
|
+
def settings(self):
|
|
158
|
+
if not self._settings:
|
|
159
|
+
self._settings = Settings()
|
|
160
|
+
return self._settings
|
|
161
|
+
|
|
162
|
+
def init_help_dialog(self):
|
|
163
|
+
self.help_dialog().set_text('Show some help information')
|
|
164
|
+
|
|
165
|
+
def init_layout(self):
|
|
166
|
+
images_dir_layout = QHBoxLayout()
|
|
167
|
+
images_dir_layout.addWidget(self.images_dir_line_edit())
|
|
168
|
+
images_dir_layout.addWidget(self.images_dir_select_button())
|
|
169
|
+
model_files_dir_layout = QHBoxLayout()
|
|
170
|
+
model_files_dir_layout.addWidget(self.model_files_dir_line_edit())
|
|
171
|
+
model_files_dir_layout.addWidget(self.model_files_dir_select_button())
|
|
172
|
+
output_dir_layout = QHBoxLayout()
|
|
173
|
+
output_dir_layout.addWidget(self.output_dir_line_edit())
|
|
174
|
+
output_dir_layout.addWidget(self.output_dir_select_button())
|
|
175
|
+
self.form_layout().addRow('Images directory', images_dir_layout)
|
|
176
|
+
self.form_layout().addRow('Model files directory', model_files_dir_layout)
|
|
177
|
+
self.form_layout().addRow('Output directory', output_dir_layout)
|
|
178
|
+
self.form_layout().addRow('Overwrite', self.overwrite_checkbox())
|
|
179
|
+
layout = QVBoxLayout()
|
|
180
|
+
layout.addLayout(self.form_layout())
|
|
181
|
+
layout.addWidget(self.run_pipeline_button())
|
|
182
|
+
self.setLayout(layout)
|
|
183
|
+
self.setObjectName(PANEL_NAME)
|
|
184
|
+
|
|
185
|
+
def handle_images_dir_select_button(self):
|
|
186
|
+
last_directory = self.settings().get('last_directory')
|
|
187
|
+
directory = QFileDialog.getExistingDirectory(dir=last_directory)
|
|
188
|
+
if directory:
|
|
189
|
+
self.images_dir_line_edit().setText(directory)
|
|
190
|
+
self.settings().set('last_directory', directory)
|
|
191
|
+
|
|
192
|
+
def handle_model_files_dir_select_button(self):
|
|
193
|
+
last_directory = self.settings().get('last_directory')
|
|
194
|
+
directory = QFileDialog.getExistingDirectory(dir=last_directory)
|
|
195
|
+
if directory:
|
|
196
|
+
self.model_files_dir_line_edit().setText(directory)
|
|
197
|
+
self.settings().set('last_directory', directory)
|
|
198
|
+
|
|
199
|
+
def handle_output_dir_select_button(self):
|
|
200
|
+
last_directory = self.settings().get('last_directory')
|
|
201
|
+
directory = QFileDialog.getExistingDirectory(dir=last_directory)
|
|
202
|
+
if directory:
|
|
203
|
+
self.output_dir_line_edit().setText(directory)
|
|
204
|
+
self.settings().set('last_directory', directory)
|
|
205
|
+
|
|
206
|
+
def handle_model_type_combobox(self, text):
|
|
207
|
+
if text == 'tensorflow':
|
|
208
|
+
self.model_version_combobox().setCurrentText('1.0')
|
|
209
|
+
if text == 'pytorch':
|
|
210
|
+
self.model_version_combobox().setCurrentText('2.2')
|
|
211
|
+
|
|
212
|
+
def handle_model_version_combobox(self, text):
|
|
213
|
+
if text == '1.0':
|
|
214
|
+
self.model_type_combobox().setCurrentText('tensorflow')
|
|
215
|
+
if text == '2.2':
|
|
216
|
+
self.model_type_combobox().setCurrentText('pytorch')
|
|
217
|
+
|
|
218
|
+
def handle_run_pipeline_button(self):
|
|
219
|
+
errors = self.check_inputs_and_parameters()
|
|
220
|
+
if len(errors) > 0:
|
|
221
|
+
error_message = 'Following errors were encountered:\n'
|
|
222
|
+
for error in errors:
|
|
223
|
+
error_message += f' - {error}\n'
|
|
224
|
+
QMessageBox.information(self, 'Error', error_message)
|
|
225
|
+
else:
|
|
226
|
+
LOG.info('Running pipeline...')
|
|
227
|
+
self.run_pipeline_button().setEnabled(False)
|
|
228
|
+
self.save_inputs_and_parameters()
|
|
229
|
+
self._task = DefaultPipeline(
|
|
230
|
+
inputs={
|
|
231
|
+
'images': self.images_dir_line_edit().text(),
|
|
232
|
+
'model_files': self.model_files_dir_line_edit().text(),
|
|
233
|
+
},
|
|
234
|
+
params={
|
|
235
|
+
'file_type': 'npy',
|
|
236
|
+
'model_type': 'tensorflow',
|
|
237
|
+
'model_version': 1.0,
|
|
238
|
+
'target_size': 512,
|
|
239
|
+
'fig_width': 10,
|
|
240
|
+
'fig_height': 10,
|
|
241
|
+
'hu_low': 30,
|
|
242
|
+
'hu_high': 150,
|
|
243
|
+
'alpha': 1.0,
|
|
244
|
+
},
|
|
245
|
+
output=self.output_dir_line_edit().text(),
|
|
246
|
+
overwrite=self.overwrite_checkbox().isChecked(),
|
|
247
|
+
)
|
|
248
|
+
self._worker = Worker(self._task)
|
|
249
|
+
self._thread = QThread()
|
|
250
|
+
self._worker.moveToThread(self._thread)
|
|
251
|
+
self._thread.started.connect(self._worker.run)
|
|
252
|
+
self._worker.progress.connect(self.handle_progress)
|
|
253
|
+
self._worker.status.connect(self.handle_status)
|
|
254
|
+
self._worker.finished.connect(self.handle_finished)
|
|
255
|
+
self._worker.finished.connect(self._thread.quit)
|
|
256
|
+
self._worker.finished.connect(self._worker.deleteLater)
|
|
257
|
+
self._thread.finished.connect(self._thread.deleteLater)
|
|
258
|
+
self._thread.start()
|
|
259
|
+
|
|
260
|
+
@Slot(int)
|
|
261
|
+
def handle_progress(self, progress):
|
|
262
|
+
LOG.info(f'Progress: {progress} / 100%')
|
|
263
|
+
|
|
264
|
+
@Slot(str)
|
|
265
|
+
def handle_status(self, status):
|
|
266
|
+
LOG.info(f'Status: {status}')
|
|
267
|
+
|
|
268
|
+
@Slot()
|
|
269
|
+
def handle_finished(self):
|
|
270
|
+
self.run_pipeline_button().setEnabled(True)
|
|
271
|
+
|
|
272
|
+
def check_inputs_and_parameters(self):
|
|
273
|
+
errors = []
|
|
274
|
+
if self.images_dir_line_edit().text() == '':
|
|
275
|
+
errors.append('Empty images directory path')
|
|
276
|
+
elif not os.path.isdir(self.images_dir_line_edit().text()):
|
|
277
|
+
errors.append('Images directory does not exist')
|
|
278
|
+
if self.model_files_dir_line_edit().text() == '':
|
|
279
|
+
errors.append('Empty model files directory path')
|
|
280
|
+
elif not os.path.isdir(self.model_files_dir_line_edit().text()):
|
|
281
|
+
errors.append('Model files directory does not exist')
|
|
282
|
+
if self.output_dir_line_edit().text() == '':
|
|
283
|
+
errors.append('Empty output directory path')
|
|
284
|
+
elif os.path.isdir(self.output_dir_line_edit().text()) and not self.overwrite_checkbox().isChecked():
|
|
285
|
+
errors.append('Output directory exists but overwrite=False. Please remove output directory first')
|
|
286
|
+
# if self.target_size_spinbox().value() != 512:
|
|
287
|
+
# errors.append('Target size must be 512')
|
|
288
|
+
# if self.full_scan_checkbox().isChecked():
|
|
289
|
+
# errors.append('Full scan support is not available yet')
|
|
290
|
+
return errors
|
|
291
|
+
|
|
292
|
+
def save_inputs_and_parameters(self):
|
|
293
|
+
self.settings().set(f'{PANEL_NAME}/images_dir', self.images_dir_line_edit().text())
|
|
294
|
+
self.settings().set(f'{PANEL_NAME}/model_files_dir', self.model_files_dir_line_edit().text())
|
|
295
|
+
self.settings().set(f'{PANEL_NAME}/output_dir', self.output_dir_line_edit().text())
|
|
296
|
+
# self.settings().set(f'{PANEL_NAME}/target_size', self.target_size_spinbox().value())
|
|
297
|
+
# self.settings().set(f'{PANEL_NAME}/model_type', self.model_type_combobox().currentText())
|
|
298
|
+
# self.settings().set(f'{PANEL_NAME}/model_version', self.model_version_combobox().currentText())
|
|
299
|
+
# self.settings().set(f'{PANEL_NAME}/fig_width', self.fig_width_spinbox().value())
|
|
300
|
+
# self.settings().set(f'{PANEL_NAME}/fig_height', self.fig_height_spinbox().value())
|
|
301
|
+
# self.settings().set(f'{PANEL_NAME}/full_scan', self.full_scan_checkbox().isChecked())
|
|
302
|
+
self.settings().set(f'{PANEL_NAME}/overwrite', self.overwrite_checkbox().isChecked())
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from PySide6.QtWidgets import (
|
|
4
|
+
QLineEdit,
|
|
5
|
+
QSpinBox,
|
|
6
|
+
QComboBox,
|
|
7
|
+
QCheckBox,
|
|
8
|
+
QHBoxLayout,
|
|
9
|
+
QVBoxLayout,
|
|
10
|
+
QFormLayout,
|
|
11
|
+
QPushButton,
|
|
12
|
+
QFileDialog,
|
|
13
|
+
QMessageBox,
|
|
14
|
+
)
|
|
15
|
+
from PySide6.QtCore import (
|
|
16
|
+
QThread,
|
|
17
|
+
Slot,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
from mosamatic2.core.managers.logmanager import LogManager
|
|
21
|
+
from mosamatic2.ui.widgets.panels.pipelines.pipelinepanel import PipelinePanel
|
|
22
|
+
from mosamatic2.ui.settings import Settings
|
|
23
|
+
from mosamatic2.ui.utils import is_macos
|
|
24
|
+
from mosamatic2.ui.worker import Worker
|
|
25
|
+
from mosamatic2.core.pipelines import LiverAnalysisPipeline
|
|
26
|
+
|
|
27
|
+
LOG = LogManager()
|
|
28
|
+
|
|
29
|
+
PANEL_TITLE = 'LiverAnalysisPipeline'
|
|
30
|
+
PANEL_NAME = 'liveranalysispipelinepanel'
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class LiverAnalysisPipelinePanel(PipelinePanel):
|
|
34
|
+
def __init__(self):
|
|
35
|
+
super(LiverAnalysisPipelinePanel, self).__init__()
|
|
36
|
+
self.set_title(PANEL_TITLE)
|
|
37
|
+
self._scans_dir_line_edit = None
|
|
38
|
+
self._scans_dir_select_button = None
|
|
39
|
+
self._output_dir_line_edit = None
|
|
40
|
+
self._output_dir_select_button = None
|
|
41
|
+
self._overwrite_checkbox = None
|
|
42
|
+
self._form_layout = None
|
|
43
|
+
self._run_pipeline_button = None
|
|
44
|
+
self._settings = None
|
|
45
|
+
self._task = None
|
|
46
|
+
self._worker = None
|
|
47
|
+
self._thread = None
|
|
48
|
+
self.init_layout()
|
|
49
|
+
|
|
50
|
+
def scans_dir_line_edit(self):
|
|
51
|
+
if not self._scans_dir_line_edit:
|
|
52
|
+
self._scans_dir_line_edit = QLineEdit()
|
|
53
|
+
self._scans_dir_line_edit.setText(self.settings().get(f'{PANEL_NAME}/scans_dir'))
|
|
54
|
+
return self._scans_dir_line_edit
|
|
55
|
+
|
|
56
|
+
def scans_dir_select_button(self):
|
|
57
|
+
if not self._scans_dir_select_button:
|
|
58
|
+
self._scans_dir_select_button = QPushButton('Select')
|
|
59
|
+
self._scans_dir_select_button.clicked.connect(self.handle_scans_dir_select_button)
|
|
60
|
+
return self._scans_dir_select_button
|
|
61
|
+
|
|
62
|
+
def output_dir_line_edit(self):
|
|
63
|
+
if not self._output_dir_line_edit:
|
|
64
|
+
self._output_dir_line_edit = QLineEdit()
|
|
65
|
+
self._output_dir_line_edit.setText(self.settings().get(f'{PANEL_NAME}/output_dir'))
|
|
66
|
+
return self._output_dir_line_edit
|
|
67
|
+
|
|
68
|
+
def output_dir_select_button(self):
|
|
69
|
+
if not self._output_dir_select_button:
|
|
70
|
+
self._output_dir_select_button = QPushButton('Select')
|
|
71
|
+
self._output_dir_select_button.clicked.connect(self.handle_output_dir_select_button)
|
|
72
|
+
return self._output_dir_select_button
|
|
73
|
+
|
|
74
|
+
def overwrite_checkbox(self):
|
|
75
|
+
if not self._overwrite_checkbox:
|
|
76
|
+
self._overwrite_checkbox = QCheckBox('')
|
|
77
|
+
self._overwrite_checkbox.setChecked(self.settings().get_bool(f'{PANEL_NAME}/overwrite', True))
|
|
78
|
+
return self._overwrite_checkbox
|
|
79
|
+
|
|
80
|
+
def form_layout(self):
|
|
81
|
+
if not self._form_layout:
|
|
82
|
+
self._form_layout = QFormLayout()
|
|
83
|
+
if is_macos():
|
|
84
|
+
self._form_layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
|
|
85
|
+
return self._form_layout
|
|
86
|
+
|
|
87
|
+
def run_pipeline_button(self):
|
|
88
|
+
if not self._run_pipeline_button:
|
|
89
|
+
self._run_pipeline_button = QPushButton('Run pipeline')
|
|
90
|
+
self._run_pipeline_button.clicked.connect(self.handle_run_pipeline_button)
|
|
91
|
+
return self._run_pipeline_button
|
|
92
|
+
|
|
93
|
+
def settings(self):
|
|
94
|
+
if not self._settings:
|
|
95
|
+
self._settings = Settings()
|
|
96
|
+
return self._settings
|
|
97
|
+
|
|
98
|
+
def init_help_dialog(self):
|
|
99
|
+
self.help_dialog().set_text('Show some help information')
|
|
100
|
+
|
|
101
|
+
def init_layout(self):
|
|
102
|
+
scans_dir_layout = QHBoxLayout()
|
|
103
|
+
scans_dir_layout.addWidget(self.scans_dir_line_edit())
|
|
104
|
+
scans_dir_layout.addWidget(self.scans_dir_select_button())
|
|
105
|
+
output_dir_layout = QHBoxLayout()
|
|
106
|
+
output_dir_layout.addWidget(self.output_dir_line_edit())
|
|
107
|
+
output_dir_layout.addWidget(self.output_dir_select_button())
|
|
108
|
+
self.form_layout().addRow('Scans directory', scans_dir_layout)
|
|
109
|
+
self.form_layout().addRow('Output directory', output_dir_layout)
|
|
110
|
+
self.form_layout().addRow('Overwrite', self.overwrite_checkbox())
|
|
111
|
+
layout = QVBoxLayout()
|
|
112
|
+
layout.addLayout(self.form_layout())
|
|
113
|
+
layout.addWidget(self.run_pipeline_button())
|
|
114
|
+
self.setLayout(layout)
|
|
115
|
+
self.setObjectName(PANEL_NAME)
|
|
116
|
+
|
|
117
|
+
def handle_scans_dir_select_button(self):
|
|
118
|
+
last_directory = self.settings().get('last_directory')
|
|
119
|
+
directory = QFileDialog.getExistingDirectory(dir=last_directory)
|
|
120
|
+
if directory:
|
|
121
|
+
self.scans_dir_line_edit().setText(directory)
|
|
122
|
+
self.settings().set('last_directory', directory)
|
|
123
|
+
|
|
124
|
+
def handle_output_dir_select_button(self):
|
|
125
|
+
last_directory = self.settings().get('last_directory')
|
|
126
|
+
directory = QFileDialog.getExistingDirectory(dir=last_directory)
|
|
127
|
+
if directory:
|
|
128
|
+
self.output_dir_line_edit().setText(directory)
|
|
129
|
+
self.settings().set('last_directory', directory)
|
|
130
|
+
|
|
131
|
+
def handle_run_pipeline_button(self):
|
|
132
|
+
errors = self.check_inputs_and_parameters()
|
|
133
|
+
if len(errors) > 0:
|
|
134
|
+
error_message = 'Following errors were encountered:\n'
|
|
135
|
+
for error in errors:
|
|
136
|
+
error_message += f' - {error}\n'
|
|
137
|
+
QMessageBox.information(self, 'Error', error_message)
|
|
138
|
+
else:
|
|
139
|
+
LOG.info('Running pipeline...')
|
|
140
|
+
self.run_pipeline_button().setEnabled(False)
|
|
141
|
+
self.save_inputs_and_parameters()
|
|
142
|
+
self._task = LiverAnalysisPipeline(
|
|
143
|
+
inputs={'scans': self.scans_dir_line_edit().text()},
|
|
144
|
+
params={'compressed': True},
|
|
145
|
+
output=self.output_dir_line_edit().text(),
|
|
146
|
+
overwrite=self.overwrite_checkbox().isChecked(),
|
|
147
|
+
)
|
|
148
|
+
self._worker = Worker(self._task)
|
|
149
|
+
self._thread = QThread()
|
|
150
|
+
self._worker.moveToThread(self._thread)
|
|
151
|
+
self._thread.started.connect(self._worker.run)
|
|
152
|
+
self._worker.progress.connect(self.handle_progress)
|
|
153
|
+
self._worker.status.connect(self.handle_status)
|
|
154
|
+
self._worker.finished.connect(self.handle_finished)
|
|
155
|
+
self._worker.finished.connect(self._thread.quit)
|
|
156
|
+
self._worker.finished.connect(self._worker.deleteLater)
|
|
157
|
+
self._thread.finished.connect(self._thread.deleteLater)
|
|
158
|
+
self._thread.start()
|
|
159
|
+
|
|
160
|
+
@Slot(int)
|
|
161
|
+
def handle_progress(self, progress):
|
|
162
|
+
LOG.info(f'Progress: {progress} / 100%')
|
|
163
|
+
|
|
164
|
+
@Slot(str)
|
|
165
|
+
def handle_status(self, status):
|
|
166
|
+
LOG.info(f'Status: {status}')
|
|
167
|
+
|
|
168
|
+
@Slot()
|
|
169
|
+
def handle_finished(self):
|
|
170
|
+
self.run_pipeline_button().setEnabled(True)
|
|
171
|
+
|
|
172
|
+
def check_inputs_and_parameters(self):
|
|
173
|
+
errors = []
|
|
174
|
+
if self.scans_dir_line_edit().text() == '':
|
|
175
|
+
errors.append('Empty scans directory path')
|
|
176
|
+
elif not os.path.isdir(self.scans_dir_line_edit().text()):
|
|
177
|
+
errors.append('Scans directory does not exist')
|
|
178
|
+
if self.output_dir_line_edit().text() == '':
|
|
179
|
+
errors.append('Empty output directory path')
|
|
180
|
+
elif os.path.isdir(self.output_dir_line_edit().text()) and not self.overwrite_checkbox().isChecked():
|
|
181
|
+
errors.append('Output directory exists but overwrite=False. Please remove output directory first')
|
|
182
|
+
return errors
|
|
183
|
+
|
|
184
|
+
def save_inputs_and_parameters(self):
|
|
185
|
+
self.settings().set(f'{PANEL_NAME}/scans_dir', self.scans_dir_line_edit().text())
|
|
186
|
+
self.settings().set(f'{PANEL_NAME}/output_dir', self.output_dir_line_edit().text())
|
|
187
|
+
self.settings().set(f'{PANEL_NAME}/overwrite', self.overwrite_checkbox().isChecked())
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from PySide6.QtWidgets import (
|
|
2
|
+
QTextEdit,
|
|
3
|
+
)
|
|
4
|
+
from mosamatic2.ui.widgets.panels.defaultpanel import DefaultPanel
|
|
5
|
+
from mosamatic2.core.managers.logmanager import LogManager
|
|
6
|
+
|
|
7
|
+
LOG = LogManager()
|
|
8
|
+
|
|
9
|
+
PANEL_TITLE = 'SettingsPanel'
|
|
10
|
+
PANEL_NAME = 'settingspanel'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SettingsPanel(DefaultPanel):
|
|
14
|
+
def __init__(self):
|
|
15
|
+
super(SettingsPanel, self).__init__()
|
|
16
|
+
self.set_title(PANEL_TITLE)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from PySide6.QtWidgets import QStackedWidget
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class StackedPanel(QStackedWidget):
|
|
5
|
+
def __init__(self):
|
|
6
|
+
super(StackedPanel, self).__init__()
|
|
7
|
+
self._current_panel_name = None
|
|
8
|
+
self._panels = {}
|
|
9
|
+
|
|
10
|
+
def add_panel(self, panel, name):
|
|
11
|
+
if name not in self._panels.keys():
|
|
12
|
+
self._panels[name] = panel
|
|
13
|
+
self._current_panel_name = name
|
|
14
|
+
self.addWidget(panel)
|
|
15
|
+
|
|
16
|
+
def current_panel_name(self):
|
|
17
|
+
return self._current_panel_name
|
|
18
|
+
|
|
19
|
+
def switch_to(self, name):
|
|
20
|
+
panel = self._panels[name]
|
|
21
|
+
self._current_panel_name = name
|
|
22
|
+
self.setCurrentWidget(panel)
|
|
File without changes
|