45 addUsageLine(
"Calculate histogram from a metadata column(1D) or from a couple of columns(2D)");
47 addParamsLine(
" [-o <text_file=\"/dev/stdout\">] : output text file with histogram, by default standard output");
48 addParamsLine(
" --col <label> : column to create the histogram");
49 addParamsLine(
" [--range <m> <M>] : range for the histogram, automatic calculated if not provided");
51 addParamsLine(
" [--col2 <label=\"\"> ] : if specified, a 2D histogram is calculated");
52 addParamsLine(
" [--range2 <m> <M>] : range for second column in 2D histogram");
54 addParamsLine(
" [--steps2 <N=100>] : number of subdivisions in second column");
56 addParamsLine(
" [--percentil <p=50.>] : Only for 1D histograms");
57 addParamsLine(
" [--write_as_image <image_file>] : Only for 2D histograms");
60 addExampleLine(
"Calculate the histogram of the column 'angleRot' from a metadata:",
false);
61 addExampleLine(
"xmipp_metadata_histogram -i images.xmd --col angleRot -o hist.txt");
69 const char* colStr = second ?
"--col2" :
"--col";
70 const char* rangeStr = second ?
"--range2" :
"--range";
71 const char* stepStr = second ?
"--steps2" :
"--steps";
92 std::vector<double> columnValues;
94 values = columnValues;
105 readColumn(col, automatic_range, m, M, StepsNo);
108 readColumn(col2, automatic_range2, m2, M2, StepsNo2,
true);
110 if ((write_img =
checkParam(
"--write_as_image")))
111 fn_img =
getParam(
"--write_as_image");
116 double avg=0., stddev=0.,
dummy;
123 std::cout <<
formatString(
"min: %f max: %f steps: %d", m, M, StepsNo) << std::endl;
125 std::cout <<
formatString(
"mean: %f stddev: %f", avg, stddev) << std::endl;
133 compute_hist(C, C2, hist2, m, M, m2, M2, StepsNo, StepsNo2);
135 std::cout <<
formatString(
"min1: %f max1: %f steps1: %d", m, M, StepsNo) << std::endl;
137 std::cout <<
formatString(
"mean: %f stddev: %f", avg, stddev) << std::endl;
139 std::cout <<
formatString(
"min2: %f max2: %f steps2: %d", m2, M2, StepsNo2) << std::endl;
141 std::cout <<
formatString(
"mean: %f stddev: %f", avg, stddev) << std::endl;
double getDoubleParam(const char *param, int arg=0)
static MDLabel str2Label(const String &labelName)
#define REPORT_ERROR(nerr, ErrormMsg)
void computeStats(double &avg, double &stddev, T &minval, T &maxval) const
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
double percentil(double percent_mass)
void addSeeAlsoLine(const char *seeAlso)
const char * getParam(const char *param, int arg=0)
void compute_hist(const MultidimArrayGeneric &array, Histogram1D &hist, int no_steps)
void computeDoubleMinMax(double &minval, double &maxval) const
void addExampleLine(const char *example, bool verbatim=true)
void write(const FileName &fn)
void write(const FileName &fn, MDLabel=MDL_X, MDLabel=MDL_COUNT)
static bool isDouble(const MDLabel label)
String formatString(const char *format,...)
bool checkParam(const char *param)
void addUsageLine(const char *line, bool verbatim=false)
int getIntParam(const char *param, int arg=0)
void addParamsLine(const String &line)