1010import time
1111from lmfit .models import GaussianModel
1212import customplotting .mscope as cpm
13+
14+ sys .path .append (os .path .abspath ('../Lifetime_analysis' ))
15+ sys .path .append (os .path .abspath ('../Spectrum_analysis' ))
16+ from Lifetime_analysis import Lifetime_plot_fit
17+ from Spectrum_analysis import Spectra_plot_fit
1318# local modules
1419
1520pg .mkQApp ()
2429WindowTemplate , TemplateBaseClass = pg .Qt .loadUiType (uiFile )
2530
2631class MainWindow (TemplateBaseClass ):
27-
32+
33+ hist_data_signal = QtCore .pyqtSignal ()
34+
2835 def __init__ (self ):
2936 super (TemplateBaseClass , self ).__init__ ()
3037
@@ -42,6 +49,8 @@ def __init__(self):
4249 self .ui .intensity_sums_viewBox .roi .sigRegionChanged .connect (self .line_profile_update_plot )
4350 self .ui .import_pkl_pushButton .clicked .connect (self .import_pkl_to_convert )
4451 self .ui .pkl_to_h5_pushButton .clicked .connect (self .pkl_to_h5 )
52+ self .ui .analyze_lifetime_pushButton .clicked .connect (self .on_analyze_lifetime )
53+ self .ui .analyze_spectrum_pushButton .clicked .connect (self .on_analyze_spectrum )
4554
4655 self .show ()
4756
@@ -130,6 +139,15 @@ def line_profile_update_plot(self):
130139 except :
131140 pass
132141
142+ def on_analyze_spectrum (self ):
143+ self .spectrum_window = Spectra_plot_fit .MainWindow ()
144+ self .spectrum_window .show ()
145+ self .spectrum_window .opened_from_flim = True
146+ sum_data = self .ui .intensity_sums_viewBox .getRoiPlot ().getPlotItem ().curves [0 ].getData ()
147+ self .spectrum_window .sum_data_from_flim = np .asarray (sum_data )
148+ self .spectrum_window .ui .plot_without_bck_radioButton .setChecked (True )
149+ self .spectrum_window .ui .result_textBrowser .setText ("Data successfully loaded from FLIM analysis." )
150+
133151 def plot_raw_scan (self ):
134152 try :
135153 self .hist_image = np .reshape (self .hist_data , newshape = (self .hist_data .shape [0 ],self .numb_x_pixels ,self .numb_y_pixels ))
@@ -191,10 +209,25 @@ def update_roi2_plot(self):
191209 # Average data within entire ROI for each frame
192210 data = data .mean (axis = max (axes )).mean (axis = min (axes ))
193211 xvals = self .ui .raw_hist_data_viewBox .tVals
194- if hasattr (self , "roi2_plot" ):
212+ if hasattr (self , "roi2_plot" ): #make sure second plot is properly cleared everytime
195213 self .roi2_plot .clear ()
214+ c = self .ui .raw_hist_data_viewBox .getRoiPlot ().getPlotItem ().curves .pop ()
215+ c .scene ().removeItem (c )
196216 self .roi2_plot = self .ui .raw_hist_data_viewBox .getRoiPlot ().plot (xvals , data , pen = 'r' )
197217
218+ def get_raw_hist_curve (self , curve_index ):
219+ #curve_index = 0 for original roi
220+ #curve_index = 1 for second comparison roi
221+ curves = self .ui .raw_hist_data_viewBox .getRoiPlot ().getPlotItem ().curves
222+ return curves [curve_index ].getData ()
223+
224+ def on_analyze_lifetime (self ):
225+ self .lifetime_window = Lifetime_plot_fit .MainWindow ()
226+ self .lifetime_window .show ()
227+ self .lifetime_window .opened_from_flim = True
228+ self .lifetime_window .hist_data_from_flim = np .asarray (self .get_raw_hist_curve (0 ))
229+ self .lifetime_window .ui .Result_textBrowser .setText ("Data successfully loaded from FLIM analysis." )
230+
198231 def save_intensities_image (self ):
199232 try :
200233 folder = os .path .dirname (self .filename [0 ])
0 commit comments