21 #include "ui_datasetextractordialog.h" 28 matrix_keys_ = matrix_keys;
30 ui->columnSpinBox->setMaximum(workspace_->GetMatrix(matrix_keys_).n_cols);
31 ui->columnSpinBox->setMinimum(1);
32 ui->valueDoubleSpinBox->setMinimum(workspace_->GetMatrix(matrix_keys_).min());
33 ui->valueDoubleSpinBox->setMaximum(workspace_->GetMatrix(matrix_keys_).max());
34 ui->nameLineEdit->setText(matrix_keys_.first() +
" (" + matrix_keys_.last() +
")");
42 void DatasetExtractorDialog::on_buttonBox_accepted()
44 QString op = ui->operatorComboBox->currentText();
45 QString name = ui->nameLineEdit->text();
46 uword column = ui->columnSpinBox->value() - 1;
47 double value = ui->valueDoubleSpinBox->value();
51 vec matrix = workspace_->GetMatrix(matrix_keys_).col(column);
53 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(matrix_keys_.first());
54 if (dataset.isNull())
throw runtime_error(
"Dataset not found");
55 if (dataset->spectra_ref().n_cols != matrix.n_rows)
throw invalid_argument(
"Dimension mismatch");
56 if (op ==
"=") indices = arma::find(matrix == value);
57 else if (op ==
">") indices = arma::find(matrix > value);
58 else if (op ==
"<") indices = arma::find(matrix < value);
59 else if (op ==
"≠") indices = arma::find(matrix != value);
60 if (indices.n_elem == 0)
throw runtime_error(
"No values with specified relationship");
61 spectra = dataset->spectra(indices);
62 x = dataset->x_ref().rows(indices);
63 y = dataset->y_ref().rows(indices);
64 abscissa = dataset->abscissa();
66 workspace_->main_window(),
67 workspace_->directory_ptr()));
68 new_dataset->SetData(spectra, abscissa, x, y);
69 workspace_->AddDataset(new_dataset);
71 workspace_->main_window()->DisplayExceptionWarning(e);
The VespucciDataset class This is the main class for dealing with hyperspectral data. This handles the import and export of spectra, and the creation of maps. Images are handled by the MapData class. This class is intended to be allocated on the heap inside of a smart pointer, there is no copy constructor.