Skip to content

Commit

Permalink
Merge pull request #8 from SarthakJariwala/development
Browse files Browse the repository at this point in the history
Merging all new updates
  • Loading branch information
SarthakJariwala authored Mar 17, 2020
2 parents 78a86c6 + 4baa92f commit 19135f2
Show file tree
Hide file tree
Showing 30 changed files with 3,252 additions and 1,543 deletions.
13 changes: 11 additions & 2 deletions PythonGUI_apps/DataBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from PLQE_analysis import plqe_analysis
from H5_Pkl import h5_pkl_view, h5_view_and_plot
from Image_analysis import Image_analysis
from Table import Table_widget
from Export_Windows import Multi_Trace_Exporter

pg.mkQApp()
#pg.setConfigOption('background', 'w')

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

self.show()
Expand Down Expand Up @@ -72,7 +76,12 @@ def load_app(self):
elif analysis_software == "Image Analysis":
self.image_window = Image_analysis.MainWindow()
self.image_window.show()

elif analysis_software == "Table View":
self.table_widget = Table_widget.MainWindow()
self.table_widget.show()
elif analysis_software == "Mulit-Trace Exporter":
self.trace_exporter = Multi_Trace_Exporter.MainWindow()
self.trace_exporter.show()


def run():
Expand Down
7 changes: 4 additions & 3 deletions PythonGUI_apps/DataBrowser.spec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- mode: python -*-
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['C:\\Users\\lindat18\\Dropbox\\Ginger_Lab\\Data_Analysis\\PythonGUI_apps\\DataBrowser.py'],
pathex=['C:\\Users\\lindat18\\Dropbox\\Ginger_Lab\\Data_Analysis\\PythonGUI_apps'],
a = Analysis(['DataBrowser.py'],
pathex=['E:\\QT_projects\\Python_GUI_apps\\PythonGUI_apps'],
binaries=[],
datas=[],
hiddenimports=['ipykernel.datapub'],
Expand Down Expand Up @@ -33,4 +33,5 @@ coll = COLLECT(exe,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='DataBrowser')
77 changes: 77 additions & 0 deletions PythonGUI_apps/Export_Windows/Export_window.py
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()
147 changes: 147 additions & 0 deletions PythonGUI_apps/Export_Windows/Multi_Trace_Exporter.py
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()
85 changes: 85 additions & 0 deletions PythonGUI_apps/Export_Windows/Multi_Trace_Exporter.ui
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>
1 change: 1 addition & 0 deletions PythonGUI_apps/Export_Windows/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
Loading

0 comments on commit 19135f2

Please sign in to comment.