Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | List of all members
ProgRestoreWithPDBDictionary Class Reference

#include <pdb_restore_with_dictionary.h>

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

Public Member Functions

void defineParams ()
 
void readParams ()
 
void show ()
 
void run ()
 
- Public Member Functions inherited from ProgPDBDictionary
void extractPatch (const MultidimArray< double > &V, MultidimArray< double > &patch, int k, int i, int j)
 
void insertPatch (MultidimArray< double > &Vhigh, MultidimArray< double > &weightHigh, const MultidimArray< double > &patchHigh, int k, int i, int j, double R2)
 
void constructRotationGroup2D ()
 
void constructRotationGroup3D ()
 
void constructRotationGroup ()
 
size_t canonicalOrientation2D (const MultidimArray< double > &patch, MultidimArray< double > &canonicalPatch, Matrix1D< double > &patchSignature)
 
size_t canonicalOrientation3D (const MultidimArray< double > &patch, MultidimArray< double > &canonicalPatch, Matrix1D< double > &patchSignature)
 
bool notInDictionary (const MultidimArray< double > &candidatePatch, MultidimArray< double > &canonicalPatch, Matrix1D< double > &canonicalSignature, size_t &canonicalIdx)
 
void selectDictionaryPatches (const MultidimArray< double > &lowResolutionPatch, Matrix1D< double > &lowResolutionPatchSignature, std::vector< size_t > &selectedPatchesIdx, std::vector< double > &weight)
 
double approximatePatch (const MultidimArray< double > &lowResolutionPatch, std::vector< size_t > &selectedPatchesIdx, std::vector< double > &weight, Matrix1D< double > &alpha)
 
void reconstructPatch (size_t idxTransf, std::vector< size_t > &selectedPatchesIdx, Matrix1D< double > &alpha, MultidimArray< double > &highResolutionPatch)
 
void loadDictionaries ()
 
void saveDictionaries () const
 
- 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 fnIn
 
FileName fnOut
 
- Public Attributes inherited from ProgPDBDictionary
FileName fnRoot
 
int patchSize
 
double stdThreshold
 
double angleThreshold
 
double lambda
 
int iterations
 
int mode
 
std::vector< MultidimArray< double > > dictionaryLow
 
std::vector< MultidimArray< double > > dictionaryHigh
 
std::vector< Matrix1D< double > > dictionarySignature
 
std::vector< Matrix2D< double > > rotationGroup
 
MultidimArray< double > auxPatch
 
Matrix1D< double > auxSignature
 
Matrix2D< double > Ui
 
Matrix2D< double > UitUi
 
Matrix1D< double > wi
 
Matrix1D< double > v1
 
Matrix1D< double > v2
 
Matrix1D< double > y
 
Matrix1D< double > yp
 
Matrix1D< double > Uity
 
int patchSize_2
 
- 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

Restore with Low and High resolution dictionary

Definition at line 34 of file pdb_restore_with_dictionary.h.

Member Function Documentation

◆ defineParams()

void ProgRestoreWithPDBDictionary::defineParams ( )
virtual

Function in which the param of each Program are defined.

Reimplemented from ProgPDBDictionary.

Definition at line 30 of file pdb_restore_with_dictionary.cpp.

31 {
32  // Usage
33  addUsageLine("This program takes a set of PDB files at low and high resolution and constructs a dictionary for them.");
34 
35  // Parameters
36  addParamsLine(" -i <volume> : Volume to restore");
37  addParamsLine(" [-o <volume=\"\">] : Restored volume");
38  addParamsLine(" [--root <root=dictionary>] : Rootname of the dictionary");
40 }
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgRestoreWithPDBDictionary::readParams ( )
virtual

Function in which each program will read parameters that it need. If some error occurs the usage will be printed out.

Reimplemented from ProgPDBDictionary.

Definition at line 42 of file pdb_restore_with_dictionary.cpp.

43 {
44  fnIn=getParam("-i");
45  fnOut=getParam("-o");
46  if (fnOut=="")
47  fnOut=fnIn;
48  fnRoot=getParam("--root");
50 }
const char * getParam(const char *param, int arg=0)

◆ run()

void ProgRestoreWithPDBDictionary::run ( )
virtual

This function will be start running the program. it also should be implemented by derived classes.

Implements ProgPDBDictionary.

Definition at line 66 of file pdb_restore_with_dictionary.cpp.

67 {
68  show();
71 
72  Image<double> V, Vhigh;
73  MultidimArray<double> weightHigh;
74  V.read(fnIn);
75  const MultidimArray<double> &mV=V();
76  double min, max, mean, std=0;
77  mV.computeStats(mean,std,min,max);
78 
79  MultidimArray<double> patchLow, patchLowNormalized, canonicalPatch, patchHigh;
81  if (mode==0)
83  else
85  patchLow.setXmippOrigin();
86  size_t Npatches=0, NcandidatePatches=0;
87 
88  std::vector< size_t > selectedPatchesIdx;
89  std::vector<double> weight;
90  Matrix1D<double> alpha, canonicalSignature;
92  Vhigh().initZeros(mV);
93  weightHigh.initZeros(mV);
94  MultidimArray<double> &mVhigh=Vhigh();
95  for (int k=patchSize_2; k<(int)ZSIZE(mV)-patchSize_2; ++k)
96  {
97  for (int i=patchSize_2; i<(int)ZSIZE(mV)-patchSize_2; ++i)
98  for (int j=patchSize_2; j<(int)ZSIZE(mV)-patchSize_2; ++j)
99  {
100  ++Npatches;
101  extractPatch(mV,patchLow,k,i,j);
102 
103  double minPatchLow, maxPatchLow, meanPatchLow, stdPatchLow=0;
104  patchLow.computeStats(meanPatchLow,stdPatchLow,minPatchLow,maxPatchLow);
105  double R2=0;
106  patchHigh.initZeros(patchLow);
107 
108  if (stdPatchLow > stdThreshold*std)
109  {
110  ++NcandidatePatches;
111  patchLowNormalized=patchLow;
112  double norm=sqrt(patchLow.sum2());
113  patchLowNormalized*=1.0/norm;
114  size_t idxTransf=0;
115  if (mode==0)
116  idxTransf=canonicalOrientation3D(patchLowNormalized,canonicalPatch,canonicalSignature);
117  else
118  idxTransf=canonicalOrientation2D(patchLowNormalized,canonicalPatch,canonicalSignature);
119  selectDictionaryPatches(canonicalPatch, canonicalSignature, selectedPatchesIdx, weight);
120  if (selectedPatchesIdx.size()>0)
121  {
122  R2=approximatePatch(canonicalPatch,selectedPatchesIdx,weight,alpha);
123  reconstructPatch(idxTransf,selectedPatchesIdx,alpha,patchHigh);
124  patchHigh*=norm;
125  R2*=norm;
126 // Image<double> save;
127 // save()=patchLow;
128 // save.write("PPPlow.vol");
129 // save()=patchHigh;
130 // save.write("PPPhigh.vol");
131 // std::cout << "R2=" << R2 << " alpha=" << alpha << std::endl;
132 // std::cout << "Press any key" << std::endl;
133 // char c; std::cin >> c;
134  }
135  }
136  // Insert patchHigh in Vhigh
137  insertPatch(mVhigh,weightHigh,patchHigh,k,i,j,R2);
138  }
139  progress_bar(k);
140  }
141  progress_bar(ZSIZE(mV));
142 
143  // Correct by the Vhigh weights
144 // Image<double> save;
145 // save()=weightHigh;
146 // save.write("PPPweightHigh.vol");
147 // save()=mVhigh;
148 // save.write("PPPVHigh.vol");
150  if (A3D_ELEM(weightHigh,k,i,j)>0)
151  A3D_ELEM(mVhigh,k,i,j)/=A3D_ELEM(weightHigh,k,i,j);
152 
153  Vhigh.write(fnOut);
154 }
void init_progress_bar(long total)
void extractPatch(const MultidimArray< double > &V, MultidimArray< double > &patch, int k, int i, int j)
void min(Image< double > &op1, const Image< double > &op2)
void resizeNoCopy(const MultidimArray< T1 > &v)
void sqrt(Image< double > &op)
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)
size_t canonicalOrientation3D(const MultidimArray< double > &patch, MultidimArray< double > &canonicalPatch, Matrix1D< double > &patchSignature)
T norm(const std::vector< T > &v)
Definition: vector_ops.h:399
#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 A3D_ELEM(V, k, i, j)
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
double approximatePatch(const MultidimArray< double > &lowResolutionPatch, std::vector< size_t > &selectedPatchesIdx, std::vector< double > &weight, Matrix1D< double > &alpha)
void progress_bar(long rlen)
void max(Image< double > &op1, const Image< double > &op2)
void insertPatch(MultidimArray< double > &Vhigh, MultidimArray< double > &weightHigh, const MultidimArray< double > &patchHigh, int k, int i, int j, double R2)
#define ZSIZE(v)
#define j
double sum2() const
void selectDictionaryPatches(const MultidimArray< double > &lowResolutionPatch, Matrix1D< double > &lowResolutionPatchSignature, std::vector< size_t > &selectedPatchesIdx, std::vector< double > &weight)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
void reconstructPatch(size_t idxTransf, std::vector< size_t > &selectedPatchesIdx, Matrix1D< double > &alpha, MultidimArray< double > &highResolutionPatch)
void initZeros(const MultidimArray< T1 > &op)
size_t canonicalOrientation2D(const MultidimArray< double > &patch, MultidimArray< double > &canonicalPatch, Matrix1D< double > &patchSignature)

◆ show()

void ProgRestoreWithPDBDictionary::show ( )
virtual

Reimplemented from ProgPDBDictionary.

Definition at line 53 of file pdb_restore_with_dictionary.cpp.

54 {
55  if (verbose)
56  {
57  std::cout
58  << "Input volume: " << fnIn << std::endl
59  << "Output volume: " << fnOut << std::endl
60  ;
62  }
63 }
int verbose
Verbosity level.

Member Data Documentation

◆ fnIn

FileName ProgRestoreWithPDBDictionary::fnIn

Input and output volume names

Definition at line 38 of file pdb_restore_with_dictionary.h.

◆ fnOut

FileName ProgRestoreWithPDBDictionary::fnOut

Definition at line 38 of file pdb_restore_with_dictionary.h.


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