MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeshProcessHeatMap.hpp
1 #ifndef MESH_PROCESS_HEAT_MAP_HPP
2 #define MESH_PROCESS_HEAT_MAP_HPP
3 
4 #include <Process.hpp>
5 
6 #include <limits>
7 
8 class Ui_LoadHeatMap;
9 
10 namespace mgx { namespace process {
11 
12  mgxBase_EXPORT void getBBox(const HVec3F& pts, Point3f* bBox);
13 
16 
22  class mgxBase_EXPORT ComputeHeatMap : public QObject, public MeshProcess {
23  Q_OBJECT
24  public:
25  ComputeHeatMap(const MeshProcess& process) : Process(process), QObject(), MeshProcess(process) {}
26 
27  bool operator()(const QStringList& parms);
28 
29  enum MapType { AREA, VOLUME, WALL };
30 
31  enum SignalType {
32  GEOMETRY = 0x1,
33  BORDER = 0x2,
34  INTERIOR = 0x4,
35  TOTAL = 0x8,
36  BORDER_TOTAL = 0x10,
37  INTERIOR_TOTAL = 0x20
38  };
39 
40  enum PolarityType { NONE, CELL_AVERAGE, WALL_MIN };
41 
42  enum MultiMapType {
43  SINGLE,
44  INCREASING_RATIO,
45  INCREASING_DIFF,
46  DECREASING_RATIO,
47  DECREASING_DIFF,
48  INCREASING_GROWTH,
49  DECREASING_GROWTH
50  };
51 
52  struct ImageHeatMaps {
53  IntFloatMap LabelGeom; // Label Areas
54  IntFloatMap LabelBordGeom; // Area of label borders
55  IntFloatMap LabelIntGeom; // Area of label interiors
56  IntFloatMap LabelTotalSig; // Label total signal
57  IntFloatMap LabelBordSig; // Label border signal
58  IntFloatMap LabelIntSig; // Label interior signal
59  IntFloatMap LabelHeatAmt; // Label HeatMap temp for change map
60  IntHVec3uMap LabelTris; // Label triangle lists
61  IntVIdSetMap LabelPts; // Label triangle list points
62 
63  IntIntFloatMap WallBordGeom; // Wall border areas
64  IntIntFloatMap WallBordSig; // Wall border signal
65  IntIntFloatMap WallHeatAmt; // Wall border signal amt for change map
66  };
67 
68  bool operator()(Mesh* mesh1, Mesh* mesh2, MapType map, SignalType signal, const QString& reportFile, int report,
69  bool manualRange, float rangeMin, float rangeMax, bool signalAverage, bool globalCoordinates,
70  PolarityType polarity, MultiMapType multiMapType, float growthTime, float borderSize);
71 
72  bool initialize(QStringList& parms, QWidget* parent);
73 
74  QString folder() const { return "Heat Map"; }
75  QString name() const { return "Heat Map"; }
76  QString description() const { return "Generate heat map for the current mesh"; }
78  {
79  return QStringList()
80  << "Type" << "Visualize" << "FileName" << "ReportFields" << "Man. Range" << "Range Min"
81  << "Range Max" << "Signal Avg" << "Global Coord" << "Polarity Type" << "Change Map"
82  << "Increasing" << "Diff Type" << "Growth Time" << QString("Border Size(%1)").arg(UM);
83  }
85  {
86  return QStringList()
87  << "Area: signal/geometry on curved surfaces,\n"
88  "Volume: for 3D only,\n"
89  "Walls: quantify signal or geometry at cell borders."
90  << "Geometry: cell areas or volume,\n"
91  "Border signal: signal associated with cell borders, within a given distance (Border Size)\n"
92  "Interior signal: total signal of a cell - border signal.\n"
93  << "Path to output file."
94  << "Options to report the following fields in spreadsheet: Geometry, Signal, Border-Interior"
95  << "Manually define the range of the color map."
96  << "Color map lower bound."
97  << "Color map upper bound."
98  << "Option to normalize the signal by cell area or volume"
99  << "Apply the rotation/translation of the stack to the cell center coordinates."
100  << "Experimental option, attempt to determine cell signal polarity based on strength of signal on "
101  "different walls.\n"
102  "Cell Average: compare each wall signal to signal average,\n"
103  "Wall/Min: compare wall signal to the weakest wall signal in the cell."
104  << "Compare two meshes with each other (deformation or change in signal) .\n"
105  << "Increasing: the current mesh is the reference (T0), the other mesh is the changed state (T1),\n"
106  "Decreasing: the other mesh is the reference (T0), the current mesh is the changed state (T1)."
107  << "Ratio: area or signal in changed state(T1) / area or signal in reference (T0),\n"
108  "Difference: area or signal in changed state(T1) - area or signal in reference (T0),\n"
109  "Growth: (Ratio -1) / growth time.\n"
110  << "Time interval between the two samples." << QString("Border Size(%1)").arg(UM);
111  }
113  {
114  return QStringList()
115  << "Area" << "Geometry" << "" << "Geometry" << "No" << "0" << "65535" << "Yes"
116  << "No" << "None" << "No" << "Yes" << "Ratio" << ".001" << "1.0";
117  }
118  QIcon icon() const { return QIcon(":/images/MakeHeatMap.png"); }
119 
120  QDialog* dlg;
121 
122  protected slots:
123  void changeMapType(const QString& type);
124  void selectSpreadsheetFile();
125 
126  protected:
127  bool getLabelMaps(ImageHeatMaps& map, Mesh* mesh);
128  MapType mapType;
129  SignalType signal;
130  int report;
131  bool manualRange;
132  float rangeMin;
133  float rangeMax;
134  bool signalAverage;
135  bool globalCoordinates;
136  PolarityType polarity;
137  bool changeMap;
138  MultiMapType multiMapType;
139  float growthTime;
140  float borderSize;
141  };
142 
148  class mgxBase_EXPORT DeleteHeatRangeLabels : public MeshProcess {
149  public:
150  DeleteHeatRangeLabels(const MeshProcess& process) : Process(process), MeshProcess(process) {}
151 
152  bool operator()(const QStringList& parms)
153  {
154  if(!checkState().mesh(MESH_NON_EMPTY))
155  return false;
156  float min, max;
157  bool ok = true;
158  if(parms[2].isEmpty())
159  min = std::numeric_limits<float>::quiet_NaN();
160  else
161  min = parms[2].toFloat(&ok);
162  if(not ok)
163  return setErrorMessage("Error, parameter 'Min Heat' must be either empty, or a number");
164  if(parms[3].isEmpty())
165  max = std::numeric_limits<float>::quiet_NaN();
166  else
167  max = parms[3].toFloat(&ok);
168  if(not ok)
169  return setErrorMessage("Error, parameter 'Min Heat' must be either empty, or a number");
170  return (*this)(currentMesh(), stringToBool(parms[0]), stringToBool(parms[1]), min, max);
171  }
172 
173  bool operator()(Mesh* mesh, bool rescale, bool deleteCells, float min, float max);
174 
175  QString folder() const { return "Heat Map"; }
176  QString name() const { return "Delete Heat Range Labels"; }
177  QString description() const { return
178  "Delete labels with heat within a given range. The heat is given relative to the total range."; }
179  QStringList parmNames() const { return QStringList()
180  << "Rescale" << "Delete cells" << "Min Heat" << "Max Heat"; }
181  QStringList parmDescs() const { return QStringList()
182  << "Redefine the lower/upper bounds of colormap to fit the range of values."
183  << "Delete vertices within a given range of the color map (Min Heat-Max Heat)."
184  << "Lower bound of color value for which the cells will be deleted (empty for current min)."
185  << "Upper bound of color value for which the cells will be deleted (empty for current max)."; }
186  QStringList parmDefaults() const { return QStringList() << "Yes" << "No" << "" << ""; }
188  {
189  ParmChoiceMap map;
190  map[0] = booleanChoice();
191  map[1] = booleanChoice();
192  return map;
193  }
194  QIcon icon() const { return QIcon(":/images/ClearStack.png"); }
195  };
196 
202  class mgxBase_EXPORT RescaleHeatMap : public MeshProcess {
203  public:
204  RescaleHeatMap(const MeshProcess& process) : Process(process), MeshProcess(process) {}
205 
206  bool operator()(const QStringList& parms)
207  {
208  if(!checkState().mesh(MESH_HEAT))
209  return false;
210  Mesh* m = currentMesh();
211  bool ok = true;
212  float min, max;
213  if(parms[0].isEmpty())
214  min = std::numeric_limits<float>::quiet_NaN();
215  else
216  min = parms[0].toFloat(&ok);
217  if(not ok)
218  return setErrorMessage("Error, parameter 'Min' must be either empty, or a number");
219  if(parms[1].isEmpty())
220  max = std::numeric_limits<float>::quiet_NaN();
221  else
222  max = parms[1].toFloat(&ok);
223  if(not ok)
224  return setErrorMessage("Error, parameter 'Max' must be either empty, or a number");
225  return (*this)(m, min, max);
226  }
227 
228  bool operator()(Mesh* m, float min, float max);
229 
230  QString folder() const { return "Heat Map"; }
231  QString name() const { return "Rescale Heat Map"; }
232  QString description() const { return "Change the range of the current heat map for display."; }
233  QStringList parmNames() const { return QStringList() << "Min" << "Max"; }
234  QStringList parmDescs() const { return QStringList()
235  << "Lower bound (empty for current)" << "Upper bound (empty for current)"; }
236  QStringList parmDefaults() const { return QStringList() << "" << ""; }
237  QIcon icon() const { return QIcon(":/images/MakeHeatMap.png"); }
238  };
239 
245  class mgxBase_EXPORT SaveHeatMap : public QObject, public MeshProcess {
246  Q_OBJECT
247  public:
248  SaveHeatMap(const MeshProcess& process) : Process(process), QObject(), MeshProcess(process) {}
249 
250  bool initialize(QStringList& parms, QWidget* parent);
251 
252  bool operator()(const QStringList& parms)
253  {
254  if(!checkState().mesh(MESH_ANY))
255  return false;
256  Mesh* m = currentMesh();
257  return (*this)(m, parms[0]);
258  }
259 
260  bool operator()(Mesh* mesh, const QString& filename);
261 
262  QString folder() const { return "Heat Map"; }
263  QString name() const { return "Save Heat Map"; }
264  QString description() const { return "Save heat map to a file"; }
265  QStringList parmNames() const { return QStringList() << "Filename"; }
266  QStringList parmDescs() const { return QStringList() << "Path to spreadsheat file."; }
267  QStringList parmDefaults() const { return QStringList() << ""; }
268  QIcon icon() const { return QIcon(":/images/MakeHeatMap.png"); }
269  };
270 
282  class mgxBase_EXPORT LoadHeatMap : public QObject, public MeshProcess {
283  Q_OBJECT
284  public:
285  LoadHeatMap(const MeshProcess& process) : Process(process) , QObject() , MeshProcess(process) {}
286 
287  bool initialize(QStringList& parms, QWidget* parent);
288 
289  bool operator()(const QStringList& parms)
290  {
291  if(!checkState().mesh(MESH_ANY))
292  return false;
293  Mesh* m = currentMesh();
294  return (*this)(m, parms[0], parms[1].toInt(), parms[2].toFloat());
295  }
296 
297  bool operator()(Mesh* mesh, const QString& filename, int column, float border_size);
298 
299  QString folder() const { return "Heat Map"; }
300  QString name() const { return "Load Heat Map"; }
301  QString description() const { return "Load a heat map file and set the corresponding heat for each label"; }
302  QStringList parmNames() const { return QStringList()
303  << "Filename" << "Column" << QString("Border size (%1)").arg(UM); }
304  QStringList parmDescs() const { return QStringList()
305  << "Path to spreadsheet file."
306  << "Column of the csv file to load for display.\n"
307  "Label: cell labels, Value: original computed values (e.g. growth or signal), Heat: "
308  "values scaled for visualization (always between 0-1)."
309  << "Width of cell outline used for vizualization of 'wall' colormaps"; }
310  QStringList parmDefaults() const { return QStringList() << "" << "2" << "1.0"; }
311  QIcon icon() const { return QIcon(":/images/MakeHeatMap.png"); }
312 
313  public slots:
314  void selectFile(const QString& filename);
315  void selectFile();
316  void selectColumn(int c);
317 
318  protected:
319  QDialog* dlg;
320  Ui_LoadHeatMap* ui;
321  QList<QString> column_unit;
322  };
323 
329  class mgxBase_EXPORT SaveParents : public MeshProcess {
330  public:
331  SaveParents(const MeshProcess& process) : Process(process), MeshProcess(process) {}
332 
333  bool initialize(QStringList& parms, QWidget* parent);
334 
335  bool operator()(const QStringList& parms)
336  {
337  if(!checkState().mesh(MESH_ANY))
338  return false;
339  Mesh* m = currentMesh();
340  return (*this)(m, parms[0]);
341  }
342 
343  bool operator()(Mesh* mesh, const QString& filename);
344 
345  QString folder() const { return "Lineage Tracking"; }
346  QString name() const { return "Save Parents"; }
347  QString description() const { return "Save map of labels to parents labels to a file"; }
348  QStringList parmNames() const { return QStringList() << "Filename"; }
349  QStringList parmDescs() const { return QStringList() << "Path to label parents file."; }
350  QStringList parmDefaults() const { return QStringList() << ""; }
351  QIcon icon() const { return QIcon(":/images/Parents.png"); }
352  };
353 
359  class mgxBase_EXPORT LoadParents : public MeshProcess {
360  public:
361  LoadParents(const MeshProcess& process) : Process(process), MeshProcess(process) {}
362 
363  bool initialize(QStringList& parms, QWidget* parent);
364 
365  bool operator()(const QStringList& parms)
366  {
367  if(!checkState().mesh(MESH_ANY))
368  return false;
369  Mesh* m = currentMesh();
370  return (*this)(m, parms[0]);
371  }
372 
373  bool operator()(Mesh* mesh, const QString& filename);
374 
375  QString folder() const { return "Lineage Tracking"; }
376  QString name() const { return "Load Parents"; }
377  QString description() const { return "Load map of labels to parents from a file"; }
378  QStringList parmNames() const { return QStringList() << "Filename"; }
379  QStringList parmDescs() const { return QStringList() << "Path to label parents file."; }
380  QStringList parmDefaults() const { return QStringList() << ""; }
381  QIcon icon() const { return QIcon(":/images/Parents.png"); }
382  };
383 
387  class mgxBase_EXPORT ResetParents : public MeshProcess {
388  public:
389  ResetParents(const MeshProcess& process) : Process(process), MeshProcess(process) {}
390 
391  bool operator()(const QStringList&)
392  {
393  if(!checkState().mesh(MESH_ANY))
394  return false;
395  Mesh* m = currentMesh();
396  return (*this)(m);
397  }
398 
399  bool operator()(Mesh* mesh);
400 
401  QString folder() const { return "Lineage Tracking"; }
402  QString name() const { return "Clear Parents"; }
403  QString description() const { return "Clear mapping from parents to labels"; }
404  QStringList parmNames() const { return QStringList(); }
405  QStringList parmDescs() const { return QStringList(); }
406  QIcon icon() const { return QIcon(":/images/Parents.png"); }
407  };
409 }}
410 
411 #endif
Definition: MeshProcessHeatMap.hpp:52
QString name() const
Returns the name of the process.
Definition: MeshProcessHeatMap.hpp:402
QString folder() const
Folder in which to place the process.
Definition: MeshProcessHeatMap.hpp:401
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessHeatMap.hpp:268
std::map< int, HVec3U > IntHVec3uMap
Map of an integer to a host vector of 3 unsigned integers.
Definition: Mesh.hpp:68
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessHeatMap.hpp:377
QString folder() const
Folder in which to place the process.
Definition: MeshProcessHeatMap.hpp:74
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessHeatMap.hpp:404
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessHeatMap.hpp:403
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessHeatMap.hpp:233
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessHeatMap.hpp:181
std::map< IntIntPair, float > IntIntFloatMap
Map of a pair of integers to a float.
Definition: Mesh.hpp:112
arg(const QString &a, int fieldWidth=0, const QChar &fillChar=QLatin1Char( ' ')
std::map< int, float > IntFloatMap
Map of an integer to a float.
Definition: Mesh.hpp:58
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessHeatMap.hpp:379
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessHeatMap.hpp:186
Rescale the heat map, specifying new lower and upper bound.
Definition: MeshProcessHeatMap.hpp:202
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessHeatMap.hpp:347
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessHeatMap.hpp:289
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessHeatMap.hpp:301
Save the current heat map in a CSV file.
Definition: MeshProcessHeatMap.hpp:245
QString name() const
Returns the name of the process.
Definition: MeshProcessHeatMap.hpp:376
Store mapping from each label to a label in a different mesh (parent).
Definition: MeshProcessHeatMap.hpp:329
Compute heat map on the current mesh.
Definition: MeshProcessHeatMap.hpp:22
QString folder() const
Folder in which to place the process.
Definition: MeshProcessHeatMap.hpp:230
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessHeatMap.hpp:351
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessHeatMap.hpp:349
QString folder() const
Folder in which to place the process.
Definition: MeshProcessHeatMap.hpp:262
QString name() const
Returns the name of the process.
Definition: MeshProcessHeatMap.hpp:300
QString name() const
Returns the name of the process.
Definition: MeshProcessHeatMap.hpp:263
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessHeatMap.hpp:194
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessHeatMap.hpp:302
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessHeatMap.hpp:179
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessHeatMap.hpp:237
QString folder() const
Folder in which to place the process.
Definition: MeshProcessHeatMap.hpp:345
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessHeatMap.hpp:335
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessHeatMap.hpp:76
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessHeatMap.hpp:267
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessHeatMap.hpp:266
QString name() const
Returns the name of the process.
Definition: MeshProcessHeatMap.hpp:346
std::map< int, VIdSet > IntVIdSetMap
Map of an integer to a set of vertex ids.
Definition: Mesh.hpp:88
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:167
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessHeatMap.hpp:118
QString folder() const
Folder in which to place the process.
Definition: MeshProcessHeatMap.hpp:175
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessHeatMap.hpp:381
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessHeatMap.hpp:84
Load the heat map from a CSV file.
Definition: MeshProcessHeatMap.hpp:282
QString folder() const
Folder in which to place the process.
Definition: MeshProcessHeatMap.hpp:375
Load mapping from each label to a label in a different mesh (parent).
Definition: MeshProcessHeatMap.hpp:359
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessHeatMap.hpp:310
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessHeatMap.hpp:234
QString name() const
Returns the name of the process.
Definition: MeshProcessHeatMap.hpp:176
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessHeatMap.hpp:378
File containing the definition of a Process.
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: MeshProcessHeatMap.hpp:187
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessHeatMap.hpp:380
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessHeatMap.hpp:77
This is the main process class, the one all process inherit from.
Definition: Process.hpp:248
QString name() const
Returns the name of the process.
Definition: MeshProcessHeatMap.hpp:75
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessHeatMap.hpp:406
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessHeatMap.hpp:304
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessHeatMap.hpp:391
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessHeatMap.hpp:265
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessHeatMap.hpp:252
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessHeatMap.hpp:348
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessHeatMap.hpp:350
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessHeatMap.hpp:112
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessHeatMap.hpp:177
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessHeatMap.hpp:232
QString folder() const
Folder in which to place the process.
Definition: MeshProcessHeatMap.hpp:299
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessHeatMap.hpp:236
QString name() const
Returns the name of the process.
Definition: MeshProcessHeatMap.hpp:231
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessHeatMap.hpp:311
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessHeatMap.hpp:206
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessHeatMap.hpp:152
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessHeatMap.hpp:365
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessHeatMap.hpp:264
Clear label to parent mapping.
Definition: MeshProcessHeatMap.hpp:387
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessHeatMap.hpp:405
Mesh processes have mutable access to meshes and non-mutable access to stacks.
Definition: Process.hpp:855
Delete labeling, and possibly cells, if their heat falls within a defined range.
Definition: MeshProcessHeatMap.hpp:148