Skip to content

Commit

Permalink
Merge branch 'master' into regressionv2
Browse files Browse the repository at this point in the history
  • Loading branch information
nawazishkhan1-nk committed May 30, 2024
2 parents 3d53af8 + 8251992 commit aad7a91
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 20 deletions.
17 changes: 12 additions & 5 deletions Libs/Groom/Groom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ bool Groom::run_alignment() {

bool global_icp = false;
bool global_landmarks = false;
bool any_alignment = false;

int reference_index = -1;
int subset_size = -1;
Expand All @@ -524,6 +525,9 @@ bool Groom::run_alignment() {
}

auto params = GroomParameters(project_, project_->get_domain_names()[domain]);
if (params.get_alignment_enabled()) {
any_alignment = true;
}

if (params.get_use_icp()) {
global_icp = true;
Expand Down Expand Up @@ -594,16 +598,17 @@ bool Groom::run_alignment() {
meshes.push_back(mesh);
} else {
// insert blank for each excluded shape
meshes.push_back(vtkSmartPointer<vtkPolyData>::New());
meshes.emplace_back(vtkSmartPointer<vtkPolyData>::New());
}
}

if (global_icp) {
std::vector<Mesh> reference_meshes;

Mesh reference_mesh = vtkSmartPointer<vtkPolyData>::New();
if (reference_index < 0 || reference_index >= reference_meshes.size()) {
reference_index = MeshUtils::findReferenceMesh(reference_meshes, subset_size);
if (reference_index < 0 || reference_index >= reference_meshes.size()) {
throw std::runtime_error("could not find reference mesh");
}
reference_mesh = reference_meshes[reference_index];
} else {
reference_mesh = get_mesh(reference_index, 0, true);
Expand All @@ -623,12 +628,14 @@ bool Groom::run_alignment() {
size_t domain = num_domains; // end
assign_transforms(transforms, domain, true /* global */);

} else { // just center
} else {
std::vector<std::vector<double>> transforms;
for (size_t i = 0; i < subjects.size(); i++) {
auto subject = subjects[i];
auto transform = vtkSmartPointer<vtkTransform>::New();
Groom::add_center_transform(transform, meshes[i]);
if (any_alignment) { // just center
Groom::add_center_transform(transform, meshes[i]);
}
transforms.push_back(ProjectUtils::convert_transform(transform));
}
size_t domain = num_domains; // end
Expand Down
10 changes: 6 additions & 4 deletions Libs/Project/ProjectReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,18 @@ void ProjectReader::load_subjects(StringMapList list) {
if (contains(item, "excluded")) {
subject->set_excluded(Variant(item["excluded"]));
}

if (contains(item, "explanatory_variable")) {
subject->set_explanatory_variable(Variant(item["explanatory_variable"]));
}

if (name == "") {
if (subject->get_original_filenames().size() != 0) {
if (name.empty()) {
if (!subject->get_original_filenames().empty()) {

name = StringUtils::getBaseFilenameWithoutExtension(subject->get_original_filenames()[0]);
} else if (subject->get_groomed_filenames().size() != 0) {
} else if (!subject->get_groomed_filenames().empty()) {
name = StringUtils::getBaseFilenameWithoutExtension(subject->get_groomed_filenames()[0]);
} else if (subject->get_local_particle_filenames().size() > 0) {
} else if (!subject->get_local_particle_filenames().empty()) {
name = StringUtils::getBaseFilenameWithoutExtension(subject->get_local_particle_filenames()[0]);
}
}
Expand Down
48 changes: 46 additions & 2 deletions Studio/Analysis/AnalysisTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include <jkqtplotter/jkqtplotter.h>
#include <ui_AnalysisTool.h>

#include <QClipboard>
#include <QMenu>

#include "ParticleAreaPanel.h"
#include "ShapeScalarPanel.h"

Expand Down Expand Up @@ -80,8 +83,6 @@ AnalysisTool::AnalysisTool(Preferences& prefs) : preferences_(prefs) {
ui_->tabWidget->tabBar()->setElideMode(Qt::TextElideMode::ElideNone);
#endif

stats_ready_ = false;

connect(ui_->view_header, &QPushButton::clicked, ui_->view_open_button, &QPushButton::toggle);
connect(ui_->metrics_header, &QPushButton::clicked, ui_->metrics_open_button, &QPushButton::toggle);
connect(ui_->surface_header, &QPushButton::clicked, ui_->surface_open_button, &QPushButton::toggle);
Expand Down Expand Up @@ -179,6 +180,14 @@ AnalysisTool::AnalysisTool(Preferences& prefs) : preferences_(prefs) {
&AnalysisTool::handle_samples_predicted_scalar_options);
connect(ui_->show_absolute_difference, &QPushButton::clicked, this,
&AnalysisTool::handle_samples_predicted_scalar_options);

// add a right click menu to the samples table allowing the user to copy the table to the clipboard
ui_->samples_table->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui_->samples_table, &QTableWidget::customContextMenuRequested, this,
&AnalysisTool::samples_table_context_menu);

// disable editing of the table
ui_->samples_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -1890,6 +1899,41 @@ void AnalysisTool::handle_samples_predicted_scalar_options() {
Q_EMIT update_view();
}

//---------------------------------------------------------------------------
void AnalysisTool::samples_table_context_menu() {
QMenu menu;
QAction* action = menu.addAction("Copy to Clipboard");
connect(action, &QAction::triggered, this, &AnalysisTool::samples_table_copy_to_clipboard);
menu.exec(QCursor::pos());
}

//---------------------------------------------------------------------------
void AnalysisTool::samples_table_copy_to_clipboard() {
QTableWidget* table = ui_->samples_table;
QString text;
// start with headers
for (int i = 0; i < table->columnCount(); i++) {
text += table->horizontalHeaderItem(i)->text();
if (i < table->columnCount() - 1) {
text += ",";
}
}
text += "\n";
for (int i = 0; i < table->rowCount(); i++) {
for (int j = 0; j < table->columnCount(); j++) {
auto item = table->item(i, j);
if (item) {
text += item->text();
}
if (j < table->columnCount() - 1) {
text += ",";
}
}
text += "\n";
}
QApplication::clipboard()->setText(text);
}

//---------------------------------------------------------------------------
void AnalysisTool::reconstruction_method_changed() {
ui_->reconstruction_options->setVisible(ui_->distance_transform_radio_button->isChecked());
Expand Down
3 changes: 3 additions & 0 deletions Studio/Analysis/AnalysisTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ class AnalysisTool : public QWidget {

void handle_samples_predicted_scalar_options();

void samples_table_context_menu();
void samples_table_copy_to_clipboard();

Q_SIGNALS:

void update_view();
Expand Down
25 changes: 19 additions & 6 deletions Studio/Data/DataTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,19 +656,32 @@ void DataTool::table_data_edited() {
}

bool change = false;

// find name and notes columns
int name_column = -1;
int notes_column = -1;
for (int i = 0; i < ui_->table->columnCount(); i++) {
if (ui_->table->horizontalHeaderItem(i)->text() == "name") {
name_column = i;
} else if (ui_->table->horizontalHeaderItem(i)->text() == "notes") {
notes_column = i;
}
}

// iterate over all rows, not just selected
for (int row = 0; row < ui_->table->rowCount(); row++) {
auto shape = session_->get_shapes()[row];
auto old_name = shape->get_subject()->get_display_name();
auto old_notes = shape->get_subject()->get_notes();
if (ui_->table->item(row, 0) == nullptr) {
continue;

std::string new_name;
if (name_column != -1) {
new_name = ui_->table->item(row, name_column)->text().toStdString();
}
auto new_name = ui_->table->item(row, 0)->text().toStdString();
if (ui_->table->item(row, 1) == nullptr) {
continue;
std::string new_notes;
if (notes_column != -1) {
new_notes = ui_->table->item(row, notes_column)->text().toStdString();
}
auto new_notes = ui_->table->item(row, 1)->text().toStdString();
if (old_name != new_name) {
shape->get_subject()->set_display_name(new_name);
shape->update_annotations();
Expand Down
1 change: 1 addition & 0 deletions Studio/Groom/GroomTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ void GroomTool::skip_grooming_toggled() {
groom_ = QSharedPointer<Groom>(new Groom(session_->get_project()));
groom_->run();
SW_MESSAGE("Skipped Grooming");
SW_PROGRESS(100, "Grooming Skipped");
Q_EMIT groom_complete();
}
}
Expand Down
6 changes: 3 additions & 3 deletions python_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ itk-segmentation==5.3.0
itkwidgets==0.32.1
itsdangerous==2.1.2
jedi==0.18.2
Jinja2==3.1.3
Jinja2==3.1.4
joblib==1.3.1
jsonpointer==2.4
jsonschema==4.18.0
Expand Down Expand Up @@ -172,7 +172,7 @@ threadpoolctl==3.1.0
tinycss2==1.2.1
toml==0.10.2
tornado==6.3.3
tqdm==4.65.0
tqdm==4.66.3
traitlets==5.9.0
traittypes==0.2.1
trimesh==3.12.6
Expand All @@ -187,7 +187,7 @@ wcwidth==0.2.6
webcolors==1.13
webencodings==0.5.1
websocket-client==1.6.1
Werkzeug==3.0.1
Werkzeug==3.0.3
widgetsnbextension==3.6.4
zipp==3.15.0
zstandard==0.21.0

0 comments on commit aad7a91

Please sign in to comment.