MorphoGraphX  2.0-1-227
MeshProcessHeatMap.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef MESH_PROCESS_HEAT_MAP_HPP
12 #define MESH_PROCESS_HEAT_MAP_HPP
13 
14 #include <limits>
15 
16 #include <QTreeWidgetItem>
17 #include <SystemProcessSave.hpp>
18 
19 #include <Process.hpp>
20 #include <Progress.hpp>
21 #include <Information.hpp>
22 
23 #include "ui_HeatMap.h"
24 #include "ui_LoadHeatMap.h"
25 #include "ui_HeatMapNew.h"
26 #include "ui_HeatMapManipulate.h"
27 
28 // define a version of UM here as we use it in processParms,
29 // and it may not yet be loaded when we access them
30 //#define local_UM (QString::fromWCharArray(L"\xb5m"))
31 
32 class Ui_LoadHeatMap;
33 
34 namespace mgx
35 {
36  typedef std::pair<vertex, vertex> VertexPr;
37  typedef std::set<vertex> Set;
38  mgxBase_EXPORT void getBBox(const HVec3F& pts, Point3f* bBox);
39 
42 
49  class mgxBase_EXPORT ComputeHeatMap : public Process
50  {
51  Q_OBJECT
52  public:
53  ComputeHeatMap(const Process& process) : Process(process)
54  {
55 
56  setName("Mesh/Heat Map/Heat Map Classic");
57  setDesc("Generate heat map for the current mesh");
58  setIcon(QIcon(":/images/MakeHeatMap.png"));
59 
60  addParm("Type","Area: signal/geometry on curved surfaces\n"
61  "Volume: for 3D only,\n"
62  "Walls: quantify signal or geometry at cell borders.","Area");
63  addParm("Visualize","Geometry: cell areas or volume,\n"
64  "Border signal: signal associated with cell borders, within a given distance (Border Size)\n"
65  "Interior signal: total signal of a cell - border signal.","Geometry");
66  addParm("FileName","Path to output file.","");
67  addParm("ReportFields","Options to report the following fields in spreadsheet: Geometry, Signal, Border-Interior","Geometry");
68  addParm("Man. Range","Manually define the range of the color map.","No");
69  addParm("Range Min","Color map lower bound.","0");
70  addParm("Range Max","Color map upper bound.","65535");
71  addParm("Signal Avg","Option to normalize the signal by cell area or volume","Yes");
72  addParm("Global Coord","Apply the rotation/translation of the stack to the cell center coordinates.","No");
73  addParm("Polarity Type","Experimental option, attempt to determine cell signal polarity based on strength of signal on different walls.\n"
74  "Cell Average: compare each wall signal to signal average,\n"
75  "Wall/Min: compare wall signal to the weakest wall signal in the cell.","None");
76  addParm("Change Map","Compare two meshes with each other (deformation or change in signal).","No");
77  addParm("Increasing","Increasing: the current mesh is the reference (T0), the other mesh is the changed state (T1),\n"
78  "Decreasing: the other mesh is the reference (T0), the current mesh is the changed state (T1).",
79  "Increasing", QStringList() <<"Increasing" << "Decreasing");
80  addParm("Diff Type","Ratio: area or signal in changed state(T1) / area or signal in reference (T0),\n"
81  "Difference: area or signal in changed state(T1) - area or signal in reference (T0),"
82  "Growth: (Ratio -1) / growth time.","Ratio", QStringList() << "Ration" <<"Grwoth"<< "Difference");
83  addParm("Growth Time","Time interval between the two samples.",".001");
84  addParm("Border Size(µm)","Border Size in µm","1.0");
85 
86  }
87 
88  bool run();
89 
90  enum MapType { AREA, VOLUME, WALL };
91 
92  enum SignalType {
93  GEOMETRY = 0x1,
94  BORDER = 0x2,
95  INTERIOR = 0x4,
96  TOTAL = 0x8,
97  BORDER_TOTAL = 0x10,
98  INTERIOR_TOTAL = 0x20
99  };
100 
101  enum PolarityType { NONE, CELL_AVERAGE, WALL_MIN };
102 
110  DECREASING_GROWTH
111  };
112 
113  struct ImageHeatMaps {
114  IntFloatAttr LabelGeom; // Label Areas
115  IntFloatAttr LabelBordGeom; // Area of label borders
116  IntFloatAttr LabelIntGeom; // Area of label interiors
117  IntFloatAttr LabelTotalSig; // Label total signal
118  IntFloatAttr LabelBordSig; // Label border signal
119  IntFloatAttr LabelIntSig; // Label interior signal
120  IntFloatAttr LabelHeatAmt; // Label HeatMap temp for change map
121  IntHVec3uMap LabelTris; // Label triangle lists
122  IntVIdSetMap LabelPts; // Label triangle list points
123 
124  IntIntFloatAttr WallBordGeom; // Wall border areas
125  IntIntFloatAttr WallBordSig; // Wall border signal
126  IntIntFloatAttr WallHeatAmt; // Wall border signal amt for change map
127  };
128 
129  bool run(Mesh* mesh1, Mesh* mesh2, MapType map, SignalType signal,
130  const QString& reportFile, int report, bool manualRange, float rangeMin,
131  float rangeMax, bool signalAverage, bool globalCoordinates, PolarityType polarity,
132  MultiMapType multiMapType, float growthTime, float borderSize);
133 
134  bool initialize(QWidget* parent);
135 
136  QDialog* dlg;
137 
138  // was protected, now accessed by cell atlas
139  bool getLabelMaps(ImageHeatMaps& map, Mesh* mesh);
140 
141  protected slots:
142  void changeMapType(const QString& type);
143  void selectSpreadsheetFile();
144 
145  protected:
146 
149  int report;
151  float rangeMin;
152  float rangeMax;
156  bool changeMap;
158  float growthTime;
159  float borderSize;
160  };
161 
167  class mgxBase_EXPORT DeleteHeatRangeLabels : public Process
168  {
169  public:
170  DeleteHeatRangeLabels(const Process& process) : Process(process)
171  {
172  setName("Mesh/Heat Map/Delete Heat Range Labels");
173  setDesc("Delete labels with heat within a given range. The heat is given relative to the total range.");
174  setIcon(QIcon(":/images/ClearStack.png"));
175 
176  addParm("Rescale","Redefine the lower/upper bounds of colormap to fit the range of values.","Yes",booleanChoice());
177  addParm("Delete cells","Delete vertices within a given range of the color map (Min Heat-Max Heat).","No",booleanChoice());
178  addParm("Min Heat","Lower bound of color value for which the cells will be deleted (empty for current min).","");
179  addParm("Max Heat","Upper bound of color value for which the cells will be deleted (empty for current max).","");
180  }
181 
182  bool run()
183  {
184  if(!checkState().mesh(MESH_NON_EMPTY))
185  return false;
186  float min, max;
187  bool ok = true;
188  if(parm("Min Heat").isEmpty())
189  min = std::numeric_limits<float>::quiet_NaN();
190  else
191  min = parm("Min Heat").toFloat(&ok);
192  if(not ok)
193  return setErrorMessage("Error, parameter 'Min Heat' must be either empty, or a number");
194  if(parm("Max Heat").isEmpty())
195  max = std::numeric_limits<float>::quiet_NaN();
196  else
197  max = parm("Max Heat").toFloat(&ok);
198  if(not ok)
199  return setErrorMessage("Error, parameter 'Min Heat' must be either empty, or a number");
200  return run(currentMesh(), stringToBool(parm("Rescale")), stringToBool(parm("Delete cells")), min, max);
201  }
202 
203  bool run(Mesh* mesh, bool rescale, bool deleteCells, float min, float max);
204 
205  };
206 
212  class mgxBase_EXPORT RescaleHeatMap : public Process
213  {
214  public:
215  RescaleHeatMap(const Process& process) : Process(process)
216  {
217  setName("Mesh/Heat Map/Heat Map Set Range");
218  setDesc("Change the range of the current heat map for display.");
219  setIcon(QIcon(":/images/MakeHeatMap.png"));
220 
221  addParm("Min","Lower bound (empty for current)","");
222  addParm("Max","Upper bound (empty for current)","");
223  }
224 
225  bool run()
226  {
227  if(!checkState().mesh(MESH_HEAT))
228  return false;
229  Mesh *mesh = currentMesh();
230  bool ok = true;
231  float min, max;
232  if(parm("Min").isEmpty())
233  min = std::numeric_limits<float>::quiet_NaN();
234  else
235  min = parm("Min").toFloat(&ok);
236  if(not ok)
237  return setErrorMessage("Error, parameter 'Min' must be either empty, or a number");
238  if(parm("Max").isEmpty())
239  max = std::numeric_limits<float>::quiet_NaN();
240  else
241  max = parm("Max").toFloat(&ok);
242  if(not ok)
243  return setErrorMessage("Error, parameter 'Max' must be either empty, or a number");
244  return run(mesh, min, max);
245  }
246 
247  bool run(Mesh* m, float min, float max);
248 
249  };
250 
256  class mgxBase_EXPORT SaveHeatMap : public Process
257  {
258  Q_OBJECT
259  public:
260  SaveHeatMap(const Process& process) : Process(process)
261  {
262  setName("Mesh/Heat Map/Heat Map Save");
263  setDesc("Save heat map to a file");
264  setIcon(QIcon(":/images/MakeHeatMap.png"));
265 
266  addParm("Filename","Path to spreadsheat file.","");
267  }
268 
269  bool initialize(QWidget* parent);
270 
271  bool run()
272  {
273  if(!checkState().mesh(MESH_ANY))
274  return false;
275  Mesh *mesh = currentMesh();
276  return run(mesh, parm("Filename"));
277  }
278 
279  bool run(Mesh* mesh, const QString& filename);
280 
281  };
282 
295  class mgxBase_EXPORT LoadHeatMap : public Process
296  {
297  Q_OBJECT
298  public:
299  LoadHeatMap(const Process& process) : Process(process)
300  {
301  setName("Mesh/Heat Map/Heat Map Load");
302  setDesc("Load a heat map file and set the corresponding heat for each label");
303 
304  addParm("File Name","Path to spreadsheet file.","");
305  addParm("Column","Column (name or number) of the csv file to load for display, s/b > 0, first column is label.\n", "2");
306  addParm("Border size (µm)","Width of cell outline used for vizualization of 'wall' colormaps","1.0");
307  setIcon(QIcon(":/images/MakeHeatMap.png"));
308  }
309 
310  bool initialize(QWidget* parent);
311 
312  bool run()
313  {
314  if(!checkState().mesh(MESH_ANY))
315  return false;
316  Mesh *mesh = currentMesh();
317  return run(mesh, parm("File Name"), parm("Column").toInt(), parm("Border size (µm)").toFloat());
318  }
319 
320  bool run(Mesh* mesh, const QString& filename, int column, float border_size);
321  bool selectFile(const QString& filename);
322 
323  public slots:
324  void selectFile();
325  void selectColumn(int c);
326 
327  protected:
328  QDialog *dlg;
329  Ui_LoadHeatMap *ui = 0;
330  QList<QString> columnUnits;
331  };
332 
338  // DUPLICATED CODE?
339  /* class mgxBase_EXPORT SaveParents : public Process
340  {
341  public:
342  SaveParents(const Process& process) : Process(process) {}
343 
344  bool initialize(QStringList& parms, QWidget* parent);
345 
346  bool run(const QStringList &parms)
347  {
348  if(!checkState().mesh(MESH_ANY))
349  return false;
350  Mesh *mesh = currentMesh();
351  return run(mesh, parms[0]);
352  }
353 
354  bool run(Mesh* mesh, const QString& filename);
355 
356  QString name() const { return "Mesh/Lineage Tracking/Save Parents"; }
357  QString description() const { return "Save map of labels to parents labels to a file"; }
358  QStringList parmNames() const { return QStringList() << "Filename"; }
359  QStringList parmDescs() const { return QStringList() << "Path to label parents file."; }
360  QStringList parmDefaults() const { return QStringList() << ""; }
361  QIcon icon() const { return QIcon(":/images/Parents.png"); }
362  };
363  */
367 /*
368  class mgxBase_EXPORT ResetParents : public Process
369  {
370  public:
371  ResetParents(const Process& process) : Process(process) {}
372 
373  bool run(const QStringList &)
374  {
375  if(!checkState().mesh(MESH_ANY))
376  return false;
377  Mesh *mesh = currentMesh();
378  return run(mesh);
379  }
380 
381  bool run(Mesh* mesh);
382 
383  QString name() const { return "Mesh/Lineage Tracking/Clear Parents"; }
384  QString description() const { return "Clear mapping from parents to labels"; }
385  QStringList parmNames() const { return QStringList(); }
386  QStringList parmDescs() const { return QStringList(); }
387  QIcon icon() const { return QIcon(":/images/Parents.png"); }
388  };
389 */
390 
391  class mgxBase_EXPORT ScaleHeatMap : public Process
392  {
393  public:
394  ScaleHeatMap(const Process& process) : Process(process)
395  {
396  setName("Mesh/Heat Map/Operators/Heat Map Scale Values");
397  setDesc("Scales the current heat map values according to the chosen type.\n"
398  "log uses the base of 10. inverse of 0 is 0 \n"
399  "the parameter (P) is used for: \n"
400  "Pow (^P) \n"
401  "Add (+P) \n"
402  "Mult (*P)");
403  setIcon(QIcon(":/images/MakeHeatMap.png"));
404 
405  addParm("Type","Type","inverse", QStringList() << "inverse" << "square" << "sqrt" << "log" << "pow" << "ordinal" << "add" << "mult");
406  addParm("Parameter","Parameter","0.0");
407  }
408 
409  bool run()
410  {
411  if(!checkState().mesh(MESH_ANY))
412  return false;
413  Mesh *mesh = currentMesh();
414  return run(mesh, parm("Type"), parm("Parameter").toDouble());
415  }
416 
417  bool run(Mesh* mesh, QString type, double parameter);
418 
419  };
420 
421  class mgxBase_EXPORT NormalizeHeatMap : public Process
422  {
423  public:
424  NormalizeHeatMap(const Process& process) : Process(process)
425  {
426  setName("Mesh/Heat Map/Operators/Heat Map Normalize");
427  setDesc("Normalizes the current heat map values according to the chosen type.");
428  setIcon(QIcon(":/images/MakeHeatMap.png"));
429 
430  addParm("Type","Type","Max Min", QStringList() << "Max Min" << "Selected Cells");
431  }
432 
433  bool run()
434  {
435  if(!checkState().mesh(MESH_ANY))
436  return false;
437  Mesh *mesh = currentMesh();
438  return run(mesh, parm("Type"));
439  }
440 
441  bool run(Mesh* mesh, QString type);
442 
443  };
444 
445  class mgxBase_EXPORT CreateAttrMap : public Process
446  {
447  public:
448  CreateAttrMap(const Process& process) : Process(process)
449  {
450 
451  setName("Mesh/Heat Map/Operators/Export Heat to Attr Map");
452  setDesc("Creates an Attribute map of the chosen name (preceding Measure Label Double) using the current heat map values.");
453  setIcon(QIcon(":/images/MakeHeatMap.png"));
454 
455  addParm("Prefix","Prefix","Measure Label Double");
456  addParm("Name","Name","Custom Heat Map");
457  addParm("Key","Keys of Attr Map","Label", QStringList() << "Label" << "Parent");
458  addParm("Heat Map Type","Type of Heat Map to be saved","Label Heat", QStringList() << "Label Heat" << "Parent Heat");
459  addParm("Save to","Save to which mesh","Active Mesh", QStringList() << "Active Mesh" << "Other Mesh");
460  addParm("Clean","Remove entries for non-existent cells","No",booleanChoice());
461  }
462 
463  bool run()
464  {
465  if(!checkState().mesh(MESH_ANY))
466  return false;
467  Mesh *m = currentMesh();
468  Mesh *m2;
469  if(currentMesh() == mesh(0))
470  m2 = mesh(1);
471  else
472  m2 = mesh(0);
473  return run(m, m2, parm("Prefix"), parm("Name"), parm("Key"), parm("Heat Map Type"), parm("Save to"),stringToBool(parm("Clean")));
474  }
475 
476  bool run(Mesh* m, Mesh* m2, QString prefix, QString name, QString key, QString value, QString meshNumber, bool cleanMesh);
477 
478  };
479 
480 //NEED TO ADD OPTION TO SPECIFY WHERE TO SAVE ALL ATTRIBUTE MAPS
481  class mgxBase_EXPORT HeatMapGrowth : public Process
482  {
483  public:
484  HeatMapGrowth(const Process& process) : Process(process)
485  {
486  setName("Mesh/Heat Map/Analysis/Growth Analysis 2D");
487  setDesc("Creates all attribute maps with a chosen prefix required for heat-map based growth analysis using the current heat map values.");
488  setIcon(QIcon(":/images/MakeHeatMap.png"));
489 
490  addParm("Name Prefix (optional)","Name Prefix (optional)","");
491  addParm("Name Time Point 1","Name Time Point 1","T1");
492  addParm("Name Time Point 2","Name Time Point 2","T2");
493  addParm("Create Custom Dirs From Heat","Create Custom Dirs From Current Heat Map","No",booleanChoice());
494  }
495 
496  bool run()
497  {
498  if(!checkState().mesh(MESH_ANY))
499  return false;
500  Mesh *m = currentMesh();
501  Mesh *m2;
502  if(currentMesh() == mesh(0))
503  m2 = mesh(1);
504  else
505  m2 = mesh(0);
506  return run(m, m2, parm("Name Prefix (optional)"), parm("Name Time Point 1"), parm("Name Time Point 2"), stringToBool(parm("Create Custom Dirs From Heat")));
507  }
508 
509  bool run(Mesh* m, Mesh* m2, QString name, QString t1, QString t2, bool createCustom);
510 
511  };
512 
513  class mgxBase_EXPORT CleanHeatMap : public Process
514  {
515  public:
516  CleanHeatMap(const Process& process) : Process(process)
517  {
518  setName("Mesh/Heat Map/Operators/Clean Heat Map");
519  setDesc("Removes unwanted entries from the heat map (i.e. values for non-existent cells).");
520  setIcon(QIcon(":/images/MakeHeatMap.png"));
521 
522  addParm("Selection","Eliminate non-selected cells","No",booleanChoice());
523  addParm("Min valid","Minimum valid value","NA");
524  addParm("Max valid","Maximum valid value","NA");
525  }
526 
527  bool run()
528  {
529  if(!checkState().mesh(MESH_ANY))
530  return false;
531  Mesh *m = currentMesh();
532  Mesh *m2;
533  if(currentMesh() == mesh(0))
534  m2 = mesh(1);
535  else
536  m2 = mesh(0);
537  return run(m, m2, /*parm("Selection"),*/ stringToBool(parm("Selection")), parm("Min valid"), parm("Max valid"));
538  }
539 
540  bool run(Mesh* m, Mesh* m2, /*QString selectedMap,*/ bool useSelection, QString minValue, QString maxValue);
541 
542  };
543 
544  class mgxBase_EXPORT CombineAttrMaps : public Process
545  {
546  public:
547  CombineAttrMaps(const Process& process) : Process(process)
548  {
549 
550  setName("Mesh/Heat Map/Operators/Heat Map Transform");
551  setDesc("Creates an Attribute map of the chosen name (preceding Measure Label Double) using the current heat map values.");
552  setIcon(QIcon(":/images/MakeHeatMap.png"));
553 
554  addParm("Attr Map 1","Attr Map 1","A1");
555  addParm("Attr Map 2","Attr Map 2","A2");
556  addParm("Combination","Combination","Yes");
557  addParm("Combination Type","Combination Type","Addition (A + B)");
558  addParm("Transformation","Transformation","No");
559  addParm("Transformation Type","Transformation Type","Neighborhood");
560  addParm("Transformation Type 2","Transformation Type 2","Average");
561  addParm("Ignore Parent","Ignore Parent","-1");
562  addParm("Lower Threshold","Lower Threshold","0");
563  addParm("Upper Threshold","Upper Threshold","100000");
564  addParm("New Attr Map","Combined Attr Map","Combined Attr Map");
565  }
566 
567  bool initialize(QWidget *parent);
568 
569  bool run()
570  {
571  if(!checkState().mesh(MESH_ANY))
572  return false;
573  Mesh *m = currentMesh();
574  return run(m, parm("Attr Map 1"), parm("Attr Map 2"),
575  stringToBool(parm("Combination")), parm("Combination Type"),
576  stringToBool(parm("Transformation")), parm("Transformation Type"), parm("Transformation Type 2"), parm("Ignore Parent").toInt(), parm("Lower Threshold").toDouble(), parm("Upper Threshold").toDouble(),
577  parm("New Attr Map"));
578  }
579 
580  bool run(Mesh* m, QString name1, QString name2,
581  bool combination, QString combinationType,
582  bool transformation, QString transformationType, QString transformationType2, int ignoreParent, double lowerT, double upperT,
583  QString combinedAttrMap);
584 
585  };
586 
587  class mgxBase_EXPORT SelectByHeat : public Process
588  {
589  public:
590  SelectByHeat(const Process& process) : Process(process)
591  {
592  setName("Mesh/Heat Map/Heat Map Select");
593  setDesc("Select Cells according to their heat value.");
594  setIcon(QIcon(":/images/MakeHeatMap.png"));
595 
596  addParm("Lower Threshold","Lower Threshold","0.0");
597  addParm("Upper Threshold","Upper Threshold","1.0");
598  addParm("Reset Selection","Reset Selection","Yes",booleanChoice());
599 
600  }
601 
602  bool run()
603  {
604  if(!checkState().mesh(MESH_ANY))
605  return false;
606  Mesh *m = currentMesh();
607  return run(m, parm("Lower Threshold").toDouble(), parm("Upper Threshold").toDouble(), stringToBool(parm("Reset Selection")));
608  }
609 
610  bool run(Mesh* m, double lowerThreshold, double upperThreshold, bool resetSelection);
611 
612  };
613 
614  class mgxBase_EXPORT SwitchHeatParent : public Process
615  {
616  public:
617  SwitchHeatParent(const Process& process) : Process(process)
618  {
619  setName("Mesh/Heat Map/Operators/Switch Heat and Parent");
620  setDesc("Select Cells according to their heat value.");
621  setIcon(QIcon(":/images/MakeHeatMap.png"));
622 
623  addParm("Direction","Direction","Heat -> Parent", QStringList() << "Heat -> Parent" << "Parent -> Heat" << "Parent <-> Heat"); // 0
624  }
625 
626  bool run()
627  {
628  if(!checkState().mesh(MESH_ANY))
629  return false;
630  Mesh *m = currentMesh();
631  return run(m, parm("Direction"));
632  }
633 
634  bool run(Mesh* m, QString direction);
635 
636  };
637 
638 
639  class mgxBase_EXPORT HeatAndChangeMap : public Process
640  {
641  Q_OBJECT
642  public:
643  QStringList measureProcesses;
644  Ui_HeatMapDialogNew ui;
645  Mesh *m;
646 
647  HeatAndChangeMap(const Process& process) : Process(process)
648  {
649  setName("Mesh/Heat Map/Heat Map");
650  setDesc("New Heat Map process that supports Attribute Maps used for: \n"
651  "- generation of heat maps of any measure or importing attribute maps as heat maps \n"
652  "- generation of change maps of any measure or attribute maps \n"
653  "- generation of heat maps based on label or parent");
654 
655  addParm("Measure","Measure","");
656  addParm("Force Recalc","Force Recalc","No",booleanChoice());
657  addParm("Identical Label Behavior","Identical Label Behavior","Sum", QStringList() << "Sum" << "Average" << "Max"<<"Min"<<"Max-Min");
658  addParm("Change Map","Change Map","No",booleanChoice());
659  addParm("Change Map Dir","Change Map Dir","Increasing", QStringList() << "Increasing" << "Decreasing");
660  addParm("Change Map Type","Change Map Type","Ratio", QStringList() << "Ratio" << "Difference");
661  addParm("Use Labels Active Mesh","Use Labels Active Mesh","Yes",booleanChoice());
662  addParm("Use Labels Inactive Mesh","Use Labels Inactive Mesh","No",booleanChoice());
663 
664 
665  setIcon(QIcon(":/images/MakeHeatMap.png"));
666  }
667 
668  bool initialize(QWidget *parent);
669 
670  bool run()
671  {
672  if(!checkState().mesh(MESH_ANY))
673  return false;
674  Mesh *m = currentMesh();
675  Mesh* m2;
676  if(currentMesh() == mesh(0))
677  m2 = mesh(1);
678  else
679  m2 = mesh(0);
680 
681  return run(m, m2, parm("Measure"), stringToBool(parm("Force Recalc")), parm("Identical Label Behavior"),
682  stringToBool(parm("Change Map")), parm("Change Map Dir"), parm("Change Map Type")/*, stringToBool(parms[7]), parms[8].toDouble(), parms[9].toDouble()*/,
683  stringToBool(parm("Use Labels Active Mesh")), stringToBool(parm("Use Labels Inactive Mesh")));
684  }
685 
686  bool getData(Mesh* m, QString measureFolder, QString measure, bool forceRecalc, AttrMap<int, double>& data);
687 
688  bool run(Mesh* m, Mesh* m2, QString measure, bool forceRecalc, QString identicalLabel,
689  bool changeMap, QString changeDir, QString changeType, bool m1Labels, bool m2Labels);
690 
691 
692  public slots:
693  void changeMapType(const QString& type);
694  };
695 
696  class mgxBase_EXPORT RunAllParentHeat : public Process
697  {
698  public:
699  RunAllParentHeat(const Process& process) : Process(process)
700  {
701  setName("Mesh/Heat Map/Analysis/Parent Heats");
702  setDesc("Computes parent based heat-maps for all identical label behaviour options. Stores in attribute maps");
703  addParm("Prefix","String to prepend to attr map names","");
704  addParm("Attr map","Name of attribute map to be used for parent heats","");
705  setIcon(QIcon(":/images/MakeHeatMap.png"));
706  }
707 
708  bool run();
709  };
710 
711 
712  class mgxBase_EXPORT HeatMapCellType : public Process
713  {
714  public:
715  HeatMapCellType(const Process& process) : Process(process)
716  {
717  setName("Mesh/Heat Map/Operators/Heat Map Binning");
718  setDesc("Use the current heat map to create a binning of based on cells or values and set the parent label according to the bin.\n"
719  "In Threshold mode only two bins are created based on the parameters in the process Select By Heat");
720  setIcon(QIcon(":/images/MakeHeatMap.png"));
721 
722  addParm("Mode","Mode","Bins Cells", QStringList() << "Bins Cells" << "Bins Heat" << "Threshold");
723  addParm("Nr of Bins","Nr of Bins","5");
724 
725  }
726 
727  bool run()
728  {
729  Mesh* m = currentMesh();
730  return run(m, parm("Mode"), parm("Nr of Bins").toInt());
731  }
732 
733  bool run(Mesh* m, QString mode, int bins);
734 
735  };
736 
737  class mgxBase_EXPORT HeatMapAllMeasures2D : public Process
738  {
739  public:
740  HeatMapAllMeasures2D(const Process &process): Process(process)
741  {
742  setName("Mesh/Heat Map/Analysis/Cell Analysis 2D");
743  setDesc("Calculates ALL 2D measure maps. (Might take a bit depending on the mesh.");
744  setIcon(QIcon(":/images/CellTypeRecognitionSpecification.jpeg"));
745 
746  addParm("Exclude Slow Measures","Exclude Slow Measures","Yes",booleanChoice());
747  }
748 
749  bool run(){
750  return run(stringToBool(parm("Exclude Slow Measures")));
751  }
752 
753  bool run(bool excludeSlow);
754 
755  };
756 
757  class mgxBase_EXPORT HeatMapSmooth : public Process
758  {
759  public:
760  HeatMapSmooth(const Process &process): Process(process)
761  {
762  setName("Mesh/Heat Map/Heat Map Smooth");
763  setDesc("Smooth the current heat map across the cell neighborhood.\n"
764  "Heat values can be weighted by cell area and the result can be directly exported to an Attr Map");
765  setIcon(QIcon(":/images/CellTypeRecognitionSpecification.jpeg"));
766 
767  addParm("Passes","Number of smoothing passes","1");
768  addParm("Weights","Weights","None",QStringList() << "None" << "Area");
769  addParm("Rescale Heat","Rescale Heat","Yes",booleanChoice());
770  addParm("Export Attr Map Name","Export Attr Map Name","");
771  }
772 
773  bool run(){
774  Mesh* m = currentMesh();
775  return run(m, parm("Passes").toInt(), parm("Weights"), stringToBool(parm("Rescale Heat")), parm("Export Attr Map Name"));
776  }
777 
778  bool run(Mesh* m, int passes, QString mode, bool rescale, QString attrName);
779 
780  };
781 
782  class mgxBase_EXPORT ApplyHeat : public Process
783  {
784  public:
785  ApplyHeat(const Process &process) : Process(process) {}
786 
787  bool run(const QStringList& parms)
788  {
789  if(!checkState().mesh(MESH_NON_EMPTY))
790  return false;
791  Mesh* m = currentMesh();
792  return run(m, parms[0], parms[1].toDouble(), parms[2].toDouble(), parms[3].toDouble());
793  }
794 
795  bool run(Mesh* mesh, const QString& heatUnit, double heat, double minHeat, double maxHeat);
796 
797  QString name() const { return "Mesh/Heat Map/Apply Heat"; }
798  QString description() const { return "Apply heat to selected labels and scale the heat to range"; }
799  QStringList parmNames() const { return QStringList() << "Units" << "Heat" << "Min Heat" << "Max Heat"; }
800  QStringList parmDescs() const { return QStringList()
801  << "Units for the new heat." << "New heat value to apply."
802  << "Lower bound for heat." << "Upper bound for heat."; }
803  QStringList parmDefaults() const { return QStringList() << "" << "1.0" << "1.0" << "10.0"; }
804  QIcon icon() const { return QIcon(":/images/ApplyHeat.png"); }
805  };
806 
807 // class mgxBase_EXPORT HeatMapCellDistanceSignal : public Process
808 // {
809 // public:
810 // HeatMapCellDistanceSignal(const Process &process): Process(process) {}
811 // bool run(const QStringList &parms){
812 // Mesh* m = currentMesh();
813 // return run(m);
814 // }
815 // bool run(Mesh* m);
816 // QString name() const { return "Mesh/Heat Map/Test/Cell Distance Signal"; }
817 // QString description() const { return "Cell Distance Signal"; }
818 // QStringList parmNames() const { return QStringList(); }
819 // QStringList parmDescs() const { return QStringList(); }
820 // QStringList parmDefaults() const { return QStringList();}
821 // QIcon icon() const { return QIcon(":/images/CellTypeRecognitionSpecification.jpeg"); }
822 
823 // };
824 
825  double geoMeanVectorValue(std::vector<double>& values);
826 
827 }
828 
829 // Clear out local_UM.
830 //#undef local_UM
831 
832 #endif
mgx::ApplyHeat::ApplyHeat
ApplyHeat(const Process &process)
Definition: MeshProcessHeatMap.hpp:785
mgx::ApplyHeat::name
QString name() const
Definition: MeshProcessHeatMap.hpp:797
mgx::HeatMapCellType::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:727
mgx::ApplyHeat::description
QString description() const
Definition: MeshProcessHeatMap.hpp:798
mgx::ComputeHeatMap::manualRange
bool manualRange
Definition: MeshProcessHeatMap.hpp:150
mgx::HeatAndChangeMap::ui
Ui_HeatMapDialogNew ui
Definition: MeshProcessHeatMap.hpp:644
mgx::ComputeHeatMap::INCREASING_DIFF
@ INCREASING_DIFF
Definition: MeshProcessHeatMap.hpp:106
mgx::ComputeHeatMap::borderSize
float borderSize
Definition: MeshProcessHeatMap.hpp:159
mgx::ComputeHeatMap::SINGLE
@ SINGLE
Definition: MeshProcessHeatMap.hpp:104
Process.hpp
mgx::deleteCells
mgx_EXPORT bool deleteCells(vvGraph &S, const VtxVec &V)
Check for unlabeled vertices, border triangles and islands of label in preparation to make a cell mes...
mgx::ApplyHeat
Definition: MeshProcessHeatMap.hpp:782
mgx::RescaleHeatMap::RescaleHeatMap
RescaleHeatMap(const Process &process)
Definition: MeshProcessHeatMap.hpp:215
mgx::ApplyHeat::parmDefaults
QStringList parmDefaults() const
Definition: MeshProcessHeatMap.hpp:803
Information.hpp
mgx::ComputeHeatMap::ImageHeatMaps::LabelBordSig
IntFloatAttr LabelBordSig
Definition: MeshProcessHeatMap.hpp:118
mgx::CleanHeatMap::CleanHeatMap
CleanHeatMap(const Process &process)
Definition: MeshProcessHeatMap.hpp:516
mgx::HeatMapCellType::HeatMapCellType
HeatMapCellType(const Process &process)
Definition: MeshProcessHeatMap.hpp:715
mgx::CleanHeatMap::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:527
mgx::SelectByHeat::SelectByHeat
SelectByHeat(const Process &process)
Definition: MeshProcessHeatMap.hpp:590
mgx::NormalizeHeatMap
Definition: MeshProcessHeatMap.hpp:421
mgx::ComputeHeatMap::DECREASING_RATIO
@ DECREASING_RATIO
Definition: MeshProcessHeatMap.hpp:107
mgx::ComputeHeatMap::ImageHeatMaps
Definition: MeshProcessHeatMap.hpp:113
mgx::ComputeHeatMap::ImageHeatMaps::LabelBordGeom
IntFloatAttr LabelBordGeom
Definition: MeshProcessHeatMap.hpp:115
mgx::ComputeHeatMap::ImageHeatMaps::LabelPts
IntVIdSetMap LabelPts
Definition: MeshProcessHeatMap.hpp:122
mgx::LoadHeatMap::LoadHeatMap
LoadHeatMap(const Process &process)
Definition: MeshProcessHeatMap.hpp:299
mgx::ScaleHeatMap::ScaleHeatMap
ScaleHeatMap(const Process &process)
Definition: MeshProcessHeatMap.hpp:394
mgx::HeatAndChangeMap::m
Mesh * m
Definition: MeshProcessHeatMap.hpp:645
mgx::DeleteHeatRangeLabels::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:182
mgx::ComputeHeatMap::mapType
MapType mapType
Definition: MeshProcessHeatMap.hpp:147
mgx::HeatMapCellType
Definition: MeshProcessHeatMap.hpp:712
mgx::CombineAttrMaps::CombineAttrMaps
CombineAttrMaps(const Process &process)
Definition: MeshProcessHeatMap.hpp:547
mgx::ComputeHeatMap::changeMap
bool changeMap
Definition: MeshProcessHeatMap.hpp:156
mgx::ComputeHeatMap::ComputeHeatMap
ComputeHeatMap(const Process &process)
Definition: MeshProcessHeatMap.hpp:53
mgx::ComputeHeatMap::ImageHeatMaps::WallBordSig
IntIntFloatAttr WallBordSig
Definition: MeshProcessHeatMap.hpp:125
mgx::HeatMapSmooth
Definition: MeshProcessHeatMap.hpp:757
mgx::ComputeHeatMap::signalAverage
bool signalAverage
Definition: MeshProcessHeatMap.hpp:153
mgx::ComputeHeatMap::multiMapType
MultiMapType multiMapType
Definition: MeshProcessHeatMap.hpp:157
mgx::DeleteHeatRangeLabels::DeleteHeatRangeLabels
DeleteHeatRangeLabels(const Process &process)
Definition: MeshProcessHeatMap.hpp:170
mgx::ApplyHeat::parmDescs
QStringList parmDescs() const
Definition: MeshProcessHeatMap.hpp:800
mgx::ComputeHeatMap::rangeMin
float rangeMin
Definition: MeshProcessHeatMap.hpp:151
mgx::HVec3F
thrust::host_vector< Point3f > HVec3F
Definition: CudaExport.hpp:26
mgx::ComputeHeatMap::report
int report
Definition: MeshProcessHeatMap.hpp:149
mgx::HeatMapAllMeasures2D::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:749
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::HeatMapGrowth::HeatMapGrowth
HeatMapGrowth(const Process &process)
Definition: MeshProcessHeatMap.hpp:484
mgx::HeatAndChangeMap::HeatAndChangeMap
HeatAndChangeMap(const Process &process)
Definition: MeshProcessHeatMap.hpp:647
mgx::ComputeHeatMap::ImageHeatMaps::LabelGeom
IntFloatAttr LabelGeom
Definition: MeshProcessHeatMap.hpp:114
mgx::NormalizeHeatMap::NormalizeHeatMap
NormalizeHeatMap(const Process &process)
Definition: MeshProcessHeatMap.hpp:424
mgx::SelectByHeat
Definition: MeshProcessHeatMap.hpp:587
mgx::ComputeHeatMap::polarity
PolarityType polarity
Definition: MeshProcessHeatMap.hpp:155
mgx::ComputeHeatMap::globalCoordinates
bool globalCoordinates
Definition: MeshProcessHeatMap.hpp:154
mgx::SaveHeatMap::SaveHeatMap
SaveHeatMap(const Process &process)
Definition: MeshProcessHeatMap.hpp:260
mgx::RescaleHeatMap
Definition: MeshProcessHeatMap.hpp:212
mgx::ComputeHeatMap::growthTime
float growthTime
Definition: MeshProcessHeatMap.hpp:158
mgx::SwitchHeatParent::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:626
mgx::DeleteHeatRangeLabels
Definition: MeshProcessHeatMap.hpp:167
mgx::LoadHeatMap::dlg
QDialog * dlg
Definition: MeshProcessHeatMap.hpp:328
mgx::Process
Definition: Process.hpp:219
mgx::ComputeHeatMap::ImageHeatMaps::LabelTotalSig
IntFloatAttr LabelTotalSig
Definition: MeshProcessHeatMap.hpp:117
mgx::LoadHeatMap::columnUnits
QList< QString > columnUnits
Definition: MeshProcessHeatMap.hpp:330
SystemProcessSave.hpp
mgx::max
T CU_HOST_DEVICE max(const T a, const T b)
Definition: Util.hpp:34
mgx::IntHVec3uMap
std::unordered_map< int, HVec3U > IntHVec3uMap
Map of an integer to a host vector of 3 unsigned integers.
Definition: Mesh.hpp:38
mgx::stringToBool
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
mgx::ApplyHeat::run
bool run(const QStringList &parms)
Definition: MeshProcessHeatMap.hpp:787
mgx::HeatMapAllMeasures2D
Definition: MeshProcessHeatMap.hpp:737
mgx::ComputeHeatMap::ImageHeatMaps::LabelHeatAmt
IntFloatAttr LabelHeatAmt
Definition: MeshProcessHeatMap.hpp:120
mgx::CreateAttrMap::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:463
mgx::SwitchHeatParent
Definition: MeshProcessHeatMap.hpp:614
mgx::HeatMapAllMeasures2D::HeatMapAllMeasures2D
HeatMapAllMeasures2D(const Process &process)
Definition: MeshProcessHeatMap.hpp:740
mgx::NormalizeHeatMap::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:433
mgx::ComputeHeatMap::ImageHeatMaps::LabelIntGeom
IntFloatAttr LabelIntGeom
Definition: MeshProcessHeatMap.hpp:116
mgx::getBBox
mgxBase_EXPORT void getBBox(const HVec3F &pts, Point3f *bBox)
mgx::ApplyHeat::icon
QIcon icon() const
Definition: MeshProcessHeatMap.hpp:804
mgx::ComputeHeatMap::signal
SignalType signal
Definition: MeshProcessHeatMap.hpp:148
mgx::HeatMapSmooth::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:773
mgx::ComputeHeatMap::rangeMax
float rangeMax
Definition: MeshProcessHeatMap.hpp:152
mgx::ComputeHeatMap::dlg
QDialog * dlg
Definition: MeshProcessHeatMap.hpp:136
mgx::HeatAndChangeMap::measureProcesses
QStringList measureProcesses
Definition: MeshProcessHeatMap.hpp:643
mgx::ApplyHeat::parmNames
QStringList parmNames() const
Definition: MeshProcessHeatMap.hpp:799
mgx::VertexPr
std::pair< vertex, vertex > VertexPr
Definition: MeshProcessHeatMap.hpp:36
Progress.hpp
mgx::ComputeHeatMap::MapType
MapType
Definition: MeshProcessHeatMap.hpp:90
mgx::IntVIdSetMap
std::map< int, VIdSet > IntVIdSetMap
Map of an integer to a set of vertex ids.
Definition: Types.hpp:74
mgx::CleanHeatMap
Definition: MeshProcessHeatMap.hpp:513
mgx::Mesh
Definition: Mesh.hpp:54
mgx::ComputeHeatMap
Definition: MeshProcessHeatMap.hpp:49
mgx::ComputeHeatMap::SignalType
SignalType
Definition: MeshProcessHeatMap.hpp:92
mgx::LoadHeatMap
Definition: MeshProcessHeatMap.hpp:295
mgx::SaveHeatMap
Definition: MeshProcessHeatMap.hpp:256
mgx::HeatAndChangeMap
Definition: MeshProcessHeatMap.hpp:639
mgx::Vector< 3, float >
mgx::ComputeHeatMap::ImageHeatMaps::LabelIntSig
IntFloatAttr LabelIntSig
Definition: MeshProcessHeatMap.hpp:119
mgx::min
CU_HOST_DEVICE T min(const T a, const T b)
Definition: Util.hpp:26
mgx::ComputeHeatMap::ImageHeatMaps::WallBordGeom
IntIntFloatAttr WallBordGeom
Definition: MeshProcessHeatMap.hpp:124
mgx::CombineAttrMaps::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:569
mgx::CombineAttrMaps
Definition: MeshProcessHeatMap.hpp:544
mgx::ComputeHeatMap::PolarityType
PolarityType
Definition: MeshProcessHeatMap.hpp:101
mgx::geoMeanVectorValue
double geoMeanVectorValue(std::vector< double > &values)
mgx::ComputeHeatMap::INCREASING_GROWTH
@ INCREASING_GROWTH
Definition: MeshProcessHeatMap.hpp:109
mgx::HeatMapGrowth
Definition: MeshProcessHeatMap.hpp:481
mgx::ComputeHeatMap::ImageHeatMaps::LabelTris
IntHVec3uMap LabelTris
Definition: MeshProcessHeatMap.hpp:121
mgx::CreateAttrMap::CreateAttrMap
CreateAttrMap(const Process &process)
Definition: MeshProcessHeatMap.hpp:448
mgx::ScaleHeatMap::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:409
mgx::ComputeHeatMap::DECREASING_DIFF
@ DECREASING_DIFF
Definition: MeshProcessHeatMap.hpp:108
mgx::CreateAttrMap
Definition: MeshProcessHeatMap.hpp:445
mgx::SaveHeatMap::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:271
mgx::RunAllParentHeat::RunAllParentHeat
RunAllParentHeat(const Process &process)
Definition: MeshProcessHeatMap.hpp:699
mgx::ComputeHeatMap::ImageHeatMaps::WallHeatAmt
IntIntFloatAttr WallHeatAmt
Definition: MeshProcessHeatMap.hpp:126
mgx::SelectByHeat::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:602
mgx::ComputeHeatMap::MultiMapType
MultiMapType
Definition: MeshProcessHeatMap.hpp:103
mgx::HeatMapGrowth::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:496
mgx::HeatAndChangeMap::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:670
mgx::LoadHeatMap::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:312
mgx::ComputeHeatMap::INCREASING_RATIO
@ INCREASING_RATIO
Definition: MeshProcessHeatMap.hpp:105
mgx::RescaleHeatMap::run
bool run()
Runs the process.
Definition: MeshProcessHeatMap.hpp:225
mgx::AttrMap< int, float >
mgx::ScaleHeatMap
Clear label to parent mapping.
Definition: MeshProcessHeatMap.hpp:391
mgx::RunAllParentHeat
Definition: MeshProcessHeatMap.hpp:696
mgx::map
CU_HOST_DEVICE Vector< dim, T > map(const T &(*fct)(const T1 &), const Vector< dim, T1 > &v)
Definition: Vector.hpp:1380
mgx::HeatMapSmooth::HeatMapSmooth
HeatMapSmooth(const Process &process)
Definition: MeshProcessHeatMap.hpp:760
mgx::SwitchHeatParent::SwitchHeatParent
SwitchHeatParent(const Process &process)
Definition: MeshProcessHeatMap.hpp:617
mgx::Set
std::set< vertex > Set
Definition: MeshProcessHeatMap.hpp:37