-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from SarthakJariwala/development
Merging all new updates
- Loading branch information
Showing
30 changed files
with
3,252 additions
and
1,543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sun Nov 3 20:43:12 2019 | ||
@author: sarth | ||
""" | ||
from pathlib import Path | ||
import pyqtgraph as pg | ||
from pyqtgraph.Qt import QtCore, QtGui | ||
|
||
"""Export Images GUI""" | ||
base_path = Path(__file__).parent | ||
ui_file_path = (base_path / "export_fig_gui.ui").resolve() | ||
exportFig_WindowTemplate, exportFig_TemplateBaseClass = pg.Qt.loadUiType(ui_file_path) | ||
|
||
class ExportFigureWindow(exportFig_TemplateBaseClass): | ||
|
||
export_fig_signal = QtCore.pyqtSignal() | ||
|
||
def __init__(self): | ||
exportFig_TemplateBaseClass.__init__(self) | ||
|
||
self.ui = exportFig_WindowTemplate() | ||
self.ui.setupUi(self) | ||
self.ui.cmap_comboBox.addItems(['viridis', 'plasma', 'inferno', 'magma', | ||
'cividis','Greys', 'Purples', 'Blues', | ||
'Greens', 'Oranges', 'Reds', 'YlOrBr', | ||
'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu', | ||
'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', | ||
'YlGn', 'binary', 'gist_yarg', 'gist_gray', | ||
'gray', 'bone', 'pink', 'spring', 'summer', | ||
'autumn', 'winter', 'cool', 'Wistia', 'hot', | ||
'afmhot', 'gist_heat', 'copper', 'rainbow', 'jet']) | ||
self.ui.cbar_checkBox.stateChanged.connect(self.cbar_title_state) | ||
self.ui.exportFig_pushButton.clicked.connect(self.export) | ||
self.show() | ||
|
||
def cbar_title_state(self): | ||
if self.ui.cbar_checkBox.isChecked(): | ||
self.ui.cbar_label.setEnabled(True) | ||
else: | ||
self.ui.cbar_label.setEnabled(False) | ||
|
||
def export(self): | ||
self.export_fig_signal.emit() | ||
self.close() | ||
|
||
"""Export plot GUI""" | ||
ui_file_path = (base_path / "export_plot.ui").resolve() | ||
export_WindowTemplate, export_TemplateBaseClass = pg.Qt.loadUiType(ui_file_path) | ||
|
||
class ExportPlotWindow(export_TemplateBaseClass): | ||
|
||
export_fig_signal = QtCore.pyqtSignal() | ||
|
||
def __init__(self): | ||
export_TemplateBaseClass.__init__(self) | ||
|
||
self.ui = export_WindowTemplate() | ||
self.ui.setupUi(self) | ||
#self.ui.traceColor_comboBox.addItems(["C0","C1","C2","C3","C4","C5","C6","C7", "r", "g", "b", "y", "k"]) | ||
#self.ui.fitColor_comboBox.addItems(["k", "r", "b", "y", "g","C0","C1","C2","C3","C4","C5","C6","C7"]) | ||
self.ui.export_pushButton.clicked.connect(self.export) | ||
#self.ui.legend_checkBox.stateChanged.connect(self.legend_title) | ||
self.show() | ||
|
||
#def legend_title(self): | ||
# if self.ui.legend_checkBox.isChecked(): | ||
# self.ui.legend1_lineEdit.setEnabled(True) | ||
# self.ui.legend2_lineEdit.setEnabled(True) | ||
# else: | ||
# self.ui.legend1_lineEdit.setEnabled(False) | ||
# self.ui.legend2_lineEdit.setEnabled(False) | ||
|
||
def export(self): | ||
self.export_fig_signal.emit() | ||
self.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import pyqtgraph as pg | ||
from pathlib import Path | ||
from pyqtgraph.Qt import QtCore, QtGui, QtWidgets | ||
try: | ||
from Lifetime_analysis.read_ph_phd import read_picoharp_phd, get_x_y | ||
except Exception as e: | ||
print(e) | ||
import matplotlib.pyplot as plt | ||
|
||
"""Recylce params for plotting""" | ||
plt.rc('xtick', labelsize = 20) | ||
plt.rc('xtick.major', pad = 3) | ||
plt.rc('ytick', labelsize = 20) | ||
plt.rc('lines', lw = 2.5, markersize = 7.5) | ||
plt.rc('legend', fontsize = 20) | ||
plt.rc('axes', linewidth=3.5) | ||
|
||
pg.mkQApp() | ||
|
||
base_path = Path(__file__).parent | ||
file_path = (base_path / "Multi_Trace_Exporter.ui").resolve() | ||
|
||
uiFile = file_path | ||
|
||
WindowTemplate, TemplateBaseClass = pg.Qt.loadUiType(uiFile) | ||
|
||
class MainWindow(TemplateBaseClass): | ||
|
||
def __init__(self): | ||
super(TemplateBaseClass, self).__init__() | ||
|
||
# Create the main window | ||
self.ui = WindowTemplate() | ||
self.ui.setupUi(self) | ||
|
||
self.temp_layout = pg.GraphicsLayoutWidget() | ||
|
||
# file system tree | ||
self.fs_model = QtWidgets.QFileSystemModel() | ||
self.fs_model.setRootPath(QtCore.QDir.currentPath()) | ||
self.ui.treeView.setModel(self.fs_model) | ||
self.ui.treeView.setIconSize(QtCore.QSize(25,25)) | ||
self.ui.treeView.setSortingEnabled(True) | ||
|
||
self.tree_selectionModel = self.ui.treeView.selectionModel() | ||
self.tree_selectionModel.selectionChanged.connect(self.on_treeview_selection_change) | ||
|
||
self.ui.comboBox.currentIndexChanged.connect(self.add_trace_to_temp_plot) | ||
self.ui.add_pushButton.clicked.connect(self.add_trace_to_mem) | ||
self.ui.export_pushButton.clicked.connect(self.pub_ready_plot_export) | ||
|
||
self.x_i = [] | ||
self.y_i = [] | ||
self.x_mem = [] | ||
self.y_mem = [] | ||
self.legend = [] | ||
|
||
self.show() | ||
|
||
def on_treeview_selection_change(self): | ||
try: | ||
fname = self.fs_model.filePath(self.tree_selectionModel.currentIndex()) | ||
_ , ext = fname.rsplit('.',1) | ||
|
||
self.ui.comboBox.clear() | ||
self.ui.textBrowser.clear() | ||
self.x_i = [] | ||
self.y_i = [] | ||
|
||
if ext in ['phd']: | ||
self.parser = read_picoharp_phd(fname) | ||
curve_list = [] | ||
|
||
for i in range(self.parser.no_of_curves()): | ||
curve_list.append("Curve "+str(i)) | ||
x, y = get_x_y(i, self.parser, smooth_trace=self.ui.smooth_checkBox.isChecked(), boxwidth=self.ui.smooth_spinBox.value()) | ||
self.x_i.append(x) | ||
self.y_i.append(y) | ||
|
||
self.ui.comboBox.addItems(curve_list) | ||
self.ui.textBrowser.setText(str(self.parser.info())) | ||
|
||
else: | ||
self.ui.textBrowser.setText(str("Select a PicoHarp File")) | ||
except Exception as e: | ||
print(e) | ||
|
||
def add_trace_to_temp_plot(self): | ||
try: | ||
#self.temp_layout = pg.GraphicsLayoutWidget() | ||
self.temp_layout.clear() | ||
self.temp_plot = self.temp_layout.addPlot(title = "Current Selection") | ||
self.temp_plot.plot(self.x_i[self.ui.comboBox.currentIndex()], self.y_i[self.ui.comboBox.currentIndex()], pen='r') | ||
self.temp_plot.setLogMode(False, True) | ||
self.temp_layout.show() | ||
except Exception as e: | ||
print(e) | ||
|
||
def add_trace_to_mem(self): | ||
try: | ||
self.x_mem.append(self.x_i[self.ui.comboBox.currentIndex()]) | ||
self.y_mem.append(self.y_i[self.ui.comboBox.currentIndex()]) | ||
self.legend.append(self.ui.lineEdit.text()) | ||
except Exception as e: | ||
print(e) | ||
|
||
def pub_ready_plot_export(self): | ||
try: | ||
filename = QtWidgets.QFileDialog.getSaveFileName(self,caption="Filename with EXTENSION") | ||
|
||
plt.figure(figsize=(8,6)) | ||
plt.tick_params(direction='out', length=8, width=3.5) | ||
for i in range(len(self.x_mem)): | ||
if self.ui.Normalize_checkBox.isChecked(): | ||
plt.plot(self.x_mem[i], self.y_mem[i]/max(self.y_mem[i]), label=str(self.legend[i])) | ||
else: | ||
plt.plot(self.x_mem[i], self.y_mem[i], label=str(self.legend[i])) | ||
|
||
plt.yscale('log') | ||
plt.xlabel("Time (ns)", fontsize=20, fontweight='bold') | ||
plt.ylabel("Intensity (norm.)", fontsize=20, fontweight='bold') | ||
plt.legend() | ||
plt.tight_layout() | ||
|
||
plt.savefig(filename[0],bbox_inches='tight', dpi=300) | ||
plt.close() | ||
|
||
self.clear_memory() | ||
|
||
except Exception as e: | ||
print(e) | ||
pass | ||
|
||
def clear_memory(self): | ||
self.x_mem = [] | ||
self.y_mem = [] | ||
self.legend = [] | ||
|
||
|
||
|
||
|
||
def run(): | ||
win = MainWindow() | ||
QtGui.QApplication.instance().exec_() | ||
return win | ||
|
||
#run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>MainWindow</class> | ||
<widget class="QMainWindow" name="MainWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>1108</width> | ||
<height>1063</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>MainWindow</string> | ||
</property> | ||
<widget class="QWidget" name="centralwidget"> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<item row="0" column="0"> | ||
<widget class="QComboBox" name="comboBox"/> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QCheckBox" name="smooth_checkBox"> | ||
<property name="text"> | ||
<string>Smoothen Trace</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="2"> | ||
<widget class="QLineEdit" name="lineEdit"> | ||
<property name="text"> | ||
<string>Enter Trace Legend Here</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="2"> | ||
<widget class="QPushButton" name="add_pushButton"> | ||
<property name="text"> | ||
<string>Add</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="0"> | ||
<widget class="QCheckBox" name="Normalize_checkBox"> | ||
<property name="text"> | ||
<string>Normalize (for export)</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QSpinBox" name="smooth_spinBox"> | ||
<property name="minimum"> | ||
<number>1</number> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="2"> | ||
<widget class="QPushButton" name="export_pushButton"> | ||
<property name="text"> | ||
<string>Export</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="2"> | ||
<widget class="QTextBrowser" name="textBrowser"/> | ||
</item> | ||
<item row="3" column="0"> | ||
<widget class="QTreeView" name="treeView"/> | ||
</item> | ||
</layout> | ||
</widget> | ||
<widget class="QMenuBar" name="menubar"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>1108</width> | ||
<height>38</height> | ||
</rect> | ||
</property> | ||
</widget> | ||
<widget class="QStatusBar" name="statusbar"/> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# -*- coding: utf-8 -*- |
Oops, something went wrong.