Exemple #1
0
    def initUI(self, wlet_pars):
        '''
        Gets called from the parent DataViewer
        '''

        self.setWindowTitle('Batch Processing')
        self.setGeometry(310, 330, 600, 200)

        # from the DataViewer
        self.wlet_pars = wlet_pars

        main_layout = QGridLayout()

        # -- Ridge Analysis Options --

        ridge_options = QGroupBox('Ridge Extraction Options')

        thresh_label = QLabel("Ridge Threshold:")
        thresh_edit = QLineEdit()
        thresh_edit.setValidator(posfloatV)
        thresh_edit.insert('0')
        thresh_edit.setMaximumWidth(60)
        thresh_edit.setToolTip(
            'Ridge points below that power value will be filtered out ')
        self.thresh_edit = thresh_edit

        smooth_label = QLabel("Ridge Smoothing:")
        smooth_edit = QLineEdit()
        smooth_edit.setMaximumWidth(60)
        smooth_edit.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        smooth_edit.setValidator(QIntValidator(bottom=3, top=99999999))
        tt = 'Savitkzy-Golay window size for smoothing the ridge,\nleave blank for no smoothing'
        smooth_edit.setToolTip(tt)
        self.smooth_edit = smooth_edit

        ridge_options_layout = QGridLayout()
        ridge_options_layout.addWidget(thresh_label, 0, 0)
        ridge_options_layout.addWidget(thresh_edit, 0, 1)
        ridge_options_layout.addWidget(smooth_label, 1, 0)
        ridge_options_layout.addWidget(smooth_edit, 1, 1)
        ridge_options.setLayout(ridge_options_layout)

        # -- Plotting Options --

        plotting_options = QGroupBox('Summary Statistics')
        self.cb_power_dis = QCheckBox('Ensemble Power Distribution')
        self.cb_power_dis.setToolTip(
            'Show time-averaged wavelet power of the ensemble')
        self.cb_plot_ens_dynamics = QCheckBox('Ensemble Dynamics')
        self.cb_plot_ens_dynamics.setToolTip(
            'Show period, amplitude and phase distribution over time')
        lo = QGridLayout()
        lo.addWidget(self.cb_power_dis, 0, 0)
        lo.addWidget(self.cb_plot_ens_dynamics, 1, 0)
        plotting_options.setLayout(lo)

        # -- Save Out Results --

        export_options = QGroupBox('Export Results')
        export_options.setToolTip('Saves also the summary statistics..')
        export_options.setCheckable(True)
        export_options.setChecked(False)
        self.cb_specs = QCheckBox('Wavelet Spectra')
        self.cb_specs.setToolTip(
            "Saves the individual wavelet spectra as images (png's)")

        self.cb_readout = QCheckBox('Ridge Readouts')
        self.cb_readout.setToolTip(
            'Saves one data frame per signal to disc as csv')

        self.cb_readout_plots = QCheckBox('Ridge Readout Plots')
        self.cb_readout_plots.setToolTip(
            "Saves the individual readout plots to disc as png's")
        self.cb_sorted_powers = QCheckBox('Sorted Average Powers')
        self.cb_sorted_powers.setToolTip(
            "Saves the time-averaged powers in descending order")
        self.cb_save_ensemble_dynamics = QCheckBox('Ensemble Dynamics')
        self.cb_save_ensemble_dynamics.setToolTip(
            "Saves each period, amplitude and phase summary statistics to a csv table"
        )

        home = expanduser("~")
        OutPath_label = QLabel('Export to:')
        self.OutPath_edit = QLineEdit(home)
        if self.debug:
            self.OutPath_edit.setText(home + '/Desktop/wres')

        PathButton = QPushButton('Select Path..')
        PathButton.setMaximumWidth(100)
        PathButton.clicked.connect(self.select_export_dir)

        line1 = QFrame()
        line1.setFrameShape(QFrame.HLine)
        line1.setFrameShadow(QFrame.Sunken)

        line2 = QFrame()
        line2.setFrameShape(QFrame.HLine)
        line2.setFrameShadow(QFrame.Sunken)

        lo = QGridLayout()
        lo.setSpacing(1.5)
        lo.addWidget(self.cb_specs, 0, 0)
        lo.addWidget(self.cb_readout, 1, 0)
        lo.addWidget(self.cb_readout_plots, 2, 0)
        #lo.addWidget(line1, 3,0)
        lo.addWidget(self.cb_sorted_powers, 4, 0)
        lo.addWidget(self.cb_save_ensemble_dynamics, 5, 0)
        #lo.addWidget(line2, 6,0)
        lo.addWidget(PathButton, 7, 0)
        lo.addWidget(self.OutPath_edit, 8, 0)
        export_options.setLayout(lo)
        self.export_options = export_options

        # -- Progress and Run --
        Nsignals = self.parentDV.df.shape[1]

        RunButton = QPushButton(f"Run for {Nsignals} Signals!", self)
        RunButton.setStyleSheet("background-color: orange")
        RunButton.clicked.connect(self.run_batch)
        #RunButton.setMaximumWidth(60)

        # the progress bar
        self.progress = QProgressBar(self)
        self.progress.setRange(0, Nsignals - 1)
        #self.progress.setGeometry(0,0, 300, 20)
        self.progress.setMinimumWidth(200)

        # nsig_label = QLabel(f'{Nsignals} Signals')

        process_box = QGroupBox('Processing')
        process_box.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        lo = QHBoxLayout()
        lo.addWidget(self.progress)
        lo.addItem(QSpacerItem(30, 2))
        # lo.addStretch(0)
        lo.addWidget(RunButton)
        lo.addStretch(0)
        process_box.setLayout(lo)

        # -- main layout --

        main_layout.addWidget(ridge_options, 0, 0, 1, 1)
        main_layout.addWidget(plotting_options, 1, 0, 1, 1)
        main_layout.addWidget(export_options, 0, 1, 2, 1)
        main_layout.addWidget(process_box, 2, 0, 1, 2)

        # set main layout
        self.setLayout(main_layout)
        self.show()
Exemple #2
0
    def initUI(self, wlet_pars):
        """
        Gets called from the parent DataViewer
        """

        self.setWindowTitle("Batch Processing")
        self.setGeometry(310, 330, 600, 200)

        # from the DataViewer
        self.wlet_pars = wlet_pars

        # for the status bar
        main_widget = QWidget()
        self.statusBar()

        main_layout = QGridLayout()

        # -- Ridge Analysis Options --

        ridge_options = QGroupBox("Ridge Detection")

        thresh_label = QLabel("Ridge Threshold:")
        thresh_edit = QLineEdit()
        thresh_edit.setValidator(posfloatV)
        thresh_edit.insert("0")
        thresh_edit.setMaximumWidth(60)
        thresh_edit.setStatusTip(
            "Ridge points below that power value will be filtered out ")
        self.thresh_edit = thresh_edit

        smooth_label = QLabel("Ridge Smoothing:")
        smooth_edit = QLineEdit()
        smooth_edit.setMaximumWidth(60)
        smooth_edit.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        smooth_edit.setValidator(QIntValidator(bottom=3, top=99999999))
        smooth_edit.setStatusTip(
            """Savitkzy-Golay window size for smoothing the ridge,
            leave blank for no smoothing""")
        self.smooth_edit = smooth_edit

        ridge_options_layout = QGridLayout()
        ridge_options_layout.addWidget(thresh_label, 0, 0)
        ridge_options_layout.addWidget(thresh_edit, 0, 1)
        ridge_options_layout.addWidget(smooth_label, 1, 0)
        ridge_options_layout.addWidget(smooth_edit, 1, 1)
        ridge_options.setLayout(ridge_options_layout)

        # -- Plotting Options --

        plotting_options = QGroupBox("Summary Statistics")
        self.cb_power_dis = QCheckBox("Ridge Power Distribution")
        self.cb_power_dis.setStatusTip(
            "Show time-averaged distribution of ridge powers")
        self.cb_plot_ens_dynamics = QCheckBox("Ensemble Dynamics")
        self.cb_plot_ens_dynamics.setStatusTip(
            "Show period, amplitude and phase distribution over time")
        self.cb_plot_Fourier_dis = QCheckBox("Fourier Spectra Distribution")
        self.cb_plot_Fourier_dis.setStatusTip(
            "Ensemble power distribution of the time averaged Wavelet spectra")

        lo = QGridLayout()
        lo.addWidget(self.cb_plot_ens_dynamics, 0, 0)
        lo.addWidget(self.cb_plot_Fourier_dis, 1, 0)
        lo.addWidget(self.cb_power_dis, 2, 0)
        plotting_options.setLayout(lo)

        # -- Save Out Results --

        export_options = QGroupBox("Export Results")
        export_options.setStatusTip("Creates various figures and csv's")
        export_options.setCheckable(True)
        export_options.setChecked(False)

        self.cb_filtered_sigs = QCheckBox("Filtered Signals")
        self.cb_filtered_sigs.setStatusTip(
            "Saves detrended and amplitude normalized signals to disc as csv's"
        )

        self.cb_specs = QCheckBox("Wavelet Spectra")
        self.cb_specs.setStatusTip(
            "Saves the individual wavelet spectra as images")

        self.cb_specs_noridge = QCheckBox("Wavelet Spectra w/o ridges")
        self.cb_specs_noridge.setStatusTip(
            "Saves the individual wavelet spectra without the ridges as images"
        )

        self.cb_readout = QCheckBox("Ridge Readouts")
        self.cb_readout.setStatusTip(
            "Saves one analysis result per signal to disc as csv")

        self.cb_readout_plots = QCheckBox("Ridge Readout Plots")
        self.cb_readout_plots.setStatusTip(
            "Saves the individual readout plots to disc")
        self.cb_sorted_powers = QCheckBox("Sorted Average Powers")
        self.cb_sorted_powers.setStatusTip(
            "Saves the time-averaged ridge powers in descending order")
        self.cb_save_ensemble_dynamics = QCheckBox("Ensemble Dynamics")
        self.cb_save_ensemble_dynamics.setStatusTip(
            "Separately saves period, amplitude, power and phase summary statistics to a csv file"
        )

        self.cb_save_Fourier_dis = QCheckBox("Fourier Distribution")
        self.cb_save_Fourier_dis.setStatusTip(
            "Saves median and quartiles of the ensemble Fourier power spectral distribution"
        )

        # defaults to HOME
        self.OutPath_edit = QLineEdit(expanduser("~"))

        PathButton = QPushButton("Select Path..")
        PathButton.setMaximumWidth(100)
        PathButton.clicked.connect(self.select_export_dir)

        line1 = QFrame()
        line1.setFrameShape(QFrame.HLine)
        line1.setFrameShadow(QFrame.Sunken)

        line2 = QFrame()
        line2.setFrameShape(QFrame.HLine)
        line2.setFrameShadow(QFrame.Sunken)

        lo = QGridLayout()
        lo.setSpacing(1.5)

        lo.addWidget(self.cb_filtered_sigs, 0, 0)

        lo.addWidget(self.cb_specs, 1, 0)
        lo.addWidget(self.cb_specs_noridge, 2, 0)

        lo.addWidget(self.cb_readout, 3, 0)
        lo.addWidget(self.cb_readout_plots, 4, 0)
        # lo.addWidget(line1, 3,0)
        lo.addWidget(self.cb_sorted_powers, 5, 0)
        lo.addWidget(self.cb_save_ensemble_dynamics, 6, 0)
        lo.addWidget(self.cb_save_Fourier_dis, 7, 0)
        # lo.addWidget(line2, 6,0)
        lo.addWidget(PathButton, 8, 0)
        lo.addWidget(self.OutPath_edit, 9, 0)
        export_options.setLayout(lo)
        self.export_options = export_options

        # -- Progress and Run --
        Nsignals = self.parentDV.df.shape[1]

        RunButton = QPushButton(f"Run for {Nsignals} Signals!", self)
        RunButton.setStyleSheet("background-color: orange")
        RunButton.clicked.connect(self.run_batch)
        # RunButton.setMaximumWidth(60)

        # the progress bar
        self.progress = QProgressBar(self)
        self.progress.setRange(0, Nsignals - 1)
        # self.progress.setGeometry(0,0, 300, 20)
        self.progress.setMinimumWidth(200)

        # nsig_label = QLabel(f'{Nsignals} Signals')

        process_box = QGroupBox("Processing")
        process_box.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        lo = QHBoxLayout()
        lo.addWidget(self.progress)
        lo.addItem(QSpacerItem(30, 2))
        # lo.addStretch(0)
        lo.addWidget(RunButton)
        lo.addStretch(0)
        process_box.setLayout(lo)

        # -- main layout --

        main_layout.addWidget(plotting_options, 0, 0, 1, 1)
        main_layout.addWidget(ridge_options, 1, 0, 1, 1)
        main_layout.addWidget(export_options, 0, 1, 2, 1)
        main_layout.addWidget(process_box, 2, 0, 1, 2)

        # set main layout
        main_widget.setLayout(main_layout)
        self.setCentralWidget(main_widget)

        self.show()