@@ -78,6 +78,23 @@ GenerateROIStatisticsAlgorithm::GenerateROIStatisticsAlgorithm()
7878 addParameter (CoordinateSpaceLabelStr, std::string ());
7979}
8080
81+ namespace
82+ {
83+ std::string formatStatistic (double x)
84+ {
85+ if (IsNan (x))
86+ return " NaN" ;
87+ return boost::str (boost::format (" %.3f" ) % x);
88+ }
89+
90+ std::string formatCount (double x)
91+ {
92+ if (IsNan (x))
93+ return " NaN" ;
94+ return boost::str (boost::format (" %d" ) % x);
95+ }
96+ }
97+
8198// / the run function can deal with multiple inputs and performs the analysis for all ROIs in the atlas mesh and for the user specified ROI
8299boost::tuple<DenseMatrixHandle, VariableHandle> GenerateROIStatisticsAlgorithm::run (FieldHandle mesh, FieldHandle AtlasMesh, const FieldHandle CoordinateSpace, const std::string& AtlasMeshLabels, const DenseMatrixHandle specROI) const
83100{
@@ -249,11 +266,11 @@ boost::tuple<DenseMatrixHandle, VariableHandle> GenerateROIStatisticsAlgorithm::
249266 {
250267 Variable::List tmp;
251268 tmp += makeVariable (" name" , AtlasMeshLabels_vector[i]), // label name
252- makeVariable (" col0" , boost::str ( boost::format ( " %.3f " ) % (*output)(i,0 ))), // average
253- makeVariable (" col1" , boost::str ( boost::format ( " %.3f " ) % (*output)(i,1 ))), // stddev
254- makeVariable (" col2" , boost::str ( boost::format ( " %.3f " ) % (*output)(i,2 ))), // min
255- makeVariable (" col3" , boost::str ( boost::format ( " %.3f " ) % (*output)(i,3 ))), // max
256- makeVariable (" col4" , boost::str ( boost::format ( " %d " ) % (*output)(i,4 ))); // element count
269+ makeVariable (" col0" , formatStatistic ( (*output)(i,0 ))), // average
270+ makeVariable (" col1" , formatStatistic ( (*output)(i,1 ))), // stddev
271+ makeVariable (" col2" , formatStatistic ( (*output)(i,2 ))), // min
272+ makeVariable (" col3" , formatStatistic ( (*output)(i,3 ))), // max
273+ makeVariable (" col4" , formatCount ( (*output)(i,4 ))); // element count
257274
258275 elc_vals_in_table.push_back (makeVariable (" row" + boost::lexical_cast<std::string>(i), tmp));
259276 }
0 commit comments