Skip to content

Commit 19135f2

Browse files
Merge pull request #8 from SarthakJariwala/development
Merging all new updates
2 parents 78a86c6 + 4baa92f commit 19135f2

30 files changed

+3252
-1543
lines changed

PythonGUI_apps/DataBrowser.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
from PLQE_analysis import plqe_analysis
2020
from H5_Pkl import h5_pkl_view, h5_view_and_plot
2121
from Image_analysis import Image_analysis
22+
from Table import Table_widget
23+
from Export_Windows import Multi_Trace_Exporter
24+
2225
pg.mkQApp()
2326
#pg.setConfigOption('background', 'w')
2427

@@ -38,7 +41,8 @@ def __init__(self):
3841
self.ui = WindowTemplate()
3942
self.ui.setupUi(self)
4043
self.ui.select_comboBox.addItems(["Lifetime Analysis", "Spectrum Analysis", "FLIM Analysis",
41-
"UV-Vis Analysis", "PLQE Analysis", "H5 View/Plot", "H5/PKL Viewer", "Image Analysis"])
44+
"UV-Vis Analysis", "PLQE Analysis", "H5 View/Plot", "H5/PKL Viewer", "Image Analysis", "Table View",
45+
"Mulit-Trace Exporter"])
4246
self.ui.load_pushButton.clicked.connect(self.load_app)
4347

4448
self.show()
@@ -72,7 +76,12 @@ def load_app(self):
7276
elif analysis_software == "Image Analysis":
7377
self.image_window = Image_analysis.MainWindow()
7478
self.image_window.show()
75-
79+
elif analysis_software == "Table View":
80+
self.table_widget = Table_widget.MainWindow()
81+
self.table_widget.show()
82+
elif analysis_software == "Mulit-Trace Exporter":
83+
self.trace_exporter = Multi_Trace_Exporter.MainWindow()
84+
self.trace_exporter.show()
7685

7786

7887
def run():

PythonGUI_apps/DataBrowser.spec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# -*- mode: python -*-
1+
# -*- mode: python ; coding: utf-8 -*-
22

33
block_cipher = None
44

55

6-
a = Analysis(['C:\\Users\\lindat18\\Dropbox\\Ginger_Lab\\Data_Analysis\\PythonGUI_apps\\DataBrowser.py'],
7-
pathex=['C:\\Users\\lindat18\\Dropbox\\Ginger_Lab\\Data_Analysis\\PythonGUI_apps'],
6+
a = Analysis(['DataBrowser.py'],
7+
pathex=['E:\\QT_projects\\Python_GUI_apps\\PythonGUI_apps'],
88
binaries=[],
99
datas=[],
1010
hiddenimports=['ipykernel.datapub'],
@@ -33,4 +33,5 @@ coll = COLLECT(exe,
3333
a.datas,
3434
strip=False,
3535
upx=True,
36+
upx_exclude=[],
3637
name='DataBrowser')
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Sun Nov 3 20:43:12 2019
4+
5+
@author: sarth
6+
"""
7+
from pathlib import Path
8+
import pyqtgraph as pg
9+
from pyqtgraph.Qt import QtCore, QtGui
10+
11+
"""Export Images GUI"""
12+
base_path = Path(__file__).parent
13+
ui_file_path = (base_path / "export_fig_gui.ui").resolve()
14+
exportFig_WindowTemplate, exportFig_TemplateBaseClass = pg.Qt.loadUiType(ui_file_path)
15+
16+
class ExportFigureWindow(exportFig_TemplateBaseClass):
17+
18+
export_fig_signal = QtCore.pyqtSignal()
19+
20+
def __init__(self):
21+
exportFig_TemplateBaseClass.__init__(self)
22+
23+
self.ui = exportFig_WindowTemplate()
24+
self.ui.setupUi(self)
25+
self.ui.cmap_comboBox.addItems(['viridis', 'plasma', 'inferno', 'magma',
26+
'cividis','Greys', 'Purples', 'Blues',
27+
'Greens', 'Oranges', 'Reds', 'YlOrBr',
28+
'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu',
29+
'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn',
30+
'YlGn', 'binary', 'gist_yarg', 'gist_gray',
31+
'gray', 'bone', 'pink', 'spring', 'summer',
32+
'autumn', 'winter', 'cool', 'Wistia', 'hot',
33+
'afmhot', 'gist_heat', 'copper', 'rainbow', 'jet'])
34+
self.ui.cbar_checkBox.stateChanged.connect(self.cbar_title_state)
35+
self.ui.exportFig_pushButton.clicked.connect(self.export)
36+
self.show()
37+
38+
def cbar_title_state(self):
39+
if self.ui.cbar_checkBox.isChecked():
40+
self.ui.cbar_label.setEnabled(True)
41+
else:
42+
self.ui.cbar_label.setEnabled(False)
43+
44+
def export(self):
45+
self.export_fig_signal.emit()
46+
self.close()
47+
48+
"""Export plot GUI"""
49+
ui_file_path = (base_path / "export_plot.ui").resolve()
50+
export_WindowTemplate, export_TemplateBaseClass = pg.Qt.loadUiType(ui_file_path)
51+
52+
class ExportPlotWindow(export_TemplateBaseClass):
53+
54+
export_fig_signal = QtCore.pyqtSignal()
55+
56+
def __init__(self):
57+
export_TemplateBaseClass.__init__(self)
58+
59+
self.ui = export_WindowTemplate()
60+
self.ui.setupUi(self)
61+
#self.ui.traceColor_comboBox.addItems(["C0","C1","C2","C3","C4","C5","C6","C7", "r", "g", "b", "y", "k"])
62+
#self.ui.fitColor_comboBox.addItems(["k", "r", "b", "y", "g","C0","C1","C2","C3","C4","C5","C6","C7"])
63+
self.ui.export_pushButton.clicked.connect(self.export)
64+
#self.ui.legend_checkBox.stateChanged.connect(self.legend_title)
65+
self.show()
66+
67+
#def legend_title(self):
68+
# if self.ui.legend_checkBox.isChecked():
69+
# self.ui.legend1_lineEdit.setEnabled(True)
70+
# self.ui.legend2_lineEdit.setEnabled(True)
71+
# else:
72+
# self.ui.legend1_lineEdit.setEnabled(False)
73+
# self.ui.legend2_lineEdit.setEnabled(False)
74+
75+
def export(self):
76+
self.export_fig_signal.emit()
77+
self.close()
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import pyqtgraph as pg
2+
from pathlib import Path
3+
from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
4+
try:
5+
from Lifetime_analysis.read_ph_phd import read_picoharp_phd, get_x_y
6+
except Exception as e:
7+
print(e)
8+
import matplotlib.pyplot as plt
9+
10+
"""Recylce params for plotting"""
11+
plt.rc('xtick', labelsize = 20)
12+
plt.rc('xtick.major', pad = 3)
13+
plt.rc('ytick', labelsize = 20)
14+
plt.rc('lines', lw = 2.5, markersize = 7.5)
15+
plt.rc('legend', fontsize = 20)
16+
plt.rc('axes', linewidth=3.5)
17+
18+
pg.mkQApp()
19+
20+
base_path = Path(__file__).parent
21+
file_path = (base_path / "Multi_Trace_Exporter.ui").resolve()
22+
23+
uiFile = file_path
24+
25+
WindowTemplate, TemplateBaseClass = pg.Qt.loadUiType(uiFile)
26+
27+
class MainWindow(TemplateBaseClass):
28+
29+
def __init__(self):
30+
super(TemplateBaseClass, self).__init__()
31+
32+
# Create the main window
33+
self.ui = WindowTemplate()
34+
self.ui.setupUi(self)
35+
36+
self.temp_layout = pg.GraphicsLayoutWidget()
37+
38+
# file system tree
39+
self.fs_model = QtWidgets.QFileSystemModel()
40+
self.fs_model.setRootPath(QtCore.QDir.currentPath())
41+
self.ui.treeView.setModel(self.fs_model)
42+
self.ui.treeView.setIconSize(QtCore.QSize(25,25))
43+
self.ui.treeView.setSortingEnabled(True)
44+
45+
self.tree_selectionModel = self.ui.treeView.selectionModel()
46+
self.tree_selectionModel.selectionChanged.connect(self.on_treeview_selection_change)
47+
48+
self.ui.comboBox.currentIndexChanged.connect(self.add_trace_to_temp_plot)
49+
self.ui.add_pushButton.clicked.connect(self.add_trace_to_mem)
50+
self.ui.export_pushButton.clicked.connect(self.pub_ready_plot_export)
51+
52+
self.x_i = []
53+
self.y_i = []
54+
self.x_mem = []
55+
self.y_mem = []
56+
self.legend = []
57+
58+
self.show()
59+
60+
def on_treeview_selection_change(self):
61+
try:
62+
fname = self.fs_model.filePath(self.tree_selectionModel.currentIndex())
63+
_ , ext = fname.rsplit('.',1)
64+
65+
self.ui.comboBox.clear()
66+
self.ui.textBrowser.clear()
67+
self.x_i = []
68+
self.y_i = []
69+
70+
if ext in ['phd']:
71+
self.parser = read_picoharp_phd(fname)
72+
curve_list = []
73+
74+
for i in range(self.parser.no_of_curves()):
75+
curve_list.append("Curve "+str(i))
76+
x, y = get_x_y(i, self.parser, smooth_trace=self.ui.smooth_checkBox.isChecked(), boxwidth=self.ui.smooth_spinBox.value())
77+
self.x_i.append(x)
78+
self.y_i.append(y)
79+
80+
self.ui.comboBox.addItems(curve_list)
81+
self.ui.textBrowser.setText(str(self.parser.info()))
82+
83+
else:
84+
self.ui.textBrowser.setText(str("Select a PicoHarp File"))
85+
except Exception as e:
86+
print(e)
87+
88+
def add_trace_to_temp_plot(self):
89+
try:
90+
#self.temp_layout = pg.GraphicsLayoutWidget()
91+
self.temp_layout.clear()
92+
self.temp_plot = self.temp_layout.addPlot(title = "Current Selection")
93+
self.temp_plot.plot(self.x_i[self.ui.comboBox.currentIndex()], self.y_i[self.ui.comboBox.currentIndex()], pen='r')
94+
self.temp_plot.setLogMode(False, True)
95+
self.temp_layout.show()
96+
except Exception as e:
97+
print(e)
98+
99+
def add_trace_to_mem(self):
100+
try:
101+
self.x_mem.append(self.x_i[self.ui.comboBox.currentIndex()])
102+
self.y_mem.append(self.y_i[self.ui.comboBox.currentIndex()])
103+
self.legend.append(self.ui.lineEdit.text())
104+
except Exception as e:
105+
print(e)
106+
107+
def pub_ready_plot_export(self):
108+
try:
109+
filename = QtWidgets.QFileDialog.getSaveFileName(self,caption="Filename with EXTENSION")
110+
111+
plt.figure(figsize=(8,6))
112+
plt.tick_params(direction='out', length=8, width=3.5)
113+
for i in range(len(self.x_mem)):
114+
if self.ui.Normalize_checkBox.isChecked():
115+
plt.plot(self.x_mem[i], self.y_mem[i]/max(self.y_mem[i]), label=str(self.legend[i]))
116+
else:
117+
plt.plot(self.x_mem[i], self.y_mem[i], label=str(self.legend[i]))
118+
119+
plt.yscale('log')
120+
plt.xlabel("Time (ns)", fontsize=20, fontweight='bold')
121+
plt.ylabel("Intensity (norm.)", fontsize=20, fontweight='bold')
122+
plt.legend()
123+
plt.tight_layout()
124+
125+
plt.savefig(filename[0],bbox_inches='tight', dpi=300)
126+
plt.close()
127+
128+
self.clear_memory()
129+
130+
except Exception as e:
131+
print(e)
132+
pass
133+
134+
def clear_memory(self):
135+
self.x_mem = []
136+
self.y_mem = []
137+
self.legend = []
138+
139+
140+
141+
142+
def run():
143+
win = MainWindow()
144+
QtGui.QApplication.instance().exec_()
145+
return win
146+
147+
#run()
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>MainWindow</class>
4+
<widget class="QMainWindow" name="MainWindow">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>1108</width>
10+
<height>1063</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>MainWindow</string>
15+
</property>
16+
<widget class="QWidget" name="centralwidget">
17+
<layout class="QGridLayout" name="gridLayout">
18+
<item row="0" column="0">
19+
<widget class="QComboBox" name="comboBox"/>
20+
</item>
21+
<item row="1" column="0">
22+
<widget class="QCheckBox" name="smooth_checkBox">
23+
<property name="text">
24+
<string>Smoothen Trace</string>
25+
</property>
26+
</widget>
27+
</item>
28+
<item row="0" column="2">
29+
<widget class="QLineEdit" name="lineEdit">
30+
<property name="text">
31+
<string>Enter Trace Legend Here</string>
32+
</property>
33+
</widget>
34+
</item>
35+
<item row="1" column="2">
36+
<widget class="QPushButton" name="add_pushButton">
37+
<property name="text">
38+
<string>Add</string>
39+
</property>
40+
</widget>
41+
</item>
42+
<item row="2" column="0">
43+
<widget class="QCheckBox" name="Normalize_checkBox">
44+
<property name="text">
45+
<string>Normalize (for export)</string>
46+
</property>
47+
</widget>
48+
</item>
49+
<item row="1" column="1">
50+
<widget class="QSpinBox" name="smooth_spinBox">
51+
<property name="minimum">
52+
<number>1</number>
53+
</property>
54+
</widget>
55+
</item>
56+
<item row="2" column="2">
57+
<widget class="QPushButton" name="export_pushButton">
58+
<property name="text">
59+
<string>Export</string>
60+
</property>
61+
</widget>
62+
</item>
63+
<item row="3" column="2">
64+
<widget class="QTextBrowser" name="textBrowser"/>
65+
</item>
66+
<item row="3" column="0">
67+
<widget class="QTreeView" name="treeView"/>
68+
</item>
69+
</layout>
70+
</widget>
71+
<widget class="QMenuBar" name="menubar">
72+
<property name="geometry">
73+
<rect>
74+
<x>0</x>
75+
<y>0</y>
76+
<width>1108</width>
77+
<height>38</height>
78+
</rect>
79+
</property>
80+
</widget>
81+
<widget class="QStatusBar" name="statusbar"/>
82+
</widget>
83+
<resources/>
84+
<connections/>
85+
</ui>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# -*- coding: utf-8 -*-

0 commit comments

Comments
 (0)