NorMIT-nav  2023.01.05-dev+develop.0da12
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 */
cx::VNNclReconstructionMethodService::getSettings
virtual std::vector< PropertyPtr > getSettings(QDomElement root)
Definition: cxVNNclReconstructionMethodService.cpp:52
cx::VNNclReconstructionMethodService::getBrightnessWeightOption
virtual DoublePropertyPtr getBrightnessWeightOption(QDomElement root)
Definition: cxVNNclReconstructionMethodService.cpp:108
cx::VNNclReconstructionMethodService::getNStartsOption
virtual DoublePropertyPtr getNStartsOption(QDomElement root)
Definition: cxVNNclReconstructionMethodService.cpp:138
cxLogger.h
cx::VNNclReconstructionMethodService::getNewnessWeightOption
virtual DoublePropertyPtr getNewnessWeightOption(QDomElement root)
Definition: cxVNNclReconstructionMethodService.cpp:102
cx::VNNclReconstructionMethodService::getName
virtual QString getName() const
Definition: cxVNNclReconstructionMethodService.cpp:47
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::VNNclReconstructionMethodService::enableProfiling
void enableProfiling()
Definition: cxVNNclReconstructionMethodService.cpp:37
cx::ProcessedUSInputDataPtr
boost::shared_ptr< class ProcessedUSInputData > ProcessedUSInputDataPtr
Definition: cxReconstructionMethodService.h:36
cx::VNNclReconstructionMethodService::getPlaneMethodID
virtual int getPlaneMethodID(QDomElement root)
Definition: cxVNNclReconstructionMethodService.cpp:149
cx::report
void report(QString msg)
Definition: cxLogger.cpp:69
cx::StringPropertyPtr
boost::shared_ptr< class StringProperty > StringPropertyPtr
Definition: cxVideoConnectionWidget.h:42
vtkImageDataPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
Definition: cxVideoConnectionWidget.h:30
cx::VNNclReconstructionMethodService::getPlaneMethodOption
virtual StringPropertyPtr getPlaneMethodOption(QDomElement root)
Definition: cxVNNclReconstructionMethodService.cpp:114
cx::VNNclReconstructionMethodService::mPlaneMethods
std::vector< QString > mPlaneMethods
Definition: cxVNNclReconstructionMethodService.h:144
cx::ReconstructionMethodService
Abstract interface for reconstruction algorithm.
Definition: cxReconstructionMethodService.h:54
cx::VNNclReconstructionMethodService::mAlgorithm
VNNclAlgorithmPtr mAlgorithm
Definition: cxVNNclReconstructionMethodService.h:146
cx::VNNclAlgorithm
Definition: cxVNNclAlgorithm.h:27
cx::VNNclReconstructionMethodService::getRadiusOption
virtual DoublePropertyPtr getRadiusOption(QDomElement root)
Definition: cxVNNclReconstructionMethodService.cpp:126
cx::DoubleProperty::initialize
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
Definition: cxDoubleProperty.cpp:30
cx::DoublePropertyPtr
boost::shared_ptr< class DoubleProperty > DoublePropertyPtr
Definition: cxReconstructionMethodService.h:33
cx::VNNclAlgorithmPtr
boost::shared_ptr< VNNclAlgorithm > VNNclAlgorithmPtr
Definition: cxVNNclAlgorithm.h:188
cx::VNNclReconstructionMethodService::getMethodOption
virtual StringPropertyPtr getMethodOption(QDomElement root)
Definition: cxVNNclReconstructionMethodService.cpp:90
cx::VNNclReconstructionMethodService::VNNclReconstructionMethodService
VNNclReconstructionMethodService(ctkPluginContext *context)
Definition: cxVNNclReconstructionMethodService.cpp:20
cxDataLocations.h
cxVNNclReconstructionMethodService.h
cx::VNNclReconstructionMethodService::~VNNclReconstructionMethodService
virtual ~VNNclReconstructionMethodService()
Definition: cxVNNclReconstructionMethodService.cpp:33
cx::StringProperty::initialize
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
Definition: cxStringProperty.cpp:29
cx::VNNclReconstructionMethodService::mMethods
std::vector< QString > mMethods
Definition: cxVNNclReconstructionMethodService.h:143
cx::VNNclReconstructionMethodService::getKernelExecutionTime
double getKernelExecutionTime()
Definition: cxVNNclReconstructionMethodService.cpp:42
cx::DoubleRange
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
cx::DataLocations::findConfigFilePath
static QString findConfigFilePath(QString fileName, QString pathRelativeToConfigRoot, QString alternativeAbsolutePath="")
Definition: cxDataLocations.cpp:264
cx::VNNclReconstructionMethodService::reconstruct
virtual bool reconstruct(ProcessedUSInputDataPtr input, vtkImageDataPtr outputData, QDomElement settings)
Definition: cxVNNclReconstructionMethodService.cpp:66
cx::VNNclReconstructionMethodService::getMethodID
virtual int getMethodID(QDomElement root)
Definition: cxVNNclReconstructionMethodService.cpp:144
cx::settings
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
cx::VNNclReconstructionMethodService::getMaxPlanesOption
virtual DoublePropertyPtr getMaxPlanesOption(QDomElement root)
Definition: cxVNNclReconstructionMethodService.cpp:132