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