MorphoGraphX
MeshProcessCurv.hpp
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 TISSUECURVATURE_HPP
12 #define TISSUECURVATURE_HPP
13 
14 #include <Process.hpp>
15 
16 #include <MeshProcessCellMesh.hpp>
17 
18 namespace mgx {
19 namespace process {
22 
28 class TissueCurvature : public MeshProcess {
29 public:
31  : Process(process)
32  , MeshProcess(process)
33  {
34  }
35 
36  bool operator()(const QStringList& parms)
37  {
39  return false;
40  bool ok;
41  float neighborhood = parms[0].toFloat(&ok);
42  if(not ok)
43  return setErrorMessage("Error, parameter 'Radius' must be a number");
44  return operator()(currentMesh(), neighborhood, stringToBool(parms[1]));
45  }
46 
47  bool operator()(Mesh* mesh, float neighborhood, bool checkLabel);
48 
49  QString folder() const {
50  return "Cell Axis/Curvature";
51  }
52  QString name() const {
53  return "Compute Tissue Curvature";
54  }
56  {
57  return "Compute curvature based on simplified mesh (from Make Cells) for a neighborhood of given radius.";
58  }
60  return QStringList() << QString("Radius (%1)").arg(UM) << "Selected cell";
61  }
63  return QStringList() << QString("Radius (%1)").arg(UM) << "Selected cell";
64  }
66  {
67  return QStringList() << "10.0"
68  << "No";
69  }
71  {
72  ParmChoiceMap map;
73  map[1] = booleanChoice();
74  return map;
75  }
76  QIcon icon() const {
77  return QIcon(":/images/Curvature.png");
78  }
79 };
80 
88 public:
90  : Process(process)
91  , MeshProcess(process)
92  {
93  }
94 
95  bool operator()(const QStringList& parms)
96  {
98  return false;
99 
100  bool ok;
101  float heatmapPercentile = parms[2].toFloat(&ok);
102  if(not ok)
103  return setErrorMessage("Error, argument 'Heatmap percentile' must be a number");
104  float axisLineWidth = parms[6].toFloat(&ok);
105  if(not ok)
106  return setErrorMessage("Error, argument 'Line Width' must be a number");
107  float axisLineScale = parms[7].toFloat(&ok);
108  if(not ok)
109  return setErrorMessage("Error, argument 'Line Scale' must be a number");
110  float axisOffset = parms[8].toFloat(&ok);
111  if(not ok)
112  return setErrorMessage("Error, argument 'Line Offset' must be a number");
113  float threshold = parms[9].toFloat(&ok);
114  if(not ok)
115  return setErrorMessage("Error, argument 'Threshold' must be a number");
116 
117  return (*this)(currentMesh(), parms[0], stringToBool(parms[1]), heatmapPercentile, parms[3], QColor(parms[4]),
118  QColor(parms[5]), axisLineWidth, axisLineScale, axisOffset, threshold);
119  }
120 
121  bool operator()(Mesh* mesh, QString DisplayHeatMap, bool compareZero, float heatmapPercentile, QString DisplayCurv,
122  const QColor& ColorExpansion, const QColor& ColorShrinkage, float AxisLineWidth,
123  float AxisLineScale, float AxisOffset, float CurvThreshold);
124 
125  QString folder() const {
126  return "Cell Axis/Curvature";
127  }
128  QString name() const {
129  return "Display Tissue Curvature";
130  }
132  return "Display curvature based on cellular mesh";
133  }
135  {
136  return QStringList() << "Heatmap"
137  << "Compare to 0"
138  << "Heatmap percentile"
139  << "Show Axis"
140  << "Color +"
141  << "Color -"
142  << "Line Width"
143  << "Line Scale"
144  << "Line Offset"
145  << "Threshold";
146  }
147 
149  {
150  return QStringList() << "Display curvature values in max or min direction as a color map.\n"
151  "Average: (CurvMax + CurvMin)/2, SignedAverageAbs: sign(CurvMax or CurvMin) x "
152  "(abs(CurvMax) + abs(CurvMin))/2, \n"
153  "Gaussian:(CurvMax x CurvMin), RootSumSquare: sqrt(CurvMax^2 + CurvMin^2), Anisotropy: "
154  "(CurvMax / CurvMin)."
155  << "Center the color map on zero, if negtive values exist."
156  << "Percentile of values used for color map upper-lower bounds."
157  << "Draw main curvature directions as vectors, scaled by 1/(curvature radius)."
158  << "Color used for convex (curvature > 0)"
159  << "Color used for concave (curvature < 0)"
160  << "Line width"
161  << "Length of the vectors = Scale * 1/(curvature radius)."
162  << "Draw the vector ends a bit tilted up for proper display on surfaces."
163  << "Minimal value of curvature required for drawing the directions.";
164  }
166  {
167  return QStringList() << "SignedAverageAbs"
168  << "Yes"
169  << "85.0"
170  << "Both"
171  << "white"
172  << "red"
173  << "2.0"
174  << "100.0"
175  << "0.1"
176  << "0.0";
177  }
179  {
180  ParmChoiceMap map;
181  map[0] = QStringList() << "none"
182  << "CurvMax"
183  << "CurvMin"
184  << "Average"
185  << "SignedAverageAbs"
186  << "Gaussian"
187  << "RootSumSquare"
188  << "Anisotropy";
189  map[1] = booleanChoice();
190  map[3] = QStringList() << "Both"
191  << "CurvMax"
192  << "CurvMin"
193  << "none";
194  map[4] = QColor::colorNames();
195  map[5] = QColor::colorNames();
196  return map;
197  }
198  QIcon icon() const {
199  return QIcon(":/images/Curvature.png");
200  }
201 };
203 } // namespace process
204 } // namespace mgx
205 
206 #endif
QString folder() const
Folder in which to place the process.
Definition: MeshProcessCurv.hpp:49
QString name() const
Returns the name of the process.
Definition: MeshProcessCurv.hpp:52
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: MeshProcessCurv.hpp:70
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessCurv.hpp:36
Once the curvature tensor has been computed, this process allows to change how it is displayed...
Definition: MeshProcessCurv.hpp:87
arg(const QString &a, int fieldWidth=0, const QChar &fillChar=QLatin1Char( ' ')
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessCurv.hpp:148
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessCurv.hpp:55
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessCurv.hpp:76
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessCurv.hpp:65
Process()
Default constructor.
QString name() const
Returns the name of the process.
Definition: MeshProcessCurv.hpp:128
CheckState checkState()
Call this function and convert the result to a boolean.
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:177
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessCurv.hpp:134
QString folder() const
Folder in which to place the process.
Definition: MeshProcessCurv.hpp:125
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: MeshProcessCurv.hpp:178
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessCurv.hpp:62
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
colorNames()
bool setErrorMessage(const QString &str)
Set an error message that will be displayed if the process returns false.
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessCurv.hpp:95
File containing the definition of a Process.
Mesh * mesh(int i)
Returns the ith mesh.
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessCurv.hpp:59
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessCurv.hpp:198
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
This namespace contains all the classes needed to define processes.
Non-empty mesh.
Definition: Process.hpp:674
QStringList booleanChoice() const
Helper function that provides a list of choices for a boolean argument.
Definition: Process.hpp:609
Mesh * currentMesh()
Returns the current mesh (i.e.
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessCurv.hpp:131
Mesh processes have mutable access to meshes and non-mutable access to stacks.
Definition: Process.hpp:865
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessCurv.hpp:165
Compute the curvature tensor for each cell of a cell mesh.
Definition: MeshProcessCurv.hpp:28