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

#include <classify_significant.h>

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

Public Member Functions

 ~ProgClassifySignificant ()
 Destructor. More...
 
void readParams ()
 Read argument from command line. More...
 
void show ()
 Show. More...
 
void defineParams ()
 Define parameters. More...
 
void produceSideInfo ()
 
void run ()
 
void generateProjection (size_t volumeIdx, size_t poolIdx, MDRow &currentRow)
 
void selectSubset (size_t particleId, bool &flagEmpty)
 
void updateClass (int n, double wn)
 
- 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 fnVols
 
FileName fnIds
 
FileName fnAngles
 
FileName fnOut
 
int numFsc
 
int pad
 
double wmin
 
bool onlyIntersection
 
int numVotes
 
bool isFsc
 
std::vector< FourierProjector * > projector
 
std::vector< FileNamesetFsc
 
std::vector< size_t > setIds
 
std::vector< MetaDataVecsetAngles
 
std::vector< MetaDataVecclassifiedAngles
 
std::vector< size_t > currentRowIdx
 
std::vector< MetaDataVecsubsetAngles
 
std::vector< MultidimArray< double > * > subsetProjections
 
std::vector< std::vector< size_t > > subsetProjectionIdx
 
std::vector< Image< double > * > Iexp
 
Projection Paux
 
std::vector< std::vector< double > > setFscValues
 
- 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

Classify Significant Parameters.

Definition at line 38 of file classify_significant.h.

Constructor & Destructor Documentation

◆ ~ProgClassifySignificant()

ProgClassifySignificant::~ProgClassifySignificant ( )

Destructor.

Definition at line 34 of file classify_significant.cpp.

35 {
36  for (size_t i=0; i<projector.size(); i++)
37  delete projector[i];
38  for (size_t i=0; i<subsetProjections.size(); i++)
39  delete subsetProjections[i];
40  for (size_t i=0; i<Iexp.size(); i++)
41  delete Iexp[i];
42 }
std::vector< Image< double > * > Iexp
#define i
std::vector< FourierProjector * > projector
std::vector< MultidimArray< double > * > subsetProjections

Member Function Documentation

◆ defineParams()

void ProgClassifySignificant::defineParams ( )
virtual

Define parameters.

Reimplemented from XmippProgram.

Definition at line 82 of file classify_significant.cpp.

83 {
84  addUsageLine("Classify a set of images into different classes. See protocol_reconstruct_heterogeneous");
85  addParamsLine(" --ref <metadata> : Reference volumes");
86  addParamsLine(" --id <metadata> : List of itemIds to classified. Sorted.");
87  addParamsLine(" --angles <metadata> : Angles assigned. Each image should have one or several angles");
88  addParamsLine(" : for each volume. The assignment per volume should be organized");
89  addParamsLine(" : in different blocks");
90  addParamsLine(" -o <metadata> : Output metadata with a set of angles per volume");
91  addParamsLine(" [--votes <numVotes=5>] : Minimum number of votes to consider an image belonging to a volume");
92  addParamsLine(" [--onlyIntersection] : Flag to select only the images belonging only to the set intersection");
93  addParamsLine(" [--padding <p=2>] : Padding factor");
94  addParamsLine(" [--minWeight <w=0.1>] : Minimum weight");
95  addParamsLine(" [--fsc <md1> <md2>] : Metadata with FSC values to take into account the SNR in the correlation measure");
96 }
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ generateProjection()

void ProgClassifySignificant::generateProjection ( size_t  volumeIdx,
size_t  poolIdx,
MDRow currentRow 
)

Generate the projection of a given volume following the instructions of currentRow. The result is stored in subsetProjections at poolIdx

Definition at line 149 of file classify_significant.cpp.

150 {
151  double rot, tilt, psi, x, y;
152  bool flip;
154  Image<double> &Iaux = *Iexp[0];
155  auto xdim = (int)XSIZE(Iaux());
156 
157  currentRow.getValue(MDL_ANGLE_ROT,rot);
158  currentRow.getValue(MDL_ANGLE_TILT,tilt);
159  currentRow.getValue(MDL_ANGLE_PSI,psi);
160  currentRow.getValue(MDL_SHIFT_X,x);
161  currentRow.getValue(MDL_SHIFT_Y,y);
162  currentRow.getValue(MDL_FLIP,flip);
163  A.initIdentity(3);
164  MAT_ELEM(A,0,2)=x;
165  MAT_ELEM(A,1,2)=y;
166  if (flip)
167  {
168  MAT_ELEM(A,0,0)*=-1;
169  MAT_ELEM(A,0,1)*=-1;
170  MAT_ELEM(A,0,2)*=-1;
171  }
172  projectVolume(*(projector[volumeIdx]), Paux, xdim, xdim, rot, tilt, psi);
173 
174  if (poolIdx>=subsetProjections.size())
175  subsetProjections.emplace_back(new MultidimArray<double>);
176  subsetProjections[poolIdx]->resizeNoCopy(xdim, xdim);
177  applyGeometry(xmipp_transformation::LINEAR,*(subsetProjections[poolIdx]),Paux(),A,xmipp_transformation::IS_INV,xmipp_transformation::DONT_WRAP,0.);
178 
179 #ifdef DEBUG
180  std::cout << "Row: " << " rot: " << rot << " tilt: " << tilt
181  << " psi: " << psi << " sx: " << x << " sy: " << y
182  << " flip: " << flip << std::endl;
183  Image<double> save;
184  save()=*(subsetProjections[poolIdx]);
185  save.write(formatString("PPPtheo%02d.xmp",poolIdx));
186 #endif
187 }
Rotation angle of an image (double,degrees)
Tilting angle of an image (double,degrees)
static double * y
Shift for the image in the X axis (double)
void applyGeometry(int SplineDegree, MultidimArray< std::complex< double > > &V2, const MultidimArray< std::complex< double > > &V1, const Matrix2D< double > &A, bool inv, bool wrap, std::complex< double > outside, MultidimArray< double > *BcoeffsPtr)
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)
Special label to be used when gathering MDs in MpiMetadataPrograms.
std::vector< Image< double > * > Iexp
doublereal * x
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
T & getValue(MDLabel label)
Flip the image? (bool)
#define XSIZE(v)
void projectVolume(FourierProjector &projector, Projection &P, int Ydim, int Xdim, double rot, double tilt, double psi, const MultidimArray< double > *ctf)
double psi(const double x)
String formatString(const char *format,...)
Shift for the image in the Y axis (double)
std::vector< FourierProjector * > projector
std::vector< MultidimArray< double > * > subsetProjections
void initIdentity()
Definition: matrix2d.h:673

◆ produceSideInfo()

void ProgClassifySignificant::produceSideInfo ( )

Produce side info. An exception is thrown if any of the files is not found

Definition at line 99 of file classify_significant.cpp.

100 {
101  if (verbose>0)
102  std::cerr << "Producing side info ..." << std::endl;
103  // Read the reference volumes
104  Image<double> V;
105  MetaDataVec mdVols;
106  mdVols.read(fnVols);
107  FileName fnVol;
108  int i=1;
109  for (size_t objId : mdVols.ids())
110  {
111  mdVols.getValue(MDL_IMAGE,fnVol, objId);
112  std::cout << fnVol << std::endl;
113  V.read(fnVol);
114  V().setXmippOrigin();
116  currentRowIdx.push_back(0);
117 
118  MetaDataVec mdAngles, mdAnglesSorted;
119 
120  mdAngles.read(formatString("angles_%02d@%s",i,fnAngles.c_str()));
121  mdAnglesSorted.sort(mdAngles, MDL_ITEM_ID, true);
122 
123  setAngles.emplace_back(mdAnglesSorted);
124  classifiedAngles.emplace_back(MetaDataVec());
125  subsetAngles.emplace_back(MetaDataVec());
126  subsetProjectionIdx.emplace_back(* (new std::vector<size_t>));
127  i += 1;
128  }
129 
130  //Read FSC if present
131  MetaDataVec mdFsc;
132  std::vector<double> fscAux;
133  if(isFsc){
134  for (int i=0; i<numFsc; i++){
135  std::cout << " fnFsc: " << setFsc[i] << std::endl;
136  mdFsc.read(setFsc[i]);
137  mdFsc.getColumnValues(MDL_RESOLUTION_FRC,fscAux);
138  setFscValues.emplace_back(fscAux);
139  }
140  }
141 
142  // Read the Ids
143  MetaDataVec mdIds;
144  mdIds.read(fnIds);
146 }
std::vector< MetaDataVec > classifiedAngles
void sort(const MetaDataVec &MDin, const MDLabel sortLabel, bool asc=true, int limit=-1, int offset=0)
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
std::vector< size_t > setIds
std::vector< MetaDataVec > subsetAngles
virtual IdIteratorProxy< false > ids()
#define i
Unique identifier for items inside a list or set (std::size_t)
std::vector< size_t > currentRowIdx
std::vector< FileName > setFsc
std::vector< std::vector< size_t > > subsetProjectionIdx
int verbose
Verbosity level.
Particle unique identifier for reference. (The MDL_ITEM_ID should be used when particle list) ...
bool getValue(MDObject &mdValueOut, size_t id) const override
void getColumnValues(const MDLabel label, std::vector< MDObject > &valuesOut) const override
String formatString(const char *format,...)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
std::vector< FourierProjector * > projector
std::vector< std::vector< double > > setFscValues
Name of an image (std::string)
Fourier shell correlation (double)
std::vector< MetaDataVec > setAngles

◆ readParams()

void ProgClassifySignificant::readParams ( )
virtual

Read argument from command line.

Reimplemented from XmippProgram.

Definition at line 45 of file classify_significant.cpp.

46 {
47  fnVols = getParam("--ref");
48  fnIds = getParam("--id");
49  fnAngles = getParam("--angles");
50  fnOut = getParam("-o");
51  pad = getIntParam("--padding");
52  wmin = getDoubleParam("--minWeight");
53  onlyIntersection = checkParam("--onlyIntersection");
54  numVotes = getIntParam("--votes");
55  isFsc = checkParam("--fsc");
56  FileName fnFsc;
57  if (isFsc){
58  numFsc = getIntParam("--fsc", 0);
59  for (int i=1; i<=numFsc; i++){
60  fnFsc = getParam("--fsc", i);
61  setFsc.emplace_back(fnFsc);
62  }
63  }
64 }
double getDoubleParam(const char *param, int arg=0)
#define i
const char * getParam(const char *param, int arg=0)
std::vector< FileName > setFsc
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)

◆ run()

void ProgClassifySignificant::run ( )
virtual

Predict angles and shift. At the input the pose parameters must have an initial guess of the parameters. At the output they have the estimated pose.

Reimplemented from XmippProgram.

Definition at line 850 of file classify_significant.cpp.

851 {
852  show();
853  produceSideInfo();
854 
855  std::ofstream fs("./correlations.txt", std::ofstream::out);
856 
857  if (verbose>0)
858  {
859  std::cerr << "Classifying images ..." << std::endl;
860  init_progress_bar(setIds.size());
861  }
862 
863  Matrix1D<double> winning(projector.size());
864  Matrix1D<double> corrDiff(projector.size());
865  Matrix1D<double> weight;
866 
867  MultidimArray<double> I1, I2;
868  MultidimArray<double> Iexp1, Iexp2;
869  bool I1isEmpty, I2isEmpty;
870  double corr1exp, corr2exp;
871  bool flagEmpty=true;
872 
873  for (size_t iid=0; iid<setIds.size(); iid++)
874  {
875  flagEmpty=true;
876  size_t id=setIds[iid];
877  selectSubset(id, flagEmpty);
878  if (flagEmpty)
879  continue;
880 
881  winning.initZeros();
882  corrDiff.initZeros();
883  Image<double> Iaux = *Iexp[0];
884  auto xdim = (int)XSIZE(Iaux());
885  I1.initZeros(1, 1, xdim, xdim);
886  I2.initZeros(1, 1, xdim, xdim);
887  Iexp1.initZeros(1, 1, xdim, xdim);
888  Iexp2.initZeros(1, 1, xdim, xdim);
889 
890  for (size_t ivol1=0; ivol1<projector.size(); ivol1++)
891  {
892  std::vector<size_t> &subset1=subsetProjectionIdx[ivol1];
893  for (size_t ivol2=ivol1+1; ivol2<projector.size(); ivol2++)
894  {
895  std::vector<size_t> &subset2=subsetProjectionIdx[ivol2];
896  size_t i1=0;
897  do //for (size_t i1=0; i1<subset1.size(); i1++)
898  {
899  //std::cout << "subset1.size()" << subset1.size() << std::endl;
900  if (subset1.size()==0)
901  I1isEmpty=true;
902  else
903  {
904  //MultidimArray<double> &I1=*(subsetProjections[subset1[i1]]);
905  I1=*(subsetProjections[subset1[i1]]);
906  Iexp1 = (*(Iexp[subset1[i1]]))();
907  I1isEmpty = false;
908  //std::cout << "subset1[i1]" << subset1[i1] << std::endl;
909  }
910 
911  size_t i2=0;
912  do //for (size_t i2=0; i2<subset2.size(); i2++)
913  {
914  //std::cout << "subset2.size()" << subset2.size() << std::endl;
915  if (subset2.size()==0)
916  I2isEmpty=true;
917  else
918  {
919  //MultidimArray<double> &I2=*(subsetProjections[subset2[i2]]);
920  I2=*(subsetProjections[subset2[i2]]);
921  Iexp2 = (*(Iexp[subset2[i2]]))();
922  I2isEmpty=false;
923  //std::cout << "subset2[i2]" << subset2[i2] << std::endl;
924  }
925 /*
927  //AJ ADDING NEW CORRELATION MEASURE
928  double ccI1Iexp1;
929  double ccI1Iexp2;
930  double ccI2Iexp1;
931  double ccI2Iexp2;
932  calculateNewCorrelation(I1, I2, Iexp1, Iexp2, ccI1Iexp1, ccI2Iexp2, isFsc, setFsc1, setFsc2);
933  if (std::isnan(ccI1Iexp1))
934  ccI1Iexp1=-1.0;
935  if (std::isnan(ccI2Iexp2))
936  ccI2Iexp2=-1.0;
937 */
939  //AJ ORIGINAL CORRELATION MEASURE
940  computeWeightedCorrelation(I1, I2, Iexp1, Iexp2, corr1exp, corr2exp, I1isEmpty, I2isEmpty,
941  xdim, onlyIntersection, numVotes);
942 
943  if (std::isnan(corr1exp))
944  corr1exp=-1.0;
945  if (std::isnan(corr2exp))
946  corr2exp=-1.0;
947 
948  double corrDiff12=corr1exp-corr2exp;
949  if (corrDiff12>0 && corr1exp>0)
950  {
951  VEC_ELEM(winning,ivol1)+=1;
952  VEC_ELEM(corrDiff,ivol1)+=corrDiff12;
953  VEC_ELEM(corrDiff,ivol2)-=corrDiff12;
954  }
955  else if (corrDiff12<0 && corr2exp>0)
956  {
957  VEC_ELEM(winning,ivol2)+=1;
958  VEC_ELEM(corrDiff,ivol2)-=corrDiff12;
959  VEC_ELEM(corrDiff,ivol1)+=corrDiff12;
960  }
961 
962 
963 /*
965  //AJ NEW CORRELATION MEASURE
966  double ccI1Iexp1;
967  double ccI1Iexp2;
968  double ccI2Iexp1;
969  double ccI2Iexp2;
970  calculateNewCorrelation(I1, I2, Iexp1, Iexp2, ccI1Iexp1, ccI2Iexp2, isFsc, setFsc1, setFsc2);
971  if (std::isnan(ccI1Iexp1))
972  ccI1Iexp1=-1.0;
973  if (std::isnan(ccI2Iexp2))
974  ccI2Iexp2=-1.0;
975 
976  double corrDiff12=ccI1Iexp1-ccI2Iexp2;
977  if (corrDiff12>0 && ccI1Iexp1>0)
978  {
979  VEC_ELEM(winning,ivol1)+=1;
980  VEC_ELEM(corrDiff,ivol1)+=corrDiff12;
981  VEC_ELEM(corrDiff,ivol2)-=corrDiff12;
982  }
983  else if (corrDiff12<0 && ccI2Iexp2>0)
984  {
985  VEC_ELEM(winning,ivol2)+=1;
986  VEC_ELEM(corrDiff,ivol2)-=corrDiff12;
987  VEC_ELEM(corrDiff,ivol1)+=corrDiff12;
988  }
990 */
991  /*Image<double> save;
992  save()=Iexp1;
993  save.write("PPPexp1.xmp");
994  save()=Iexp2;
995  save.write("PPPexp2.xmp");
996  save()=I1;
997  save.write("PPP1.xmp");
998  save()=I2;
999  save.write("PPP2.xmp");
1000  std::cout << id << " " << ccI1Iexp1 << " " << ccI2Iexp2 << " " << I1isEmpty << " " << I2isEmpty << std::endl;
1001  std::cout << "winning=" << winning << std::endl;
1002  std::cout << "corrDiff=" << corrDiff << std::endl;
1003 
1004  char c;
1005  std::cout << "Press any key" << std::endl;
1006  std::cin >> c;*/
1007 
1008 
1009  i2++;
1010  }while(i2<subset2.size());
1011 
1012  i1++;
1013  }while(i1<subset1.size());
1014  }
1015  }
1016  double iNcomparisons=1.0/winning.sum();
1017  winning*=iNcomparisons;
1018  weight=corrDiff;
1019  weight*=iNcomparisons;
1020  weight*=winning;
1021 
1022 // std::cout << corrDiff << std::endl;
1023 // std::cout << winning << std::endl;
1024 // std::cout << weight << std::endl;
1025 
1026 
1027  int nBest=weight.maxIndex();
1028  double wBest=VEC_ELEM(weight,nBest);
1029  if (wBest>0)
1030  updateClass(nBest,wBest);
1031  if (verbose>0)
1032  progress_bar(iid);
1033 
1034  }
1035  progress_bar(setIds.size());
1036 
1037  // Write output
1038  MetaDataDb md;
1039  for (size_t ivol=0; ivol<projector.size(); ivol++)
1040  {
1041  size_t objId=md.addObject();
1042  md.setValue(MDL_REF3D,(int)ivol+1,objId);
1043  md.setValue(MDL_CLASS_COUNT,classifiedAngles[ivol].size(),objId);
1044  }
1045  md.write("classes@"+fnOut);
1046  for (size_t ivol=0; ivol<projector.size(); ivol++)
1047  {
1048  md.clear();
1049  if (classifiedAngles[ivol].size()>0)
1050  {
1051  md = classifiedAngles[ivol];
1052  double currentWmax=md.getColumnMax(MDL_WEIGHT);
1053  double currentWmin=md.getColumnMin(MDL_WEIGHT);
1054  if (currentWmax>currentWmin)
1055  md.operate(formatString("weight=%f*(weight-%f)+%f",(1.0-wmin)/(currentWmax-currentWmin),currentWmin,wmin));
1056  else
1057  md.operate(formatString("weight=%f",wmin));
1058  md.setValueCol(MDL_REF3D,(int)ivol+1);
1059  }
1060  else
1061  REPORT_ERROR(ERR_VALUE_EMPTY,formatString("Class %d have been depleted of images. Cannot continue processing",ivol));
1062  md.write(formatString("class%06d_images@%s",ivol+1,fnOut.c_str()),MD_APPEND);
1063  }
1064 
1065  fs.close();
1066 
1067 }
void selectSubset(size_t particleId, bool &flagEmpty)
void init_progress_bar(long total)
Empty value.
Definition: xmipp_error.h:194
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
std::vector< MetaDataVec > classifiedAngles
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
std::vector< size_t > setIds
std::vector< Image< double > * > Iexp
size_t addObject() override
void updateClass(int n, double wn)
#define XSIZE(v)
void progress_bar(long rlen)
std::vector< std::vector< size_t > > subsetProjectionIdx
int verbose
Verbosity level.
3D Class to which the image belongs (int)
Number of images assigned to the same class as this image.
String formatString(const char *format,...)
void computeWeightedCorrelation(MultidimArray< double > &I1, MultidimArray< double > &I2, MultidimArray< double > &Iexp1, MultidimArray< double > &Iexp2, double &corr1exp, double &corr2exp, bool I1isEmpty, bool I2isEmpty, int xdim, bool onlyIntersection, int numVotes, double ccI1Iexp1=-1.0, double ccI2Iexp2=-1.0)
void initZeros(const MultidimArray< T1 > &op)
std::vector< FourierProjector * > projector
std::vector< MultidimArray< double > * > subsetProjections
< Score 4 for volumes

◆ selectSubset()

void ProgClassifySignificant::selectSubset ( size_t  particleId,
bool &  flagEmpty 
)

Choose the subset for particleID and generate its projections

Definition at line 190 of file classify_significant.cpp.

191 {
192  size_t poolIdx=0;
193  FileName fnImg;
194  for (size_t i=0; i<projector.size(); i++)
195  {
196  subsetAngles[i].clear();
197  subsetProjectionIdx[i].clear();
198  size_t crIdx=currentRowIdx[i];
199  if (crIdx>=setAngles[i].size())
200  return;
201  MDRowVec currentRow;
202  setAngles[i].getRow(currentRow, crIdx);
203  /*if (i==0) // First time we see this image
204  {
205  currentRow.getValue(MDL_IMAGE,fnImg);
206  Iexp.read(fnImg);
207  std::cout << "Particle fnImg: " << fnImg << std::endl;
208  }*/
209  size_t currentParticleId;
210  currentRow.getValue(MDL_PARTICLE_ID,currentParticleId);
211  size_t idxMax=setAngles[i].size();
212  while (currentParticleId<=particleId)
213  {
214  if (currentParticleId==particleId)
215  {
216  flagEmpty=false;
217  subsetAngles[i].addRow(currentRow);
218  subsetProjectionIdx[i].emplace_back(poolIdx);
219  currentRow.getValue(MDL_IMAGE,fnImg);
220  Iexp.emplace_back(new Image<double>);
221  Iexp[poolIdx]->read(fnImg);
222  //std::cout << "Particle fnImg: " << fnImg << " in " << poolIdx << std::endl;
223  generateProjection(i,poolIdx,currentRow);
224  poolIdx+=1;
225  }
226  crIdx+=1;
227  if (crIdx<idxMax)
228  {
229  setAngles[i].getRow(currentRow, crIdx);
230  currentRow.getValue(MDL_PARTICLE_ID,currentParticleId);
231  }
232  else
233  break;
234  }
235  currentRowIdx[i]=crIdx;
236  }
237 #ifdef DEBUG
238  std::cout << "Reading " << fnImg << std::endl;
239  char c;
240  std::cout << "Press any key" << std::endl;
241  std::cin >> c;
242 #endif
243 }
doublereal * c
std::vector< MetaDataVec > subsetAngles
std::vector< Image< double > * > Iexp
#define i
T & getValue(MDLabel label)
std::vector< size_t > currentRowIdx
std::vector< std::vector< size_t > > subsetProjectionIdx
Particle unique identifier for reference. (The MDL_ITEM_ID should be used when particle list) ...
std::vector< FourierProjector * > projector
void generateProjection(size_t volumeIdx, size_t poolIdx, MDRow &currentRow)
Name of an image (std::string)
std::vector< MetaDataVec > setAngles

◆ show()

void ProgClassifySignificant::show ( )

Show.

Definition at line 67 of file classify_significant.cpp.

68 {
69  if (!verbose)
70  return;
71  std::cout
72  << "Reference volumes: " << fnVols << std::endl
73  << "Ids: " << fnIds << std::endl
74  << "Angles: " << fnAngles << std::endl
75  << "Output: " << fnOut << std::endl
76  << "Padding factor: " << pad << std::endl
77  << "Min. Weight: " << wmin << std::endl
78  ;
79 }
int verbose
Verbosity level.

◆ updateClass()

void ProgClassifySignificant::updateClass ( int  n,
double  wn 
)

Update class

Definition at line 825 of file classify_significant.cpp.

826 {
827  double CCbest=-1e38;
828  int idCCbest=-1;
829  MetaDataVec &subsetAngles_n = subsetAngles[n];
830  for (size_t objId : subsetAngles_n.ids())
831  {
832  double cc;
833  subsetAngles_n.getValue(MDL_MAXCC, cc, objId);
834  if (cc>CCbest)
835  {
836  CCbest=cc;
837  idCCbest=objId;
838  }
839  }
840  if (idCCbest>=0)
841  {
842  MDRowVec newRow;
843  subsetAngles_n.getRow(newRow, idCCbest);
844  // COSS newRow.setValue(MDL_WEIGHT,wn);
845  classifiedAngles[n].addRow(newRow);
846  }
847 }
std::vector< MetaDataVec > classifiedAngles
std::vector< MetaDataVec > subsetAngles
virtual IdIteratorProxy< false > ids()
std::unique_ptr< MDRow > getRow(size_t id) override
Maximum cross-correlation for the image (double)
bool getValue(MDObject &mdValueOut, size_t id) const override
int * n

Member Data Documentation

◆ classifiedAngles

std::vector<MetaDataVec> ProgClassifySignificant::classifiedAngles

Definition at line 73 of file classify_significant.h.

◆ currentRowIdx

std::vector<size_t> ProgClassifySignificant::currentRowIdx

Definition at line 75 of file classify_significant.h.

◆ fnAngles

FileName ProgClassifySignificant::fnAngles

Filename of angles assigned

Definition at line 46 of file classify_significant.h.

◆ fnIds

FileName ProgClassifySignificant::fnIds

Filename of indexes to study

Definition at line 44 of file classify_significant.h.

◆ fnOut

FileName ProgClassifySignificant::fnOut

Output file

Definition at line 48 of file classify_significant.h.

◆ fnVols

FileName ProgClassifySignificant::fnVols

Filename of the reference volumes

Definition at line 42 of file classify_significant.h.

◆ Iexp

std::vector<Image<double> *> ProgClassifySignificant::Iexp

Definition at line 83 of file classify_significant.h.

◆ isFsc

bool ProgClassifySignificant::isFsc

To check if there is FSC provided by user

Definition at line 61 of file classify_significant.h.

◆ numFsc

int ProgClassifySignificant::numFsc

FSC file

Definition at line 50 of file classify_significant.h.

◆ numVotes

int ProgClassifySignificant::numVotes

Minimum number of votes to consider an image belonging to a volume

Definition at line 59 of file classify_significant.h.

◆ onlyIntersection

bool ProgClassifySignificant::onlyIntersection

Flag to select only the images belonging only to the set intersection

Definition at line 57 of file classify_significant.h.

◆ pad

int ProgClassifySignificant::pad

Padding factor

Definition at line 53 of file classify_significant.h.

◆ Paux

Projection ProgClassifySignificant::Paux

Definition at line 85 of file classify_significant.h.

◆ projector

std::vector<FourierProjector *> ProgClassifySignificant::projector

Definition at line 65 of file classify_significant.h.

◆ setAngles

std::vector<MetaDataVec> ProgClassifySignificant::setAngles

Definition at line 71 of file classify_significant.h.

◆ setFsc

std::vector<FileName> ProgClassifySignificant::setFsc

Definition at line 67 of file classify_significant.h.

◆ setFscValues

std::vector< std::vector<double> > ProgClassifySignificant::setFscValues

Definition at line 87 of file classify_significant.h.

◆ setIds

std::vector<size_t> ProgClassifySignificant::setIds

Definition at line 69 of file classify_significant.h.

◆ subsetAngles

std::vector<MetaDataVec> ProgClassifySignificant::subsetAngles

Definition at line 77 of file classify_significant.h.

◆ subsetProjectionIdx

std::vector< std::vector<size_t> > ProgClassifySignificant::subsetProjectionIdx

Definition at line 81 of file classify_significant.h.

◆ subsetProjections

std::vector<MultidimArray<double> *> ProgClassifySignificant::subsetProjections

Definition at line 79 of file classify_significant.h.

◆ wmin

double ProgClassifySignificant::wmin

Min. Weight

Definition at line 55 of file classify_significant.h.


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