Xmipp  v3.23.11-Nereus
Classes | Public Member Functions | Public Attributes | List of all members

#include <volume_deform_sph.h>

Inheritance diagram for ProgVolDeformSph:
Inheritance graph
[legend]
Collaboration diagram for ProgVolDeformSph:
Collaboration graph
[legend]

Public Member Functions

void defineParams ()
 Define params. More...
 
void readParams ()
 Read arguments from command line. More...
 
void show ()
 Show. More...
 
double distance (double *pclnm)
 Distance. More...
 
void run ()
 Run. More...
 
void minimizepos (int l2, Matrix1D< double > &steps) const
 Determine the positions to be minimize of a vector containing spherical harmonic coefficients. More...
 
void numCoefficients (int l1, int l2, int &nc) const
 Length of coefficients vector. More...
 
void fillVectorTerms (int l1, int l2)
 Zernike and SPH coefficients allocation. More...
 
void computeStrain ()
 Compute strain. More...
 
void writeVector (std::string const &outPath, Matrix1D< double > const &v, bool append) const
 Save vector to file. More...
 
- Public Member Functions inherited from XmippProgram
const char * getParam (const char *param, int arg=0)
 
const char * getParam (const char *param, const char *subparam, int arg=0)
 
int getIntParam (const char *param, int arg=0)
 
int getIntParam (const char *param, const char *subparam, int arg=0)
 
double getDoubleParam (const char *param, int arg=0)
 
double getDoubleParam (const char *param, const char *subparam, int arg=0)
 
float getFloatParam (const char *param, int arg=0)
 
float getFloatParam (const char *param, const char *subparam, int arg=0)
 
void getListParam (const char *param, StringVector &list)
 
int getCountParam (const char *param)
 
bool checkParam (const char *param)
 
bool existsParam (const char *param)
 
void addParamsLine (const String &line)
 
void addParamsLine (const char *line)
 
ParamDefgetParamDef (const char *param) const
 
virtual void quit (int exit_code=0) const
 
virtual int tryRun ()
 
void initProgress (size_t total, size_t stepBin=60)
 
void setProgress (size_t value=0)
 
void endProgress ()
 
void processDefaultComment (const char *param, const char *left)
 
void setDefaultComment (const char *param, const char *comment)
 
virtual void initComments ()
 
void setProgramName (const char *name)
 
void addUsageLine (const char *line, bool verbatim=false)
 
void clearUsage ()
 
void addExampleLine (const char *example, bool verbatim=true)
 
void addSeeAlsoLine (const char *seeAlso)
 
void addKeywords (const char *keywords)
 
const char * name () const
 
virtual void usage (int verb=0) const
 
virtual void usage (const String &param, int verb=2)
 
int version () const
 
virtual void show () const
 
virtual void read (int argc, const char **argv, bool reportErrors=true)
 
virtual void read (int argc, char **argv, bool reportErrors=true)
 
void read (const String &argumentsLine)
 
 XmippProgram ()
 
 XmippProgram (int argc, const char **argv)
 
virtual ~XmippProgram ()
 

Public Attributes

FileName fnVolI
 Volume to deform. More...
 
FileName fnVolR
 Reference volume. More...
 
FileName fnVolOut
 Output Volume (deformed input volume) More...
 
FileName fnRoot
 Root name for several output files. More...
 
bool analyzeStrain
 Save the deformation of each voxel for local strain and rotation analysis. More...
 
bool optimizeRadius
 Radius optimization. More...
 
int L1
 Degree of Zernike polynomials and spherical harmonics. More...
 
int L2
 
std::vector< double > sigma
 Gaussian width to filter the volumes. More...
 
std::vector< Image< double > > volumesI
 Image Vector. More...
 
std::vector< Image< double > > volumesR
 
double Rmax
 Maximum radius for the transformation. More...
 
int vecSize
 Coefficient vector size. More...
 
Image< double > VI
 Images. More...
 
Image< double > VR
 
Image< double > VO
 
Image< double > Gx
 
Image< double > Gy
 
Image< double > Gz
 
std::vector< double > absMaxR_vec
 Maxima of reference volumes (in absolute value) More...
 
double deformation
 
double sumVI
 
double sumVD
 
double lambda
 
bool applyTransformation
 
bool saveDeformation
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Additional Inherited Members

- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- Protected Attributes inherited from XmippProgram
int errorCode
 
ProgramDefprogDef
 Program definition and arguments parser. More...
 
std::map< String, CommentListdefaultComments
 
int argc
 Original command line arguments. More...
 
const char ** argv
 

Detailed Description

Sph Alignment Parameters.

Definition at line 38 of file volume_deform_sph.h.

Member Function Documentation

◆ computeStrain()

void ProgVolDeformSph::computeStrain ( )

Compute strain.

Definition at line 514 of file volume_deform_sph.cpp.

515 {
516  Image<double> LS, LR;
517  LS().initZeros(Gx());
518  LR().initZeros(Gx());
519 
520  // Gaussian filter of the derivatives
524  f.w1=2;
525  f.applyMaskSpace(Gx());
526  f.applyMaskSpace(Gy());
527  f.applyMaskSpace(Gz());
528 
529  Gx.write(fnRoot+"_PPPGx.vol");
530  Gy.write(fnRoot+"_PPPGy.vol");
531  Gz.write(fnRoot+"_PPPGz.vol");
532 
533  MultidimArray<double> &mLS=LS();
534  MultidimArray<double> &mLR=LR();
535  MultidimArray<double> &mGx=Gx();
536  MultidimArray<double> &mGy=Gy();
537  MultidimArray<double> &mGz=Gz();
538  Matrix2D<double> U(3,3), D(3,3), H(3,3);
539  std::vector< std::complex<double> > eigs;
540  H.initZeros();
541  for (int k=STARTINGZ(mLS)+2; k<=FINISHINGZ(mLS)-2; ++k)
542  {
543  int km1=k-1;
544  int kp1=k+1;
545  int km2=k-2;
546  int kp2=k+2;
547  for (int i=STARTINGY(mLS)+2; i<=FINISHINGY(mLS)-2; ++i)
548  {
549  int im1=i-1;
550  int ip1=i+1;
551  int im2=i-2;
552  int ip2=i+2;
553  for (int j=STARTINGX(mLS)+2; j<=FINISHINGX(mLS)-2; ++j)
554  {
555  int jm1=j-1;
556  int jp1=j+1;
557  int jm2=j-2;
558  int jp2=j+2;
559  MAT_ELEM(U,0,0)=Dx(mGx); MAT_ELEM(U,0,1)=Dy(mGx); MAT_ELEM(U,0,2)=Dz(mGx);
560  MAT_ELEM(U,1,0)=Dx(mGy); MAT_ELEM(U,1,1)=Dy(mGy); MAT_ELEM(U,1,2)=Dz(mGy);
561  MAT_ELEM(U,2,0)=Dx(mGz); MAT_ELEM(U,2,1)=Dy(mGz); MAT_ELEM(U,2,2)=Dz(mGz);
562 
563  MAT_ELEM(D,0,0) = MAT_ELEM(U,0,0);
564  MAT_ELEM(D,0,1) = MAT_ELEM(D,1,0) = 0.5*(MAT_ELEM(U,0,1)+MAT_ELEM(U,1,0));
565  MAT_ELEM(D,0,2) = MAT_ELEM(D,2,0) = 0.5*(MAT_ELEM(U,0,2)+MAT_ELEM(U,2,0));
566  MAT_ELEM(D,1,1) = MAT_ELEM(U,1,1);
567  MAT_ELEM(D,1,2) = MAT_ELEM(D,2,1) = 0.5*(MAT_ELEM(U,1,2)+MAT_ELEM(U,2,1));
568  MAT_ELEM(D,2,2) = MAT_ELEM(U,2,2);
569 
570  MAT_ELEM(H,0,1) = 0.5*(MAT_ELEM(U,0,1)-MAT_ELEM(U,1,0));
571  MAT_ELEM(H,0,2) = 0.5*(MAT_ELEM(U,0,2)-MAT_ELEM(U,2,0));
572  MAT_ELEM(H,1,2) = 0.5*(MAT_ELEM(U,1,2)-MAT_ELEM(U,2,1));
573  MAT_ELEM(H,1,0) = -MAT_ELEM(H,0,1);
574  MAT_ELEM(H,2,0) = -MAT_ELEM(H,0,2);
575  MAT_ELEM(H,2,1) = -MAT_ELEM(H,1,2);
576 
577  A3D_ELEM(mLS,k,i,j)=fabs(D.det());
578  allEigs(H,eigs);
579  for (size_t n=0; n < eigs.size(); n++)
580  {
581  double imagabs=fabs(eigs[n].imag());
582  if (imagabs>1e-6)
583  {
584  A3D_ELEM(mLR,k,i,j)=imagabs*180/PI;
585  break;
586  }
587  }
588  }
589  }
590  LS.write(fnVolOut.withoutExtension()+"_strain.mrc");
591  LR.write(fnVolOut.withoutExtension()+"_rotation.mrc");
592  }
593 }
#define Dx(V)
#define FINISHINGX(v)
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)
FileName fnRoot
Root name for several output files.
#define Dy(V)
Image< double > Gy
#define FINISHINGZ(v)
#define STARTINGX(v)
#define i
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
#define STARTINGY(v)
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
#define A3D_ELEM(V, k, i, j)
double * f
Image< double > Gx
void allEigs(const Matrix2D< double > &A, std::vector< std::complex< double > > &eigs)
Definition: matrix2d.cpp:345
#define j
Image< double > Gz
#define FINISHINGY(v)
FileName withoutExtension() const
#define REALGAUSSIAN
#define PI
Definition: tools.h:43
#define STARTINGZ(v)
int * n
FileName fnVolOut
Output Volume (deformed input volume)
#define LOWPASS
void applyMaskSpace(MultidimArray< double > &v)
#define Dz(V)

◆ defineParams()

void ProgVolDeformSph::defineParams ( )
virtual

Define params.

Reimplemented from XmippProgram.

Definition at line 35 of file volume_deform_sph.cpp.

35  {
36  addUsageLine("Compute the deformation that properly fits two volumes using spherical harmonics");
37  addParamsLine(" -i <volume> : Volume to deform");
38  addParamsLine(" -r <volume> : Reference volume");
39  addParamsLine(" [-o <volume=\"\">] : Output volume which is the deformed input volume");
40  addParamsLine(" [--oroot <rootname=\"Volumes\">] : Root name for output files");
41  addParamsLine(" : By default, the input file is rewritten");
42  addParamsLine(" [--sigma <Matrix1D=\"\">] : Sigma values to filter the volume to perform a multiresolution analysis");
43  addParamsLine(" [--analyzeStrain] : Save the deformation of each voxel for local strain and rotation analysis");
44  addParamsLine(" [--optimizeRadius] : Optimize the radius of each spherical harmonic");
45  addParamsLine(" [--l1 <l1=3>] : Degree Zernike Polynomials=1,2,3,...");
46  addParamsLine(" [--l2 <l2=2>] : Harmonical depth of the deformation=1,2,3,...");
47  addParamsLine(" [--regularization <l=0.00025>] : Regularization weight");
48  addParamsLine(" [--Rmax <r=-1>] : Maximum radius for the transformation");
49  addParamsLine(" [--thr <N=-1>] : Maximal number of the processing CPU threads");
50  addExampleLine("xmipp_volume_deform_sph -i vol1.vol -r vol2.vol -o vol1DeformedTo2.vol");
51 }
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ distance()

double ProgVolDeformSph::distance ( double *  pclnm)

Distance.

Definition at line 256 of file volume_deform_sph.cpp.

257 {
259  {
260  VO().initZeros(VR());
261  VO().setXmippOrigin();
262  }
263  const MultidimArray<double> &mVR=VR();
264  const MultidimArray<double> &mVI=VI();
265  const size_t size = m_clnm.size();
266  for (size_t i = 0; i < size; ++i) {
267  auto &p = m_clnm[i];
268  p.x = pclnm[i + 1];
269  p.y = pclnm[i + size + 1];
270  p.z = pclnm[i + size + size + 1];
271  }
272 
273  const auto distance_vals = computeDistance();
274  deformation=std::sqrt(distance_vals.modg / (double)distance_vals.count);
275  sumVD = distance_vals.VD;
276 
278  VO.write(fnVolOut);
279 
280  double massDiff=std::abs(sumVI-sumVD)/sumVI;
281  return std::sqrt(distance_vals.diff / (double)distance_vals.count)+lambda*(deformation+massDiff);
282 }
void computeDistance(const Matrix2D< double > &X, Matrix2D< double > &distance, DimRedDistance2 f, bool computeSqrt)
void sqrt(Image< double > &op)
Image< double > VI
Images.
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 abs(Image< double > &op)
#define i
Image< double > VO
Image< double > VR
FileName fnVolOut
Output Volume (deformed input volume)

◆ fillVectorTerms()

void ProgVolDeformSph::fillVectorTerms ( int  l1,
int  l2 
)

Zernike and SPH coefficients allocation.

Definition at line 486 of file volume_deform_sph.cpp.

487 {
488  m_zshVals.resize(vecSize);
489  int idx = 0;
490  for (int h=0; h<=l2; h++)
491  {
492  int totalSPH = 2*h+1;
493  auto aux = (int)(std::floor(totalSPH/2));
494  for (int l=h; l<=l1; l+=2)
495  {
496  for (int m=0; m<totalSPH; m++)
497  {
498  auto &t = m_zshVals[idx];
499  t.l1 = l;
500  t.n = h;
501  t.l2 = h;
502  t.m = m - aux;
503  idx++;
504  }
505  }
506  }
507 }
__host__ __device__ float2 floor(const float2 v)
int m
int vecSize
Coefficient vector size.

◆ minimizepos()

void ProgVolDeformSph::minimizepos ( int  l2,
Matrix1D< double > &  steps 
) const

Determine the positions to be minimize of a vector containing spherical harmonic coefficients.

Definition at line 454 of file volume_deform_sph.cpp.

455 {
456  int size = 0;
457  numCoefficients(L1,l2,size);
458  auto totalSize = (int)(steps.size()/3);
459  for (int idx=0; idx<size; idx++)
460  {
461  VEC_ELEM(steps,idx) = 1;
462  VEC_ELEM(steps,idx+totalSize) = 1;
463  VEC_ELEM(steps,idx+2*totalSize) = 1;
464  }
465 }
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
size_t size() const
Definition: matrix1d.h:508
int L1
Degree of Zernike polynomials and spherical harmonics.
void numCoefficients(int l1, int l2, int &nc) const
Length of coefficients vector.

◆ numCoefficients()

void ProgVolDeformSph::numCoefficients ( int  l1,
int  l2,
int &  nc 
) const

Length of coefficients vector.

Definition at line 467 of file volume_deform_sph.cpp.

468 {
469  // l1 -> Degree Zernike
470  // l2 & h --> Degree SPH
471  for (int h=0; h<=l2; h++)
472  {
473  // For the current SPH degree (h), determine the number of SPH components/equations
474  int numSPH = 2*h+1;
475  // Finf the total number of radial components with even degree for a given l1 and h
476  int count=l1-h+1;
477  int numEven=(count>>1)+(count&1 && !(h&1));
478  // Total number of components is the number of SPH as many times as Zernike components
479  if (h%2 == 0)
480  nc += numSPH*numEven;
481  else
482  nc += numSPH*(l1-h+1-numEven);
483  }
484 }

◆ readParams()

void ProgVolDeformSph::readParams ( )
virtual

Read arguments from command line.

Reimplemented from XmippProgram.

Definition at line 54 of file volume_deform_sph.cpp.

54  {
55  std::string aux;
56  fnVolI = getParam("-i");
57  fnVolR = getParam("-r");
58  L1 = getIntParam("--l1");
59  L2 = getIntParam("--l2");
60  fnRoot = getParam("--oroot");
61 
62  aux = getParam("--sigma");
63  // Transform string ov values separated by white spaces into substrings stored in a vector
64  std::stringstream ss(aux);
65  std::istream_iterator<std::string> begin(ss);
66  std::istream_iterator<std::string> end;
67  std::vector<std::string> vstrings(begin, end);
68  sigma.resize(vstrings.size());
69  std::transform(vstrings.begin(), vstrings.end(), sigma.begin(), [](const std::string& val)
70  {
71  return std::stod(val);
72  });
73 
74  fnVolOut = getParam("-o");
75  if (fnVolOut=="")
76  fnVolOut=fnVolI;
77  analyzeStrain=checkParam("--analyzeStrain");
78  optimizeRadius=checkParam("--optimizeRadius");
79  lambda = getDoubleParam("--regularization");
80  Rmax = getDoubleParam("--Rmax");
81  applyTransformation = false;
82  int threads = getIntParam("--thr");
83  if (0 >= threads) {
84  threads = CPU::findCores();
85  }
86  m_threadPool.resize(threads);
87 }
double getDoubleParam(const char *param, int arg=0)
FileName fnRoot
Root name for several output files.
static unsigned findCores()
Definition: cpu.h:41
void resize(int nThreads)
Definition: ctpl.h:70
int L1
Degree of Zernike polynomials and spherical harmonics.
const char * getParam(const char *param, int arg=0)
bool optimizeRadius
Radius optimization.
FileName fnVolI
Volume to deform.
bool analyzeStrain
Save the deformation of each voxel for local strain and rotation analysis.
bool checkParam(const char *param)
double Rmax
Maximum radius for the transformation.
FileName fnVolR
Reference volume.
std::vector< double > sigma
Gaussian width to filter the volumes.
int getIntParam(const char *param, int arg=0)
FileName fnVolOut
Output Volume (deformed input volume)

◆ run()

void ProgVolDeformSph::run ( )
virtual

Run.

Reimplemented from XmippProgram.

Definition at line 292 of file volume_deform_sph.cpp.

292  {
293  saveDeformation=false;
294 
295  VI.read(fnVolI);
296  VR.read(fnVolR);
297  sumVI = 0.0;
298  if (Rmax<0)
299  Rmax=XSIZE(VI())/2;
300 
301  VI().setXmippOrigin();
302  VR().setXmippOrigin();
303 
304  // Filter input and reference volumes according to the values of sigma
305  FourierFilter filter;
306  filter.FilterShape = REALGAUSSIAN;
307  filter.FilterBand = LOWPASS;
308  filter.generateMask(VI());
309 
310  // We need also to normalized the filtered volumes to compare them appropiately
311  Image<double> auxI = VI;
312  Image<double> auxR = VR;
313 
314  MultidimArray<int> bg_mask;
315  bg_mask.resizeNoCopy(VI().zdim, VI().ydim, VI().xdim);
316  bg_mask.setXmippOrigin();
317  normalize_Robust(auxI(), bg_mask, true);
318  bg_mask *= 0;
319  normalize_Robust(auxR(), bg_mask, true);
320 
322  {
323  if (DIRECT_A3D_ELEM(auxI(),k,i,j) >= 0.0)
324  sumVI += DIRECT_A3D_ELEM(auxI(),k,i,j);
325  }
326 
327  volumesI.push_back(auxI());
328  volumesR.push_back(auxR());
329  if (sigma.size() > 1 || sigma[0] != 0)
330  {
331  for (int ids=0; ids<sigma.size(); ids++)
332  {
333  Image<double> auxI = VI;
334  Image<double> auxR = VR;
335  filter.w1 = sigma[ids];
336 
337  // Filer input vol
338  filter.do_generate_3dmask = true;
339  filter.applyMaskSpace(auxI());
340  bg_mask *= 0;
341  normalize_Robust(auxI(), bg_mask, true);
342  volumesI.push_back(auxI);
344  {
345  if (DIRECT_A3D_ELEM(auxI(),k,i,j) >= 0.0)
346  sumVI += DIRECT_A3D_ELEM(auxI(),k,i,j);
347  }
348 
349  // Filter ref vol
350  filter.applyMaskSpace(auxR());
351  bg_mask *= 0;
352  normalize_Robust(auxR(), bg_mask, true);
353  volumesR.push_back(auxR);
354  }
355  }
356 
359  vecSize = 0;
361  size_t totalSize = 3*vecSize;
363  m_clnm.resize(vecSize);
364  x.initZeros(totalSize);
365  for (int h=0;h<=L2;h++)
366  {
367  steps.clear();
368  steps.initZeros(totalSize);
369  minimizepos(h,steps);
370 
371  std::cout<<std::endl;
372  std::cout<<"-------------------------- Basis Degrees: ("<<L1<<","<<h<<") --------------------------"<<std::endl;
373 #ifdef NEVERDEFINED
374  for (int d=0;d<VEC_XSIZE(x);d++)
375  {
376  if (x(d)==0)
377  {
378  steps(d) = 1;
379  }
380  else if (d>=VEC_XSIZE(steps)+nh(h)-nh(h+1)&d<VEC_XSIZE(steps)+nh(h+1))
381  {
382  steps(d) = 1;
383  }
384  else
385  {
386  steps(d) = 0;
387  }
388  //std::cout<<steps(d)<<" ";
389  }
390  //std::cout<<std::endl;
391 #endif
392  int iter;
393  double fitness;
394  powellOptimizer(x, 1, (int)(totalSize), &volDeformSphGoal, this,
395  0.01, fitness, iter, steps, true);
396 
397  std::cout<<std::endl;
398  std::cout << "Deformation " << deformation << std::endl;
399  std::ofstream deformFile;
400  deformFile.open (fnRoot+"_deformation.txt");
401  deformFile << deformation;
402  deformFile.close();
403 
404 // #define DEBUG
405 #ifdef DEBUG
406  Image<double> save;
407  save() = VI();
408  save.write(fnRoot+"_PPPIdeformed.vol");
409  save()-=VR();
410  save.write(fnRoot+"_PPPdiff.vol");
411  save()=VR();
412  save.write(fnRoot+"_PPPR.vol");
413  std::cout << "Error=" << deformation << std::endl;
414  std::cout << "Press any key\n";
415  char c; std::cin >> c;
416 #endif
417 
418  }
419  applyTransformation=true;
420  Matrix1D<double> degrees;
421  degrees.initZeros(3);
422  VEC_ELEM(degrees,0) = L1;
423  VEC_ELEM(degrees,1) = L2;
424  VEC_ELEM(degrees,2) = Rmax;
425  writeVector(fnRoot+"_clnm.txt", degrees, false);
426  writeVector(fnRoot+"_clnm.txt", x, true);
427  if (analyzeStrain)
428  {
429  saveDeformation=true;
430  Gx().initZeros(VR());
431  Gy().initZeros(VR());
432  Gz().initZeros(VR());
433  Gx().setXmippOrigin();
434  Gy().setXmippOrigin();
435  Gz().setXmippOrigin();
436  }
437 
438  distance(x.adaptForNumericalRecipes()); // To save the output volume
439 
440 #ifdef DEBUG
441  Image<double> save;
442  save() = Gx();
443  save.write(fnRoot+"_PPPGx.vol");
444  save() = Gy();
445  save.write(fnRoot+"_PPPGy.vol");
446  save() = Gz();
447  save.write(fnRoot+"_PPPGz.vol");
448 #endif
449 
450  if (analyzeStrain)
451  computeStrain();
452 }
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
void clear()
Definition: matrix1d.cpp:67
std::vector< Image< double > > volumesR
std::vector< Image< double > > volumesI
Image Vector.
void computeStrain()
Compute strain.
#define VEC_XSIZE(m)
Definition: matrix1d.h:77
doublereal * c
void resizeNoCopy(const MultidimArray< T1 > &v)
Image< double > VI
Images.
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)
FileName fnRoot
Root name for several output files.
void powellOptimizer(Matrix1D< double > &p, int i0, int n, double(*f)(double *x, void *), void *prm, double ftol, double &fret, int &iter, const Matrix1D< double > &steps, bool show)
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY3D(V)
Image< double > Gy
glob_prnt iter
void fillVectorTerms(int l1, int l2)
Zernike and SPH coefficients allocation.
doublereal * x
#define i
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
doublereal * d
int L1
Degree of Zernike polynomials and spherical harmonics.
void numCoefficients(int l1, int l2, int &nc) const
Length of coefficients vector.
#define XSIZE(v)
void normalize_Robust(MultidimArray< double > &I, const MultidimArray< int > &bg_mask, bool clip)
Definition: normalize.cpp:265
Image< double > Gx
void initZeros()
Definition: matrix1d.h:592
void writeVector(std::string const &outPath, Matrix1D< double > const &v, bool append) const
Save vector to file.
#define DIRECT_A3D_ELEM(v, k, i, j)
#define j
double steps
Image< double > Gz
double distance(double *pclnm)
Distance.
double volDeformSphGoal(double *p, void *vprm)
FileName fnVolI
Volume to deform.
bool analyzeStrain
Save the deformation of each voxel for local strain and rotation analysis.
double Rmax
Maximum radius for the transformation.
int vecSize
Coefficient vector size.
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
Image< double > VR
#define REALGAUSSIAN
FileName fnVolR
Reference volume.
std::vector< double > sigma
Gaussian width to filter the volumes.
void minimizepos(int l2, Matrix1D< double > &steps) const
Determine the positions to be minimize of a vector containing spherical harmonic coefficients.
T * adaptForNumericalRecipes() const
Definition: matrix1d.h:844
void generateMask(MultidimArray< double > &v)
double fitness(double *p)
#define LOWPASS
void applyMaskSpace(MultidimArray< double > &v)

◆ show()

void ProgVolDeformSph::show ( )

Show.

Definition at line 90 of file volume_deform_sph.cpp.

90  {
91  if (verbose==0)
92  return;
93  std::cout
94  << "Volume to deform: " << fnVolI << std::endl
95  << "Reference volume: " << fnVolR << std::endl
96  << "Output volume: " << fnVolOut << std::endl
97  << "Zernike Degree: " << L1 << std::endl
98  << "SH Degree: " << L2 << std::endl
99  << "Save deformation: " << analyzeStrain << std::endl
100  << "Regularization: " << lambda << std::endl
101  ;
102 
103 }
int L1
Degree of Zernike polynomials and spherical harmonics.
int verbose
Verbosity level.
FileName fnVolI
Volume to deform.
bool analyzeStrain
Save the deformation of each voxel for local strain and rotation analysis.
FileName fnVolR
Reference volume.
FileName fnVolOut
Output Volume (deformed input volume)

◆ writeVector()

void ProgVolDeformSph::writeVector ( std::string const &  outPath,
Matrix1D< double > const &  v,
bool  append 
) const

Save vector to file.

Definition at line 595 of file volume_deform_sph.cpp.

597 {
598  std::ofstream outFile;
599  if (append)
600  outFile.open(outPath, std::ios_base::app);
601  else
602  outFile.open(outPath);
604  outFile << VEC_ELEM(v,i) << " ";
605  outFile << std::endl;
606 }
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
#define i
#define FOR_ALL_ELEMENTS_IN_MATRIX1D(v)
Definition: matrix1d.h:72

Member Data Documentation

◆ absMaxR_vec

std::vector<double> ProgVolDeformSph::absMaxR_vec

Maxima of reference volumes (in absolute value)

Definition at line 86 of file volume_deform_sph.h.

◆ analyzeStrain

bool ProgVolDeformSph::analyzeStrain

Save the deformation of each voxel for local strain and rotation analysis.

Definition at line 54 of file volume_deform_sph.h.

◆ applyTransformation

bool ProgVolDeformSph::applyTransformation

Definition at line 97 of file volume_deform_sph.h.

◆ deformation

double ProgVolDeformSph::deformation

Definition at line 89 of file volume_deform_sph.h.

◆ fnRoot

FileName ProgVolDeformSph::fnRoot

Root name for several output files.

Definition at line 51 of file volume_deform_sph.h.

◆ fnVolI

FileName ProgVolDeformSph::fnVolI

Volume to deform.

Definition at line 42 of file volume_deform_sph.h.

◆ fnVolOut

FileName ProgVolDeformSph::fnVolOut

Output Volume (deformed input volume)

Definition at line 48 of file volume_deform_sph.h.

◆ fnVolR

FileName ProgVolDeformSph::fnVolR

Reference volume.

Definition at line 45 of file volume_deform_sph.h.

◆ Gx

Image<double> ProgVolDeformSph::Gx

Definition at line 81 of file volume_deform_sph.h.

◆ Gy

Image<double> ProgVolDeformSph::Gy

Definition at line 82 of file volume_deform_sph.h.

◆ Gz

Image<double> ProgVolDeformSph::Gz

Definition at line 83 of file volume_deform_sph.h.

◆ L1

int ProgVolDeformSph::L1

Degree of Zernike polynomials and spherical harmonics.

Definition at line 60 of file volume_deform_sph.h.

◆ L2

int ProgVolDeformSph::L2

Definition at line 61 of file volume_deform_sph.h.

◆ lambda

double ProgVolDeformSph::lambda

Definition at line 94 of file volume_deform_sph.h.

◆ optimizeRadius

bool ProgVolDeformSph::optimizeRadius

Radius optimization.

Definition at line 57 of file volume_deform_sph.h.

◆ Rmax

double ProgVolDeformSph::Rmax

Maximum radius for the transformation.

Definition at line 71 of file volume_deform_sph.h.

◆ saveDeformation

bool ProgVolDeformSph::saveDeformation

Definition at line 100 of file volume_deform_sph.h.

◆ sigma

std::vector<double> ProgVolDeformSph::sigma

Gaussian width to filter the volumes.

Definition at line 64 of file volume_deform_sph.h.

◆ sumVD

double ProgVolDeformSph::sumVD

Definition at line 91 of file volume_deform_sph.h.

◆ sumVI

double ProgVolDeformSph::sumVI

Definition at line 90 of file volume_deform_sph.h.

◆ vecSize

int ProgVolDeformSph::vecSize

Coefficient vector size.

Definition at line 75 of file volume_deform_sph.h.

◆ VI

Image<double> ProgVolDeformSph::VI

Images.

Definition at line 78 of file volume_deform_sph.h.

◆ VO

Image<double> ProgVolDeformSph::VO

Definition at line 80 of file volume_deform_sph.h.

◆ volumesI

std::vector<Image<double> > ProgVolDeformSph::volumesI

Image Vector.

Definition at line 67 of file volume_deform_sph.h.

◆ volumesR

std::vector<Image<double> > ProgVolDeformSph::volumesR

Definition at line 68 of file volume_deform_sph.h.

◆ VR

Image<double> ProgVolDeformSph::VR

Definition at line 79 of file volume_deform_sph.h.


The documentation for this class was generated from the following files: