|
|
|
@ -1,5 +1,7 @@
@@ -1,5 +1,7 @@
|
|
|
|
|
import sys |
|
|
|
|
import json |
|
|
|
|
import os |
|
|
|
|
import sys |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from pathlib import Path |
|
|
|
|
from subprocess import Popen |
|
|
|
@ -23,6 +25,7 @@ from .workflows import (
@@ -23,6 +25,7 @@ from .workflows import (
|
|
|
|
|
postprocessing_workflow, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
PARAMETERS_FILE = "mia-gui-parameters.json" |
|
|
|
|
|
|
|
|
|
class MtorImageAnalysis(QWidget): |
|
|
|
|
def __init__(self): |
|
|
|
@ -85,6 +88,17 @@ class MtorImageAnalysis(QWidget):
@@ -85,6 +88,17 @@ class MtorImageAnalysis(QWidget):
|
|
|
|
|
self.btn_exit = QPushButton("Exit", self) |
|
|
|
|
self.btn_exit.clicked.connect(QApplication.instance().quit) |
|
|
|
|
|
|
|
|
|
self.fields_map = { |
|
|
|
|
'folder': (self.dir_selected, str), |
|
|
|
|
'top': (self.roi_top_input, int), |
|
|
|
|
'right': (self.roi_right_input, int), |
|
|
|
|
'bottom': (self.roi_bottom_input, int), |
|
|
|
|
'left': (self.roi_left_input, int), |
|
|
|
|
'cut_pad_x': (self.pad_x_input, int), |
|
|
|
|
'cut_pad_y': (self.pad_y_input, int), |
|
|
|
|
'boost': (self.cc_boost_input, int), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# Layout |
|
|
|
|
grid = QGridLayout() |
|
|
|
|
grid.setSpacing(10) |
|
|
|
@ -155,6 +169,16 @@ class MtorImageAnalysis(QWidget):
@@ -155,6 +169,16 @@ class MtorImageAnalysis(QWidget):
|
|
|
|
|
self.check_button_state() |
|
|
|
|
else: |
|
|
|
|
self.dir_selected.setText(filenames[0]) |
|
|
|
|
parameter_path = folder / PARAMETERS_FILE |
|
|
|
|
if parameter_path.is_file(): |
|
|
|
|
try: |
|
|
|
|
with parameter_path.open("r") as fh: |
|
|
|
|
parameters = json.load(fh) |
|
|
|
|
for key, value in parameters.items(): |
|
|
|
|
field = self.fields_map[key][0] |
|
|
|
|
field.setText(str(value)) |
|
|
|
|
except Exception: |
|
|
|
|
pass |
|
|
|
|
self.check_button_state() |
|
|
|
|
|
|
|
|
|
def check_button_state(self): |
|
|
|
@ -162,19 +186,9 @@ class MtorImageAnalysis(QWidget):
@@ -162,19 +186,9 @@ class MtorImageAnalysis(QWidget):
|
|
|
|
|
self.btn_run.setEnabled(all(parameters.values())) |
|
|
|
|
|
|
|
|
|
def get_parameters(self): |
|
|
|
|
fields = { |
|
|
|
|
'folder': (self.dir_selected, str), |
|
|
|
|
'top': (self.roi_top_input, int), |
|
|
|
|
'right': (self.roi_right_input, int), |
|
|
|
|
'bottom': (self.roi_bottom_input, int), |
|
|
|
|
'left': (self.roi_left_input, int), |
|
|
|
|
'cut_pad_x': (self.pad_x_input, int), |
|
|
|
|
'cut_pad_y': (self.pad_y_input, int), |
|
|
|
|
'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 |
|
|
|
|
parameters = {key: None for key in self.fields_map} |
|
|
|
|
for key, field_and_func in self.fields_map.items(): |
|
|
|
|
field, func = field_and_func |
|
|
|
|
raw_data = field.text().strip() |
|
|
|
|
if raw_data: |
|
|
|
|
if func is int: |
|
|
|
@ -186,6 +200,15 @@ class MtorImageAnalysis(QWidget):
@@ -186,6 +200,15 @@ class MtorImageAnalysis(QWidget):
|
|
|
|
|
def run_analysis(self): |
|
|
|
|
parameters = self.get_parameters() |
|
|
|
|
if all(parameters.values()): |
|
|
|
|
parameter_path = Path(parameters["folder"]) / PARAMETERS_FILE |
|
|
|
|
try: |
|
|
|
|
with parameter_path.open("w") as fh: |
|
|
|
|
tmp = {k: v for k, v in parameters.items() if k != "folder"} |
|
|
|
|
print(tmp) |
|
|
|
|
json.dump(tmp, fh) |
|
|
|
|
except Exception: |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
self.analysis_parameters = parameters |
|
|
|
|
self.hide() |
|
|
|
|
QApplication.instance().quit() |
|
|
|
|