34 addUsageLine(
"Search for a linear transformation of the gray values of a volume so that the");
35 addUsageLine(
"error between the theoretically projected images and the experimental images");
36 addUsageLine(
"is minimized. This program must be used before computing the Volumetric SSNR");
37 addUsageLine(
"if the reconstruction algorithm scales the output volume differently.");
42 addExampleLine(
"xmipp_adjust_volume_grey_levels -i input_volume.vol -m experimental.sel -o output_volume.vol ");
45 addParamsLine(
" -i <volume_file> : Volume to adjust its range.");
47 addParamsLine(
" -m <metadata_file> : Set of projections of the volume.");
49 addParamsLine(
" [-o <volume_file=\"\">] : Output adjusted volume. By default, the input one.");
51 addParamsLine(
" [--optimize] : Optimize the linear transformation. By default, keep the initially computed.");
52 addParamsLine(
" [--probb_eval <p=0.2>] : The goal function is evaluated each time from a random set of projections.");
53 addParamsLine(
" : Each image has a probability of p of being evaluated.");
84 ImOut().setXmippOrigin();
99 return globalAdjustVolumeProg->
mismatching(p[1], p[2]);
119 std::cerr <<
"Empty inputFile File\n";
125 for (
size_t objId :
SF.
ids())
134 I().setXmippOrigin();
144 retval += diff.sum2();
148 I.
write(
"PPPexp.xmp");
150 I.
write(
"PPPtheo.xmp");
151 std::cout <<
"Difference=" << diff.sum2() << std::endl;
152 std::cout <<
"Press any key\n";
172 double sum = 0, sum2 = 0, N = 0;
173 std::cerr <<
"Computing first estimate of the linear transformation ...\n";
178 int projXdim, projYdim;
181 std::cerr <<
"Empty inputFile File\n";
185 for (
size_t objId :
SF.
ids())
189 projXdim =
XSIZE(I());
190 projYdim =
YSIZE(I());
193 double avg=0., stddev=0.,
min,
max;
194 I().computeStats(avg, stddev,
min, max);
195 double Ni = projXdim * projYdim;
197 sum2 += stddev * stddev;
206 std::cout << std::endl;
209 double avg0=0., stddev0=0., min0, max0;
231 double avg_pict = sum / imgno;
232 double stddev_pict =
sqrt(sum2 / imgno);
233 double avgF = avg_pict / r;
234 double stddevF = stddev_pict /
sqrt(r);
235 double a = stddevF / stddev0;
236 double b = avgF - a * avg0;
237 std::cout <<
"First Linear transformation: y=" << a <<
"*x+" << b << std::endl;
246 double ftol = 0.01, fret;
248 globalAdjustVolumeProg =
this;
250 ftol, fret, iter, steps,
true);
263 std::cout <<
"Input Volume: " <<
fn_vol << std::endl
264 <<
"Input MetaDAtaFile: " <<
fn_sel << std::endl
265 <<
"Output Volume: " <<
fn_out << std::endl
266 <<
"Optimize: " <<
optimize << std::endl;
void init_progress_bar(long total)
ProgAdjustVolume * globalAdjustVolumeProg
void min(Image< double > &op1, const Image< double > &op2)
double mismatching(double a, double b)
double getDoubleParam(const char *param, int arg=0)
#define REPORT_ERROR(nerr, ErrormMsg)
double psi(const size_t n=0) const
void sqrt(Image< double > &op)
MultidimArray< double > V
void computeStats(double &avg, double &stddev, T &minval, T &maxval) const
double probb_eval
Probability of being evaluated.
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 rot(const size_t n=0) const
int readApplyGeo(const FileName &name, const MDRow &row, const ApplyGeoParams ¶ms=DefaultApplyGeoParams)
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
double tilt(const size_t n=0) const
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
const char * getParam(const char *param, int arg=0)
void progress_bar(long rlen)
void max(Image< double > &op1, const Image< double > &op2)
Error related to numerical calculation.
void addExampleLine(const char *example, bool verbatim=true)
void projectVolume(FourierProjector &projector, Projection &P, int Ydim, int Xdim, double rot, double tilt, double psi, const MultidimArray< double > *ctf)
int verbose
Verbosity level.
void alias(const MultidimArray< T > &m)
#define STR_EQUAL(str1, str2)
FileName fn_sel
Filename with the input projections.
void apply(MultidimArray< float > &output_volume)
double projectionMismatching(double *p, void *prm)
bool checkParam(const char *param)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
void addUsageLine(const char *line, bool verbatim=false)
int getIntParam(const char *param, int arg=0)
void mapFile2Write(size_t Xdim, size_t Ydim, size_t Zdim, const FileName &_filename, bool createTempFile=false, size_t select_img=APPEND_IMAGE, bool isStack=false, int mode=WRITE_OVERWRITE)
void addParamsLine(const String &line)
FileName fn_vol
Filename with the input volume.