51 addUsageLine(
"This program modifies a volume as much as possible in order to assimilate it to another one,");
52 addUsageLine(
"without loosing the important information in it process. Then, the subtraction of the two volumes");
53 addUsageLine(
"can be optionally calculated. Sharpening: reference volume must be an atomic structure previously");
54 addUsageLine(
"converted into a density map of the same specimen than in input volume 2.");
58 addParamsLine(
"[--sub]\t: Perform the subtraction of the volumes. Output will be the difference");
59 addParamsLine(
"[--sigma <s=3>]\t: Decay of the filter (sigma) to smooth the mask transition");
60 addParamsLine(
"[--iter <n=5>]\t: Number of iterations for the adjustment process");
63 addParamsLine(
"[--maskSub <mask=\"\">]\t: Mask for subtraction region");
64 addParamsLine(
"[--cutFreq <f=0>]\t: Filter both volumes with a filter which specified cutoff frequency " 65 "(i.e. resolution inverse, <0.5)");
66 addParamsLine(
"[--lambda <l=1>]\t: Relaxation factor for Fourier Amplitude POCS, i.e. 'how much modification " 67 "of volume Fourier amplitudes', between 1 (full modification, recommended) and 0 (no modification)");
68 addParamsLine(
"[--radavg]\t: Match the radially averaged Fourier amplitudes when adjusting the amplitudes instead " 69 "of taking directly them from the reference volume");
70 addParamsLine(
"[--computeEnergy]\t: Compute the energy difference between each step (energy difference gives " 71 "information about the convergence of the adjustment process, while it can slightly slow the performance)");
72 addParamsLine(
"[--saveV1 <structure=\"\"> ]\t: Save subtraction intermediate file (vol1 filtered) just when option " 73 "--sub is passed, if not passed the input reference volume is not modified");
74 addParamsLine(
"[--saveV2 <structure=\"\"> ]\t: Save subtraction intermediate file (vol2 adjusted) just when option " 75 "--sub is passed, if not passed the output of the program is this file");
93 fnVol1F =
"volume1_filtered.mrc";
96 fnVol2A =
"volume2_adjusted.mrc";
106 <<
"Input volume(s):\t" <<
fnVolMd << std::endl
107 <<
"Reference volume:\t" <<
fnVolRef << std::endl
108 <<
"Input mask 1:\t" <<
fnMask1 << std::endl
109 <<
"Input mask 2:\t" <<
fnMask2 << std::endl
110 <<
"Input mask subtract:\t" <<
fnMaskSub << std::endl
111 <<
"Sigma:\t" <<
sigma << std::endl
112 <<
"Iterations:\t" <<
iter << std::endl
113 <<
"Cutoff frequency:\t" <<
cutFreq << std::endl
114 <<
"Relaxation factor:\t" <<
lambda << std::endl
115 <<
"Match radial averages:\t" <<
radavg << std::endl
116 <<
"Output:\t" <<
fnOut << std::endl;
122 V().setXmippOrigin();
155 int V1size2_x = V1size_x/2;
156 double V1sizei_x = 1.0/V1size_x;
157 int V1size2_y = V1size_y/2;
158 double V1sizei_y = 1.0/V1size_y;
159 int V1size2_z = V1size_z/2;
160 double V1sizei_z = 1.0/V1size_z;
171 double wy2_wz2 = wy*wy + wz2;
175 double w =
sqrt(wx*wx + wy2_wz2);
204 double phi = atan2(*(ptr + 1), *ptr);
230 int Vsize2_x = int(
XSIZE(V))/2;
231 double Vsizei_x = 1.0/int(
XSIZE(V));
232 int Vsize2_y = int(
YSIZE(V))/2;
233 double Vsizei_y = 1.0/int(
YSIZE(V));
234 int Vsize2_z = int(
ZSIZE(V))/2;
235 double Vsizei_z = 1.0/int(
ZSIZE(V));
239 auto maxrad = int(
floor(
sqrt(Vsize2_x*Vsize2_x + Vsize2_y*Vsize2_y + Vsize2_z*Vsize2_z)));
242 for (
int k=0;
k<Vsize2_z; ++
k)
246 for (
int i=0;
i<Vsize2_y; ++
i)
249 double wy2_wz2 = wy*wy + wz2;
250 for (
int j=0;
j<Vsize2_x; ++
j)
253 double w =
sqrt(wx*wx + wy2_wz2);
260 radial_mean/= radial_count;
274 radQuotient(
i) =
std::min(radQuotient(
i), 1.0);
275 if (radQuotient(
i) != radQuotient(
i))
297 V1Filtered.
write(fnVol1F);
323 if (fnM1 !=
"" && fnM2 !=
"") {
328 mask = mask1() * mask2();
358 masksub.
read(fnMSub);
373 V1().setXmippOrigin();
378 std1 =
V1().computeStddev();
421 auto V1size_x = (int)
XSIZE(
V1());
422 auto V1size_y = (int)
YSIZE(
V1());
423 auto V1size_z = (int)
ZSIZE(
V1());
void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut) override
void min(Image< double > &op1, const Image< double > &op2)
MultidimArray< double > computeRadQuotient(const MultidimArray< double > &, const MultidimArray< double > &, const MultidimArray< double > &, const MultidimArray< double > &)
void radialAverage(const MultidimArray< double > &, const MultidimArray< double > &, MultidimArray< double > &)
double getDoubleParam(const char *param, int arg=0)
__host__ __device__ float2 floor(const float2 v)
void postProcess() override
void resizeNoCopy(const MultidimArray< T1 > &v)
struct Angles part_angles
void sqrt(Image< double > &op)
MultidimArray< double > getSubtractionMask(const FileName &, MultidimArray< double >)
void readParams() override
Read argument from command line.
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)
void preProcess() override
MPI methods.
void abs(Image< double > &op)
void POCSmask(const MultidimArray< double > &, MultidimArray< double > &)
Processing methods.
MultidimArray< double > mask
Matrix1D< double > roffset
MultidimArray< std::complex< double > > V2Fourier
Image< double > subtraction(Image< double >, Image< double > &, const MultidimArray< double > &, const FileName &, const FileName &, FourierFilter &, double)
ProgSubtomoSubtraction()
Empty constructor.
void extractPhase(MultidimArray< std::complex< double >> &) const
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
FourierTransformer transformer2
void CenterFFT(MultidimArray< T > &v, bool forward)
#define FFT_IDX2DIGFREQ_FAST(idx, size, size_2, isize, freq)
#define DIRECT_A1D_ELEM(v, i)
void window(MultidimArray< T1 > &result, int n0, int z0, int y0, int x0, int nF, int zF, int yF, int xF, T1 init_value=0) const
const char * getParam(const char *param, int arg=0)
void centerFFTMagnitude(MultidimArray< double > &, MultidimArray< std::complex< double >> &, MultidimArray< double > &) const
void createFilter(FourierFilter &, double)
void POCSFourierAmplitude(const MultidimArray< double > &, MultidimArray< std::complex< double >> &, double)
void filterMask(MultidimArray< double > &) const
void max(Image< double > &op1, const Image< double > &op2)
void show() const override
Show.
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
MultidimArray< std::complex< double > > computePhase(MultidimArray< double > &)
#define DIRECT_MULTIDIM_ELEM(v, n)
MultidimArray< double > computeMagnitude(MultidimArray< double > &)
void Euler_rotate(const MultidimArray< double > &V, double rot, double tilt, double psi, MultidimArray< double > &result)
int verbose
Verbosity level.
void POCSFourierPhase(const MultidimArray< std::complex< double >> &, MultidimArray< std::complex< double >> &)
void mod(const MultidimArray< T > &x, MultidimArray< T > &m, double y)
#define DIRECT_A3D_ELEM(v, k, i, j)
MultidimArray< double > createMask(const Image< double > &, const FileName &, const FileName &)
void POCSFourierAmplitudeRadAvg(MultidimArray< std::complex< double >> &, double, const MultidimArray< double > &, int, int, int)
const T & getValueOrDefault(MDLabel label, const T &def) const
void setValue(MDLabel label, const T &d, bool addLabel=true)
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
void POCSMinMax(MultidimArray< double > &, double, double)
void POCSnonnegative(MultidimArray< double > &)
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)
double computeStddev() const
void initZeros(const MultidimArray< T1 > &op)
int getIntParam(const char *param, int arg=0)
void FFT_magnitude(const MultidimArray< std::complex< double > > &v, MultidimArray< double > &mag)
void computeEnergy(MultidimArray< double > &, const MultidimArray< double > &) const
void generateMask(MultidimArray< double > &v)
void readParticle(const MDRow &rowIn)
Read and write methods.
void defineParams() override
Define parameters.
void addParamsLine(const String &line)
void writeParticle(MDRow &rowOut, FileName, Image< double > &)
MultidimArray< double > V1FourierMag
void applyMaskSpace(MultidimArray< double > &v)