Vespucci  1.0.0
plsdialog.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2014-2016 Wright State University - All Rights Reserved
3  Daniel P. Foose - Maintainer/Lead Developer
4 
5  This file is part of Vespucci.
6 
7  Vespucci is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Vespucci is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Vespucci. If not, see <http://www.gnu.org/licenses/>.
19 *******************************************************************************/
20 #include "GUI/Analysis/plsdialog.h"
21 #include "ui_plsdialog.h"
23 
24 PLSDialog::PLSDialog(QWidget *parent, QSharedPointer<VespucciWorkspace> ws, QSharedPointer<AbstractDataAnalyzer> analyzer) :
25  QDialog(parent),
26  ui(new Ui::PLSDialog),
27  workspace_(ws),
28  analyzer_(analyzer)
29 {
30  ui->setupUi(this);
31  ui->matrixDisplayLabel->setVisible(false);
32  ui->matrixLabel->setVisible(false);
33  ui->selectPushButton->setVisible(false);
34  matrix_selection_dialog_ = new MatrixSelectionDialog(this, workspace_->dataset_tree_model());
35  connect(matrix_selection_dialog_, &MatrixSelectionDialog::MatrixSelected,
37 }
38 
40 {
41  delete ui;
42 }
43 
48 void PLSDialog::on_buttonBox_accepted()
49 {
50  if (!analyzer_.isNull()){
51  int components = ui->componentsSpinBox->value();
52  QString name = ui->nameLineEdit->text();
53  QString type = ui->analysisTypeComboBox->currentText();
54 
55  try{
56  if (type == "Classification (Principal Components)")
57  analyzer_->PartialLeastSquares(name, components);
58  else if (type == "Calibration")
59  analyzer_->PLSCalibration(name, control_keys_);
60  else if (type == "Train PLS-DA")
61  analyzer_->TrainPLSDA(name, control_keys_);
62  }catch(exception e){
63  workspace_->main_window()->DisplayExceptionWarning(e);
64  }
65  }
66  close();
67  analyzer_.clear();
68 }
69 
73 void PLSDialog::on_buttonBox_rejected()
74 {
75  close();
76  analyzer_.clear();
77 }
78 
79 void PLSDialog::on_predictionCheckBox_clicked(bool checked)
80 {
81  ui->componentsSpinBox->setVisible(!checked);
82 }
83 
84 void PLSDialog::on_analysisTypeComboBox_currentIndexChanged(const QString &arg1)
85 {
86  if (arg1 == "Classification (Principal Components)"){
87  ui->matrixDisplayLabel->setVisible(false);
88  ui->matrixLabel->setVisible(false);
89  ui->selectPushButton->setVisible(false);
90  ui->componentsLabel->setVisible(true);
91  ui->componentsSpinBox->setVisible(true);
92  }
93  else if (arg1 == "Calibration"){
94  ui->matrixDisplayLabel->setVisible(true);
95  ui->matrixLabel->setVisible(true);
96  ui->selectPushButton->setVisible(true);
97  ui->componentsLabel->setVisible(false);
98  ui->componentsSpinBox->setVisible(false);
99  }
100  else if (arg1 == "Train PLS-DA"){
101  ui->matrixDisplayLabel->setVisible(true);
102  ui->matrixLabel->setVisible(true);
103  ui->selectPushButton->setVisible(true);
104  ui->componentsLabel->setVisible(false);
105  ui->componentsSpinBox->setVisible(false);
106  }
107 }
108 
109 void PLSDialog::on_selectPushButton_clicked()
110 {
111  matrix_selection_dialog_->show();
112 }
113 
114 void PLSDialog::MatrixSelected(QStringList keys)
115 {
116  control_keys_ = keys;
117  ui->matrixDisplayLabel->setText(control_keys_.last());
118  raise();
119 }
Definition: ahcadialog.h:26
void MatrixSelected(QStringList keys)
Definition: plsdialog.cpp:114
PLSDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > ws, QSharedPointer< AbstractDataAnalyzer > analyzer)
Definition: plsdialog.cpp:24
The PLSDialog class Dialog that allows the user to perform PLS determinant analysis.
Definition: plsdialog.h:33
void MatrixSelected(QStringList keys)