|
|
@ -61,6 +61,22 @@ class MtorImageAnalysis(QWidget): |
|
|
|
self.roi_bottom_input.setValidator(QIntValidator()) |
|
|
|
self.roi_bottom_input.setValidator(QIntValidator()) |
|
|
|
self.roi_bottom_input.textChanged.connect(self.check_button_state) |
|
|
|
self.roi_bottom_input.textChanged.connect(self.check_button_state) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# aditional parameters |
|
|
|
|
|
|
|
self.pad_x_label = QLabel("Roi padding on x axis") |
|
|
|
|
|
|
|
self.pad_x_input = QLineEdit() |
|
|
|
|
|
|
|
self.pad_x_input.setValidator(QIntValidator()) |
|
|
|
|
|
|
|
self.pad_x_input.textChanged.connect(self.check_button_state) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.pad_y_label = QLabel("Roi padding on y axis") |
|
|
|
|
|
|
|
self.pad_y_input = QLineEdit() |
|
|
|
|
|
|
|
self.pad_y_input.setValidator(QIntValidator()) |
|
|
|
|
|
|
|
self.pad_y_input.textChanged.connect(self.check_button_state) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.cc_boost_label = QLabel("Intensity factor for colored images") |
|
|
|
|
|
|
|
self.cc_boost_input = QLineEdit() |
|
|
|
|
|
|
|
self.cc_boost_input.setValidator(QIntValidator()) |
|
|
|
|
|
|
|
self.cc_boost_input.textChanged.connect(self.check_button_state) |
|
|
|
|
|
|
|
|
|
|
|
# action buttons |
|
|
|
# action buttons |
|
|
|
self.btn_run = QPushButton("Run", self) |
|
|
|
self.btn_run = QPushButton("Run", self) |
|
|
|
self.btn_run.setEnabled(False) |
|
|
|
self.btn_run.setEnabled(False) |
|
|
@ -94,8 +110,22 @@ class MtorImageAnalysis(QWidget): |
|
|
|
|
|
|
|
|
|
|
|
grid.addWidget(QLabel(), 8, 0, 1, 2) |
|
|
|
grid.addWidget(QLabel(), 8, 0, 1, 2) |
|
|
|
|
|
|
|
|
|
|
|
grid.addWidget(self.btn_exit, 9, 0) |
|
|
|
grid.addWidget(self.pad_x_label, 9, 0) |
|
|
|
grid.addWidget(self.btn_run, 9, 1) |
|
|
|
grid.addWidget(self.pad_x_input, 9, 1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grid.addWidget(self.pad_y_label, 10, 0) |
|
|
|
|
|
|
|
grid.addWidget(self.pad_y_input, 10, 1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grid.addWidget(self.cc_boost_label, 11, 0) |
|
|
|
|
|
|
|
grid.addWidget(self.cc_boost_input, 11, 1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grid.addWidget(self.btn_exit, 12, 0) |
|
|
|
|
|
|
|
grid.addWidget(self.btn_run, 12, 1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# set default values |
|
|
|
|
|
|
|
self.pad_x_input.setText("50") |
|
|
|
|
|
|
|
self.pad_y_input.setText("25") |
|
|
|
|
|
|
|
self.cc_boost_input.setText("5") |
|
|
|
|
|
|
|
|
|
|
|
self.setLayout(grid) |
|
|
|
self.setLayout(grid) |
|
|
|
# self.resize(350, 300) |
|
|
|
# self.resize(350, 300) |
|
|
@ -128,35 +158,37 @@ class MtorImageAnalysis(QWidget): |
|
|
|
self.check_button_state() |
|
|
|
self.check_button_state() |
|
|
|
|
|
|
|
|
|
|
|
def check_button_state(self): |
|
|
|
def check_button_state(self): |
|
|
|
values = self.get_values() |
|
|
|
parameters = self.get_parameters() |
|
|
|
self.btn_run.setEnabled(all(values)) |
|
|
|
self.btn_run.setEnabled(all(parameters.values())) |
|
|
|
|
|
|
|
|
|
|
|
def get_values(self): |
|
|
|
def get_parameters(self): |
|
|
|
fields = [ |
|
|
|
fields = { |
|
|
|
(self.dir_selected, str), |
|
|
|
'folder': (self.dir_selected, str), |
|
|
|
(self.roi_top_input, int), |
|
|
|
'top': (self.roi_top_input, int), |
|
|
|
(self.roi_right_input, int), |
|
|
|
'right': (self.roi_right_input, int), |
|
|
|
(self.roi_bottom_input, int), |
|
|
|
'bottom': (self.roi_bottom_input, int), |
|
|
|
(self.roi_left_input, int), |
|
|
|
'left': (self.roi_left_input, int), |
|
|
|
] |
|
|
|
'cut_pad_x': (self.pad_x_input, int), |
|
|
|
result = [] |
|
|
|
'cut_pad_y': (self.pad_y_input, int), |
|
|
|
for field, func in fields: |
|
|
|
'boost': (self.cc_boost_input, int), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
parameters = {key: None for key in fields} |
|
|
|
|
|
|
|
for key, name_and_func in fields.items(): |
|
|
|
|
|
|
|
field, func = name_and_func |
|
|
|
raw_data = field.text().strip() |
|
|
|
raw_data = field.text().strip() |
|
|
|
if raw_data: |
|
|
|
if raw_data: |
|
|
|
if func is int: |
|
|
|
if func is int: |
|
|
|
# in qt5, a point as 1000 separator is allowed |
|
|
|
# in qt5, a point as 1000 separator is allowed |
|
|
|
raw_data = raw_data.replace(".", "") |
|
|
|
raw_data = raw_data.replace(".", "") |
|
|
|
result.append(func(raw_data)) |
|
|
|
parameters[key] = func(raw_data) |
|
|
|
else: |
|
|
|
return parameters |
|
|
|
result.append(None) |
|
|
|
|
|
|
|
return tuple(result) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_analysis(self): |
|
|
|
def run_analysis(self): |
|
|
|
parameters = self.get_values() |
|
|
|
parameters = self.get_parameters() |
|
|
|
if all(parameters): |
|
|
|
if all(parameters.values()): |
|
|
|
self.analysis_parameters = parameters |
|
|
|
self.analysis_parameters = parameters |
|
|
|
self.hide() |
|
|
|
self.hide() |
|
|
|
QApplication.instance().quit() |
|
|
|
QApplication.instance().quit() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_gui(): |
|
|
|
def run_gui(): |
|
|
@ -165,8 +197,7 @@ def run_gui(): |
|
|
|
app.exec_() |
|
|
|
app.exec_() |
|
|
|
|
|
|
|
|
|
|
|
if mia.analysis_parameters is not None: |
|
|
|
if mia.analysis_parameters is not None: |
|
|
|
analysis_parameters = tuple((p for p in mia.analysis_parameters)) |
|
|
|
pw = prescan_workflow(**mia.analysis_parameters) |
|
|
|
pw = prescan_workflow(*analysis_parameters) |
|
|
|
|
|
|
|
iw = image_workflow(pw.parameters) |
|
|
|
iw = image_workflow(pw.parameters) |
|
|
|
dw = data_workflow(iw.data, iw.parameters) |
|
|
|
dw = data_workflow(iw.data, iw.parameters) |
|
|
|
fw = postprocessing_workflow(dw.data, dw.parameters) |
|
|
|
fw = postprocessing_workflow(dw.data, dw.parameters) |
|
|
|