@@ -88,7 +88,7 @@ def __init__(self):
8888 # self.ui.config_fit_params_pushButton.clicked.connect(self.configure_fit_params)
8989 self .ui .clear_pushButton .clicked .connect (self .clear_plot )
9090 self .ui .export_single_figure_pushButton .clicked .connect (self .pub_ready_plot_export )
91- self .ui .export_scan_figure_pushButton .clicked .connect (self .pub_ready_plot_export )
91+ self .ui .export_scan_figure_pushButton .clicked .connect (self .export_window )
9292 self .ui .analyze_spectra_fits_pushButton .clicked .connect (self .analyze_spectra_fits )
9393
9494 self .ui .import_pkl_pushButton .clicked .connect (self .open_pkl_file )
@@ -495,6 +495,10 @@ def fit_and_plot(self):
495495
496496 except Exception as e :
497497 self .ui .result_textBrowser .append (str (e ))
498+
499+ def export_window (self ):
500+ self .export_window = ExportFigureWindow ()
501+ self .export_window .export_fig_signal .connect (self .pub_ready_plot_export )
498502
499503 def pub_ready_plot_export (self ):
500504 filename = QtWidgets .QFileDialog .getSaveFileName (self ,caption = "Filename with EXTENSION" )
@@ -511,10 +515,21 @@ def pub_ready_plot_export(self):
511515 data = self .spec_scan_file
512516 except :
513517 data = self .fit_scan_file
514- param_selection = str (self .ui .comboBox .currentText ())
515- if param_selection == 'pk_pos' : label = 'PL Peak Position (n.m.)'
516- elif param_selection == 'fwhm' : label = 'PL FWHM (n.m.)'
517- cpm .plot_confocal (self .img , figsize = (10 ,10 ), stepsize = data ['Scan Parameters' ]['X step size (um)' ], cmap = "seismic" , cbar_label = label )
518+ if self .export_window .ui .reverse_checkBox .isChecked ():
519+ colormap = str (self .export_window .ui .cmap_comboBox .currentText ())+ "_r"
520+ else :
521+ colormap = str (self .export_window .ui .cmap_comboBox .currentText ())
522+ if str (self .export_window .ui .dataChannel_comboBox .currentText ()) == "Fitted" :
523+ param_selection = str (self .ui .comboBox .currentText ())
524+ if param_selection == 'pk_pos' : label = 'PL Peak Position (n.m.)'
525+ elif param_selection == 'fwhm' : label = 'PL FWHM (n.m.)'
526+ cpm .plot_confocal (self .img , figsize = (10 ,10 ), stepsize = data ['Scan Parameters' ]['X step size (um)' ], cmap = colormap , cbar_label = label ,
527+ vmin = self .export_window .ui .vmin_spinBox .value (), vmax = self .export_window .ui .vmax_spinBox .value ())
528+ elif str (self .export_window .ui .dataChannel_comboBox .currentText ()) == "Raw" :
529+ cpm .plot_confocal (self .sums , figsize = (10 ,10 ), stepsize = data ['Scan Parameters' ]['X step size (um)' ], cmap = colormap ,
530+ vmin = self .export_window .ui .vmin_spinBox .value (), vmax = self .export_window .ui .vmax_spinBox .value ())
531+ plt .tick_params (direction = 'out' , length = 8 , width = 3.5 )
532+ plt .tight_layout ()
518533 plt .savefig (filename [0 ],bbox_inches = 'tight' , dpi = 300 )
519534 plt .close ()
520535 except :
@@ -674,9 +689,9 @@ def plot_intensity_sums(self):
674689 #intensities = np.reshape(intensities, newshape=(2048, numb_pixels_X*numb_pixels_Y))
675690
676691 sums = np .sum (self .intensities , axis = - 1 )
677- sums = np .reshape (sums , newshape = (self .numb_x_pixels , self .numb_y_pixels ))
692+ self . sums = np .reshape (sums , newshape = (self .numb_x_pixels , self .numb_y_pixels ))
678693
679- self .ui .intensity_sums_viewBox .setImage (sums , scale =
694+ self .ui .intensity_sums_viewBox .setImage (self . sums , scale =
680695 (self .x_step_size ,
681696 self .y_step_size ))
682697 self .ui .intensity_sums_viewBox .view .invertY (False )
@@ -884,6 +899,45 @@ def run(self):
884899 win = Analyze ()
885900 QtGui .QApplication .instance ().exec_ ()
886901 return win
902+
903+ """Export Images GUI"""
904+ ui_file_path = (base_path / "export_fig_gui.ui" ).resolve ()
905+ export_WindowTemplate , export_TemplateBaseClass = pg .Qt .loadUiType (ui_file_path )
906+
907+ class ExportFigureWindow (export_TemplateBaseClass ):
908+
909+ export_fig_signal = QtCore .pyqtSignal ()
910+
911+ def __init__ (self ):
912+ export_TemplateBaseClass .__init__ (self )
913+
914+ self .ui = export_WindowTemplate ()
915+ self .ui .setupUi (self )
916+ self .ui .cmap_comboBox .addItems (['viridis' , 'plasma' , 'inferno' , 'magma' ,
917+ 'cividis' ,'Greys' , 'Purples' , 'Blues' ,
918+ 'Greens' , 'Oranges' , 'Reds' , 'YlOrBr' ,
919+ 'YlOrRd' , 'OrRd' , 'PuRd' , 'RdPu' , 'BuPu' ,
920+ 'GnBu' , 'PuBu' , 'YlGnBu' , 'PuBuGn' , 'BuGn' ,
921+ 'YlGn' , 'binary' , 'gist_yarg' , 'gist_gray' ,
922+ 'gray' , 'bone' , 'pink' , 'spring' , 'summer' ,
923+ 'autumn' , 'winter' , 'cool' , 'Wistia' , 'hot' ,
924+ 'afmhot' , 'gist_heat' , 'copper' , 'rainbow' , 'jet' ])
925+ self .ui .dataChannel_comboBox .addItems (['Raw' , 'Fitted' ])
926+ self .ui .exportFig_pushButton .clicked .connect (self .export )
927+ # self.ui.legend_checkBox.stateChanged.connect(self.legend_title)
928+ self .show ()
929+
930+ # def legend_title(self):
931+ # if self.ui.legend_checkBox.isChecked():
932+ # self.ui.legend1_lineEdit.setEnabled(True)
933+ # self.ui.legend2_lineEdit.setEnabled(True)
934+ # else:
935+ # self.ui.legend1_lineEdit.setEnabled(False)
936+ # self.ui.legend2_lineEdit.setEnabled(False)
937+
938+ def export (self ):
939+ self .export_fig_signal .emit ()
940+ self .close ()
887941
888942"""Run the Main Window"""
889943def run ():
0 commit comments