5252#include < boost/algorithm/string/trim.hpp>
5353#include < boost/algorithm/string/split.hpp>
5454#include < boost/format.hpp>
55- #include < boost/assign.hpp>
56- #include < math.h>
5755#include < Core/Math/MiscMath.h>
5856
5957using namespace SCIRun ::Core::Algorithms;
@@ -62,9 +60,6 @@ using namespace SCIRun::Core::Algorithms::Fields;
6260using namespace SCIRun ::Core::Datatypes;
6361using namespace SCIRun ::Core::Geometry;
6462using namespace SCIRun ;
65- using namespace boost ;
66- using namespace boost ::assign;
67- using namespace Eigen ;
6863
6964ALGORITHM_PARAMETER_DEF (BrainStimulator, NumberOfPrototypes);
7065ALGORITHM_PARAMETER_DEF (BrainStimulator, TableValues);
@@ -141,7 +136,7 @@ VariableHandle ElectrodeCoilSetupAlgorithm::fill_table(FieldHandle, DenseMatrixH
141136
142137 if (tab_values.size () < locations->nrows ())
143138 {
144- row +=
139+ row = {
145140 Variable (columnNames[0 ], boost::str (boost::format (" %s" ) % " 0" )),
146141 Variable (columnNames[1 ], boost::str (boost::format (" %s" ) % " 0" )),
147142 Variable (columnNames[2 ], boost::str (boost::format (" %.3f" ) % (*locations)(i, 0 ))),
@@ -151,7 +146,7 @@ VariableHandle ElectrodeCoilSetupAlgorithm::fill_table(FieldHandle, DenseMatrixH
151146 Variable (columnNames[6 ], std::string (" ???" )),
152147 Variable (columnNames[7 ], std::string (" ???" )),
153148 Variable (columnNames[8 ], std::string (" ???" )),
154- Variable (columnNames[9 ], std::string (" ???" ));
149+ Variable (columnNames[9 ], std::string (" ???" )) } ;
155150/*
156151//TODO: this compiles but needs testing by user. Not sure it's an improvement.
157152 row = makeNamedVariableList(columnNames,
@@ -212,7 +207,7 @@ VariableHandle ElectrodeCoilSetupAlgorithm::fill_table(FieldHandle, DenseMatrixH
212207 Variable var8 = makeVariable (" NY" , boost::str (boost::format (" %s" ) % str8));
213208 Variable var9 = makeVariable (" NZ" , boost::str (boost::format (" %s" ) % str9));
214209 Variable var10 = makeVariable (" thickness" , boost::str (boost::format (" %s" ) % str10));
215- row += var1, var2, var3, var4, var5, var6, var7, var8, var9, var10;
210+ row = { var1, var2, var3, var4, var5, var6, var7, var8, var9, var10 } ;
216211
217212 }
218213 }
@@ -230,9 +225,9 @@ DenseMatrixHandle ElectrodeCoilSetupAlgorithm::make_rotation_matrix(const double
230225 DenseMatrixHandle result (new DenseMatrix (3 , 3 ));
231226
232227 double normal_vector_norm = sqrt (normal[0 ] * normal[0 ] + normal[1 ] * normal[1 ] + normal[2 ] * normal[2 ]);
233- Vector3d normal_vector ((double )normal[0 ] / normal_vector_norm, (double )normal[1 ] / normal_vector_norm, (double )normal[2 ] / normal_vector_norm);
228+ Eigen:: Vector3d normal_vector ((double )normal[0 ] / normal_vector_norm, (double )normal[1 ] / normal_vector_norm, (double )normal[2 ] / normal_vector_norm);
234229
235- Vector3d tan_vector1, tan_vector2;
230+ Eigen:: Vector3d tan_vector1, tan_vector2;
236231 if (normal_vector (0 ) != 0 || normal_vector (2 ) != 0 )
237232 {
238233 tan_vector1 (0 ) = normal_vector (2 );
@@ -254,8 +249,6 @@ DenseMatrixHandle ElectrodeCoilSetupAlgorithm::make_rotation_matrix(const double
254249 tan_vector2 = normal_vector.cross (tan_vector1);
255250 normal_vector_norm = sqrt (tan_vector2 (0 )*tan_vector2 (0 ) + tan_vector2 (1 )*tan_vector2 (1 ) + tan_vector2 (2 )*tan_vector2 (2 ));
256251 tan_vector2 (0 ) /= normal_vector_norm; tan_vector2 (1 ) /= normal_vector_norm; tan_vector2 (2 ) /= normal_vector_norm;
257- DenseMatrixHandle rotation_matrix2;
258- Matrix3d rotation_matrix (3 , 3 ), rotation_matrix1 (3 , 3 );
259252
260253 (*result)(0 , 2 ) = normal_vector (0 );
261254 (*result)(1 , 2 ) = normal_vector (1 );
@@ -299,7 +292,7 @@ FieldHandle ElectrodeCoilSetupAlgorithm::make_tms(FieldHandle scalp, const std::
299292 VMesh* tms_coils_vmesh = tms_coils_field->vmesh ();
300293 VField* tms_coils_vfld = tms_coils_field->vfield ();
301294 std::vector<Point> tms_coils_field_values;
302-
295+
303296 for (int i = 0 ; i < coil_prototyp_map.size (); i++)
304297 {
305298 if (coil_prototyp_map[i] <= elc_coil_proto.size () && coil_prototyp_map[i] >= 0 )
@@ -340,7 +333,7 @@ FieldHandle ElectrodeCoilSetupAlgorithm::make_tms(FieldHandle scalp, const std::
340333 THROW_ALGORITHM_PROCESSING_ERROR (" Internal error: could not retrieve coil prototype positions " );
341334 }
342335
343- DenseMatrixHandle magnetic_dipoles (boost::make_shared<DenseMatrix>(fielddata->nrows (), 3 ));
336+ auto magnetic_dipoles (boost::make_shared<DenseMatrix>(fielddata->nrows (), 3ul ));
344337
345338 // / subtract the mean from the coil positions to move them accourding to GUI table entries
346339 double mean_loc_x = 0 , mean_loc_y = 0 , mean_loc_z = 0 ;
@@ -524,7 +517,6 @@ FieldHandle ElectrodeCoilSetupAlgorithm::make_tms(FieldHandle scalp, const std::
524517
525518boost::tuple<Variable::List, double , double , double > ElectrodeCoilSetupAlgorithm::make_table_row (int i, double x, double y, double z, double nx, double ny, double nz) const
526519{
527- Variable::List row;
528520 double out_nx, out_ny, out_nz;
529521 auto tab_values = get (Parameters::TableValues).toVector ();
530522 auto col = tab_values[i].toVector ();
@@ -552,7 +544,7 @@ boost::tuple<Variable::List, double, double, double> ElectrodeCoilSetupAlgorithm
552544 {
553545 out_nx = boost::lexical_cast<double >(col[6 ].toString ());
554546 }
555- catch (bad_lexical_cast&) {}
547+ catch (boost:: bad_lexical_cast&) {}
556548 }
557549
558550 if (str8.compare (" ???" ) == 0 )
@@ -566,7 +558,7 @@ boost::tuple<Variable::List, double, double, double> ElectrodeCoilSetupAlgorithm
566558 {
567559 out_ny = boost::lexical_cast<double >(col[7 ].toString ());
568560 }
569- catch (bad_lexical_cast&) {}
561+ catch (boost:: bad_lexical_cast&) {}
570562 }
571563
572564 if (str9.compare (" ???" ) == 0 )
@@ -580,7 +572,7 @@ boost::tuple<Variable::List, double, double, double> ElectrodeCoilSetupAlgorithm
580572 {
581573 out_nz = boost::lexical_cast<double >(col[8 ].toString ());
582574 }
583- catch (bad_lexical_cast&) {}
575+ catch (boost:: bad_lexical_cast&) {}
584576 }
585577
586578 Variable var1 = makeVariable (" Input #" , boost::str (boost::format (" %s" ) % str1));
@@ -609,9 +601,9 @@ boost::tuple<Variable::List, double, double, double> ElectrodeCoilSetupAlgorithm
609601 Variable var7 = makeVariable (" NX" , boost::str (boost::format (" %s" ) % str7));
610602 Variable var8 = makeVariable (" NY" , boost::str (boost::format (" %s" ) % str8));
611603 Variable var9 = makeVariable (" NZ" , boost::str (boost::format (" %s" ) % str9));
612-
613604 Variable var10 = makeVariable (" thickness" , boost::str (boost::format (" %s" ) % str10));
614- row += var1, var2, var3, var4, var5, var6, var7, var8, var9, var10;
605+
606+ Variable::List row{ var1, var2, var3, var4, var5, var6, var7, var8, var9, var10 };
615607
616608 return boost::make_tuple (row, out_nx, out_ny, out_nz);
617609}
@@ -724,12 +716,10 @@ boost::tuple<DenseMatrixHandle, FieldHandle, FieldHandle, VariableHandle> Electr
724716 {
725717 THROW_ALGORITHM_PROCESSING_ERROR (" Internal error: could not retrieve positions from assigned prototype " );
726718 }
727-
728- if (fieldnodes->nrows () <= 0 ) // put this to tms as well
719+ if (fieldnodes->nrows () == 0 ) // put this to tms as well
729720 {
730721 THROW_ALGORITHM_PROCESSING_ERROR (" Internal error: could not retrieve positions from assigned prototype " );
731722 }
732-
733723 // /second, subtract the mean of the prototyp positions to center it in origin
734724 double mean_loc_x = 0 , mean_loc_y = 0 , mean_loc_z = 0 ;
735725 for (int j = 0 ; j < fieldnodes->nrows (); j++)
@@ -768,7 +758,6 @@ boost::tuple<DenseMatrixHandle, FieldHandle, FieldHandle, VariableHandle> Electr
768758 (*fieldnodes)(j, 1 ) = (*rotated_positions)(1 , 0 ) + elc_y[i];
769759 (*fieldnodes)(j, 2 ) = (*rotated_positions)(2 , 0 ) + elc_z[i];
770760 }
771-
772761 VMesh* prototype_vmesh = prototype->vmesh ();
773762
774763 FieldInformation fieldinfo (" TriSurfMesh" , CONSTANTDATA_E, " double" ); // / this is the final moved prototype for elc i
@@ -1433,19 +1422,19 @@ boost::tuple<VariableHandle, DenseMatrixHandle, FieldHandle, FieldHandle, FieldH
14331422
14341423 try
14351424 {
1436- c1 = lexical_cast<int >(row[0 ].toString ());
1425+ c1 = boost:: lexical_cast<int >(row[0 ].toString ());
14371426 }
1438- catch (bad_lexical_cast &)
1427+ catch (boost:: bad_lexical_cast &)
14391428 {
14401429 c1 = std::numeric_limits<double >::quiet_NaN ();
14411430 row_valid = false ;
14421431 }
14431432
14441433 try
14451434 {
1446- c2 = lexical_cast<int >(row[1 ].toString ());
1435+ c2 = boost:: lexical_cast<int >(row[1 ].toString ());
14471436 }
1448- catch (bad_lexical_cast &)
1437+ catch (boost:: bad_lexical_cast &)
14491438 {
14501439 c2 = std::numeric_limits<double >::quiet_NaN ();
14511440 row_valid = false ;
@@ -1460,9 +1449,9 @@ boost::tuple<VariableHandle, DenseMatrixHandle, FieldHandle, FieldHandle, FieldH
14601449 {
14611450 try
14621451 {
1463- c3 = lexical_cast<double >(str_x);
1452+ c3 = boost:: lexical_cast<double >(str_x);
14641453 }
1465- catch (bad_lexical_cast &)
1454+ catch (boost:: bad_lexical_cast &)
14661455 {
14671456 c3 = std::numeric_limits<double >::quiet_NaN ();
14681457 valid_position = false ;
@@ -1478,9 +1467,9 @@ boost::tuple<VariableHandle, DenseMatrixHandle, FieldHandle, FieldHandle, FieldH
14781467 {
14791468 try // /get the electrode thickness from GUI
14801469 {
1481- c4 = lexical_cast<double >(str_y);
1470+ c4 = boost:: lexical_cast<double >(str_y);
14821471 }
1483- catch (bad_lexical_cast &)
1472+ catch (boost:: bad_lexical_cast &)
14841473 {
14851474 c4 = std::numeric_limits<double >::quiet_NaN ();
14861475 valid_position = false ;
@@ -1496,9 +1485,9 @@ boost::tuple<VariableHandle, DenseMatrixHandle, FieldHandle, FieldHandle, FieldH
14961485 {
14971486 try // /get the electrode thickness from GUI
14981487 {
1499- c5 = lexical_cast<double >(str_z);
1488+ c5 = boost:: lexical_cast<double >(str_z);
15001489 }
1501- catch (bad_lexical_cast &)
1490+ catch (boost:: bad_lexical_cast &)
15021491 {
15031492 c5 = std::numeric_limits<double >::quiet_NaN ();
15041493 valid_position = false ;
@@ -1511,9 +1500,9 @@ boost::tuple<VariableHandle, DenseMatrixHandle, FieldHandle, FieldHandle, FieldH
15111500 {
15121501 try
15131502 {
1514- c6 = lexical_cast<double >(row[5 ].toString ());
1503+ c6 = boost:: lexical_cast<double >(row[5 ].toString ());
15151504 }
1516- catch (bad_lexical_cast &)
1505+ catch (boost:: bad_lexical_cast &)
15171506 {
15181507 c6 = std::numeric_limits<double >::quiet_NaN ();
15191508 }
@@ -1583,9 +1572,9 @@ boost::tuple<VariableHandle, DenseMatrixHandle, FieldHandle, FieldHandle, FieldH
15831572 // / get NX
15841573 try
15851574 {
1586- c7 = lexical_cast<double >(row[6 ].toString ());
1575+ c7 = boost:: lexical_cast<double >(row[6 ].toString ());
15871576 }
1588- catch (bad_lexical_cast &)
1577+ catch (boost:: bad_lexical_cast &)
15891578 {
15901579 c7 = std::numeric_limits<double >::quiet_NaN ();
15911580 valid_normal = false ;
@@ -1594,9 +1583,9 @@ boost::tuple<VariableHandle, DenseMatrixHandle, FieldHandle, FieldHandle, FieldH
15941583 // / get NY
15951584 try
15961585 {
1597- c8 = lexical_cast<double >(row[7 ].toString ());
1586+ c8 = boost:: lexical_cast<double >(row[7 ].toString ());
15981587 }
1599- catch (bad_lexical_cast &)
1588+ catch (boost:: bad_lexical_cast &)
16001589 {
16011590 c8 = std::numeric_limits<double >::quiet_NaN ();
16021591 valid_normal = false ;
@@ -1605,9 +1594,9 @@ boost::tuple<VariableHandle, DenseMatrixHandle, FieldHandle, FieldHandle, FieldH
16051594 // / get NZ
16061595 try
16071596 {
1608- c9 = lexical_cast<double >(row[8 ].toString ());
1597+ c9 = boost:: lexical_cast<double >(row[8 ].toString ());
16091598 }
1610- catch (bad_lexical_cast &)
1599+ catch (boost:: bad_lexical_cast &)
16111600 {
16121601 c9 = std::numeric_limits<double >::quiet_NaN ();
16131602 valid_normal = false ;
@@ -1616,9 +1605,9 @@ boost::tuple<VariableHandle, DenseMatrixHandle, FieldHandle, FieldHandle, FieldH
16161605 // / get electrode thickness
16171606 try
16181607 {
1619- c10 = lexical_cast<double >(row[9 ].toString ());
1608+ c10 = boost:: lexical_cast<double >(row[9 ].toString ());
16201609 }
1621- catch (bad_lexical_cast &)
1610+ catch (boost:: bad_lexical_cast &)
16221611 {
16231612 c10 = std::numeric_limits<double >::quiet_NaN ();
16241613 }
0 commit comments