48 min (INFINITY, INFINITY),
49 max (-INFINITY, -INFINITY),
52 ignore_zero (ignorezero) { }
56 if (std::isfinite (val.real()) && std::isfinite (val.imag()) && !(ignore_zero && val.real() == 0.0 && val.imag() == 0.0)) {
57 if (min.real() > val.real()) min =
complex_type (val.real(), min.imag());
58 if (min.imag() > val.imag()) min =
complex_type (min.real(), val.imag());
59 if (max.real() < val.real()) max =
complex_type (val.real(), max.imag());
60 if (max.imag() < val.imag()) max =
complex_type (max.real(), val.imag());
64 mean +=
cdouble(delta.real() / count, delta.imag() / count);
66 m2 +=
cdouble(delta.real() * delta2.real(), delta.imag() * delta2.imag());
68 values.push_back(val.real());
77 std::sort (values.begin(), values.end());
81 if (fields.size() == 1 && fields.front() ==
"count") {
85 throw Exception (
"Cannot output statistic of interest; no values read (empty mask?)");
88 for (
size_t n = 0; n < fields.size(); ++n) {
89 if (fields[n] ==
"mean") std::cout <<
str(mean) <<
" ";
90 else if (fields[n] ==
"median") std::cout << ( values.size() > 0 ?
str(
Math::median (values)) :
"N/A" ) <<
" ";
91 else if (fields[n] ==
"std") std::cout << ( count > 1 ?
str(
std) :
"N/A" ) <<
" ";
92 else if (fields[n] ==
"std_rv") std::cout << ( count > 1 ?
str(std_rv) :
"N/A" ) <<
" ";
93 else if (fields[n] ==
"min") std::cout <<
str(min) <<
" ";
94 else if (fields[n] ==
"max") std::cout <<
str(max) <<
" ";
95 else if (fields[n] ==
"count") std::cout << count <<
" ";
96 else throw Exception(
"stats type not supported: " + fields[n]);
103 std::string s =
"[ ";
105 for (
size_t n = 3; n < ima.ndim(); n++)
106 s +=
str (ima.index(n)) +
" ";
112 std::cout << std::setw(12) << std::right << s <<
" ";
114 std::cout << std::setw(width) << std::right << ( count ?
str(mean) :
"N/A" );
117 std::cout <<
" " << std::setw(width) << std::right;
123 std::cout <<
" " << std::setw(width) << std::right << ( count > 1 ?
str(
std) :
"N/A" )
124 <<
" " << std::setw(width) << std::right << ( count ?
str(min) :
"N/A" )
125 <<
" " << std::setw(width) << std::right << ( count ?
str(max) :
"N/A" )
126 <<
" " << std::setw(10) << std::right << count <<
"\n";
143 std::cout << std::setw(12) << std::right <<
"volume"
144 <<
" " << std::setw(width) << std::right <<
"mean";
146 std::cout <<
" " << std::setw(width) << std::right <<
"median";
147 std::cout <<
" " << std::setw(width) << std::right <<
"std"
148 <<
" " << std::setw(width) << std::right <<
"min"
149 <<
" " << std::setw(width) << std::right <<
"max"
150 <<
" " << std::setw(10) << std::right <<
"count" <<
"\n";
a class to hold a named list of Option's
Stats(const bool is_complex=false, const bool ignorezero=false)
void operator()(complex_type val)
void print(ImageType &ima, const vector< std::string > &fields)
Container::value_type median(Container &list)
void print_header(bool is_complex)
const char * field_choices[]
const App::OptionGroup Options
std::complex< double > cdouble
double default_type
the default type used throughout MRtrix
std::string str(const T &value, int precision=0)
check whether type is complex: