27 template<
typename T >
30 readDenoisingParams();
31 readDeconvolutionParams();
32 readFilterBankParams();
33 readDifferenceParams();
37 template<
typename T >
39 fnV1 = getParam(
"--i1");
40 fnV2 = getParam(
"--i2");
41 fnRoot = getParam(
"--oroot");
44 template<
typename T >
46 const int iters = getIntParam(
"--denoising");
51 builder.setDenoising(iters);
54 template<
typename T >
56 const int iters = getIntParam(
"--deconvolution");
57 const T sigma = getDoubleParam(
"--deconvolution", 1);
58 const T
lambda = getDoubleParam(
"--deconvolution", 2);
63 builder.setDeconvolution(iters, sigma, lambda);
66 template<
typename T >
68 const T bankStep = getDoubleParam(
"--filterBank", 0);
69 const T bankOverlap = getDoubleParam(
"--filterBank", 1);
70 const int weightFun = getIntParam(
"--filterBank", 2);
71 const T weightPower = getDoubleParam(
"--filterBank", 3);
72 if (bankStep < 0 || bankStep > 0.5001) {
75 if (bankOverlap < 0 || bankOverlap > 1.001) {
79 if (weightFun < 0 || weightFun > 3) {
83 builder.setFilterBank(bankStep, bankOverlap, weightFun, weightPower);
86 template<
typename T >
88 const int iters = getIntParam(
"--difference");
89 const T Kdiff = getDoubleParam(
"--difference", 1);
94 builder.setDifference(iters, Kdiff);
97 template<
typename T >
99 if (checkParam(
"--mask")) {
100 mask.fn_mask = getParam(
"--mask");
101 mask.mask_type =
"binary_file";
104 if (checkParam(
"--center")) {
105 mask.x0 = getDoubleParam(
"--center", 0);
106 mask.y0 = getDoubleParam(
"--center", 1);
107 mask.z0 = getDoubleParam(
"--center", 2);
112 template<
typename T >
117 <<
"Input/Ouput filenames:" << std::endl
118 <<
" Volume1: " << fnV1 << std::endl
119 <<
" Volume2: " << fnV2 << std::endl
120 <<
" Rootname: " << fnRoot << std::endl
122 std::cout << restorator;
127 template<
typename T >
129 addUsageLine(
"Given two halves of a volume (and an optional mask), produce a better estimate of the volume underneath");
130 addParamsLine(
" --i1 <volume1> : First half");
131 addParamsLine(
" --i2 <volume2> : Second half");
132 addParamsLine(
" [--oroot <root=\"volumeRestored\">] : Output rootname");
133 addParamsLine(
" [--denoising <N=0>] : Number of iterations of denoising in real space");
134 addParamsLine(
" [--deconvolution <N=0> <sigma0=0.2> <lambda=0.001>] : Number of iterations of deconvolution in Fourier space, initial sigma and lambda");
135 addParamsLine(
" [--filterBank <step=0> <overlap=0.5> <weightFun=1> <weightPower=3>] : Frequency step for the filter bank (typically, 0.01; between 0 and 0.5)");
136 addParamsLine(
" : filter overlap is between 0 (no overlap) and 1 (full overlap)");
137 addParamsLine(
" : Weight function (0=mean, 1=min, 2=mean*diff");
138 addParamsLine(
" [--difference <N=0> <K=1.5>] : Number of iterations of difference evaluation in real space");
139 addParamsLine(
" [--mask <binary_file>] : Read from file and cast to binary");
140 addParamsLine(
" [--center <x0=0> <y0=0> <z0=0>] : Mask center");
143 template<
typename T >
145 builder.setVerbosity(verbose);
146 auto restorator = builder.build();
151 restorator.
apply(V1(), V2(), maskData);
153 saveResults(restorator);
156 template<
typename T >
160 V1().setXmippOrigin();
161 V2().setXmippOrigin();
163 checkInputDimensions();
165 if (!mask.fn_mask.isEmpty()) {
166 mask.generate_mask();
167 maskData = mask.get_binary_mask().data;
171 template<
typename T >
178 auto& maskArray = mask.get_binary_mask();
186 template<
typename T >
189 saveImage(V1,
"_restored1.vol");
191 saveImage(V1,
"_restored2.vol");
193 saveImage(V1,
"_filterBank.vol");
195 saveImage(V1,
"_deconvolved.vol");
197 saveImage(V1,
"_convolved.vol");
199 saveImage(V1,
"_avgDiff.vol");
202 template<
typename T >
204 if (
XSIZE(image()) != 0) {
205 image.
write(fnRoot + filename);
Errors on command line parameters.
virtual void read(int argc, const char **argv, bool reportErrors=true)
#define REPORT_ERROR(nerr, ErrormMsg)
virtual void show() const
const MultidimArray< T > & getReconstructedVolume2() const
const MultidimArray< T > & getConvolvedS() 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)
const MultidimArray< T > & getReconstructedVolume1() const
const MultidimArray< T > & getDeconvolvedS() const
const MultidimArray< T > & getAverageDifference() const
const MultidimArray< T > & getFilterBankVolume() const
void defineParams() override
Problem with matrix dimensions.
void apply(const MultidimArray< T > &volume1, const MultidimArray< T > &volume2, const int *mask)
void readParams() override