CustusX  22.04
An IGT application
cxVNNclReconstructionMethodService.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
13 #include "cxLogger.h"
14 #include "recConfig.h"
15 #include "cxDataLocations.h"
16 
17 namespace cx
18 {
19 
22 {
24 
25  mMethods.push_back("VNN");
26  mMethods.push_back("VNN2");
27  mMethods.push_back("DW");
28  mMethods.push_back("Anisotropic");
29  mPlaneMethods.push_back("Heuristic");
30  mPlaneMethods.push_back("Closest");
31 }
32 
34 {
35 }
36 
38 {
39  mAlgorithm->setProfiling(true);
40 }
41 
43 {
44  return mAlgorithm->getKernelExecutionTime();
45 }
46 
48 {
49  return "vnn_cl";
50 }
51 
52 std::vector<PropertyPtr> VNNclReconstructionMethodService::getSettings(QDomElement root)
53 {
54  std::vector<PropertyPtr> retval;
55 
56  retval.push_back(this->getMethodOption(root));
57  retval.push_back(this->getRadiusOption(root));
58  retval.push_back(this->getPlaneMethodOption(root));
59  retval.push_back(this->getMaxPlanesOption(root));
60  retval.push_back(this->getNStartsOption(root));
61  retval.push_back(this->getNewnessWeightOption(root));
62  retval.push_back(this->getBrightnessWeightOption(root));
63  return retval;
64 }
65 
67 {
68  int nClosePlanes = getMaxPlanesOption(settings)->getValue();
69 
70  int method = getMethodID(settings);
71  float radius = getRadiusOption(settings)->getValue();
72  int planeMethod = getPlaneMethodID(settings);
73  int nStarts = getNStartsOption(settings)->getValue();
74  float newnessWeight = getNewnessWeightOption(settings)->getValue();
75  float brightnessWeight = getBrightnessWeightOption(settings)->getValue();
76 
77  report(
78  QString("Method: %1, radius: %2, planeMethod: %3, nClosePlanes: %4, nPlanes: %5, nStarts: %6 ").arg(method).arg(
79  radius).arg(planeMethod).arg(nClosePlanes).arg(input->getDimensions()[2]).arg(nStarts));
80 
81  QString kernel = DataLocations::findConfigFilePath("/kernels.cl", "/shaders", VNNCL_KERNEL_PATH);
82  if (!mAlgorithm->initCL(kernel, nClosePlanes, input->getDimensions()[2], method, planeMethod, nStarts, newnessWeight, brightnessWeight))
83  return false;
84 
85  bool ret = mAlgorithm->reconstruct(input, outputData, radius, nClosePlanes);
86 
87  return ret;
88 }
89 
91 {
92  QStringList methods;
93  for (std::vector<QString>::iterator it = mMethods.begin(); it != mMethods.end(); ++it)
94  {
95  QString method = *it;
96  methods << method;
97  }
98  return StringProperty::initialize("Method", "", "Which algorithm to use for reconstruction", methods[2],
99  methods, root);
100 }
101 
103 {
104  return DoubleProperty::initialize("Newness weight", "", "Newness weight", 0, DoubleRange(0.0, 10, 0.1), 1,
105  root);
106 }
107 
109 {
110  return DoubleProperty::initialize("Brightness weight", "", "Brightness weight", 1, DoubleRange(0.0, 10, 0.1),
111  1, root);
112 }
113 
115 {
116  QStringList methods;
117  for (std::vector<QString>::iterator it = mPlaneMethods.begin(); it != mPlaneMethods.end(); ++it)
118  {
119  QString method = *it;
120  methods << method;
121  }
122  return StringProperty::initialize("Plane method", "", "Which method to use for finding close planes",
123  methods[0], methods, root);
124 }
125 
127 {
128  return DoubleProperty::initialize("Radius (mm)", "", "Radius of kernel. mm.", 3, DoubleRange(0.1, 10, 0.1), 1,
129  root);
130 }
131 
133 {
134  return DoubleProperty::initialize("nPlanes", "", "Number of planes to include in closest planes", 10,
135  DoubleRange(1, 200, 1), 0, root);
136 }
137 
139 {
140  return DoubleProperty::initialize("nStarts", "", "Number of starts for multistart searchs", 16,
141  DoubleRange(1, 16, 1), 0, root);
142 }
143 
145 {
146  return find(mMethods.begin(), mMethods.end(), this->getMethodOption(root)->getValue()) - mMethods.begin();
147 }
148 
150 {
151  return find(mPlaneMethods.begin(), mPlaneMethods.end(), this->getPlaneMethodOption(root)->getValue())
152  - mPlaneMethods.begin();
153 }
154 
155 
156 } /* namespace cx */
Abstract interface for reconstruction algorithm.
virtual bool reconstruct(ProcessedUSInputDataPtr input, vtkImageDataPtr outputData, QDomElement settings)
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
virtual StringPropertyPtr getMethodOption(QDomElement root)
virtual DoublePropertyPtr getNewnessWeightOption(QDomElement root)
virtual DoublePropertyPtr getNStartsOption(QDomElement root)
boost::shared_ptr< class StringProperty > StringPropertyPtr
virtual std::vector< PropertyPtr > getSettings(QDomElement root)
virtual DoublePropertyPtr getRadiusOption(QDomElement root)
static QString findConfigFilePath(QString fileName, QString pathRelativeToConfigRoot, QString alternativeAbsolutePath="")
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
boost::shared_ptr< class DoubleProperty > DoublePropertyPtr
void report(QString msg)
Definition: cxLogger.cpp:69
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
virtual StringPropertyPtr getPlaneMethodOption(QDomElement root)
boost::shared_ptr< class ProcessedUSInputData > ProcessedUSInputDataPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
boost::shared_ptr< VNNclAlgorithm > VNNclAlgorithmPtr
virtual DoublePropertyPtr getMaxPlanesOption(QDomElement root)
virtual DoublePropertyPtr getBrightnessWeightOption(QDomElement root)
Namespace for all CustusX production code.