Skip to content

Commit d008228

Browse files
committed
created dummy run methods to cover for the inheritance requirements from algorithmInterface. This is a patch
1 parent be8d0ea commit d008228

File tree

7 files changed

+101
-95
lines changed

7 files changed

+101
-95
lines changed

src/Core/Algorithms/Legacy/Inverse/SolveInverseProblemWithTikhonovSVD_impl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ namespace SCIRun
6363

6464
public:
6565

66-
SolveInverseProblemWithTikhonovSVD_impl( const SCIRun::Core::Datatypes::DenseMatrixHandle& forwardMatrix,
67-
const SCIRun::Core::Datatypes::DenseMatrixHandle& measuredData,
68-
bool computeRegularizedInverse = false,
69-
SCIRun::Core::Logging::LegacyLoggerInterface* pr = 0)
66+
SolveInverseProblemWithTikhonovSVD_impl( const SCIRun::Core::Datatypes::DenseMatrixHandle& forwardMatrix,
67+
const SCIRun::Core::Datatypes::DenseMatrixHandle& measuredData,
68+
bool computeRegularizedInverse = false,
69+
SCIRun::Core::Logging::LegacyLoggerInterface* pr = 0)
7070

7171
: TikhonovImplAbstractBase( forwardMatrix,
7272
measuredData,

src/Core/Algorithms/Legacy/Inverse/TikhonovImplAbstractBase.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ using namespace SCIRun::Core::Algorithms::Inverse;
221221

222222
/////////////////////////
223223
///////// run()
224-
void TikhonovImplAbstractBase::run(const TikhonovImplAbstractBase::Input& input)
224+
void TikhonovImplAbstractBase::run1(const TikhonovImplAbstractBase::Input& input)
225225
{
226226

227227
const int M = forwardMatrix_->nrows();
@@ -270,6 +270,13 @@ using namespace SCIRun::Core::Algorithms::Inverse;
270270
//////// fi run()
271271
///////////////////////////
272272

273+
AlgorithmOutput TikhonovImplAbstractBase::run(const AlgorithmInput& input) const
274+
{
275+
AlgorithmOutput output;
276+
277+
return output;
278+
}
279+
273280

274281
///////////////////////////
275282
/////// compute L-curve

src/Core/Algorithms/Legacy/Inverse/TikhonovImplAbstractBase.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ namespace SCIRun {
5151
namespace Algorithms {
5252
namespace Inverse {
5353

54-
// TODO: this needs to be moved into a SCIRun algorithm class
55-
5654
namespace TikhonovAlgorithm {
5755

5856
struct SCISHARE LCurveInput
@@ -76,7 +74,7 @@ namespace SCIRun {
7674

7775

7876

79-
class SCISHARE TikhonovImplAbstractBase : public AlgorithmBase, boost::noncopyable
77+
class SCISHARE TikhonovImplAbstractBase : public AlgorithmBase //, boost::noncopyable
8078
{
8179

8280
// PUBLIC MEMBERS OF CLASS TikhonovImplAbstractBase
@@ -129,7 +127,8 @@ namespace SCIRun {
129127
};
130128

131129
// abstract functions
132-
virtual void run(const Input& input);
130+
virtual AlgorithmOutput run(const AlgorithmInput & input) const override;
131+
virtual void run1(const TikhonovImplAbstractBase::Input& input);
133132

134133
// defined functions
135134
void update_graph(const TikhonovImplAbstractBase::Input& input, double lambda, int lambda_index, const double epsilon);

src/Modules/Legacy/Inverse/SolveInverseProblemWithTikhonov.cc

Lines changed: 60 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -75,73 +75,66 @@ void SolveInverseProblemWithTikhonov::setStateDefaults()
7575

7676
void SolveInverseProblemWithTikhonov::execute()
7777
{
78-
auto forward_matrix_h = getRequiredInput(ForwardMatrix);
79-
auto hMatrixMeasDat = getRequiredInput(MeasuredPotentials);
80-
81-
auto hMatrixRegMat = getOptionalInput(WeightingInSourceSpace);
82-
auto hMatrixNoiseCov = getOptionalInput(WeightingInSensorSpace);
83-
84-
const bool computeRegularizedInverse = oport_connected(InverseSolution);
85-
86-
if (needToExecute())
87-
{
88-
// using namespace BioPSE;
89-
auto state = get_state();
90-
// <<<<<<< HEAD
91-
92-
auto gui_tikhonov_case = static_cast<SolveInverseProblemWithTikhonovImpl_child::AlgorithmChoice>(state->getValue(TikhonovCase).toInt());
93-
auto gui_tikhonov_solution_subcase = static_cast<SolveInverseProblemWithTikhonovImpl_child::AlgorithmSolutionSubcase>(state->getValue(Core::Algorithms::Inverse::Parameters::TikhonovSolutionSubcase).toInt());
94-
auto gui_tikhonov_residual_subcase = static_cast<SolveInverseProblemWithTikhonovImpl_child::AlgorithmResidualSubcase>(state->getValue(Core::Algorithms::Inverse::Parameters::TikhonovResidualSubcase).toInt());
95-
96-
// =======
97-
// auto gui_tikhonov_case = static_cast<TikhonovAlgorithmImpl::AlgorithmChoice>(state->getValue(TikhonovCase).toInt());
98-
// auto gui_tikhonov_solution_subcase = static_cast<TikhonovAlgorithmImpl::AlgorithmSolutionSubcase>(state->getValue(Parameters::TikhonovSolutionSubcase).toInt());
99-
// auto gui_tikhonov_residual_subcase = static_cast<TikhonovAlgorithmImpl::AlgorithmResidualSubcase>(state->getValue(Parameters::TikhonovResidualSubcase).toInt());
100-
//
101-
// >>>>>>> sciinstitute/master
102-
auto denseForward = castMatrix::toDense(forward_matrix_h);
103-
auto measuredDense = convertMatrix::toDense(hMatrixMeasDat);
104-
auto regMatDense = castMatrix::toDense(hMatrixRegMat.get_value_or(nullptr));
105-
auto noiseCovDense = castMatrix::toDense(hMatrixNoiseCov.get_value_or(nullptr));
106-
107-
108-
// create algorithm solver
109-
SolveInverseProblemWithTikhonovImpl_child algo(denseForward,
110-
measuredDense,
111-
gui_tikhonov_case,
112-
gui_tikhonov_solution_subcase,
113-
gui_tikhonov_residual_subcase,
114-
regMatDense,
115-
noiseCovDense,
116-
computeRegularizedInverse, this);
117-
118-
119-
SolveInverseProblemWithTikhonovImpl_child::Input::lcurveGuiUpdate update = boost::bind(&SolveInverseProblemWithTikhonov::update_lcurve_gui, this, _1, _2, _3);
120-
121-
// set input
122-
SolveInverseProblemWithTikhonovImpl_child::Input input(
123-
state->getValue(RegularizationMethod).toString(),
124-
state->getValue(LambdaFromDirectEntry).toDouble(),
125-
state->getValue(LambdaSliderValue).toDouble(),
126-
state->getValue(LambdaNum).toInt(),
127-
state->getValue(LambdaMin).toDouble(),
128-
state->getValue(LambdaMax).toDouble(),
129-
update);
130-
131-
132-
// run aglrithm
133-
algo.run(input);
134-
135-
// send output
136-
if (computeRegularizedInverse)
137-
{
138-
sendOutput(RegInverse, algo.get_inverse_matrix());
139-
}
140-
141-
sendOutput(InverseSolution, algo.get_inverse_solution());
142-
143-
sendOutput(RegularizationParameter, algo.get_regularization_parameter());
144-
}
78+
auto forward_matrix_h = getRequiredInput(ForwardMatrix);
79+
auto hMatrixMeasDat = getRequiredInput(MeasuredPotentials);
80+
81+
auto hMatrixRegMat = getOptionalInput(WeightingInSourceSpace);
82+
auto hMatrixNoiseCov = getOptionalInput(WeightingInSensorSpace);
83+
84+
const bool computeRegularizedInverse = oport_connected(InverseSolution);
85+
86+
if (needToExecute())
87+
{
88+
// using namespace BioPSE;
89+
auto state = get_state();
90+
91+
auto gui_tikhonov_case = static_cast<SolveInverseProblemWithTikhonovImpl_child::AlgorithmChoice>(state->getValue(TikhonovCase).toInt());
92+
auto gui_tikhonov_solution_subcase = static_cast<SolveInverseProblemWithTikhonovImpl_child::AlgorithmSolutionSubcase>(state->getValue(Core::Algorithms::Inverse::Parameters::TikhonovSolutionSubcase).toInt());
93+
auto gui_tikhonov_residual_subcase = static_cast<SolveInverseProblemWithTikhonovImpl_child::AlgorithmResidualSubcase>(state->getValue(Core::Algorithms::Inverse::Parameters::TikhonovResidualSubcase).toInt());
94+
95+
auto denseForward = castMatrix::toDense(forward_matrix_h);
96+
auto measuredDense = convertMatrix::toDense(hMatrixMeasDat);
97+
auto regMatDense = castMatrix::toDense(hMatrixRegMat.get_value_or(nullptr));
98+
auto noiseCovDense = castMatrix::toDense(hMatrixNoiseCov.get_value_or(nullptr));
99+
100+
101+
// create algorithm solver
102+
SolveInverseProblemWithTikhonovImpl_child algo(denseForward,
103+
measuredDense,
104+
gui_tikhonov_case,
105+
gui_tikhonov_solution_subcase,
106+
gui_tikhonov_residual_subcase,
107+
regMatDense,
108+
noiseCovDense,
109+
computeRegularizedInverse, this);
110+
111+
112+
SolveInverseProblemWithTikhonovImpl_child::Input::lcurveGuiUpdate update = boost::bind(&SolveInverseProblemWithTikhonov::update_lcurve_gui, this, _1, _2, _3);
113+
114+
// set input
115+
SolveInverseProblemWithTikhonovImpl_child::Input input(
116+
state->getValue(RegularizationMethod).toString(),
117+
state->getValue(LambdaFromDirectEntry).toDouble(),
118+
state->getValue(LambdaSliderValue).toDouble(),
119+
state->getValue(LambdaNum).toInt(),
120+
state->getValue(LambdaMin).toDouble(),
121+
state->getValue(LambdaMax).toDouble(),
122+
update);
123+
124+
125+
// run aglrithm
126+
algo.run1(input);
127+
128+
// send output
129+
if (computeRegularizedInverse)
130+
{
131+
sendOutput(RegInverse, algo.get_inverse_matrix());
132+
}
133+
134+
sendOutput(InverseSolution, algo.get_inverse_solution());
135+
136+
sendOutput(RegularizationParameter, algo.get_regularization_parameter());
137+
}
145138
}
146139

147140
void SolveInverseProblemWithTikhonov::update_lcurve_gui(const double lambda, const TikhonovAlgorithm::LCurveInput& input, const int lambda_index)

src/Modules/Legacy/Inverse/SolveInverseProblemWithTikhonov.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,11 @@ namespace SCIRun {
7676
static const Core::Algorithms::AlgorithmParameterName LambdaSliderValue;
7777
static const Core::Algorithms::AlgorithmParameterName LambdaCorner;
7878
static const Core::Algorithms::AlgorithmParameterName LCurveText;
79-
// <<<<<<< HEAD
80-
//
81-
// =======
82-
79+
8380
LEGACY_BIOPSE_MODULE
8481

8582
MODULE_TRAITS_AND_INFO(ModuleHasUI)
8683

87-
// >>>>>>> sciinstitute/master
8884
private:
8985
void update_lcurve_gui(const double lambda, const Core::Algorithms::Inverse::TikhonovAlgorithm::LCurveInput& input, const int lambda_index);
9086
};

src/Modules/Legacy/Inverse/SolveInverseProblemWithTikhonovSVD.cc

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,36 @@ void SolveInverseProblemWithTikhonovSVD::execute()
5555
auto forward_matrix_h = getRequiredInput(ForwardMatrix);
5656
auto hMatrixMeasDat = getRequiredInput(MeasuredPotentials);
5757

58+
auto hMatrixRegMat = getOptionalInput(WeightingInSourceSpace);
59+
auto hMatrixNoiseCov = getOptionalInput(WeightingInSensorSpace);
5860

5961
const bool computeRegularizedInverse = oport_connected(InverseSolution);
6062

6163
if (needToExecute())
6264
{
6365

64-
using namespace BioPSE;
65-
auto state = get_state();
66+
auto state = get_state();
6667

68+
auto gui_tikhonov_case = static_cast<SolveInverseProblemWithTikhonovSVD_impl::AlgorithmChoice>(state->getValue(TikhonovCase).toInt());
69+
auto gui_tikhonov_solution_subcase = static_cast<SolveInverseProblemWithTikhonovSVD_impl::AlgorithmSolutionSubcase>(state->getValue(Core::Algorithms::Inverse::Parameters::TikhonovSolutionSubcase).toInt());
70+
auto gui_tikhonov_residual_subcase = static_cast<SolveInverseProblemWithTikhonovSVD_impl::AlgorithmResidualSubcase>(state->getValue(Core::Algorithms::Inverse::Parameters::TikhonovResidualSubcase).toInt());
6771

68-
auto denseForward = castMatrix::toDense(forward_matrix_h);
69-
auto measuredDense = convertMatrix::toDense(hMatrixMeasDat);
7072

7173

72-
SolveInverseProblemWithTikhonovSVD_impl algo( denseForward,
73-
measuredDense,
74-
computeRegularizedInverse,
75-
this);
74+
auto denseForward = castMatrix::toDense(forward_matrix_h);
75+
auto measuredDense = convertMatrix::toDense(hMatrixMeasDat);
76+
auto regMatDense = castMatrix::toDense(hMatrixRegMat.get_value_or(nullptr));
77+
auto noiseCovDense = castMatrix::toDense(hMatrixNoiseCov.get_value_or(nullptr));
7678

77-
TikhonovImplAbstractBase::Input::lcurveGuiUpdate update = boost::bind(&SolveInverseProblemWithTikhonovSVD::update_lcurve_gui, this, _1, _2, _3);
7879

79-
TikhonovImplAbstractBase::Input input(
80+
SolveInverseProblemWithTikhonovSVD_impl algo( denseForward,
81+
measuredDense,
82+
computeRegularizedInverse,
83+
this);
84+
85+
SolveInverseProblemWithTikhonovSVD_impl::Input::lcurveGuiUpdate update = boost::bind(&SolveInverseProblemWithTikhonovSVD::update_lcurve_gui, this, _1, _2, _3);
86+
87+
SolveInverseProblemWithTikhonovSVD_impl::Input input(
8088
state->getValue(RegularizationMethod).toString(),
8189
state->getValue(LambdaFromDirectEntry).toDouble(),
8290
state->getValue(LambdaSliderValue).toDouble(),
@@ -86,7 +94,7 @@ void SolveInverseProblemWithTikhonovSVD::execute()
8694
update);
8795

8896

89-
algo.run(input);
97+
algo.run1(input);
9098

9199
if (computeRegularizedInverse)
92100
{
@@ -137,13 +145,13 @@ void SolveInverseProblemWithTikhonovSVD::setStateDefaults()
137145
/////////////////////////////////////
138146
////// MODULE UI DECLARATION
139147
///////////////////////////////////
140-
const ModuleLookupInfo SolveInverseProblemWithTikhonovSVD::staticInfo_("SolveInverseProblemWithTikhonovSVD", "Inverse", "SCIRun");
148+
// const ModuleLookupInfo SolveInverseProblemWithTikhonovSVD::staticInfo_("SolveInverseProblemWithTikhonovSVD", "Inverse", "SCIRun");
141149

142150

143151
///////////////////////////////////
144152
//// UPDATE L-CURVE IN GUI
145153
//////////////////////////////////
146-
void SolveInverseProblemWithTikhonovSVD::update_lcurve_gui(const double lambda, const BioPSE::TikhonovAlgorithm::LCurveInput& input, const int lambda_index)
154+
void SolveInverseProblemWithTikhonovSVD::update_lcurve_gui(const double lambda, const Core::Algorithms::Inverse::TikhonovAlgorithm::LCurveInput& input, const int lambda_index)
147155
{
148156
auto state = get_state();
149157
state->setValue(LambdaCorner, lambda);

src/Modules/Legacy/Inverse/SolveInverseProblemWithTikhonovSVD.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ namespace SCIRun {
8080
static const Core::Algorithms::AlgorithmParameterName LambdaCorner;
8181
static const Core::Algorithms::AlgorithmParameterName LCurveText;
8282

83+
LEGACY_BIOPSE_MODULE
84+
85+
MODULE_TRAITS_AND_INFO(ModuleHasUI)
8386

8487
private:
8588
// update L-curve in UI
86-
void update_lcurve_gui(const double lambda, const BioPSE::TikhonovAlgorithm::LCurveInput& input, const int lambda_index);
89+
void update_lcurve_gui(const double lambda, const Core::Algorithms::Inverse::TikhonovAlgorithm::LCurveInput& input, const int lambda_index);
8790
};
8891

8992
}

0 commit comments

Comments
 (0)