|
|
@ -1,22 +1,18 @@ |
|
|
|
|
|
|
|
import sys |
|
|
|
|
|
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
from pathlib import Path |
|
|
|
from pathlib import Path |
|
|
|
from subprocess import Popen |
|
|
|
from subprocess import Popen |
|
|
|
home = Path.home() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import sys |
|
|
|
|
|
|
|
import os |
|
|
|
|
|
|
|
from PyQt5.QtWidgets import ( |
|
|
|
from PyQt5.QtWidgets import ( |
|
|
|
QApplication, |
|
|
|
QApplication, |
|
|
|
QMainWindow, |
|
|
|
|
|
|
|
QPushButton, |
|
|
|
|
|
|
|
QDesktopWidget, |
|
|
|
QDesktopWidget, |
|
|
|
QHBoxLayout, |
|
|
|
QFileDialog, |
|
|
|
QVBoxLayout, |
|
|
|
QGridLayout, |
|
|
|
QWidget, |
|
|
|
|
|
|
|
QLabel, |
|
|
|
QLabel, |
|
|
|
QLineEdit, |
|
|
|
QLineEdit, |
|
|
|
QGridLayout, |
|
|
|
QPushButton, |
|
|
|
QFileDialog, |
|
|
|
QWidget, |
|
|
|
) |
|
|
|
) |
|
|
|
from PyQt5.QtGui import QIcon, QIntValidator |
|
|
|
from PyQt5.QtGui import QIcon, QIntValidator |
|
|
|
|
|
|
|
|
|
|
@ -24,7 +20,6 @@ from .workflows import ( |
|
|
|
prescan_workflow, |
|
|
|
prescan_workflow, |
|
|
|
image_workflow, |
|
|
|
image_workflow, |
|
|
|
data_workflow, |
|
|
|
data_workflow, |
|
|
|
cached_data_workflow, |
|
|
|
|
|
|
|
postprocessing_workflow, |
|
|
|
postprocessing_workflow, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -103,18 +98,11 @@ class MtorImageAnalysis(QWidget): |
|
|
|
grid.addWidget(self.btn_run, 9, 1) |
|
|
|
grid.addWidget(self.btn_run, 9, 1) |
|
|
|
|
|
|
|
|
|
|
|
self.setLayout(grid) |
|
|
|
self.setLayout(grid) |
|
|
|
#self.resize(350, 300) |
|
|
|
# self.resize(350, 300) |
|
|
|
self.center_window_on_desktop() |
|
|
|
self.center_window_on_desktop() |
|
|
|
self.setWindowTitle("mTor Image Analysis") |
|
|
|
self.setWindowTitle("mTor Image Analysis") |
|
|
|
self.setWindowIcon(QIcon("web.png")) |
|
|
|
self.setWindowIcon(QIcon("web.png")) |
|
|
|
|
|
|
|
|
|
|
|
# helpers |
|
|
|
|
|
|
|
self.dir_selected.setText("/Users/holgerfrey/Developer/mtor/mtor-bilder") |
|
|
|
|
|
|
|
self.roi_top_input.setText("50") |
|
|
|
|
|
|
|
self.roi_right_input.setText("875") |
|
|
|
|
|
|
|
self.roi_bottom_input.setText("300") |
|
|
|
|
|
|
|
self.roi_left_input.setText("725") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.show() |
|
|
|
self.show() |
|
|
|
|
|
|
|
|
|
|
|
def center_window_on_desktop(self): |
|
|
|
def center_window_on_desktop(self): |
|
|
@ -124,7 +112,7 @@ class MtorImageAnalysis(QWidget): |
|
|
|
self.move(fg.topLeft()) |
|
|
|
self.move(fg.topLeft()) |
|
|
|
|
|
|
|
|
|
|
|
def get_tif_dir(self): |
|
|
|
def get_tif_dir(self): |
|
|
|
dlg = QFileDialog(directory=str(home)) |
|
|
|
dlg = QFileDialog(directory=str(Path.home())) |
|
|
|
dlg.setFileMode(QFileDialog.Directory) |
|
|
|
dlg.setFileMode(QFileDialog.Directory) |
|
|
|
|
|
|
|
|
|
|
|
if dlg.exec_(): |
|
|
|
if dlg.exec_(): |
|
|
@ -139,7 +127,6 @@ class MtorImageAnalysis(QWidget): |
|
|
|
self.dir_selected.setText(filenames[0]) |
|
|
|
self.dir_selected.setText(filenames[0]) |
|
|
|
self.check_button_state() |
|
|
|
self.check_button_state() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_button_state(self): |
|
|
|
def check_button_state(self): |
|
|
|
values = self.get_values() |
|
|
|
values = self.get_values() |
|
|
|
self.btn_run.setEnabled(all(values)) |
|
|
|
self.btn_run.setEnabled(all(values)) |
|
|
@ -178,19 +165,26 @@ 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) ) |
|
|
|
analysis_parameters = tuple((p for p in mia.analysis_parameters)) |
|
|
|
pw = prescan_workflow(*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) |
|
|
|
pdf_path = dw.parameters.data_dir / "report.pdf" |
|
|
|
pdf_path = fw.parameters.data_dir / "report.pdf" |
|
|
|
if sys.platform.startswith("win"): |
|
|
|
if sys.platform.startswith("win"): |
|
|
|
os.startfile(str(pdf_path)) |
|
|
|
os.startfile(str(pdf_path)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
if sys.platform.startswith("darwin"): |
|
|
|
if sys.platform.startswith("darwin"): |
|
|
|
cmd = ["open", path] |
|
|
|
cmd = ["open", str(pdf_path)] |
|
|
|
else: |
|
|
|
else: |
|
|
|
cmd = ["xdg-open", path] |
|
|
|
cmd = ["xdg-open", str(pdf_path)] |
|
|
|
Popen(cmd, shell=False, stding=None, stdout=None, stderr=None, close_fds=True) |
|
|
|
Popen( |
|
|
|
|
|
|
|
cmd, |
|
|
|
|
|
|
|
shell=False, |
|
|
|
|
|
|
|
stding=None, |
|
|
|
|
|
|
|
stdout=None, |
|
|
|
|
|
|
|
stderr=None, |
|
|
|
|
|
|
|
close_fds=True, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
sys.exit() |
|
|
|
sys.exit() |
|
|
|