Skip to content

Commit bb79c84

Browse files
merge newest master
2 parents 9f5c8b5 + fa9a967 commit bb79c84

File tree

63 files changed

+5839
-768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+5839
-768
lines changed

src/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ IF(BUILD_TESTING)
143143
MESSAGE( WARNING "Test resource path does not exist. Please set it correctly to run all the unit and regression tests. Clone this github repo to get all the files: https://github.com/CIBC-Internal/SCIRunTestData" )
144144
ENDIF()
145145

146-
ADD_DEFINITIONS(-DTEST_RESOURCE_ROOT_DIR="${USER_UNIT_TEST_RESOURCE_DIR}" -DBUILD_TESTING)
146+
ADD_DEFINITIONS(-DTEST_RESOURCE_ROOT_DIR="${SCIRUN_TEST_RESOURCE_DIR}" -DBUILD_TESTING)
147147
ENDIF()
148148

149149
########################################################################
@@ -675,6 +675,7 @@ SET_PROPERTY(TARGET Interface_Modules_Fields PROPERTY FOLDER "Interface/Module
675675
SET_PROPERTY(TARGET Interface_Modules_Bundle PROPERTY FOLDER "Interface/Modules")
676676
SET_PROPERTY(TARGET Interface_Modules_Matlab PROPERTY FOLDER "Interface/Modules")
677677
SET_PROPERTY(TARGET Interface_Modules_Forward PROPERTY FOLDER "Interface/Modules")
678+
SET_PROPERTY(TARGET Interface_Modules_Inverse PROPERTY FOLDER "Interface/Modules")
678679
SET_PROPERTY(TARGET Interface_Modules_Factory PROPERTY FOLDER "Interface/Modules")
679680
SET_PROPERTY(TARGET Interface_Application PROPERTY FOLDER "Interface/Application")
680681

@@ -692,6 +693,7 @@ SET_PROPERTY(TARGET Modules_BrainStimulator PROPERTY FOLDER "Modules/Brain")
692693
SET_PROPERTY(TARGET Modules_Legacy_FiniteElements PROPERTY FOLDER "Modules/FiniteElements")
693694
SET_PROPERTY(TARGET Modules_Legacy_Fields PROPERTY FOLDER "Modules/Fields")
694695
SET_PROPERTY(TARGET Modules_Legacy_Forward PROPERTY FOLDER "Modules/Forward")
696+
SET_PROPERTY(TARGET Modules_Legacy_Inverse PROPERTY FOLDER "Modules/Inverse")
695697
SET_PROPERTY(TARGET Modules_Legacy_Matlab_DataIO PROPERTY FOLDER "Modules/DataIO")
696698
SET_PROPERTY(TARGET Modules_Factory PROPERTY FOLDER "Modules")
697699

src/Core/Algorithms/Base/AlgorithmVariableNames.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ PARAMETER(ColorMapName)
4747
PARAMETER(FileTypeList)
4848
PARAMETER(FileExtension)
4949
PARAMETER(FileTypeName)
50+
PARAMETER(FunctionString)
5051

5152
INPUT(InputMatrix)
5253
INPUT(FirstMatrix)

src/Core/Algorithms/Base/AlgorithmVariableNames.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class SCISHARE Variables
5252
static const AlgorithmParameterName FileTypeList;
5353
static const AlgorithmParameterName FileExtension;
5454
static const AlgorithmParameterName FileTypeName;
55+
static const AlgorithmParameterName FunctionString;
5556

5657
static const AlgorithmInputName InputMatrix;
5758
static const AlgorithmInputName FirstMatrix;

src/Core/Algorithms/BrainStimulator/SetupRHSforTDCSandTMSAlgorithm.cc

Lines changed: 109 additions & 69 deletions
Large diffs are not rendered by default.

src/Core/Algorithms/BrainStimulator/SetupRHSforTDCSandTMSAlgorithm.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
DEALINGS IN THE SOFTWARE.
2727
*/
2828

29-
///@file SetupRHSforTDCSandTMSAlgorithm
29+
///@file SetupTDCSAlgorithm
3030
///@brief
3131
/// This module sets up tDCS by providing the right hand side vector (parameterized by module GUI) and inputs for the modules: AddKnownsToLinearSystem, BuildTDCSMatrix.
3232
///
@@ -37,8 +37,8 @@
3737
/// .
3838
///
3939

40-
#ifndef ALGORITHMS_MATH_SETUPRHSFORTDCSANDTMSALGORITHM_H
41-
#define ALGORITHMS_MATH_SETUPRHSFORTDCSANDTMSALGORITHM_H
40+
#ifndef ALGORITHMS_MATH_SetupTDCSAlgorithm_H
41+
#define ALGORITHMS_MATH_SetupTDCSAlgorithm_H
4242

4343
#include <Core/Algorithms/Base/AlgorithmBase.h>
4444
#include <Core/Algorithms/BrainStimulator/share.h>
@@ -49,6 +49,7 @@ namespace Algorithms {
4949
namespace BrainStimulator {
5050
ALGORITHM_PARAMETER_DECL(ImpedanceTableValues);
5151
ALGORITHM_PARAMETER_DECL(ElectrodeTableValues);
52+
ALGORITHM_PARAMETER_DECL(SurfaceAreaValues);
5253
ALGORITHM_PARAMETER_DECL(ELECTRODE_VALUES);
5354
ALGORITHM_PARAMETER_DECL(IMPEDANCE_VALUES);
5455
ALGORITHM_PARAMETER_DECL(refnode);
@@ -62,7 +63,8 @@ namespace BrainStimulator {
6263
SetupTDCSAlgorithm();
6364
virtual AlgorithmOutput run_generic(const AlgorithmInput& input) const;
6465

65-
boost::tuple<Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, FieldHandle, Datatypes::DenseMatrixHandle> run(FieldHandle mesh, const std::vector<Variable>& elcs, const std::vector<Variable>& impelc,int num_of_elc, FieldHandle scalp_tri_surf, FieldHandle elc_tri_surf, SCIRun::Core::Datatypes::DenseMatrixHandle elc_sponge_location) const;
66+
boost::tuple<Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle,
67+
Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, FieldHandle, Datatypes::DenseMatrixHandle, std::vector<double>> run(FieldHandle mesh, const std::vector<Variable>& elcs, const std::vector<Variable>& impelc,int num_of_elc, FieldHandle scalp_tri_surf, FieldHandle elc_tri_surf, SCIRun::Core::Datatypes::DenseMatrixHandle elc_sponge_location) const;
6668

6769
//static AlgorithmParameterName number_of_electrodes();
6870

@@ -82,10 +84,11 @@ namespace BrainStimulator {
8284
static Core::Algorithms::AlgorithmParameterName ElectrodeParameterName(int i);
8385
static Core::Algorithms::AlgorithmParameterName ElectrodeImpedanceParameterName(int i);
8486
private:
85-
static const double special_label;
87+
static const int special_label;
88+
static const int max_number_of_electrodes;
8689
static const double electode_current_summation_bound;
8790
SCIRun::Core::Datatypes::DenseMatrixHandle create_rhs(FieldHandle mesh, const std::vector<Variable>& elcs, int num_of_elc) const;
88-
boost::tuple<Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, FieldHandle> create_lhs(FieldHandle mesh, const std::vector<Variable>& impelc, FieldHandle scalp_tri_surf, FieldHandle elc_tri_surf, SCIRun::Core::Datatypes::DenseMatrixHandle elc_sponge_location) const;
91+
boost::tuple<Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, Datatypes::DenseMatrixHandle, FieldHandle, std::vector<double>> create_lhs(FieldHandle mesh, const std::vector<Variable>& impelc, FieldHandle scalp_tri_surf, FieldHandle elc_tri_surf, SCIRun::Core::Datatypes::DenseMatrixHandle elc_sponge_location) const;
8992
};
9093

9194
}}}}

src/Core/Algorithms/Math/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ TARGET_LINK_LIBRARIES(Algorithms_Math
6666
Core_Datatypes
6767
Core_Thread
6868
Algorithms_Base
69+
Core_Parser
6970
${SCI_BOOST_LIBRARY}
7071
)
7172

src/Core/Algorithms/Math/EvaluateLinearAlgebraBinaryAlgo.cc

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@
3030
#include <Core/Algorithms/Base/AlgorithmVariableNames.h>
3131
#include <Core/Algorithms/Math/EvaluateLinearAlgebraBinaryAlgo.h>
3232
#include <Core/Datatypes/DenseMatrix.h>
33+
#include <Core/Parser/ArrayMathEngine.h>
34+
#include <Core/Datatypes/MatrixTypeConversions.h>
3335

3436
using namespace SCIRun::Core::Algorithms;
3537
using namespace SCIRun::Core::Datatypes;
3638
using namespace SCIRun::Core::Algorithms::Math;
39+
using namespace SCIRun;
3740

3841
EvaluateLinearAlgebraBinaryAlgorithm::EvaluateLinearAlgebraBinaryAlgorithm()
3942
{
4043
addParameter(Variables::Operator, 0);
44+
addParameter(Variables::FunctionString, "x+y");
4145
}
4246

4347
EvaluateLinearAlgebraBinaryAlgorithm::Outputs EvaluateLinearAlgebraBinaryAlgorithm::run(const EvaluateLinearAlgebraBinaryAlgorithm::Inputs& inputs, const EvaluateLinearAlgebraBinaryAlgorithm::Parameters& params) const
@@ -48,8 +52,7 @@ EvaluateLinearAlgebraBinaryAlgorithm::Outputs EvaluateLinearAlgebraBinaryAlgorit
4852
ENSURE_ALGORITHM_INPUT_NOT_NULL(lhs, "lhs");
4953
ENSURE_ALGORITHM_INPUT_NOT_NULL(rhs, "rhs");
5054

51-
Operator oper = params;
52-
55+
Operator oper = params.get<0>();
5356
/// @todo: absolutely need matrix move semantics here!!!!!!!
5457
switch (oper)
5558
{
@@ -65,6 +68,31 @@ EvaluateLinearAlgebraBinaryAlgorithm::Outputs EvaluateLinearAlgebraBinaryAlgorit
6568
result.reset(lhs->clone());
6669
*result *= *rhs;
6770
break;
71+
case FUNCTION:
72+
{
73+
NewArrayMathEngine engine;
74+
MatrixHandle lhsInput, rhsInput;
75+
lhsInput.reset(lhs->clone());
76+
rhsInput.reset(rhs->clone());
77+
78+
if (!(engine.add_input_fullmatrix("x", lhsInput ) )) ;//return;
79+
if (!(engine.add_input_fullmatrix("y", rhsInput ) )) ;//return;
80+
81+
boost::optional<std::string> func = params.get<1>();
82+
std::string function_string = func.get();
83+
84+
function_string = "RESULT="+function_string;
85+
engine.add_expressions(function_string);
86+
87+
if(!(engine.add_output_fullmatrix("RESULT",lhsInput))) ;//return;
88+
//if (!(engine.add_output_fullmatrix("RESULT", lhsInput)));
89+
// Actual engine call, which does the dynamic compilation, the creation of the
90+
// code for all the objects, as well as inserting the function and looping
91+
// over every data point
92+
if (!(engine.run())) ;//return;
93+
result = matrix_cast::as_dense(lhsInput);
94+
}
95+
break;
6896
default:
6997
THROW_ALGORITHM_INPUT_ERROR("ERROR: unknown binary operation");
7098
break;
@@ -77,8 +105,9 @@ AlgorithmOutput EvaluateLinearAlgebraBinaryAlgorithm::run_generic(const Algorith
77105
{
78106
auto LHS = input.get<DenseMatrix>(Variables::LHS);
79107
auto RHS = input.get<DenseMatrix>(Variables::RHS);
108+
auto func = boost::make_optional(get(Variables::FunctionString).toString());
80109

81-
auto result = run(boost::make_tuple(LHS, RHS), Operator(get(Variables::Operator).toInt()));
110+
auto result = run(boost::make_tuple(LHS, RHS), boost::make_tuple(Operator(get(Variables::Operator).toInt()), func));
82111

83112
AlgorithmOutput output;
84113
output[Variables::Result] = result;

src/Core/Algorithms/Math/EvaluateLinearAlgebraBinaryAlgo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ namespace SCIRun {
3737
namespace Core {
3838
namespace Algorithms {
3939
namespace Math {
40-
4140
class SCISHARE EvaluateLinearAlgebraBinaryAlgorithm : public AlgorithmBase
4241
{
4342
public:
4443
enum Operator
4544
{
4645
ADD,
4746
SUBTRACT,
48-
MULTIPLY
47+
MULTIPLY,
48+
FUNCTION
4949
};
5050

5151
/// @todo: idea (type, name)
@@ -54,7 +54,7 @@ namespace Math {
5454

5555
EvaluateLinearAlgebraBinaryAlgorithm();
5656
typedef boost::tuple<SCIRun::Core::Datatypes::DenseMatrixConstHandle, SCIRun::Core::Datatypes::DenseMatrixConstHandle> Inputs;
57-
typedef Operator Parameters;
57+
typedef boost::tuple<Operator, boost::optional<std::string> > Parameters;
5858
typedef SCIRun::Core::Datatypes::DenseMatrixHandle Outputs;
5959

6060
Outputs run(const Inputs& inputs, const Parameters& params) const;

src/Core/Algorithms/Math/EvaluateLinearAlgebraUnaryAlgo.cc

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include <Core/Datatypes/DenseMatrix.h>
3333
#include <stdexcept>
3434

35+
#include <Core/Parser/ArrayMathEngine.h>
36+
#include <Core/Datatypes/MatrixTypeConversions.h>
37+
3538
using namespace SCIRun::Core::Datatypes;
3639
using namespace SCIRun::Core::Algorithms::Math;
3740
using namespace SCIRun::Core::Algorithms;
@@ -40,6 +43,7 @@ EvaluateLinearAlgebraUnaryAlgorithm::EvaluateLinearAlgebraUnaryAlgorithm()
4043
{
4144
addParameter(Variables::Operator, 0);
4245
addParameter(Variables::ScalarValue, 0);
46+
addParameter(Variables::FunctionString, "x+10");
4347
}
4448

4549
EvaluateLinearAlgebraUnaryAlgorithm::Outputs EvaluateLinearAlgebraUnaryAlgorithm::run(const EvaluateLinearAlgebraUnaryAlgorithm::Inputs& matrix, const EvaluateLinearAlgebraUnaryAlgorithm::Parameters& params) const
@@ -50,7 +54,7 @@ EvaluateLinearAlgebraUnaryAlgorithm::Outputs EvaluateLinearAlgebraUnaryAlgorithm
5054
Operator oper = params.get<0>();
5155

5256
/// @todo: absolutely need matrix move semantics here!!!!!!!
53-
switch (oper)
57+
switch (oper)
5458
{
5559
case NEGATE:
5660
result.reset(matrix->clone());
@@ -70,6 +74,28 @@ EvaluateLinearAlgebraUnaryAlgorithm::Outputs EvaluateLinearAlgebraUnaryAlgorithm
7074
(*result) *= scalar;
7175
}
7276
break;
77+
case FUNCTION:
78+
{
79+
NewArrayMathEngine engine;
80+
MatrixHandle matrixInput;
81+
matrixInput.reset(matrix->clone());
82+
83+
if (!(engine.add_input_fullmatrix("x", matrixInput ) )) ;
84+
85+
boost::optional<std::string> func = params.get<2>();
86+
std::string function_string = func.get();
87+
88+
function_string = "RESULT="+function_string;
89+
engine.add_expressions(function_string);
90+
91+
if(!(engine.add_output_fullmatrix("RESULT",matrixInput))) ;
92+
// Actual engine call, which does the dynamic compilation, the creation of the
93+
// code for all the objects, as well as inserting the function and looping
94+
// over every data point
95+
if (!(engine.run())) ;
96+
result = matrix_cast::as_dense(matrixInput);
97+
}
98+
break;
7399
default:
74100
THROW_ALGORITHM_INPUT_ERROR("Unknown operand");
75101
}
@@ -82,7 +108,9 @@ AlgorithmOutput EvaluateLinearAlgebraUnaryAlgorithm::run_generic(const Algorithm
82108
auto matrix = input.get<DenseMatrix>(Variables::InputMatrix);
83109

84110
auto scalar = boost::make_optional(get(Variables::ScalarValue).toDouble());
85-
auto result = run(matrix, boost::make_tuple(Operator(get(Variables::Operator).toInt()), scalar));
111+
auto function = boost::make_optional(get(Variables::FunctionString).toString());
112+
113+
auto result = run(matrix, boost::make_tuple(Operator(get(Variables::Operator).toInt()), scalar, function));
86114

87115
AlgorithmOutput output;
88116
output[Variables::Result] = result;

src/Core/Algorithms/Math/EvaluateLinearAlgebraUnaryAlgo.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#include <Core/Algorithms/Base/AlgorithmBase.h>
3333
#include <Core/Datatypes/MatrixFwd.h>
34-
#include <boost/optional.hpp>
34+
//#include <boost/optional.hpp>
3535
#include <Core/Algorithms/Math/share.h>
3636

3737
/// \addtogroup Algorithms_Math
@@ -85,11 +85,12 @@ namespace Math {
8585
{
8686
NEGATE,
8787
TRANSPOSE,
88-
SCALAR_MULTIPLY
88+
SCALAR_MULTIPLY,
89+
FUNCTION
8990
};
9091

9192
typedef SCIRun::Core::Datatypes::DenseMatrixConstHandle Inputs;
92-
typedef boost::tuple<Operator, boost::optional<double> > Parameters;
93+
typedef boost::tuple<Operator, boost::optional<double>, boost::optional<std::string> > Parameters;
9394
typedef SCIRun::Core::Datatypes::DenseMatrixHandle Outputs;
9495

9596
EvaluateLinearAlgebraUnaryAlgorithm();

0 commit comments

Comments
 (0)