Developer documentation
Version 3.0.3-105-gd3941f44
connectome.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __gui_mrview_tool_connectome_connectome_h__
18#define __gui_mrview_tool_connectome_connectome_h__
19
20#include <map>
21
22#include "image.h"
23#include "types.h"
24
25#include "misc/bitset.h"
26#include "surface/mesh.h"
27
28#include "gui/opengl/gl.h"
29#include "gui/opengl/lighting.h"
30#include "gui/opengl/shader.h"
40#include "gui/color_button.h"
41#include "gui/projection.h"
42
43#include "connectome/mat2vec.h"
44#include "connectome/lut.h"
45
56
57
58
60namespace MR
61{
62 namespace GUI
63 {
64 namespace MRView
65 {
66 namespace Tool
67 {
68
69 class Connectome : public Base
70 { MEMALIGN(Connectome)
71 Q_OBJECT
72
73 enum class node_visibility_matrix_operator_t { ANY, ALL };
74 enum class node_property_matrix_operator_t { MIN, MEAN, SUM, MAX };
75
76 public:
77
78 Connectome (Dock* parent);
79
80 virtual ~Connectome ();
82 void draw (const Projection& transform, bool is_3D, int axis, int slice) override;
83 void draw_colourbars() override;
84 size_t visible_number_colourbars () override;
85
86 node_t num_nodes() const { return nodes.size() ? nodes.size() - 1 : 0; }
87 size_t num_edges() const { return edges.size(); }
88
90 virtual bool process_commandline_option (const MR::App::ParsedOption& opt) override;
91
92 private slots:
93
94 void image_open_slot();
95 void hide_all_slot();
96
97 void matrix_open_slot();
98 void matrix_close_slot();
99 void connectome_selection_changed_slot (const QItemSelection&, const QItemSelection&);
100
101 void node_visibility_selection_slot (int);
102 void node_geometry_selection_slot (int);
103 void node_colour_selection_slot (int);
104 void node_size_selection_slot (int);
105 void node_alpha_selection_slot (int);
106
107 void node_visibility_matrix_operator_slot (int);
108 void node_visibility_parameter_slot();
109 void sphere_lod_slot (int);
110 void overlay_interp_slot (int);
111 void node_colour_matrix_operator_slot (int);
112 void node_fixed_colour_change_slot();
113 void node_colour_parameter_slot();
114 void node_size_matrix_operator_slot (int);
115 void node_size_value_slot();
116 void node_size_parameter_slot();
117 void node_alpha_matrix_operator_slot (int);
118 void node_alpha_value_slot (int);
119 void node_alpha_parameter_slot();
120
121 void edge_visibility_selection_slot (int);
122 void edge_geometry_selection_slot (int);
123 void edge_colour_selection_slot (int);
124 void edge_size_selection_slot (int);
125 void edge_alpha_selection_slot (int);
126
127 void edge_visibility_parameter_slot();
128 void cylinder_lod_slot (int);
129 void edge_colour_change_slot();
130 void edge_colour_parameter_slot();
131 void edge_size_value_slot();
132 void edge_size_parameter_slot();
133 void edge_alpha_value_slot (int);
134 void edge_alpha_parameter_slot();
135
136 void lut_open_slot ();
137 void lighting_change_slot (int);
138 void lighting_settings_slot();
139 void lighting_parameter_slot();
140 void crop_to_slab_toggle_slot (int);
141 void crop_to_slab_parameter_slot();
142 void show_node_list_slot();
143 void node_selection_settings_changed_slot();
144
145 protected:
146
148
151
159
165
173
181
189
197
202
209
216
223
224 QPushButton *lut_button;
232
233 private:
234
235 NodeShader node_shader;
236 EdgeShader edge_shader;
237
238
239 // For the sake of viewing nodes as an overlay, need to ALWAYS
240 // have access to the parcellation image
241 std::unique_ptr< MR::Image<node_t> > buffer;
242
243
244 vector<Node> nodes;
245 vector<Edge> edges;
246
247
248 // For converting connectome matrices to vectors
249 std::unique_ptr<MR::Connectome::Mat2Vec> mat2vec;
250
251
252 // If a lookup table is provided, this container will store the
253 // properties of each node as provided in that file (e.g. name & colour)
255
256
257 // Fixed lighting settings from the main window, and popup dialog
258 GL::Lighting lighting;
259 std::unique_ptr<LightingDock> lighting_dock;
260
261
262 // Model for selecting connectome matrices
263 Matrix_list_model* matrix_list_model;
264
265
266 // Node selection
267 Tool::Dock* node_list;
268
269
270 // Used when the geometry of node visualisation is a sphere
271 Shapes::Sphere sphere;
272 GL::VertexArrayObject sphere_VAO;
273
274 // Used when the geometry of node visualisation is a cube
275 Shapes::Cube cube;
276 GL::VertexArrayObject cube_VAO;
277
278 // Used when the geometry of node visualisation is an image overlay
279 std::unique_ptr<NodeOverlay> node_overlay;
280
281 // Used when the geometry of edge visualisation is a cylinder
282 Shapes::Cylinder cylinder;
283 GL::VertexArrayObject cylinder_VAO;
284
285
286 // Settings related to slab cropping
287 bool is_3D, crop_to_slab;
288 float slab_thickness;
289
290
291 // Settings for colour bars
292 bool show_node_colour_bar, show_edge_colour_bar;
293
294
295 // Current node visualisation settings
296 node_visibility_t node_visibility;
297 node_geometry_t node_geometry;
298 node_colour_t node_colour;
299 node_size_t node_size;
300 node_alpha_t node_alpha;
301
302 // Values that need to be stored locally w.r.t. node visualisation
303 BitSet selected_nodes;
304 node_t selected_node_count;
305 NodeSelectionSettings node_selection_settings;
306
307 bool have_meshes;
308 node_visibility_matrix_operator_t node_visibility_matrix_operator;
309 node_property_matrix_operator_t node_colour_matrix_operator, node_size_matrix_operator, node_alpha_matrix_operator;
310 Eigen::Array3f node_fixed_colour;
311 size_t node_colourmap_index;
312 bool node_colourmap_invert;
313 float node_fixed_alpha;
314 float node_size_scale_factor;
315 float voxel_volume;
316 FileDataVector node_values_from_file_visibility;
317 FileDataVector node_values_from_file_colour;
318 FileDataVector node_values_from_file_size;
319 FileDataVector node_values_from_file_alpha;
320
321
322 // Current edge visualisation settings
323 edge_visibility_t edge_visibility;
324 edge_geometry_t edge_geometry;
325 edge_colour_t edge_colour;
326 edge_size_t edge_size;
327 edge_alpha_t edge_alpha;
328
329 // Other values that need to be stored w.r.t. edge visualisation
330 bool have_exemplars, have_streamtubes;
331 Eigen::Array3f edge_fixed_colour;
332 size_t edge_colourmap_index;
333 bool edge_colourmap_invert;
334 float edge_fixed_alpha;
335 float edge_size_scale_factor;
336 FileDataVector edge_values_from_file_visibility;
337 FileDataVector edge_values_from_file_colour;
338 FileDataVector edge_values_from_file_size;
339 FileDataVector edge_values_from_file_alpha;
340
341 // Limits on drawing line thicknesses from OpenGL
342 GLint line_thickness_range_aliased[2];
343 GLint line_thickness_range_smooth[2];
344
345
346 // Classes to receive inputs from the colourmap buttons and act accordingly
347 NodeColourObserver node_colourmap_observer;
348 EdgeColourObserver edge_colourmap_observer;
349
350
351 // Helper functions
352 void clear_all();
353 void enable_all (const bool);
354 void initialise (const std::string&);
355 void add_matrices (const vector<std::string>&);
356
357 void draw_nodes (const Projection&);
358 void draw_edges (const Projection&);
359
360 bool import_vector_file (FileDataVector&, const std::string&);
361 bool import_matrix_file (FileDataVector&, const std::string&);
362
363 void load_properties();
364
365 void calculate_node_visibility();
366 void calculate_node_colours();
367 void calculate_node_sizes();
368 void calculate_node_alphas();
369
370 void update_node_overlay();
371
372 void calculate_edge_visibility();
373 void calculate_edge_colours();
374 void calculate_edge_sizes();
375 void calculate_edge_alphas();
376
377 // Helper functions for determining actual node / edge visual properties
378 // given current selection status
379 void node_selection_changed (const vector<node_t>&);
380 bool node_visibility_given_selection (const node_t);
381 Eigen::Array3f node_colour_given_selection (const node_t);
382 float node_size_given_selection (const node_t);
383 float node_alpha_given_selection (const node_t);
384 bool edge_visibility_given_selection (const Edge&);
385 Eigen::Array3f edge_colour_given_selection (const Edge&);
386 float edge_size_given_selection (const Edge&);
387 float edge_alpha_given_selection (const Edge&);
388
389 // Helper functions to update the min / max / value / rate of parameter controls
390 void update_controls_node_visibility (const float, const float, const float);
391 void update_controls_node_colour (const float, const float, const float);
392 void update_controls_node_size (const float, const float, const float);
393 void update_controls_node_alpha (const float, const float, const float);
394 void update_controls_edge_visibility (const float, const float, const float);
395 void update_controls_edge_colour (const float, const float, const float);
396 void update_controls_edge_size (const float, const float, const float);
397 void update_controls_edge_alpha (const float, const float, const float);
398
399 // Uses the value of the maximum control to set the maximal limit of the
400 // minimum control, and vice-versa
401 void limit_min_max_controls (AdjustButton* const, AdjustButton* const) const;
402 // Update the values & limits of controls based on statistics of input data
403 void update_control (AdjustButton* const, const float, const float, const float);
404 void update_controls (AdjustButton* const, AdjustButton* const, const float, const float, const float);
405
406 void get_meshes();
407 void get_exemplars();
408 void get_streamtubes();
409
410 bool use_lighting() const;
411 bool use_alpha_nodes() const;
412 bool use_alpha_edges() const;
413
414 float calc_line_width (const float, const bool) const;
415
416 friend class NodeColourObserver;
417 friend class EdgeColourObserver;
418
419 friend class NodeShader;
420 friend class EdgeShader;
421
422 friend class Node_list;
423 friend class Node_list_model;
424
425 };
426
427
428
429 }
430 }
431 }
432}
433
434#endif
435
436
437
438
a class to hold the list of option groups
Definition: app.h:139
object storing information about option parsed from command-line
Definition: app.h:286
a class for storing bitwise information
Definition: bitset.h:43
QCheckBox * edge_visibility_by_nodes_checkbox
Definition: connectome.h:196
AdjustButton * node_colour_lower_button
Definition: connectome.h:172
ColourMapButton * edge_colour_colourmap_button
Definition: connectome.h:205
QCheckBox * edge_geometry_line_smooth_checkbox
Definition: connectome.h:201
void draw(const Projection &transform, bool is_3D, int axis, int slice) override
AdjustButton * edge_size_lower_button
Definition: connectome.h:214
AdjustButton * node_size_upper_button
Definition: connectome.h:179
AdjustButton * node_alpha_lower_button
Definition: connectome.h:187
QCheckBox * node_visibility_threshold_invert_checkbox
Definition: connectome.h:158
size_t visible_number_colourbars() override
AdjustButton * node_colour_upper_button
Definition: connectome.h:172
AdjustButton * edge_colour_lower_button
Definition: connectome.h:208
QComboBox * node_alpha_matrix_operator_combobox
Definition: connectome.h:183
AdjustButton * edge_visibility_threshold_button
Definition: connectome.h:194
QColorButton * node_colour_fixedcolour_button
Definition: connectome.h:168
AdjustButton * node_visibility_threshold_button
Definition: connectome.h:157
QCheckBox * node_geometry_overlay_interp_checkbox
Definition: connectome.h:163
QComboBox * node_visibility_matrix_operator_combobox
Definition: connectome.h:153
AdjustButton * node_alpha_upper_button
Definition: connectome.h:187
QComboBox * node_colour_matrix_operator_combobox
Definition: connectome.h:167
AdjustButton * edge_alpha_upper_button
Definition: connectome.h:221
ColourMapButton * node_colour_colourmap_button
Definition: connectome.h:169
AdjustButton * edge_alpha_lower_button
Definition: connectome.h:221
AdjustButton * edge_colour_upper_button
Definition: connectome.h:208
QColorButton * edge_colour_fixedcolour_button
Definition: connectome.h:204
virtual bool process_commandline_option(const MR::App::ParsedOption &opt) override
static void add_commandline_options(MR::App::OptionList &options)
QPushButton * lighting_settings_button
Definition: connectome.h:226
AdjustButton * node_size_lower_button
Definition: connectome.h:179
AdjustButton * edge_size_upper_button
Definition: connectome.h:214
QCheckBox * edge_visibility_threshold_invert_checkbox
Definition: connectome.h:195
QComboBox * node_size_matrix_operator_combobox
Definition: connectome.h:175
MR::Connectome::node_t node_t
Definition: connectome.h:40
Definition: base.h:24
int axis