mirror of
https://github.com/Athemis/PyDSF.git
synced 2025-07-03 10:41:07 +00:00
First implementation of parameter dependency analysis
in additions, averaging over rows was added
This commit is contained in:
parent
455f715e37
commit
b8c67a13ed
6 changed files with 4357 additions and 136 deletions
3905
ui/Ui_mainwindow.py
3905
ui/Ui_mainwindow.py
File diff suppressed because it is too large
Load diff
|
@ -57,6 +57,15 @@ class Worker(QRunnable):
|
|||
files = []
|
||||
for item in items:
|
||||
files.append(item.text())
|
||||
|
||||
replicates = self.owner.groupBox_replicates.isChecked()
|
||||
row_replicates = self.owner.radioButton_rep_rows.isChecked()
|
||||
|
||||
if replicates and row_replicates:
|
||||
average_rows = self.owner.spinBox_avg_rows.value()
|
||||
else:
|
||||
average_rows = None
|
||||
|
||||
self.exp = Experiment(instrument=self.owner.instrument,
|
||||
files=files,
|
||||
t1=self.owner.doubleSpinBox_tmin.value(),
|
||||
|
@ -67,7 +76,9 @@ class Worker(QRunnable):
|
|||
cutoff_low=c_lower,
|
||||
cutoff_high=c_upper,
|
||||
signal_threshold=signal_threshold,
|
||||
color_range=cbar_range)
|
||||
color_range=cbar_range,
|
||||
concentrations=self.owner.concentrations,
|
||||
average_rows=average_rows)
|
||||
self.exp.analyze()
|
||||
self.signals.finished.emit()
|
||||
|
||||
|
@ -77,7 +88,6 @@ class TaskSignals(QObject):
|
|||
|
||||
|
||||
class Tasks(QObject):
|
||||
|
||||
def __init__(self):
|
||||
super(Tasks, self).__init__()
|
||||
|
||||
|
@ -116,7 +126,6 @@ class Tasks(QObject):
|
|||
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
"""
|
||||
Class documentation goes here.
|
||||
"""
|
||||
|
@ -141,10 +150,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
QDialogButtonBox.AcceptRole)
|
||||
self.tasks = Tasks()
|
||||
self.tasks.signals.finished.connect(self.on_processing_finished)
|
||||
self.lineEdit_conc.textChanged.connect(
|
||||
self.on_lineEdit_conc_textChanged)
|
||||
self.worker = None
|
||||
self.outputPath = None
|
||||
self.instrument = None
|
||||
self.concentrations = None
|
||||
self.populateInstrumentList()
|
||||
self.instrument = self.getSelectedInstrument()
|
||||
|
||||
def populateInstrumentList(self):
|
||||
self.instruments = [AnalytikJenaqTower2()]
|
||||
|
@ -152,6 +164,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
instrument = self.instruments[i]
|
||||
self.comboBox_instrument.setItemText(i, instrument.name)
|
||||
|
||||
@pyqtSlot()
|
||||
def getInstrumentFromName(self, name):
|
||||
for instrument in self.instruments:
|
||||
if instrument.name == name:
|
||||
|
@ -178,7 +191,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.groupBox_replicates.setChecked(True)
|
||||
self.radioButton_rep_files.setEnabled(True)
|
||||
elif button == self.buttonBox_open_reset.button(
|
||||
QDialogButtonBox.Reset):
|
||||
QDialogButtonBox.Reset):
|
||||
self.listWidget_data.clear()
|
||||
|
||||
@pyqtSlot("QAbstractButton*")
|
||||
|
@ -202,8 +215,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
else:
|
||||
self.groupBox_temp.setEnabled(True)
|
||||
|
||||
def generate_plot_tab(self, name):
|
||||
tab = MplWidget(parent=self.tabWidget)
|
||||
def generate_plot_tab(self, name, mouse_event=False):
|
||||
if mouse_event:
|
||||
tab = MplWidget(parent=self.tabWidget, mouse_event=True)
|
||||
else:
|
||||
tab = MplWidget(parent=self.tabWidget)
|
||||
tab.setObjectName(name)
|
||||
return tab
|
||||
|
||||
|
@ -220,7 +236,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
plotter = PlotResults()
|
||||
|
||||
if plate.id != 'average':
|
||||
tab = self.generate_plot_tab("tab_heatmap_{}".format(plate.id))
|
||||
tab = self.generate_plot_tab("tab_heatmap_{}".format(plate.id),
|
||||
mouse_event=True)
|
||||
title = _translate("MainWindow", "Heatmap #")
|
||||
self.tabWidget.addTab(tab, title + str(plate.id))
|
||||
plotter.plot_tm_heatmap_single(plate, tab)
|
||||
|
@ -243,8 +260,26 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
if self.checkBox_saveplots.isChecked():
|
||||
tab.canvas.save(
|
||||
"{}/derivatives_{}.svg".format(self.outputPath, plate.id))
|
||||
|
||||
if self.groupBox_conc.isChecked():
|
||||
tab = self.generate_plot_tab("tab_derivative_{}".format(
|
||||
plate.id))
|
||||
title = _translate("MainWindow", "Parameter Dependency #")
|
||||
self.tabWidget.addTab(tab, title + str(plate.id))
|
||||
if self.lineEdit_par_label.text():
|
||||
par_label = self.lineEdit_par_label.text()
|
||||
plotter.plot_concentration_dependency(
|
||||
plate,
|
||||
tab,
|
||||
parameter_label=par_label)
|
||||
else:
|
||||
plotter.plot_concentration_dependency(plate, tab)
|
||||
if self.checkBox_saveplots.isChecked():
|
||||
tab.canvas.save(
|
||||
"{}/para_{}.svg".format(self.outputPath, plate.id))
|
||||
else:
|
||||
tab = self.generate_plot_tab("tab_heatmap_{}".format(plate.id))
|
||||
tab = self.generate_plot_tab("tab_heatmap_{}".format(plate.id),
|
||||
mouse_event=True)
|
||||
title = _translate("MainWindow", "Heatmap ")
|
||||
self.tabWidget.addTab(tab, title + str(plate.id))
|
||||
plotter.plot_tm_heatmap_single(plate, tab)
|
||||
|
@ -252,6 +287,26 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
tab.canvas.save(
|
||||
"{}/heatmap_{}.svg".format(self.outputPath, plate.id))
|
||||
|
||||
if self.groupBox_conc.isChecked():
|
||||
tab = self.generate_plot_tab("tab_derivative_{}".format(
|
||||
plate.id))
|
||||
title = _translate("MainWindow", "Parameter Dependency #")
|
||||
self.tabWidget.addTab(tab, title + str(plate.id))
|
||||
if self.lineEdit_par_label.text():
|
||||
par_label = self.lineEdit_par_label.text()
|
||||
plotter.plot_concentration_dependency(
|
||||
plate,
|
||||
tab,
|
||||
parameter_label=par_label,
|
||||
error_bars=True)
|
||||
else:
|
||||
plotter.plot_concentration_dependency(plate,
|
||||
tab,
|
||||
error_bars=True)
|
||||
if self.checkBox_saveplots.isChecked():
|
||||
tab.canvas.save(
|
||||
"{}/para_{}.svg".format(self.outputPath, plate.id))
|
||||
|
||||
@pyqtSlot()
|
||||
def on_buttonBox_process_accepted(self):
|
||||
"""
|
||||
|
@ -267,8 +322,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
_translate("MainWindow", "No data file loaded!"),
|
||||
QMessageBox.Close, QMessageBox.Close)
|
||||
return
|
||||
if self.groupBox_conc.isChecked():
|
||||
self.concentrations = self.lineEdit_conc.text().split(',')
|
||||
if (self.groupBox_output.isChecked() and
|
||||
self.lineEdit_output.text().strip() == ''):
|
||||
self.lineEdit_output.text().strip() == ''):
|
||||
QMessageBox.critical(
|
||||
self, _translate("MainWindow", "Error"),
|
||||
_translate("MainWindow", "No output path set!"),
|
||||
|
@ -323,8 +380,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
if self.checkBox_savetables.isChecked():
|
||||
for plate in exp.plates:
|
||||
plate.write_tm_table(
|
||||
'{}/plate_{}_tm.csv'.format(self.outputPath,
|
||||
str(plate.id)))
|
||||
'{}/plate_{}_tm.csv'.format(self.outputPath, str(
|
||||
plate.id)))
|
||||
plate.write_data_table(
|
||||
'{}/plate_{}_dI_dT.csv'.format(self.outputPath,
|
||||
str(plate.id)),
|
||||
|
@ -380,10 +437,25 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
dialog.ui.setupUi(dialog)
|
||||
dialog.exec_()
|
||||
|
||||
|
||||
@pyqtSlot()
|
||||
def on_actionAbout_Qt_triggered(self):
|
||||
"""
|
||||
Slot documentation goes here.
|
||||
"""
|
||||
QApplication.aboutQt()
|
||||
|
||||
@pyqtSlot()
|
||||
def on_lineEdit_conc_textChanged(self):
|
||||
"""
|
||||
Slot documentation goes here.
|
||||
"""
|
||||
num_conc = len(self.lineEdit_conc.text().split(','))
|
||||
self.spinBox_num_conc.setValue(num_conc)
|
||||
if self.comboBox_direction.currentIndex() == 0:
|
||||
max_wells = self.instrument.wells_horizontal
|
||||
else:
|
||||
max_wells = self.instrument.wells_vertical
|
||||
if num_conc > max_wells:
|
||||
self.spinBox_num_conc.setStyleSheet("QSpinBox { color : red; }")
|
||||
else:
|
||||
self.spinBox_num_conc.setStyleSheet("QSpinBox { color : black; }")
|
||||
|
|
134
ui/mainwindow.ui
134
ui/mainwindow.ui
|
@ -79,7 +79,7 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_instrument">
|
||||
<property name="text">
|
||||
<string>Instrument</string>
|
||||
<string>I&nstrument</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboBox_instrument</cstring>
|
||||
|
@ -150,6 +150,13 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_rep_rows">
|
||||
<property name="text">
|
||||
<string>Rows</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="radioButton_rep_files">
|
||||
<property name="enabled">
|
||||
|
@ -163,6 +170,23 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="spinBox_avg_rows">
|
||||
<property name="minimum">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_rows">
|
||||
<property name="text">
|
||||
<string>Rows to average</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -465,7 +489,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_output">
|
||||
<property name="title">
|
||||
<string>Sa&ve processing results</string>
|
||||
|
@ -477,14 +501,14 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_saveplots">
|
||||
<property name="text">
|
||||
<string>Save plots</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox_output">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
|
@ -500,14 +524,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLineEdit" name="lineEdit_output">
|
||||
<property name="toolTip">
|
||||
<string>Output results to this path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_savetables">
|
||||
<property name="text">
|
||||
<string>Save tabular results</string>
|
||||
|
@ -517,6 +541,102 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_conc">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Parameter Dependency</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_direction">
|
||||
<property name="text">
|
||||
<string>Direction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBox_direction">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_conc">
|
||||
<property name="text">
|
||||
<string>Parameter Values</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_conc">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Comma-seperated list of concentrations. This has to match the number of wells in either horizontal or vertical dimension. If a well is unused, either leave blank or use &quot;NaN&quot; as input.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_conc_num">
|
||||
<property name="text">
|
||||
<string>Number of wells</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_num_conc">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Displays the number of wells specified above.</p></body></html></string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_par">
|
||||
<property name="text">
|
||||
<string>Parameter Label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_par_label">
|
||||
<property name="placeholderText">
|
||||
<string>Parameter [au]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -601,7 +721,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>4095</width>
|
||||
<height>28</height>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="locale">
|
||||
|
|
|
@ -19,12 +19,6 @@ class MplCanvas(FigureCanvas):
|
|||
QtWidgets.QSizePolicy.Expanding)
|
||||
FigureCanvas.updateGeometry(self)
|
||||
|
||||
# override mouseMoveEvent with non-functional dummy
|
||||
# this will prevent the gui thread to hang while moving the mouse
|
||||
# while a large number of plots is shown simultaniously
|
||||
def mouseMoveEvent(self, event):
|
||||
pass
|
||||
|
||||
def clear(self):
|
||||
self.ax.clear()
|
||||
self.fig.clear()
|
||||
|
@ -40,6 +34,16 @@ class MplCanvas(FigureCanvas):
|
|||
QtWidgets.QMessageBox.Close, QtWidgets.QMessageBox.Close)
|
||||
|
||||
|
||||
class MplCanvasNoMouse(MplCanvas):
|
||||
|
||||
# override mouseMoveEvent with non-functional dummy
|
||||
# this will prevent the gui thread to hang while moving the mouse
|
||||
# while a large number of plots is shown simultaniously
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
pass
|
||||
|
||||
|
||||
class CustomNavigationToolbar(NavigationToolbar):
|
||||
|
||||
toolitems = (
|
||||
|
@ -60,9 +64,12 @@ class CustomNavigationToolbar(NavigationToolbar):
|
|||
|
||||
class MplWidget(QtWidgets.QGraphicsView):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, parent=None, mouse_event=False):
|
||||
QtWidgets.QGraphicsView.__init__(self, parent)
|
||||
self.canvas = MplCanvas()
|
||||
if mouse_event:
|
||||
self.canvas = MplCanvas()
|
||||
else:
|
||||
self.canvas = MplCanvasNoMouse()
|
||||
self.ntb = CustomNavigationToolbar(self.canvas, self,
|
||||
coordinates=False)
|
||||
self.vbl = QtWidgets.QVBoxLayout()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue