CustusX  16.5.0-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
34 #include "cxLogger.h"
35 #include "recConfig.h"
36 #include "cxDataLocations.h"
37 
38 namespace cx
39 {
40 
43 {
45 
46  mMethods.push_back("VNN");
47  mMethods.push_back("VNN2");
48  mMethods.push_back("DW");
49  mMethods.push_back("Anisotropic");
50  mPlaneMethods.push_back("Heuristic");
51  mPlaneMethods.push_back("Closest");
52 }
53 
55 {
56 }
57 
59 {
60  mAlgorithm->setProfiling(true);
61 }
62 
64 {
65  return mAlgorithm->getKernelExecutionTime();
66 }
67 
69 {
70  return "VNNcl";
71 }
72 
73 std::vector<PropertyPtr> VNNclReconstructionMethodService::getSettings(QDomElement root)
74 {
75  std::vector<PropertyPtr> retval;
76 
77  retval.push_back(this->getMethodOption(root));
78  retval.push_back(this->getRadiusOption(root));
79  retval.push_back(this->getPlaneMethodOption(root));
80  retval.push_back(this->getMaxPlanesOption(root));
81  retval.push_back(this->getNStartsOption(root));
82  retval.push_back(this->getNewnessWeightOption(root));
83  retval.push_back(this->getBrightnessWeightOption(root));
84  return retval;
85 }
86 
88 {
89  int nClosePlanes = getMaxPlanesOption(settings)->getValue();
90 
91  int method = getMethodID(settings);
92  float radius = getRadiusOption(settings)->getValue();
93  int planeMethod = getPlaneMethodID(settings);
94  int nStarts = getNStartsOption(settings)->getValue();
95  float newnessWeight = getNewnessWeightOption(settings)->getValue();
96  float brightnessWeight = getBrightnessWeightOption(settings)->getValue();
97 
98  report(
99  QString("Method: %1, radius: %2, planeMethod: %3, nClosePlanes: %4, nPlanes: %5, nStarts: %6 ").arg(method).arg(
100  radius).arg(planeMethod).arg(nClosePlanes).arg(input->getDimensions()[2]).arg(nStarts));
101 
102  QString kernel = DataLocations::findConfigFilePath("/kernels.cl", "/shaders", VNNCL_KERNEL_PATH);
103  if (!mAlgorithm->initCL(kernel, nClosePlanes, input->getDimensions()[2], method, planeMethod, nStarts, newnessWeight, brightnessWeight))
104  return false;
105 
106  bool ret = mAlgorithm->reconstruct(input, outputData, radius, nClosePlanes);
107 
108  return ret;
109 }
110 
112 {
113  QStringList methods;
114  for (std::vector<QString>::iterator it = mMethods.begin(); it != mMethods.end(); ++it)
115  {
116  QString method = *it;
117  methods << method;
118  }
119  return StringProperty::initialize("Method", "", "Which algorithm to use for reconstruction", methods[2],
120  methods, root);
121 }
122 
124 {
125  return DoubleProperty::initialize("Newness weight", "", "Newness weight", 0, DoubleRange(0.0, 10, 0.1), 1,
126  root);
127 }
128 
130 {
131  return DoubleProperty::initialize("Brightness weight", "", "Brightness weight", 1, DoubleRange(0.0, 10, 0.1),
132  1, root);
133 }
134 
136 {
137  QStringList methods;
138  for (std::vector<QString>::iterator it = mPlaneMethods.begin(); it != mPlaneMethods.end(); ++it)
139  {
140  QString method = *it;
141  methods << method;
142  }
143  return StringProperty::initialize("Plane method", "", "Which method to use for finding close planes",
144  methods[0], methods, root);
145 }
146 
148 {
149  return DoubleProperty::initialize("Radius (mm)", "", "Radius of kernel. mm.", 3, DoubleRange(0.1, 10, 0.1), 1,
150  root);
151 }
152 
154 {
155  return DoubleProperty::initialize("nPlanes", "", "Number of planes to include in closest planes", 10,
156  DoubleRange(1, 200, 1), 0, root);
157 }
158 
160 {
161  return DoubleProperty::initialize("nStarts", "", "Number of starts for multistart searchs", 16,
162  DoubleRange(1, 16, 1), 0, root);
163 }
164 
166 {
167  return find(mMethods.begin(), mMethods.end(), this->getMethodOption(root)->getValue()) - mMethods.begin();
168 }
169 
171 {
172  return find(mPlaneMethods.begin(), mPlaneMethods.end(), this->getPlaneMethodOption(root)->getValue())
173  - mPlaneMethods.begin();
174 }
175 
176 
177 } /* 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:53
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:42
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:90
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)