Fraxinus  16.5.0-fx-rc8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxReconstructParams.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 
33 #include "cxReconstructParams.h"
34 
35 #include "cxStringProperty.h"
36 #include "cxDoubleProperty.h"
37 #include "cxBoolProperty.h"
39 #include "cxDoubleRange.h"
40 #include "cxPatientModelService.h"
41 #include "cxLogger.h"
42 #include "cxTypeConversions.h"
43 
44 //Windows fix
45 #ifndef M_PI
46 #define M_PI 3.14159265358979323846
47 #endif
48 
49 namespace cx
50 {
51 
53  mPatientModelService(patientModelService),
54  mSettings(settings)
55 {
56  connect(mPatientModelService.get(), &PatientModelService::patientChanged, this, &ReconstructParams::onPatientChanged);
57 }
58 
60 {
61  mSettings.save();
62 }
63 
64 void ReconstructParams::onPatientChanged()
65 {
66  if (mParameters.empty())
67  return;
68 
69  PresetTransferFunctions3DPtr presets = mPatientModelService->getPresetTransferFunctions3D();
70  QStringList presetList;
71  if (presets)
72  {
73  presetList = presets->getPresetList("US");
74  mPresetTFAdapter->setValueRange(presetList);
75  }
76 }
77 
78 void ReconstructParams::createParameters()
79 {
80  if (!mParameters.empty())
81  return;
82 
83  mSettings.getElement("algorithms");
84 
85  mOrientationAdapter = StringProperty::initialize("Orientation", "",
86  "Algorithm to use for output volume orientation", "MiddleFrame",
87  QString("PatientReference MiddleFrame").split(" "),
88  mSettings.getElement());
89  connect(mOrientationAdapter.get(), &StringProperty::valueWasSet, this, &ReconstructParams::changedInputSettings);
90  this->add(mOrientationAdapter);
91 
92  // note: value range initialized by onPatientChanged()
93  mPresetTFAdapter = StringProperty::initialize("Preset", "",
94  "Preset transfer function to apply to the reconstructed volume", "US B-Mode", QStringList(),
95  mSettings.getElement());
96  connect(mPresetTFAdapter.get(), &StringProperty::valueWasSet, this, &ReconstructParams::transferFunctionChangedSlot);
97  this->add(mPresetTFAdapter);
98 
99  mMaskReduce = StringProperty::initialize("Reduce mask (% in 1D)", "",
100  "Speedup by reducing mask size", "3",
101  QString("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15").split(" "),
102  mSettings.getElement());
103  connect(mMaskReduce.get(), &StringProperty::valueWasSet, this, &ReconstructParams::changedInputSettings);
104  this->add(mMaskReduce);
105 
106  mAlignTimestamps = BoolProperty::initialize("Align timestamps", "",
107  "Align the first of tracker and frame timestamps, ignoring lags.", false,
108  mSettings.getElement());
109  connect(mAlignTimestamps.get(), SIGNAL(valueWasSet()), this, SIGNAL(changedInputSettings()));
110  this->add(mAlignTimestamps);
111 
112  mTimeCalibration = DoubleProperty::initialize("Extra Temporal Calib", "",
113  "Set an offset in the frame timestamps, in addition to the one used in acquisition", 0.0,
114  DoubleRange(-1000, 1000, 10), 0,
115  mSettings.getElement());
116  connect(mTimeCalibration.get(), SIGNAL(valueWasSet()), this, SIGNAL(changedInputSettings()));
117  this->add(mTimeCalibration);
118 
119  double maxVolumeSizeFactor = 1024*1024;
120  mMaxVolumeSize = DoubleProperty::initialize("Volume Size", "",
121  "Output Volume Size (Mb)", 32*maxVolumeSizeFactor,
122  DoubleRange(maxVolumeSizeFactor, maxVolumeSizeFactor*500, maxVolumeSizeFactor), 0,
123  mSettings.getElement());
124  mMaxVolumeSize->setInternal2Display(1.0/maxVolumeSizeFactor);
125  connect(mMaxVolumeSize.get(), SIGNAL(valueWasSet()), this, SIGNAL(changedInputSettings()));
126  this->add(mMaxVolumeSize);
127 
128  mAngioAdapter = BoolProperty::initialize("Angio data", "",
129  "Ultrasound angio data is used as input", false,
130  mSettings.getElement());
131  connect(mAngioAdapter.get(), SIGNAL(valueWasSet()), this, SIGNAL(changedInputSettings()));
132  this->add(mAngioAdapter);
133 
134  mCreateBModeWhenAngio = BoolProperty::initialize("Dual Angio", "",
135  "If angio requested, also create a B-mode reconstruction based on the same data set.", true,
136  mSettings.getElement());
137  connect(mCreateBModeWhenAngio.get(), SIGNAL(valueWasSet()), this, SIGNAL(changedInputSettings()));
138  this->add(mCreateBModeWhenAngio);
139 
140  mAlgorithmAdapter = StringProperty::initialize("Algorithm", "", "Choose algorithm to use for reconstruction",
141  QString(), QStringList(), mSettings.getElement());
142  connect(mAlgorithmAdapter.get(), &StringProperty::valueWasSet, this, &ReconstructParams::changedInputSettings);
143  this->add(mAlgorithmAdapter);
144 
145  this->onPatientChanged();
146 }
147 
148 void ReconstructParams::add(PropertyPtr param)
149 {
150  mParameters[param->getUid()] = param;
151 }
152 
154 {
155  if (mParameters.empty())
156  this->createParameters();
157  if (mParameters.count(uid))
158  return mParameters[uid];
159  return PropertyPtr();
160 }
161 
163 {
164  QStringList retval;
165  for (std::map<QString, PropertyPtr>::const_iterator iter=mParameters.begin(); iter!=mParameters.end(); ++iter)
166  retval << iter->first;
167  return retval;
168 }
169 
170 void ReconstructParams::transferFunctionChangedSlot()
171 {
172  //Use angio reconstruction also if only transfer function is set to angio
173  if(mPresetTFAdapter->getValue() == "US Angio")
174  {
175  reportDebug("Reconstructing angio (Because of angio transfer function)");
176  mAngioAdapter->setValue(true);
177  }
178  else if(mPresetTFAdapter->getValue() == "US B-Mode" && mAngioAdapter->getValue())
179  {
180  reportDebug("Not reconstructing angio (Because of B-Mode transfer function)");
181  mAngioAdapter->setValue(false);
182  }
183 }
184 
185 
186 
187 }
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
QStringList getParameterUids() const
boost::shared_ptr< class TransferFunctions3DPresets > PresetTransferFunctions3DPtr
Definition: cxDataManager.h:56
ReconstructParams(PatientModelServicePtr patientModelService, XmlOptionFile settings)
QDomElement getElement()
return the current element
boost::shared_ptr< class Property > PropertyPtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
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())
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
void save()
save entire document.
Helper class for xml files used to store ssc/cx data.
void reportDebug(QString msg)
Definition: cxLogger.cpp:89
PropertyPtr getParameter(QString uid)