Skip to content

Commit

Permalink
Updated the Analysis Options Dialog; analysis results all use csv out…
Browse files Browse the repository at this point in the history
…put now; automatically set the radius from center coordinates.
  • Loading branch information
Ting Xu authored and Ting Xu committed Mar 5, 2015
1 parent 5a62f3c commit b580e38
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 142 deletions.
176 changes: 96 additions & 80 deletions analysis_options_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ namespace soax {
AnalysisOptionsDialog::AnalysisOptionsDialog(QWidget *parent) :
QDialog(parent) {
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(this->CreatePointDensityGroup());
layout->addWidget(this->CreateGeneralGroup());
layout->addWidget(this->CreateCurvatureGroup());
layout->addWidget(this->CreatePointDensityGroup());

button_box_ = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Cancel);
Expand All @@ -26,10 +27,12 @@ AnalysisOptionsDialog::AnalysisOptionsDialog(QWidget *parent) :
connect(button_box_, SIGNAL(rejected()), this, SLOT(reject()));
}

void AnalysisOptionsDialog::SetImageCenter(const PointType &center) {
center_x_edit_->setText(QString::number(center[0]));
center_y_edit_->setText(QString::number(center[1]));
center_z_edit_->setText(QString::number(center[2]));
double AnalysisOptionsDialog::GetPixelSize() const {
return pixel_size_edit_->text().toDouble();
}

int AnalysisOptionsDialog::GetCoarseGraining() const {
return coarse_graining_edit_->text().toInt();
}

void AnalysisOptionsDialog::GetImageCenter(PointType &center) const {
Expand All @@ -38,79 +41,10 @@ void AnalysisOptionsDialog::GetImageCenter(PointType &center) const {
center[2] = center_z_edit_->text().toDouble();
}

QGroupBox * AnalysisOptionsDialog::CreateCurvatureGroup() {
QGroupBox *gb = new QGroupBox(tr("Curvature (1/pixel)"));
coarse_graining_edit_ = new QLineEdit("8");

connect(coarse_graining_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));

QLabel *label = new QLabel(tr("Coarse graining (SOAC points)"));

QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(label);
layout->addWidget(coarse_graining_edit_);
layout->addStretch();
gb->setLayout(layout);
return gb;
}

QGroupBox * AnalysisOptionsDialog::CreatePointDensityGroup() {
QGroupBox *gb = new QGroupBox(
tr("Spherical, Radial Orientation && Point Density"));
center_x_edit_ = new QLineEdit("0");
center_y_edit_ = new QLineEdit("0");
center_z_edit_ = new QLineEdit("0");
radius_edit_ = new QLineEdit("100");
pixel_size_edit_ = new QLineEdit("1.0");

connect(center_x_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));
connect(center_y_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));
connect(center_z_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));
connect(radius_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));
connect(pixel_size_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));

QLabel *center_label = new QLabel(tr("Center x, y, z (pixels)"));
QLabel *radius_label = new QLabel(tr("Radius (pixels) "));
QLabel *pixel_size_label = new QLabel(tr("Pixel size (um)"));

QHBoxLayout *hlayout1 = new QHBoxLayout;
hlayout1->addWidget(center_label);
hlayout1->addWidget(center_x_edit_);
hlayout1->addWidget(center_y_edit_);
hlayout1->addWidget(center_z_edit_);
hlayout1->addStretch();

QHBoxLayout *hlayout4 = new QHBoxLayout;
hlayout4->addWidget(radius_label);
hlayout4->addWidget(radius_edit_);
hlayout4->addWidget(pixel_size_label);
hlayout4->addWidget(pixel_size_edit_);
hlayout4->addStretch();

QVBoxLayout *vlayout = new QVBoxLayout;
vlayout->addLayout(hlayout1);
vlayout->addLayout(hlayout4);

gb->setLayout(vlayout);
return gb;
}

void AnalysisOptionsDialog::DisableOKButton() {
button_box_->button(QDialogButtonBox::Ok)->setEnabled(false);
}

void AnalysisOptionsDialog::EnableOKButton() {
button_box_->button(QDialogButtonBox::Ok)->setEnabled(true);
}

int AnalysisOptionsDialog::GetCoarseGraining() const {
return coarse_graining_edit_->text().toInt();
void AnalysisOptionsDialog::SetImageCenter(const PointType &center) {
center_x_edit_->setText(QString::number(center[0]));
center_y_edit_->setText(QString::number(center[1]));
center_z_edit_->setText(QString::number(center[2]));
}

double AnalysisOptionsDialog::GetCenterX() const {
Expand Down Expand Up @@ -147,8 +81,90 @@ unsigned AnalysisOptionsDialog::GetRadius() const {
return radius_edit_->text().toUInt();
}

double AnalysisOptionsDialog::GetPixelSize() const {
return pixel_size_edit_->text().toDouble();
void AnalysisOptionsDialog::SetRadius(double r) {
radius_edit_->setText(QString::number(r));
}

void AnalysisOptionsDialog::DisableOKButton() {
button_box_->button(QDialogButtonBox::Ok)->setEnabled(false);
}

void AnalysisOptionsDialog::EnableOKButton() {
button_box_->button(QDialogButtonBox::Ok)->setEnabled(true);
}

QGroupBox * AnalysisOptionsDialog::CreateGeneralGroup() {
QGroupBox *gb = new QGroupBox(tr("General"));
pixel_size_edit_ = new QLineEdit("1.0");
connect(pixel_size_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));
QLabel *label = new QLabel(tr("Pixel Size (um)"));
QHBoxLayout *hbox = new QHBoxLayout;
hbox->addWidget(label);
hbox->addWidget(pixel_size_edit_);
hbox->addStretch();
gb->setLayout(hbox);
return gb;
}

QGroupBox * AnalysisOptionsDialog::CreateCurvatureGroup() {
QGroupBox *gb = new QGroupBox(tr("Curvature"));
coarse_graining_edit_ = new QLineEdit("8");
connect(coarse_graining_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));
QLabel *label = new QLabel(tr("Coarse Graining (snake points)"));
QHBoxLayout *hbox = new QHBoxLayout;
hbox->addWidget(label);
hbox->addWidget(coarse_graining_edit_);
hbox->addStretch();
gb->setLayout(hbox);
return gb;
}

QGroupBox * AnalysisOptionsDialog::CreatePointDensityGroup() {
QGroupBox *gb = new QGroupBox(tr("Spherical Confinement"));
center_x_edit_ = new QLineEdit("0");
center_y_edit_ = new QLineEdit("0");
center_z_edit_ = new QLineEdit("0");
radius_edit_ = new QLineEdit("0");

connect(center_x_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));
connect(center_y_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));
connect(center_z_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));
connect(radius_edit_, SIGNAL(textChanged(const QString &)),
this, SLOT(EnableOKButton()));

QLabel *label_x = new QLabel(tr("Center X (pixels)"));
QLabel *label_y = new QLabel(tr("Center Y (pixels)"));
QLabel *label_z = new QLabel(tr("Center Z (pixels)"));
QLabel *label_r = new QLabel(tr("Radius (pixels)"));
QHBoxLayout *hbox1 = new QHBoxLayout;
hbox1->addWidget(label_x);
hbox1->addWidget(center_x_edit_);
hbox1->addStretch();
QHBoxLayout *hbox2 = new QHBoxLayout;
hbox2->addWidget(label_y);
hbox2->addWidget(center_y_edit_);
hbox2->addStretch();
QHBoxLayout *hbox3 = new QHBoxLayout;
hbox3->addWidget(label_z);
hbox3->addWidget(center_z_edit_);
hbox3->addStretch();
QHBoxLayout *hbox4 = new QHBoxLayout;
hbox4->addWidget(label_r);
hbox4->addWidget(radius_edit_);
hbox4->addStretch();
QVBoxLayout *vbox = new QVBoxLayout;
vbox->addLayout(hbox1);
vbox->addLayout(hbox2);
vbox->addLayout(hbox3);
vbox->addLayout(hbox4);
gb->setLayout(vbox);
return gb;
}


} // namespace soax
12 changes: 7 additions & 5 deletions analysis_options_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ class AnalysisOptionsDialog : public QDialog {
public:
explicit AnalysisOptionsDialog(QWidget * parent = NULL);

void SetImageCenter(const PointType &center);
void GetImageCenter(PointType &center) const;

double GetPixelSize() const;
int GetCoarseGraining() const;

void GetImageCenter(PointType &center) const;
void SetImageCenter(const PointType &center);

double GetCenterX() const;
double GetCenterY() const;
double GetCenterZ() const;
Expand All @@ -36,15 +37,16 @@ class AnalysisOptionsDialog : public QDialog {
void SetCenterZ(double value);

unsigned GetRadius() const;
double GetPixelSize() const;
void SetRadius(double r);

public slots: // NOLINT(whitespace/indent)
void EnableOKButton();
void DisableOKButton();

private:
QGroupBox *CreatePointDensityGroup();
QGroupBox *CreateGeneralGroup();
QGroupBox *CreateCurvatureGroup();
QGroupBox *CreatePointDensityGroup();

QLineEdit *coarse_graining_edit_;
QLineEdit *center_x_edit_;
Expand Down
24 changes: 16 additions & 8 deletions main_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "./view_options_dialog.h"
#include "./solver_bank.h"
#include "./analysis_options_dialog.h"
#include "./utility.h"


namespace soax {

Expand Down Expand Up @@ -514,7 +516,14 @@ void MainWindow::OpenImage() {
view_options_dialog_->SetClipSpan(viewer_->clip_span());
view_options_dialog_->SetColorSegmentStep(viewer_->color_segment_step());

analysis_options_dialog_->SetImageCenter(multisnake_->GetImageCenter());
PointType center = multisnake_->GetImageCenter();
analysis_options_dialog_->SetImageCenter(center);
DataContainer center_coordinates;
for (int i = 0; i < kDimension; i++) {
center_coordinates.push_back(center[i]);
}
double radius = Minimum(center_coordinates);
analysis_options_dialog_->SetRadius(radius);

open_image_->setEnabled(false);
save_as_isotropic_image_->setEnabled(true);
Expand Down Expand Up @@ -1025,8 +1034,7 @@ void MainWindow::GroupSnakes() {
void MainWindow::ComputeSphericalOrientation() {
QString dir = this->GetLastDirectory(analysis_filename_);
QString filename = QFileDialog::getSaveFileName(
this, tr("Save spherical orientation"),
dir, tr("CSV files (*.csv)"));
this, tr("Save spherical orientation"), dir, tr("CSV files (*.csv)"));
if (filename.isEmpty()) return;
analysis_filename_ = filename.toStdString();

Expand All @@ -1052,7 +1060,7 @@ void MainWindow::ComputeSphericalOrientation() {
void MainWindow::ComputeRadialOrientation() {
QString dir = this->GetLastDirectory(analysis_filename_);
QString filename = QFileDialog::getSaveFileName(
this, tr("Save radial orientation"), dir, tr("Text files (*.txt)"));
this, tr("Save radial orientation"), dir, tr("CSV files (*.csv)"));
if (filename.isEmpty()) return;
analysis_filename_ = filename.toStdString();

Expand All @@ -1079,7 +1087,7 @@ void MainWindow::ComputePointDensity() {
QString dir = this->GetLastDirectory(analysis_filename_);
QString filename = QFileDialog::getSaveFileName(
this, tr("Save SOAC point density/intensity"), dir,
tr("Text files (*.txt)"));
tr("CSV files (*.csv)"));
if (filename.isEmpty()) return;
analysis_filename_ = filename.toStdString();

Expand Down Expand Up @@ -1109,12 +1117,12 @@ void MainWindow::ComputePointDensity() {
void MainWindow::ComputeCurvature() {
QString dir = this->GetLastDirectory(analysis_filename_);
QString filename = QFileDialog::getSaveFileName(
this, tr("Save curvature"), dir, tr("Text files (*.txt)"));
this, tr("Save curvature"), dir, tr("CSV files (*.csv)"));
if (filename.isEmpty()) return;
analysis_filename_ = filename.toStdString();

int coarse_graining = analysis_options_dialog_->GetCoarseGraining();

double pixel_size = analysis_options_dialog_->GetPixelSize();
std::ofstream outfile;
outfile.open(analysis_filename_.c_str());
if (!outfile.is_open()) {
Expand All @@ -1124,7 +1132,7 @@ void MainWindow::ComputeCurvature() {
msg_box.exec();
return;
}
multisnake_->ComputeCurvature(coarse_graining, outfile);
multisnake_->ComputeCurvature(coarse_graining, pixel_size, outfile);
statusBar()->showMessage(tr("Curvature file saved."));
outfile.close();
}
Expand Down
Loading

0 comments on commit b580e38

Please sign in to comment.