-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathAnalysisTool.h
301 lines (199 loc) · 7.16 KB
/
AnalysisTool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#pragma once
#include <Eigen/Dense>
#include <Eigen/Sparse>
// Qt
#include <QSharedPointer>
#include <QWidget>
// ShapeWorks
#include <Analyze/Analyze.h>
#include <ParticleShapeStatistics.h>
// Studio
#include <Analysis/ShapeEvaluationJob.h>
#include <Data/Preferences.h>
#include <Shape.h>
#include <Visualization/Visualizer.h>
class Ui_AnalysisTool;
class JKQTPlotter;
namespace shapeworks {
class Session;
class Lightbox;
class ShapeWorksStudioApp;
class GroupPvalueJob;
class NetworkAnalysisJob;
class StatsGroupLDAJob;
class ParticleAreaPanel;
class ShapeScalarPanel;
class AnalysisTool : public QWidget {
Q_OBJECT;
public:
using AlignmentType = Analyze::AlignmentType;
enum GroupAnalysisType { None = 0, Pvalues = 1, NetworkAnalysis = 2, LDA = 3 };
enum McaMode { Vanilla, Within, Between };
using PointType = itk::Point<double, 3>;
AnalysisTool(Preferences& prefs);
~AnalysisTool();
/// set the pointer to the session
void set_session(QSharedPointer<Session> session);
//! Return the session
QSharedPointer<Session> get_session();
/// set the pointer to the application
void set_app(ShapeWorksStudioApp* app);
ShapeWorksStudioApp* get_app() { return app_; }
//! Set if this tool is active
void set_active(bool active);
//! Return if this tool is active
bool get_active();
bool get_group_difference_mode();
std::vector<Shape::Point> get_group_difference_vectors();
std::string get_analysis_mode();
void set_analysis_mode(std::string mode);
void set_labels(QString which, QString value);
int get_pca_mode();
double get_group_ratio();
double get_pca_value();
bool pca_animate();
McaMode get_mca_level() const;
int get_sample_number();
bool compute_stats();
void update_slider();
void reset_stats();
void enable_actions(bool newly_enabled = false);
Particles get_mean_shape_points();
ShapeHandle get_mean_shape();
Particles get_shape_points(int mode, double value);
Particles get_multi_level_shape_points(int mode, double value, McaMode level);
ShapeHandle get_mode_shape(int mode, double value);
ShapeHandle get_mca_mode_shape(int mode, double value, McaMode level);
ShapeHandle get_current_shape();
ParticleShapeStatistics get_stats();
void load_settings();
void store_settings();
void shutdown();
bool export_variance_graph(QString filename);
void compute_shape_evaluations();
static const std::string MODE_ALL_SAMPLES_C;
static const std::string MODE_MEAN_C;
static const std::string MODE_PCA_C;
static const std::string MODE_SINGLE_SAMPLE_C;
static const std::string MODE_REGRESSION_C;
GroupAnalysisType get_group_analysis_type();
bool pca_scalar_only_mode();
bool pca_shape_plus_scalar_mode();
bool pca_shape_only_mode();
public Q_SLOTS:
// analysis mode
void on_tabWidget_currentChanged();
void handle_analysis_options();
void handle_median();
void on_mean_button_clicked();
void on_group1_button_clicked();
void on_group2_button_clicked();
void on_difference_button_clicked();
// PCA
void on_pcaSlider_valueChanged();
void on_group_slider_valueChanged();
void on_pcaModeSpinBox_valueChanged(int i);
void handle_pca_animate_state_changed();
void handle_pca_timer();
void handle_group_animate_state_changed();
void handle_group_timer();
void handle_reconstruction_complete();
void on_reconstructionButton_clicked();
//! Set the currently selected feature map
void set_feature_map(const std::string& feature_map);
std::string get_display_feature_map();
void group_changed();
bool groups_active();
void on_view_open_button_toggled();
void on_surface_open_button_toggled();
void on_metrics_open_button_toggled();
bool is_group_active(int shape_index);
void reconstruction_method_changed();
void initialize_mesh_warper();
void group_p_values_clicked();
void network_analysis_clicked();
void handle_eval_thread_complete(ShapeEvaluationJob::JobType job_type, Eigen::VectorXd data);
void handle_eval_thread_progress(ShapeEvaluationJob::JobType job_type, float progress);
void handle_eval_particle_normals_progress(float progress);
void handle_eval_particle_normals_complete(std::vector<bool> good_bad);
void handle_group_pvalues_complete();
void handle_alignment_changed(int new_alignment);
void handle_distance_method_changed();
void run_good_bad_particles();
void handle_lda_progress(double progress);
void handle_lda_complete();
void handle_network_analysis_progress(int progress);
void handle_network_analysis_complete();
void show_difference_to_mean_clicked();
void group_analysis_combo_changed();
void change_pca_analysis_type();
//! Compute the mean shape outside of the PCA in case we are using scalars only
Eigen::VectorXd construct_mean_shape();
void handle_samples_predicted_scalar_options();
void samples_table_context_menu();
void samples_table_copy_to_clipboard();
// mesh warping options
void mesh_warp_median_clicked();
void mesh_warp_sample_changed();
void mesh_warp_run_clicked();
Q_SIGNALS:
void update_view();
void analysis_mode_changed();
void pca_update();
void progress(int);
void reconstruction_complete();
private:
void compute_reconstructed_domain_transforms();
bool active_ = false;
void pca_labels_changed(QString value, QString eigen, QString lambda);
void update_interface();
bool group_pvalues_valid();
bool groups_on();
//! Break apart combined points into per-domain
Particles convert_from_combined(const Eigen::VectorXd& points);
void update_group_boxes();
void update_group_values();
void update_domain_alignment_box();
void update_lda_graph();
void update_difference_particles();
Eigen::VectorXd get_mean_shape_particles();
ShapeHandle create_shape_from_points(Particles points);
Preferences& preferences_;
Ui_AnalysisTool* ui_;
QSharedPointer<Session> session_;
ShapeWorksStudioApp* app_;
ParticleShapeStatistics stats_;
bool stats_ready_ = false;
bool evals_ready_ = false;
bool large_particle_disclaimer_waived_ = false;
bool skip_evals_ = false;
Eigen::VectorXd eval_specificity_;
Eigen::VectorXd eval_compactness_;
Eigen::VectorXd eval_generalization_;
vnl_vector<double> empty_shape_;
Eigen::VectorXd temp_shape_;
Eigen::VectorXd temp_shape_mca;
std::vector<int> number_of_particles_array_;
Eigen::VectorXd computed_scalars_;
bool pca_animate_direction_ = true;
QTimer pca_animate_timer_;
bool group_animate_direction_ = true;
QTimer group_animate_timer_;
ShapeHandle computed_shape_;
ShapeList group1_list_;
ShapeList group2_list_;
std::string feature_map_;
std::vector<std::string> current_group_names_;
std::vector<std::string> current_group_values_;
std::vector<vtkSmartPointer<vtkTransform>> reconstruction_transforms_;
QSharedPointer<GroupPvalueJob> group_pvalue_job_;
QSharedPointer<StatsGroupLDAJob> group_lda_job_;
QSharedPointer<NetworkAnalysisJob> network_analysis_job_;
bool group_lda_job_running_ = false;
bool lda_computed_ = false;
bool block_group_change_ = false;
ParticleAreaPanel* particle_area_panel_{nullptr};
ShapeScalarPanel* shape_scalar_panel_{nullptr};
std::vector<QPointer<Worker>> workers_;
};
} // namespace shapeworks