Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit f2d6d5a

Browse files
author
LAKESIDE\LindaT18
committed
flim line roi, lifetime spinbox, h5 view/plot x axis
1 parent 15c45fd commit f2d6d5a

6 files changed

Lines changed: 114 additions & 61 deletions

File tree

PythonGUI_apps/FLIM_analysis/FLIM_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def plot_intensity_sums(self):
6969
self.ui.intensity_sums_viewBox.setImage(self.intensity_sums, scale=
7070
(data['Scan Parameters']['X step size (um)'],
7171
data['Scan Parameters']['Y step size (um)']))
72-
self.ui.intensity_sums_viewBox.roi.setSize([self.x_scan_size, self.y_scan_size])
72+
self.ui.intensity_sums_viewBox.roi.setSize([self.x_scan_size, self.y_step_size]) #line roi
7373
scale = pg.ScaleBar(size=1,suffix='um')
7474
scale.setParentItem(self.ui.intensity_sums_viewBox.view)
7575
scale.anchor((1, 1), (1, 1), offset=(-30, -30))

PythonGUI_apps/H5_Pkl/h5_pkl_view_gui.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<item>
5959
<widget class="QLabel" name="dataview_placeholder">
6060
<property name="text">
61-
<string>Once a valid file is loaded, data will show up here.</string>
61+
<string>Once a file is loaded, data will show up here.</string>
6262
</property>
6363
</widget>
6464
</item>

PythonGUI_apps/H5_Pkl/h5_view_and_plot.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,20 @@ def plot_dataset(self):
8585

8686
data = self.dataset[()]
8787
if self.dataset_shape == 1:
88-
x_values = np.arange(self.dataset.shape[0]) * self.ui.plotWidget_x_scaling_factor_spinBox.value() #scale x axis
88+
x_start = self.ui.plotWidget_x_start_spinBox.value()
89+
x_end = self.ui.plotWidget_x_end_spinBox.value()
90+
num_points = self.dataset.shape[0]
91+
x_values = np.linspace(x_start, x_end, num_points)
8992
self.plot.plot(x_values, data)
9093
elif self.dataset_shape == 2 and self.ui.plot_radioButton.isChecked():
9194
self.plot.plot(data[0], data[1]) # TODO check and test this
9295
elif self.dataset_shape == 2 and self.ui.image_radioButton.isChecked():
9396
self.data_img.setImage(data)
9497
elif self.dataset_shape == 3:
95-
x_values = np.arange(self.dataset.shape[0]) * self.ui.imageView_x_scaling_spinBox.value() #scale x axis
98+
x_start = self.ui.imageView_x_start_spinBox.value()
99+
x_end = self.ui.imageView_x_end_spinBox.value()
100+
num_points = self.dataset.shape[0]
101+
x_values = np.linspace(x_start, x_end, num_points) #scale x axis
96102
self.ui.data_imageView.setImage(data, xvals=x_values)
97103

98104
def on_data_selection(self):

PythonGUI_apps/H5_Pkl/h5_view_and_plot_gui.ui

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,32 +93,49 @@
9393
<item row="1" column="0" colspan="2">
9494
<widget class="QStackedWidget" name="data_stackedWidget">
9595
<property name="currentIndex">
96-
<number>0</number>
96+
<number>2</number>
9797
</property>
9898
<widget class="QWidget" name="dataplot_page">
9999
<layout class="QGridLayout" name="gridLayout_6">
100100
<item row="0" column="0">
101101
<widget class="PlotWidget" name="data_plotWidget"/>
102102
</item>
103103
<item row="1" column="0">
104-
<layout class="QFormLayout" name="formLayout_3">
104+
<layout class="QGridLayout" name="gridLayout">
105+
<item row="0" column="2">
106+
<widget class="QLabel" name="label_4">
107+
<property name="text">
108+
<string>X end</string>
109+
</property>
110+
</widget>
111+
</item>
105112
<item row="0" column="0">
106113
<widget class="QLabel" name="label_3">
107114
<property name="text">
108-
<string>X-axis scaling factor</string>
115+
<string>X start</string>
109116
</property>
110117
</widget>
111118
</item>
112119
<item row="0" column="1">
113-
<widget class="QDoubleSpinBox" name="plotWidget_x_scaling_factor_spinBox">
120+
<widget class="QDoubleSpinBox" name="plotWidget_x_start_spinBox">
114121
<property name="maximumSize">
115122
<size>
116123
<width>203</width>
117124
<height>16777215</height>
118125
</size>
119126
</property>
127+
<property name="maximum">
128+
<double>9999999.000000000000000</double>
129+
</property>
120130
<property name="value">
121-
<double>1.000000000000000</double>
131+
<double>0.000000000000000</double>
132+
</property>
133+
</widget>
134+
</item>
135+
<item row="0" column="3">
136+
<widget class="QDoubleSpinBox" name="plotWidget_x_end_spinBox">
137+
<property name="maximum">
138+
<double>9999999.000000000000000</double>
122139
</property>
123140
</widget>
124141
</item>
@@ -134,25 +151,42 @@
134151
<item row="0" column="0" colspan="2">
135152
<widget class="ImageView" name="data_imageView"/>
136153
</item>
137-
<item row="1" column="0">
138-
<layout class="QFormLayout" name="formLayout">
154+
<item row="1" column="0" colspan="2">
155+
<layout class="QGridLayout" name="gridLayout_9">
156+
<item row="0" column="2">
157+
<widget class="QLabel" name="label_5">
158+
<property name="text">
159+
<string>X end</string>
160+
</property>
161+
</widget>
162+
</item>
139163
<item row="0" column="0">
140164
<widget class="QLabel" name="label">
141165
<property name="text">
142-
<string>X-axis scaling factor</string>
166+
<string>X start</string>
143167
</property>
144168
</widget>
145169
</item>
146170
<item row="0" column="1">
147-
<widget class="QDoubleSpinBox" name="imageView_x_scaling_spinBox">
171+
<widget class="QDoubleSpinBox" name="imageView_x_start_spinBox">
148172
<property name="maximumSize">
149173
<size>
150174
<width>203</width>
151175
<height>16777215</height>
152176
</size>
153177
</property>
178+
<property name="maximum">
179+
<double>9999999.000000000000000</double>
180+
</property>
154181
<property name="value">
155-
<double>1.000000000000000</double>
182+
<double>0.000000000000000</double>
183+
</property>
184+
</widget>
185+
</item>
186+
<item row="0" column="3">
187+
<widget class="QDoubleSpinBox" name="imageView_x_end_spinBox">
188+
<property name="maximum">
189+
<double>9999999.000000000000000</double>
156190
</property>
157191
</widget>
158192
</item>

PythonGUI_apps/Lifetime_analysis/Lifetime_analysis_gui_layout.ui

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -916,96 +916,110 @@
916916
<bool>false</bool>
917917
</property>
918918
<layout class="QGridLayout" name="gridLayout_11">
919-
<item row="0" column="0">
919+
<item row="1" column="0">
920920
<widget class="QLabel" name="label_37">
921921
<property name="text">
922922
<string>Bulk Lifetime (ns)</string>
923923
</property>
924924
</widget>
925925
</item>
926-
<item row="1" column="0">
926+
<item row="2" column="0">
927927
<widget class="QLabel" name="label_38">
928928
<property name="text">
929929
<string>Thickness (nm)</string>
930930
</property>
931931
</widget>
932932
</item>
933-
<item row="0" column="1">
934-
<widget class="QDoubleSpinBox" name="bulk_lifetime_spinBox">
933+
<item row="2" column="1">
934+
<widget class="QDoubleSpinBox" name="thickness_spinBox">
935935
<property name="maximum">
936936
<double>100000.000000000000000</double>
937937
</property>
938938
<property name="value">
939-
<double>8000.000000000000000</double>
939+
<double>250.000000000000000</double>
940940
</property>
941941
</widget>
942942
</item>
943-
<item row="1" column="1">
944-
<widget class="QDoubleSpinBox" name="thickness_spinBox">
943+
<item row="3" column="1">
944+
<widget class="QDoubleSpinBox" name="diffusion_coefficient_spinBox">
945945
<property name="maximum">
946-
<double>100000.000000000000000</double>
946+
<double>1000000.000000000000000</double>
947947
</property>
948948
<property name="value">
949-
<double>250.000000000000000</double>
949+
<double>3.000000000000000</double>
950950
</property>
951951
</widget>
952952
</item>
953-
<item row="5" column="0">
953+
<item row="5" column="1">
954+
<widget class="QLabel" name="surface_lifetime_label">
955+
<property name="text">
956+
<string>0</string>
957+
</property>
958+
</widget>
959+
</item>
960+
<item row="6" column="0">
954961
<widget class="QLabel" name="label_42">
955962
<property name="text">
956963
<string>SRV (cm/s)</string>
957964
</property>
958965
</widget>
959966
</item>
960-
<item row="2" column="0">
967+
<item row="3" column="0">
961968
<widget class="QLabel" name="label_39">
962969
<property name="text">
963970
<string>Diffusion Coefficient (cm2/s)</string>
964971
</property>
965972
</widget>
966973
</item>
967-
<item row="2" column="1">
968-
<widget class="QDoubleSpinBox" name="diffusion_coefficient_spinBox">
974+
<item row="4" column="0">
975+
<widget class="QCheckBox" name="srv1_srv2_checkBox">
976+
<property name="text">
977+
<string>SRV1 = SRV2</string>
978+
</property>
979+
</widget>
980+
</item>
981+
<item row="7" column="0">
982+
<widget class="QPushButton" name="calculate_srv_pushButton">
983+
<property name="text">
984+
<string>Calculate</string>
985+
</property>
986+
</widget>
987+
</item>
988+
<item row="1" column="1">
989+
<widget class="QDoubleSpinBox" name="bulk_lifetime_spinBox">
969990
<property name="maximum">
970-
<double>1000000.000000000000000</double>
991+
<double>100000.000000000000000</double>
971992
</property>
972993
<property name="value">
973-
<double>3.000000000000000</double>
994+
<double>8000.000000000000000</double>
974995
</property>
975996
</widget>
976997
</item>
977-
<item row="4" column="0">
998+
<item row="5" column="0">
978999
<widget class="QLabel" name="label_40">
9791000
<property name="text">
9801001
<string>Surface Lifetime (ns)</string>
9811002
</property>
9821003
</widget>
9831004
</item>
984-
<item row="5" column="1">
1005+
<item row="6" column="1">
9851006
<widget class="QLabel" name="srv_label">
9861007
<property name="text">
9871008
<string>0</string>
9881009
</property>
9891010
</widget>
9901011
</item>
991-
<item row="4" column="1">
992-
<widget class="QLabel" name="surface_lifetime_label">
993-
<property name="text">
994-
<string>0</string>
995-
</property>
996-
</widget>
997-
</item>
998-
<item row="3" column="0">
999-
<widget class="QCheckBox" name="srv1_srv2_checkBox">
1012+
<item row="0" column="0">
1013+
<widget class="QLabel" name="label_45">
10001014
<property name="text">
1001-
<string>SRV1 = SRV2</string>
1015+
<string>Average Lifetime (ns)</string>
10021016
</property>
10031017
</widget>
10041018
</item>
1005-
<item row="6" column="0">
1006-
<widget class="QPushButton" name="calculate_srv_pushButton">
1007-
<property name="text">
1008-
<string>Calculate</string>
1019+
<item row="0" column="1">
1020+
<widget class="QDoubleSpinBox" name="average_lifetime_spinBox">
1021+
<property name="maximum">
1022+
<double>9999999.000000000000000</double>
10091023
</property>
10101024
</widget>
10111025
</item>
@@ -1243,7 +1257,7 @@ Ready Figure!</string>
12431257
<x>0</x>
12441258
<y>0</y>
12451259
<width>1985</width>
1246-
<height>21</height>
1260+
<height>31</height>
12471261
</rect>
12481262
</property>
12491263
<widget class="QMenu" name="menuFile">
@@ -1286,7 +1300,7 @@ Ready Figure!</string>
12861300
<customwidget>
12871301
<class>PlotWidget</class>
12881302
<extends>QGraphicsView</extends>
1289-
<header>pyqtgraph</header>
1303+
<header location="global">pyqtgraph</header>
12901304
</customwidget>
12911305
</customwidgets>
12921306
<resources/>

PythonGUI_apps/Lifetime_analysis/Lifetime_plot_fit.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ def fit_and_plot_with_irf(self):
313313
"\nbeta = %.5f"
314314
"\ntau_c = %.5f ns"
315315
"\na = %.5f \nnoise = %.5f counts" %(t_avg, bestfit_params[1], bestfit_params[0], bestfit_params[2], bestfit_params[3]))
316-
self.effective_lifetime = t_avg
316+
#self.effective_lifetime = t_avg
317+
self.ui.average_lifetime_spinBox.setValue(t_avg)
317318

318319
elif fit_func == "Double Exponential": #double exponential tab
319320
a1_bounds = (self.ui.de_a1_min_spinBox.value(), self.ui.de_a1_max_spinBox.value())
@@ -380,24 +381,22 @@ def call_fit_and_plot(self):
380381
self.fit_and_plot()
381382

382383
def calculate_surface_lifetime(self):
384+
effective_lifetime = self.ui.average_lifetime_spinBox.value()
383385
self.bulk_lifetime = self.ui.bulk_lifetime_spinBox.value() # in ns
384-
self.surface_lifetime = (self.effective_lifetime * self.bulk_lifetime)/(self.bulk_lifetime - self.effective_lifetime)
386+
self.surface_lifetime = (effective_lifetime * self.bulk_lifetime)/(self.bulk_lifetime - effective_lifetime)
385387
self.ui.surface_lifetime_label.setText(str(self.surface_lifetime))
386388

387389
def calculate_srv (self):
388-
if not hasattr(self, "effective_lifetime"):
389-
self.ui.Result_textBrowser.setText("No Tau_c value exists. Plot stretched exponential fit with IRF before calculating SRV.")
390+
self.calculate_surface_lifetime()
391+
self.thickness = self.ui.thickness_spinBox.value()*1e-7 # convert to cm
392+
self.diffusion_coeffecient = self.ui.diffusion_coefficient_spinBox.value() # in cm2/s
393+
394+
if self.ui.srv1_srv2_checkBox.isChecked():
395+
self.srv = self.thickness / (2*((1e-9*self.surface_lifetime) - ((1/self.diffusion_coeffecient)*((self.thickness/np.pi)**2)) ))
390396
else:
391-
self.calculate_surface_lifetime()
392-
self.thickness = self.ui.thickness_spinBox.value()*1e-7 # convert to cm
393-
self.diffusion_coeffecient = self.ui.diffusion_coefficient_spinBox.value() # in cm2/s
394-
395-
if self.ui.srv1_srv2_checkBox.isChecked():
396-
self.srv = self.thickness / (2*((1e-9*self.surface_lifetime) - ((1/self.diffusion_coeffecient)*((self.thickness/np.pi)**2)) ))
397-
else:
398-
self.srv = self.thickness / ((1e-9*self.surface_lifetime) - ((4/self.diffusion_coeffecient)*((self.thickness/np.pi)**2)) )
399-
400-
self.ui.srv_label.setText(str(self.srv))
397+
self.srv = self.thickness / ((1e-9*self.surface_lifetime) - ((4/self.diffusion_coeffecient)*((self.thickness/np.pi)**2)) )
398+
399+
self.ui.srv_label.setText(str(self.srv))
401400

402401
def pub_ready_plot_export(self):
403402
try:

0 commit comments

Comments
 (0)