MorphoGraphX  2.0-1-227
MeshProcessCurv.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 TISSUECURVATURE_HPP
12 #define TISSUECURVATURE_HPP
13 
14 #include <Process.hpp>
15 
16 #include <MeshProcessCellMesh.hpp>
17 
18 namespace mgx
19 {
22 
28  class mgxBase_EXPORT TissueCurvature : public Process {
29  public:
30  TissueCurvature(const Process& process) : Process(process)
31  {
32  setName("Mesh/Cell Axis/Curvature/Compute Tissue Curvature");
33  setDesc("Compute curvature based on simplified mesh (from Make Cells) for a neighborhood of given radius.");
34  setIcon(QIcon(":/images/Curvature.png"));
35 
36  addParm("Radius","Radius for curvature calculation (µm)","10.0");
37  addParm("Selected Cell","Compute curvature only for selected cell","No",booleanChoice());
38  }
39 
40  bool run()
41  {
42  double radius = parm("Radius").toDouble();
43  if(radius <= 0)
44  throw QString("%1::run Radius must be > 0").arg(name());
45  return run(currentMesh(), radius, stringToBool(parm("Selected Cell")));
46  }
47 
48  bool run(Mesh* mesh, float neighborhood, bool checkLabel);
49 
50  };
51 
58  class mgxBase_EXPORT DisplayTissueCurvature : public Process {
59  public:
60  DisplayTissueCurvature(const Process& process) : Process(process)
61  {
62  setName("Mesh/Cell Axis/Curvature/Display Tissue Curvature");
63  setDesc("Display curvature based on cellular mesh");
64  setIcon(QIcon(":/images/Curvature.png"));
65 
66  addParm("Heatmap","Display curvature values in max or min direction as a color map. \n"
67  "Average: (CurvMax + CurvMin)/2, SignedAverageAbs: sign(CurvMax or CurvMin) x (abs(CurvMax) + abs(CurvMin))/2,\n"
68  "Gaussian:(CurvMax x CurvMin), RootSumSquare: sqrt(CurvMax^2 + CurvMin^2), Anisotropy: (CurvMax / CurvMin).","SignedAverageAbs", QStringList() << "None" << "CurvMax" << "CurvMin" << "Average" << "SignedAverageAbs" << "Gaussian" << "RootSumSquare" << "Anisotropy");
69  addParm("Compare to 0","Center the color map on zero, if negtive values exist.","Yes",booleanChoice());
70  addParm("Heatmap percentile","Percentile of values used for color map upper-lower bounds.","85.0");
71  addParm("Show Axis","Draw main curvature directions as vectors, scaled by 1/(curvature radius).","Both", QStringList() << "Both" << "CurvMax" << "CurvMin" << "None"); // 3
72  addParm("Color +","Color used for convex (curvature > 0)","white", QColor::colorNames());
73  addParm("Color -","Color used for concave (curvature < 0)","red", QColor::colorNames());
74  addParm("Line Width","Line width","2.0");
75  addParm("Line Scale","Length of the vectors = Scale * 1/(curvature radius).","100.0");
76  addParm("Line Offset","Draw the vector ends a bit tilted up for proper display on surfaces.","0.1");
77  addParm("Threshold","Minimal value of curvature required for drawing the directions.","0.0");
78  }
79 
80  bool run()
81  {
82  if(!checkState().mesh(MESH_NON_EMPTY))
83  return false;
84 
85  bool ok;
86  float heatmapPercentile = parm("Heatmap percentile").toFloat(&ok);
87  if(not ok)
88  return setErrorMessage("Error, argument 'Heatmap percentile' must be a number");
89  float axisLineWidth = parm("Line Width").toFloat(&ok);
90  if(not ok)
91  return setErrorMessage("Error, argument 'Line Width' must be a number");
92  float axisLineScale = parm("Line Scale").toFloat(&ok);
93  if(not ok)
94  return setErrorMessage("Error, argument 'Line Scale' must be a number");
95  float axisOffset = parm("Line Offset").toFloat(&ok);
96  if(not ok)
97  return setErrorMessage("Error, argument 'Line Offset' must be a number");
98  float threshold = parm("Threshold").toFloat(&ok);
99  if(not ok)
100  return setErrorMessage("Error, argument 'Threshold' must be a number");
101 
102  return run(currentMesh(), parm("Heatmap"), stringToBool(parm("Compare to 0")), heatmapPercentile,
103  parm("Show Axis"), QColor(parm("Color +")), QColor(parm("Color -")), axisLineWidth, axisLineScale,
104  axisOffset, threshold);
105  }
106 
107  bool run(Mesh* mesh, QString DisplayHeatMap, bool compareZero, float heatmapPercentile,
108  QString DisplayCurv, const QColor& ColorExpansion, const QColor& ColorShrinkage,
109  float AxisLineWidth, float AxisLineScale, float AxisOffset, float CurvThreshold);
110 
111  };
113 }
114 
115 #endif
Process.hpp
mgx::TissueCurvature::run
bool run()
Runs the process.
Definition: MeshProcessCurv.hpp:40
mgx::DisplayTissueCurvature
Definition: MeshProcessCurv.hpp:58
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::Process
Definition: Process.hpp:219
mgx::stringToBool
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
mgx::TissueCurvature::TissueCurvature
TissueCurvature(const Process &process)
Definition: MeshProcessCurv.hpp:30
mgx::Mesh
Definition: Mesh.hpp:54
mgx::DisplayTissueCurvature::run
bool run()
Runs the process.
Definition: MeshProcessCurv.hpp:80
mgx::TissueCurvature
Definition: MeshProcessCurv.hpp:28
MeshProcessCellMesh.hpp
mgx::DisplayTissueCurvature::DisplayTissueCurvature
DisplayTissueCurvature(const Process &process)
Definition: MeshProcessCurv.hpp:60