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

#include <mpi_angular_class_average.h>

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

Public Member Functions

 MpiProgAngularClassAverage ()
 
 MpiProgAngularClassAverage (int argc, char **argv)
 
void readParams ()
 
void defineParams ()
 
void run ()
 
void mpi_process_loop (double *Def_3Dref_2Dref_JobNo)
 
void mpi_process (double *Def_3Dref_2Dref_JobNo)
 
void mpi_produceSideInfo ()
 
void mpi_preprocess ()
 
void filterInputMetadata ()
 
void saveDiscardedImages ()
 
void initFileNames ()
 
void initDimentions ()
 
void initWeights ()
 
void initOutputFiles ()
 
void mpi_postprocess ()
 
void createJobList ()
 
void mpi_write (size_t dirno, int ref3dIndex, Image< double > avg, Image< double > avg1, Image< double > avg2, double w1, double w2, double old_w, double old_w1, double old_w2)
 
void mpi_writeController (size_t dirno, Image< double > avg, Image< double > avg1, Image< double > avg2, const MetaDataDb &SFclass, const MetaDataDb &SFclass1, const MetaDataDb &SFclass2, const MetaDataDb &SFclassDiscarded, const MetaDataDb &_DF, double w1, double w2, double w, int lockIndex)
 
void mpi_writeFile (Image< double > avg, size_t dirno, FileName fileNameStk, double w_old)
 
void getPolar (MultidimArray< double > &img, Polar< std::complex< double > > &fP, bool conjugated=false, float xoff=0., float yoff=0.)
 
void reAlignClass (Image< double > &avg1, Image< double > &avg2, MetaData &SFclass1, MetaData &SFclass2, std::vector< Image< double > > imgs, std::vector< int > splits, std::vector< int > numbers, size_t dirno, double *my_output)
 
void applyWienerFilter (MultidimArray< double > &img)
 
- Public Member Functions inherited from XmippMpiProgram
void read (int argc, char **argv)
 
virtual int tryRun ()
 
- 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
 
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

unsigned int master_seed
 
MetaDataDb mdJobList
 
MetaDataDb DF
 
MetaDataDb DFlib
 
MetaDataDb DFscore
 
MetaDataDb DFclassesExp
 
FileName fn_out
 
FileName fn_out1
 
FileName fn_out2
 
FileName fn_wien
 
FileName fn_ref
 
std::string col_select
 
double limit0
 
double limitF
 
double limitRclass
 
double limitRper
 
bool do_limit0
 
bool do_limitF
 
bool do_limitR0class
 
bool do_limitRFclass
 
bool do_limitR0per
 
bool do_limitRFper
 
bool do_mirrors
 
bool do_split
 
size_t paddim
 
double pad
 
Image< double > Iempty
 
bool do_save_images_assigned_to_classes
 
bool do_add
 
bool do_pcaSorting
 
MultidimArray< double > Mwien
 
MetaDataDb SFclasses
 
MetaDataDb SFclasses1
 
MetaDataDb SFclasses2
 
FileName inFile
 
FileName refGroup
 
int Ri
 
int Ro
 
int nr_iter
 
double eps
 
double max_shift
 
double max_shift_change
 
double max_psi_change
 
Polar_fftw_plans global_plans
 
RotationalCorrelationAux rotAux
 
MultidimArray< double > corr
 
int ctfNum
 
int ref3dNum
 
size_t Xdim
 
size_t Ydim
 
size_t Zdim
 
size_t Ndim
 
size_t mpi_job_size
 
MultidimArray< bool > lockArray
 
MultidimArray< double > weightArray
 
MultidimArray< double > weightArrays1
 
MultidimArray< double > weightArrays2
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Additional Inherited Members

- Protected Member Functions inherited from XmippMpiProgram
void setNode (const std::shared_ptr< MpiNode > &node)
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- Protected Attributes inherited from XmippMpiProgram
std::shared_ptr< MpiNodenode
 
size_t nProcs
 
size_t numberOfJobs
 
MPI_Status status
 
- 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

Definition at line 71 of file mpi_angular_class_average.h.

Constructor & Destructor Documentation

◆ MpiProgAngularClassAverage() [1/2]

MpiProgAngularClassAverage::MpiProgAngularClassAverage ( )

Definition at line 35 of file mpi_angular_class_average.cpp.

36 {}

◆ MpiProgAngularClassAverage() [2/2]

MpiProgAngularClassAverage::MpiProgAngularClassAverage ( int  argc,
char **  argv 
)

Definition at line 38 of file mpi_angular_class_average.cpp.

39 {
40  this->read(argc, argv);
41 }
int argc
Original command line arguments.
Definition: xmipp_program.h:86
const char ** argv
Definition: xmipp_program.h:87
void read(int argc, char **argv)
Definition: xmipp_mpi.cpp:240

Member Function Documentation

◆ applyWienerFilter()

void MpiProgAngularClassAverage::applyWienerFilter ( MultidimArray< double > &  img)

Apply Wiener filter

Definition at line 1685 of file mpi_angular_class_average.cpp.

1686 {
1688 
1689  if (paddim > Xdim)
1690  {
1691  // pad real-space image
1692  int x0 = FIRST_XMIPP_INDEX(paddim);
1693  int xF = LAST_XMIPP_INDEX(paddim);
1694  img.selfWindow(x0, x0, xF, xF);
1695  }
1696  FourierTransform(img, Faux);
1698  {
1699  dAij(Faux,i,j) *= dAij(Mwien,i,j);
1700  }
1701  InverseFourierTransform(Faux, img);
1702  if (paddim > Xdim)
1703  {
1704  // de-pad real-space image
1705  int x0 = FIRST_XMIPP_INDEX(Xdim);
1706  int xF = LAST_XMIPP_INDEX(Xdim);
1707  img.selfWindow(x0, x0, xF, xF);
1708  }
1709 }
void selfWindow(int n0, int z0, int y0, int x0, int nF, int zF, int yF, int xF, T init_value=0)
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY2D(m)
#define dAij(M, i, j)
void InverseFourierTransform(const MultidimArray< std::complex< double > > &in, MultidimArray< double > &out)
Definition: xmipp_fft.cpp:155
#define i
#define x0
void FourierTransform(const MultidimArray< double > &in, MultidimArray< std::complex< double > > &out)
Definition: xmipp_fft.cpp:124
#define xF
#define j
#define FIRST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:439
#define LAST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:448

◆ createJobList()

void MpiProgAngularClassAverage::createJobList ( )

Compute list of parallel jobs to be performed

Definition at line 1501 of file mpi_angular_class_average.cpp.

1502 {
1503  const MDLabel myGroupByLabels[] =
1504  {
1506  };
1507  std::vector<MDLabel> groupbyLabels(myGroupByLabels,myGroupByLabels+6);
1509 #define DEBUG
1510 #ifdef DEBUG
1511  DF.write("/tmp/kk_DF.xmd");
1512  mdJobList.write("/tmp/kk_mdJobList.xmd");
1513 #endif
1514 #undef DEBUG
1515 
1517 }
Rotation angle of an image (double,degrees)
Tilting angle of an image (double,degrees)
size_t numberOfJobs
Definition: xmipp_mpi.h:168
void aggregateGroupBy(const MetaDataDb &mdIn, AggregateOperation op, const std::vector< MDLabel > &groupByLabels, MDLabel operateLabel, MDLabel resultLabel)
Number of elements of a type (int) [this is a genereic type do not use to transfer information to ano...
Defocus group.
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const override
size_t size() const override
3D Class to which the image belongs (int)
Class to which the image belongs (int)
MDLabel

◆ defineParams()

void MpiProgAngularClassAverage::defineParams ( )
virtual

Function in which the param of each Program are defined.

Reimplemented from XmippProgram.

Definition at line 124 of file mpi_angular_class_average.cpp.

125 {
126  addUsageLine("Make class average images and corresponding selfiles from angular_projection_matching docfiles.");
127  addSeeAlsoLine("angular_project_library, angular_projection_matching");
128  addKeywords("class average images");
129 
130  addParamsLine(" -i <doc_file> : Docfile with assigned angles for all experimental particles");
131  addParamsLine(" --lib <doc_file> : Docfile with angles used to generate the projection matching library");
132  addParamsLine(" -o <root_name> : Output rootname for class averages and selfiles");
133  addParamsLine(" [--split ] : Also output averages of random halves of the data");
134  addParamsLine(" [--wien <img=\"\"> ] : Apply this Wiener filter to the averages");
135  addParamsLine(" [--pad <factor=1.> ] : Padding factor for Wiener correction");
136  addParamsLine(" [--save_images_assigned_to_classes] : Save images assigned te each class in output metadatas");
137  addParamsLine("alias --siatc;");
138  addParamsLine("==+ IMAGE SELECTION BASED ON INPUT DOCFILE (select one between: limit 0, F and R ==");
139  addParamsLine(" [--select <col=\"maxCC\">] : Column to use for image selection (limit0, limitF or limitR)");
140  addParamsLine(" [--limit0 <l0>] : Discard images below <l0>");
141  addParamsLine(" [--limitF <lF>] : Discard images above <lF>");
142  addParamsLine(" [--limitRclass <lRc>] : if (lRc>0 && lRc< 100): discard lowest <lRc> % in each class");
143  addParamsLine(" : if (lRc<0 && lR>-100): discard highest <lRc> % in each class");
144  addParamsLine(" [--limitRper <lRp>] : if (lRp>0 && lRp< 100): discard lowest <lRa> %");
145  addParamsLine(" : if (lRp<0 && lRp>-100): discard highest <lRa> %");
146 #ifdef NEVERDEFINED
147  addParamsLine(" [--pcaSorting ] : Perform PCA sorting to obtain the average classes");
148 #endif
149  addParamsLine("==+ REALIGNMENT OF CLASSES ==");
150  addParamsLine(" [--iter <nr_iter=0>] : Number of iterations for re-alignment");
151  addParamsLine(" [--Ri <ri=1>] : Inner radius to limit rotational search");
152  addParamsLine(" [--Ro <r0=-1>] : Outer radius to limit rotational search");
153  addParamsLine(" : ro = -1 -> dim/2-1");
154  addParamsLine(" [--mpi_job_size <size=10>] : Number of images sent to a cpu in a single job ");
155  addParamsLine(" : 10 may be a good value");
156 
157  addExampleLine("Sample at default values and calculating output averages of random halves of the data",false);
158  addExampleLine("xmipp_angular_class_average -i proj_match.doc --lib ref_angles.doc -o out_dir --split");
159 }
void addSeeAlsoLine(const char *seeAlso)
void addKeywords(const char *keywords)
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ filterInputMetadata()

void MpiProgAngularClassAverage::filterInputMetadata ( )

Read input metadata and filter following the user define constraints

a take 1: using a copy of mdJobList

Definition at line 1118 of file mpi_angular_class_average.cpp.

1119 {
1120  MetaDataDb auxDF,auxF1;
1121 
1122  //auxDF.read((String)"ctfGroup[0-9][0-9][0-9][0-9][0-9][0-9]$@" + inFile);
1123  //std::cerr << "DEBUG_JM: inFile: " << inFile << std::endl;
1124  auxDF.read(inFile);
1125  if (!auxDF.containsLabel(MDL_REF3D))
1126  auxDF.fillConstant(MDL_REF3D, "1");
1127  if (!auxDF.containsLabel(MDL_DEFGROUP))
1128  auxDF.fillConstant(MDL_DEFGROUP, "1");
1129  // if (!auxDF.containsLabel(MDL_ORDER))
1130  // {
1131  //
1132  // String cmd = formatString("%s=%s+%d", MDL::label2Str(MDL_ORDER).c_str(),
1133  // MDL::label2Str(MDL_REF).c_str(), FIRST_IMAGE);
1134  // auxDF.addLabel(MDL_ORDER);
1135  // auxDF.operate(cmd);
1136  // }
1137  if (!auxDF.containsLabel(MDL_ORDER))
1138  auxDF.addLabel(MDL_ORDER);
1139  {
1140  String labelOrder=MDL::label2Str(MDL_ORDER);
1141  String labelRef=MDL::label2Str(MDL_REF);
1142  String cmd = formatString("%s=%s+%d", labelOrder.c_str(), labelRef.c_str(), FIRST_IMAGE);
1143  auxDF.operate(cmd);
1144  }
1145  //std::cerr << "DEBUG_JM: Read inFile" <<std::endl;
1146  //auxDF.write("/tmp/inputfileBeforeRemove.xmd");
1147 
1148  MDMultiQuery multi;
1151 
1152  // remove percent of images
1154  {
1155  bool asc= !do_limitR0per;
1156  MDLabel codifyLabel = MDL::str2Label(col_select);
1157  int size = auxDF.size();
1158  int limit = size - ROUND((limitRper/100.) * size);
1159  auxF1.sort(auxDF,codifyLabel,asc,limit,0);
1160  }
1161  //remove images bellow (above) these limits
1162  else if(do_limit0 || do_limitF)
1163  {
1164  if (do_limit0)
1165  multi.addAndQuery(eq1);
1166  if (do_limitF)
1167  multi.addAndQuery(eq2);
1168  auxF1.importObjects(auxDF, multi);
1169  }
1170  // remove percentage of images from each class
1171  else if (do_limitR0class || do_limitRFclass)
1172  {
1173  //Delete a percentage of images in each class
1174  MetaDataDb auxMdJobList;
1175 
1177  const MDLabel myGroupByLabels[] =
1178  {
1180  };
1181  std::vector<MDLabel> groupbyLabels(myGroupByLabels,myGroupByLabels+6);
1182  auxMdJobList.aggregateGroupBy(auxDF, AGGR_COUNT, groupbyLabels, MDL_ORDER, MDL_COUNT);
1183 
1184  // Output stack size (number of valid projection directions)
1185  MDObject mdValueOut1(MDL_ORDER);
1186  auxMdJobList.aggregateSingleSizeT(mdValueOut1, AGGR_MAX ,MDL_ORDER);
1187  Ndim = mdValueOut1.getValue2(Ndim);
1188 
1189  MDObject mdValueOut2(MDL_DEFGROUP);
1190  auxMdJobList.aggregateSingleInt(mdValueOut2, AGGR_MAX ,MDL_DEFGROUP);
1191  ctfNum = mdValueOut2.getValue2(ctfNum);
1192 
1193  MDObject mdValueOut3(MDL_REF3D);
1194  auxMdJobList.aggregateSingleInt(mdValueOut3, AGGR_MAX ,MDL_REF3D);
1195  ref3dNum = mdValueOut3.getValue2(ref3dNum);
1196  MultidimArray <int> multiCounter(Ndim+1, ctfNum+1, ref3dNum+1);
1197  multiCounter.initZeros();
1198 
1199  int ref3d, defgroup;
1200  size_t order, jobCount, jobCount2;
1201 
1202  for (size_t objId : auxMdJobList.ids())
1203  {
1204  auxMdJobList.getValue(MDL_REF3D, ref3d, objId);
1205  auxMdJobList.getValue(MDL_DEFGROUP, defgroup, objId);
1206  auxMdJobList.getValue(MDL_ORDER, order, objId);
1207 
1208  auxMdJobList.getValue(MDL_COUNT,jobCount, objId);
1209 
1210  jobCount2 = ROUND(limitRclass * jobCount);
1211 
1212  if (jobCount2 == 0)
1213  if(rnd_unif(0,1)<limitRclass)
1214  jobCount2 = 1;
1215 
1216  dAkij(multiCounter, order, defgroup, ref3d) = jobCount2;
1217  }
1218 
1219  // sort
1220  if(do_limitR0class)
1221  auxF1.sort(auxDF, MDL::str2Label(col_select), true);
1222  else
1223  auxF1.sort(auxDF, MDL::str2Label(col_select), false);
1224 
1225  auxF1.removeDisabled();
1226  auxF1.addLabel(MDL_ENABLED);
1227  auxF1.setValueCol(MDL_ENABLED, 1);
1228 
1229  for (size_t objId : auxF1.ids())
1230  {
1231  auxF1.getValue(MDL_REF3D, ref3d, objId);
1232  auxF1.getValue(MDL_DEFGROUP, defgroup, objId);
1233  auxF1.getValue(MDL_ORDER, order, objId);
1234 
1235  if (dAkij(multiCounter, order, defgroup, ref3d) > 0)
1236  {
1237  auxF1.setValue(MDL_ENABLED,-1,objId);
1238  dAkij(multiCounter, order, defgroup, ref3d)--;
1239  }
1240  }
1241  auxF1.removeDisabled();
1242  }
1243  else
1244  {
1245  auxF1 = auxDF;
1246  }
1247  auxF1.write("/tmp/inputfileAfterREmove.xmd");
1248  DF.sort(auxF1, MDL_IMAGE);
1249 }
Rotation angle of an image (double,degrees)
static MDLabel str2Label(const String &labelName)
void addAndQuery(MDQuery &query)
bool getValue(MDObject &mdValueOut, size_t id) const override
Tilting angle of an image (double,degrees)
void aggregateSingleInt(MDObject &mdValueOut, AggregateOperation op, MDLabel aggregateLabel)
virtual IdIteratorProxy< false > ids()
void aggregateGroupBy(const MetaDataDb &mdIn, AggregateOperation op, const std::vector< MDLabel > &groupByLabels, MDLabel operateLabel, MDLabel resultLabel)
Is this image enabled? (int [-1 or 1])
void fillConstant(MDLabel label, const String &value) override
double rnd_unif()
Number of elements of a type (int) [this is a genereic type do not use to transfer information to ano...
void aggregateSingleSizeT(MDObject &mdValueOut, AggregateOperation op, MDLabel aggregateLabel)
Defocus group.
void operate(const String &expression)
#define dAkij(V, k, i, j)
#define ROUND(x)
Definition: xmipp_macros.h:210
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const override
size_t size() const override
3D Class to which the image belongs (int)
bool addLabel(const MDLabel label, int pos=-1) override
void importObjects(const MetaData &md, const std::vector< size_t > &objectsToAdd, bool doClear=true) override
Class to which the image belongs (int)
void sort(MetaDataDb &MDin, const MDLabel sortLabel, bool asc=true, int limit=-1, int offset=0)
bool setValue(const MDObject &mdValueIn, size_t id) override
Definition: metadata_db.cpp:90
virtual void removeDisabled()
std::string String
Definition: xmipp_strings.h:34
String formatString(const char *format,...)
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=NULL, bool decomposeStack=true) override
#define FIRST_IMAGE
static String label2Str(const MDLabel &label)
bool setValueCol(const MDObject &mdValueIn) override
Name of an image (std::string)
MDLabel
bool containsLabel(const MDLabel label) const override
Definition: metadata_db.h:305

◆ getPolar()

void MpiProgAngularClassAverage::getPolar ( MultidimArray< double > &  img,
Polar< std::complex< double > > &  fP,
bool  conjugated = false,
float  xoff = 0.,
float  yoff = 0. 
)

Definition at line 1520 of file mpi_angular_class_average.cpp.

1523 {
1524  MultidimArray<double> Maux;
1525  Polar<double> P;
1526 
1527  // Calculate FTs of polar rings and its stddev
1529  P.getPolarFromCartesianBSpline(Maux, Ri, Ro, 3, xoff, yoff);
1530  fourierTransformRings(P, fP, global_plans, conjugated);
1531 }
void getPolarFromCartesianBSpline(const MultidimArray< T > &M1, int first_ring, int last_ring, int BsplineOrder=3, double xoff=0., double yoff=0., double oversample1=1., int mode1=FULL_CIRCLES)
Definition: polar.h:625
void produceSplineCoefficients(int SplineDegree, MultidimArray< double > &coeffs, const MultidimArray< T > &V1)
void fourierTransformRings(Polar< double > &in, Polar< std::complex< double > > &out, Polar_fftw_plans &plans, bool conjugated)
Definition: polar.cpp:34

◆ initDimentions()

void MpiProgAngularClassAverage::initDimentions ( )

Get file and stack dimensions, and number of 3d references and number of defocus groups.

Definition at line 1287 of file mpi_angular_class_average.cpp.

1288 {
1290 
1291  // Output stack size (number of valid projection directions)
1292  MDObject mdValueOut1(MDL_ORDER);
1294  Ndim = mdValueOut1.getValue2(Ndim);
1295 
1296  MDObject mdValueOut2(MDL_DEFGROUP);
1298  ctfNum = mdValueOut2.getValue2(ctfNum);
1299 
1300  MDObject mdValueOut3(MDL_REF3D);
1302  ref3dNum = mdValueOut3.getValue2(ref3dNum);
1303 
1304  //Check Wiener filter image has correct size
1305  if (fn_wien != "")
1306  {
1307  size_t x,y,z, n;
1308  getImageSize(fn_wien,x,y,z,n);
1309 
1310  // Get and check padding dimensions
1311  paddim = ROUND(pad * Xdim);
1312  if (x != paddim)
1314  "Incompatible padding factor for this Wiener filter");
1315  }
1316 
1317 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
static double * y
void getImageSize(const MetaData &md, size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim, MDLabel image_label)
void aggregateSingleInt(MDObject &mdValueOut, AggregateOperation op, MDLabel aggregateLabel)
doublereal * x
void aggregateSingleSizeT(MDObject &mdValueOut, AggregateOperation op, MDLabel aggregateLabel)
Defocus group.
double z
#define ROUND(x)
Definition: xmipp_macros.h:210
3D Class to which the image belongs (int)
Incorrect value received.
Definition: xmipp_error.h:195
int * n

◆ initFileNames()

void MpiProgAngularClassAverage::initFileNames ( )

Initialize file names.

Definition at line 1106 of file mpi_angular_class_average.cpp.

1107 {
1108 
1109  // Set up output rootnames
1110  if (do_split)
1111  {
1112  fn_out1 = fn_out + "_split_1";
1113  fn_out2 = fn_out + "_split_2";
1114  }
1115 
1116 }

◆ initOutputFiles()

void MpiProgAngularClassAverage::initOutputFiles ( )

Delete output files if they exist and init stacks.

Definition at line 1328 of file mpi_angular_class_average.cpp.

1329 {
1330  //alloc space for output files
1331  FileName fn_tmp;
1332 
1333  for (int i = 1; i <= ref3dNum; i++)
1334  {
1335  formatStringFast(fn_tmp, "_Ref3D_%03lu", i);
1336 
1337  unlink((fn_out + fn_tmp + ".xmd").c_str());
1338  unlink((fn_out + fn_tmp + ".stk").c_str());
1339  createEmptyFile(fn_out + fn_tmp + ".stk", Xdim, Ydim, Zdim, Ndim, true,
1340  WRITE_OVERWRITE);
1341  if (do_split)
1342  {
1343  unlink((fn_out1 + fn_tmp + ".xmd").c_str());
1344  unlink((fn_out1 + fn_tmp + ".stk").c_str());
1345  createEmptyFile(fn_out1 + fn_tmp + ".stk", Xdim, Ydim, Zdim, Ndim,
1346  true, WRITE_OVERWRITE);
1347  unlink((fn_out2 + fn_tmp + ".xmd").c_str());
1348  unlink((fn_out2 + fn_tmp + ".stk").c_str());
1349  createEmptyFile(fn_out2 + fn_tmp + ".stk", Xdim, Ydim, Zdim, Ndim,
1350  true, WRITE_OVERWRITE);
1351  }
1352  unlink((fn_out + fn_tmp + "_discarded.xmd").c_str());
1353  }
1354 
1355 }
#define i
void createEmptyFile(const FileName &filename, int xdim, int ydim, int Zdim, size_t select_img, bool isStack, int mode, int _swapWrite, const MDRowVec *md)
void formatStringFast(String &str, const char *format,...)

◆ initWeights()

void MpiProgAngularClassAverage::initWeights ( )

Initialize weights matrices.

Definition at line 1319 of file mpi_angular_class_average.cpp.

1320 {
1321  lockArray.initZeros(Ndim+1,ref3dNum+1);//this should be 3D or 2D is enought ROB
1325 
1326 }
MultidimArray< double > weightArray
MultidimArray< double > weightArrays1
MultidimArray< double > weightArrays2
void initZeros(const MultidimArray< T1 > &op)

◆ mpi_postprocess()

void MpiProgAngularClassAverage::mpi_postprocess ( )

Definition at line 1358 of file mpi_angular_class_average.cpp.

1359 {
1360  // Write class selfile to disc (even if its empty)
1361  //std::cerr << "DEBUG_JM: mpi_postprocess: " << std::endl;
1362  FileName imageName, fileNameXmd, blockNameXmd;
1363  FileName imageNames1, fileNameXmds1, imageNames2, fileNameXmds2;
1364  MetaDataDb auxMd,auxMd2,auxMd3;
1365  size_t order_number;
1366  int ref3d;
1367  double weights1, weights2, weights;
1368 
1369  MDValueEQ eq1(MDL_REF3D, 0), eq2(MDL_ORDER, (size_t) 0);
1370  MDMultiQuery multi;
1371 
1372  auto
1373  comment =
1374  (String) "This file contains a list of class averages with direction projections and weights.";
1375  auxMd2.setComment(comment);
1376 
1377  for (int i=1; i<=ref3dNum; i++)
1378  {
1379 
1380  auxMd.clear();
1381  auxMd2.clear();
1382 
1383  formatStringFast(fileNameXmd,
1384  "Ref3D_%03lu@%s_Ref3D_%03lu.xmd", i, fn_out.c_str(), i);
1385 
1386 
1387 
1389 
1390  const MDLabel myGroupByLabels[] =
1391  {
1393  };
1394  std::vector<MDLabel> groupbyLabels(myGroupByLabels,myGroupByLabels+5);
1395  auxMd2.aggregateGroupBy(auxMd, AGGR_SUM, groupbyLabels, MDL_COUNT, MDL_WEIGHT);
1396 
1397  auxMd2.addLabel(MDL_IMAGE, 1);
1398  auxMd2.addLabel(MDL_ANGLE_PSI);
1399  auxMd2.setValueCol(MDL_ANGLE_PSI,0.);
1400 
1401  for (size_t objId : auxMd2.ids())
1402  {
1403  auxMd2.getValue(MDL_ORDER, order_number,objId);
1404  formatStringFast(imageName, "%06lu@%s_Ref3D_%03lu.stk", order_number, fn_out.c_str(), i);
1405  auxMd2.setValue(MDL_IMAGE, imageName,objId);
1406  weights = 0.;
1407  weights += dAkij(weightArray,0,order_number, i);
1408  int enable;
1409  if(weights == 0)
1410  enable= -1;
1411  else
1412  enable= 1;
1413  auxMd2.setValue(MDL_ENABLED,enable,objId);
1414  auxMd2.setValue(MDL_WEIGHT, weights,objId);
1415 
1416  }
1417  auxMd2.write(fileNameXmd);
1418 
1420  {
1421  for (size_t j= 1; j <= Ndim; j++)
1422  {
1423  eq1.setValue(i);
1424  eq2.setValue(j);
1425  multi.clear();
1426 
1427  multi.addAndQuery(eq1);
1428  multi.addAndQuery(eq2);
1429 
1430  auxMd3.importObjects(DF, multi);
1431 
1432  if(auxMd3.size() != 0)
1433  {
1434  formatStringFast(blockNameXmd, "orderGroup%06lu_%s", j, fileNameXmd.c_str());
1435  auxMd3.write(blockNameXmd, MD_APPEND);
1436  }
1437  }
1438  }
1439  auxMd2.addLabel(MDL_ENABLED);
1440  auxMd2.setValueCol(MDL_ENABLED, 1);
1441 
1442  if(do_split)
1443  {
1444  MetaDataDb auxMds1(auxMd2);
1445  MetaDataDb auxMds2(auxMd2);
1446 
1447  formatStringFast(fileNameXmds1,
1448  "Ref3D_%03lu@%s_Ref3D_%03lu.xmd", i, fn_out1.c_str(), i);
1449 
1450  formatStringFast(fileNameXmds2,
1451  "Ref3D_%03lu@%s_Ref3D_%03lu.xmd", i, fn_out2.c_str(), i);
1452 
1453  auto idIter1 = auxMds1.ids().begin();
1454  auto idIter2 = auxMds2.ids().begin();
1455 
1456  const auto totalSize = auxMds1.ids().end();
1457  for (; idIter1 != totalSize; ++idIter1, ++idIter2)
1458  {
1459  auxMds1.getValue(MDL_ORDER, order_number, *idIter1);
1460  auxMds1.getValue(MDL_REF3D, ref3d, *idIter1);
1461 
1462  //weights1 = dAij(weightArrays1,order_number, ref3d);
1463  weights1 = 0.;
1464  weights2 = 0.;
1465  //for (size_t var = 0; var < weightArrays1.zdim; ++var)
1466  {
1467  weights1 += dAkij(weightArrays1,0,order_number, i);
1468  weights2 += dAkij(weightArrays2,0,order_number, i);
1469  }
1470 
1471 
1472  if(weights1 == 0)
1473  auxMds1.setValue(MDL_ENABLED,-1, *idIter1);
1474  else
1475  {
1476  auxMds1.setValue(MDL_WEIGHT, weights1, *idIter1);
1477  formatStringFast(imageName, "%06lu@%s_Ref3D_%03lu.stk", order_number, fn_out1.c_str(), i);
1478  auxMds1.setValue(MDL_IMAGE, imageName, *idIter1);
1479  }
1480 
1481  //weights2 = dAij(weightArrays2,order_number, ref3d);
1482  if(weights2 == 0)
1483  auxMds2.setValue(MDL_ENABLED,-1, *idIter2);
1484  else
1485  {
1486  auxMds2.setValue(MDL_WEIGHT, weights2, *idIter2);
1487  formatStringFast(imageName, "%06lu@%s_Ref3D_%03lu.stk", order_number, fn_out2.c_str(), i);
1488  auxMds2.setValue(MDL_IMAGE, imageName, *idIter2);
1489  }
1490 
1491 
1492  }
1493  auxMds1.removeDisabled();
1494  auxMds1.write(fileNameXmds1);
1495  auxMds2.removeDisabled();
1496  auxMds2.write(fileNameXmds2);
1497  }
1498  }
1499 }
Rotation angle of an image (double,degrees)
void addAndQuery(MDQuery &query)
bool getValue(MDObject &mdValueOut, size_t id) const override
Tilting angle of an image (double,degrees)
Special label to be used when gathering MDs in MpiMetadataPrograms.
virtual IdIteratorProxy< false > ids()
void aggregateGroupBy(const MetaDataDb &mdIn, AggregateOperation op, const std::vector< MDLabel > &groupByLabels, MDLabel operateLabel, MDLabel resultLabel)
#define i
Is this image enabled? (int [-1 or 1])
virtual void setComment(const String &newComment="No comment")
MultidimArray< double > weightArray
MultidimArray< double > weightArrays1
Number of elements of a type (int) [this is a genereic type do not use to transfer information to ano...
void clear() override
Definition: metadata_db.cpp:54
#define dAkij(V, k, i, j)
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const override
size_t size() const override
MultidimArray< double > weightArrays2
#define j
3D Class to which the image belongs (int)
bool addLabel(const MDLabel label, int pos=-1) override
void importObjects(const MetaData &md, const std::vector< size_t > &objectsToAdd, bool doClear=true) override
Class to which the image belongs (int)
bool setValue(const MDObject &mdValueIn, size_t id) override
Definition: metadata_db.cpp:90
std::string String
Definition: xmipp_strings.h:34
bool setValueCol(const MDObject &mdValueIn) override
Name of an image (std::string)
MDLabel
void formatStringFast(String &str, const char *format,...)
< Score 4 for volumes

◆ mpi_preprocess()

void MpiProgAngularClassAverage::mpi_preprocess ( )

Initialize variables, create infrastructure for mpi job submission, and delete output files.

Definition at line 1059 of file mpi_angular_class_average.cpp.

1060 {
1061  initFileNames();
1062 
1063  if (node->rank==0)
1064  {
1066  }
1067  MPI_Bcast(&master_seed,1,MPI_UNSIGNED ,0,MPI_COMM_WORLD);
1069 
1071 
1072  if (node->rank==0)
1073  {
1074  //std::cerr << "DEBUG_JM: saveDiscardedImages" <<std::endl;
1076  //std::cerr << "DEBUG_JM: createJobList" <<std::endl;
1077  createJobList();
1078  //std::cerr << "DEBUG_JM: initDimentions" <<std::endl;
1079  initDimentions();
1080  //std::cerr << "DEBUG_JM: initWeights" <<std::endl;
1081  initWeights();
1082  //std::cerr << "DEBUG_JM: initOutputFiles" <<std::endl;
1083  initOutputFiles();
1084  }
1085 
1086  MPI_Bcast(&Xdim,1,XMIPP_MPI_SIZE_T,0,MPI_COMM_WORLD);
1087  MPI_Bcast(&Ydim,1,XMIPP_MPI_SIZE_T,0,MPI_COMM_WORLD);
1088  MPI_Bcast(&Zdim,1,XMIPP_MPI_SIZE_T,0,MPI_COMM_WORLD);
1089  MPI_Bcast(&Ndim,1,XMIPP_MPI_SIZE_T,0,MPI_COMM_WORLD);
1090  MPI_Bcast(&numberOfJobs,1,XMIPP_MPI_SIZE_T,0,MPI_COMM_WORLD);
1091  MPI_Bcast(&ref3dNum,1,XMIPP_MPI_SIZE_T,0,MPI_COMM_WORLD);
1092  MPI_Bcast(&ctfNum,1,MPI_INT,0,MPI_COMM_WORLD);
1093  MPI_Bcast(&paddim,1,XMIPP_MPI_SIZE_T,0,MPI_COMM_WORLD);
1094 
1096 
1097  // if (node->rank == 0)
1098  // {
1099  // std::cerr << "DEBUG_JM: end of mpi_preprocess" <<std::endl;
1100  // }
1101 
1102  node->barrierWait();
1103 }
size_t numberOfJobs
Definition: xmipp_mpi.h:168
void init_random_generator(int seed)
#define XMIPP_MPI_SIZE_T
Definition: xmipp_mpi.h:37
std::shared_ptr< MpiNode > node
Definition: xmipp_mpi.h:164
unsigned int randomize_random_generator()

◆ mpi_process()

void MpiProgAngularClassAverage::mpi_process ( double *  Def_3Dref_2Dref_JobNo)

Process a single job (ref3d - ctfGroup - ref2d)

Definition at line 368 of file mpi_angular_class_average.cpp.

369 {
370 //#define DEBUG
371 #ifdef DEBUG
372  std::cerr<<"["<<node->rank<<"]"
373  << " 3DRef: " << ROUND(Def_3Dref_2Dref_JobNo[index_3DRef])
374  << " DefGroup: " << ROUND(Def_3Dref_2Dref_JobNo[index_DefGroup])
375  << " 2DRef: " << ROUND(Def_3Dref_2Dref_JobNo[index_2DRef])
376  << " Order: " << ROUND(Def_3Dref_2Dref_JobNo[index_Order])
377  << " Count: " << ROUND(Def_3Dref_2Dref_JobNo[index_Count])
378  << " jobId: " << ROUND(Def_3Dref_2Dref_JobNo[index_jobId])
379  << " rot: " << Def_3Dref_2Dref_JobNo[index_Rot]
380  << " tilt: " << Def_3Dref_2Dref_JobNo[index_Tilt]
381  << " Sat node: " << node->rank
382  << std::endl;
383 #endif
384 #undef DEBUG
385 
386  Image<double> img, img_ref, avg, avg1, avg2;
387  FileName fn_img, fn_tmp;
388  MetaDataDb SFclass, SFclass1, SFclass2;
389  MetaDataDb SFclassDiscarded;
390  double psi, xshift, yshift, w, w1, w2, scale;
391  bool mirror;
392  int ref_number, this_image, ref3d, defGroup;
393  static int defGroup_last = 0;
394  int isplit, lockIndex;
395  MetaDataDb _DF;
396  size_t id;
397  size_t order_number;
398 
399  w = 0.;
400  w1 = 0.;
401  w2 = 0.;
402  this_image = 0;
403 
404  order_number = ROUND(Def_3Dref_2Dref_JobNo[index_Order]);
405  ref_number = ROUND(Def_3Dref_2Dref_JobNo[index_2DRef]);
406  defGroup = ROUND(Def_3Dref_2Dref_JobNo[index_DefGroup]);
407  ref3d = ROUND(Def_3Dref_2Dref_JobNo[index_3DRef]);
408  //std::cerr << "DEBUG_ROB: order_number: " << order_number << std::endl;
409  lockIndex = ROUND(Def_3Dref_2Dref_JobNo[index_jobId]);
410 
411  if (fn_wien != "" && defGroup_last != defGroup)
412  {
413  // Read wiener filter
414  FileName fn_wfilter;
415  Image<double> auxImg;
416 
417  fn_wfilter.compose(defGroup,fn_wien);
418  auxImg.read(fn_wfilter);
419  Mwien = auxImg();
420  defGroup_last = defGroup;
421  }
422 
423  //std::cerr << "DEBUG_JM: BEFORE MDValueEQ" <<std::endl;
424  MDValueEQ eq1(MDL_REF3D, ref3d);
425  MDValueEQ eq2(MDL_DEFGROUP, defGroup);
426  MDValueEQ eq3(MDL_REF, ref_number);
427  MDMultiQuery multi;
428  multi.addAndQuery(eq1);
429  multi.addAndQuery(eq2);
430  multi.addAndQuery(eq3);
431 
432  _DF.importObjects(DF, multi);
433 
434  //std::cerr << "DEBUG_JM: AFTER MDValueEQ" <<std::endl;
435 
436  if (_DF.size() == 0)
438  "Program should never execute this line, something went wrong");
439 
440 
441  MetaDataDb _DF_ref((fn_ref.removeAllExtensions()+".doc"));
442  MetaDataDb _DF_temp;
443  MDValueEQ eq4(MDL_REF, ref_number);
444  _DF_temp.importObjects(_DF_ref, eq4);
445  int noRef = 0;
446  if (_DF_temp.size() > 1)
448  "Program should never execute this line, something went wrong");
449  if (_DF_temp.size() == 0)
450  noRef =1;
451 
452  if (noRef!=1)
453  {
454  for (size_t objId : _DF_temp.ids())
455  {
456  _DF_temp.getValue(MDL_IMAGE, fn_img, objId);
457  img_ref.read(fn_img);
458  }
459  }
460 
461  Matrix2D<double> A(3, 3);
462  std::vector<int> exp_number, exp_split;
463  std::vector<Image<double> > exp_imgs;
464 
465  Iempty.setEulerAngles(Def_3Dref_2Dref_JobNo[index_Rot], Def_3Dref_2Dref_JobNo[index_Tilt], 0.);
466  Iempty.setShifts(0., 0.);
467  Iempty.setFlip(0.);
468  avg = Iempty;
469  avg1 = Iempty;
470  avg2 = Iempty;
471 #ifdef NEVERDEFINED
472  PCAMahalanobisAnalyzer pcaAnalyzerSplit1,pcaAnalyzerSplit2,pcaAnalyzer;
473  pcaAnalyzer.clear();
474  pcaAnalyzerSplit1.clear();
475  pcaAnalyzerSplit2.clear();
476 #endif
477  // Loop over all images in the input docfile
478  for (size_t objId : _DF.ids())
479  {
480  _DF.getValue(MDL_IMAGE, fn_img, objId);
481  this_image++;
482  _DF.getValue(MDL_ANGLE_PSI, psi, objId);
483  _DF.getValue(MDL_SHIFT_X, xshift, objId);
484  _DF.getValue(MDL_SHIFT_Y, yshift, objId);
485  if (do_mirrors)
486  _DF.getValue(MDL_FLIP, mirror, objId);
487  _DF.getValue(MDL_SCALE, scale, objId);
488 
489  img.read(fn_img);
490  img().setXmippOrigin();
491  img.setEulerAngles(0., 0., psi);
492  img.setShifts(-xshift, -yshift);
493 
494  if (do_mirrors)
495  img.setFlip(mirror);
496  img.setScale(scale);
497 
498  if (do_split)
499  isplit = ROUND(rnd_unif());
500  else
501  isplit = 0;
502  // For re-alignment of class: store all images in memory
503  if (nr_iter > 0)
504  {
505  exp_imgs.push_back(img);
506  exp_number.push_back(this_image);
507  }
508 
509  if (nr_iter > 0)
510 #ifdef NEVERDEFINED
511 || do_pcaSorting)
512 #endif
513  {
514  exp_split.push_back(isplit);
515  }
516 
517  // Apply in-plane transformation
519  if (!A.isIdentity())
520  selfApplyGeometry(xmipp_transformation::BSPLINE3, img(), A, xmipp_transformation::IS_INV, xmipp_transformation::DONT_WRAP);
521 
522  MultidimArray<float> auxImg(img().nzyxdim);
523  const MultidimArray<double> &mImg=img();
525  DIRECT_MULTIDIM_ELEM(auxImg,n)=(float)DIRECT_MULTIDIM_ELEM(mImg,n);
526 
527 #ifdef NEVERDEFINED
528  if (do_pcaSorting)
529  {
530  pcaAnalyzer.addVector(auxImg);
531  }
532 #endif
533  // Add to average
534  if (isplit == 0)
535  {
536  avg1() += img();
537  w1 += 1.;
538  id = SFclass1.addObject();
539  SFclass1.setValue(MDL_IMAGE, fn_img, id);
540  SFclass1.setValue(MDL_ANGLE_ROT, Def_3Dref_2Dref_JobNo[index_Rot], id);
541  SFclass1.setValue(MDL_ANGLE_TILT, Def_3Dref_2Dref_JobNo[index_Tilt], id);
542  SFclass1.setValue(MDL_REF, ref_number, id);
543  SFclass1.setValue(MDL_REF3D, ref3d, id);
544  SFclass1.setValue(MDL_DEFGROUP, defGroup, id);
545  SFclass1.setValue(MDL_ORDER, order_number, id);
546 #ifdef NEVERDEFINED
547  if (do_pcaSorting)
548  {
549  pcaAnalyzerSplit1.addVector(auxImg);
550  }
551 #endif
552  }
553  else
554  {
555  avg2() += img();
556  w2 += 1.;
557  id = SFclass2.addObject();
558  SFclass2.setValue(MDL_IMAGE, fn_img, id);
559  SFclass2.setValue(MDL_ANGLE_ROT, Def_3Dref_2Dref_JobNo[index_Rot], id);
560  SFclass2.setValue(MDL_ANGLE_TILT, Def_3Dref_2Dref_JobNo[index_Tilt], id);
561  SFclass2.setValue(MDL_REF, ref_number, id);
562  SFclass2.setValue(MDL_REF3D, ref3d, id);
563  SFclass2.setValue(MDL_DEFGROUP, defGroup, id);
564  SFclass2.setValue(MDL_ORDER, order_number, id);
565 #ifdef NEVERDEFINED
566  if (do_pcaSorting)
567  {
568  pcaAnalyzerSplit2.addVector(auxImg);
569  }
570 #endif
571  }
572 
573  //#define DEBUG
574 #ifdef DEBUG
575  //WRITE IMAGES TO AVERAGE
576  FileName fn_tmp1;
577  int static static_i=0;
578  static_i++;
579  formatStringFast(fn_tmp1, "test_img_%06d.spi", static_i);
580  img.write(fn_tmp1);
581  formatStringFast(fn_tmp1, "test_avg_%06d.spi", static_i);
582  avg1.write(fn_tmp1);
583  std::cout << fn_img
584  << psi
585  << A <<std::endl;
586  if (static_i> 25)
587  {
588  std::cerr << "static_i:" << static_i << std::endl;
589  _DF.write("DF.xmd");
590  exit(1);
591  }
592 #endif
593 #undef DEBUG
594 
595  }
596 
597  //this_image = 0;
598 #ifdef NEVERDEFINED
599  if (do_pcaSorting)
600  {
601  avg().initZeros();
602  avg1().initZeros();
603  avg2().initZeros();
604  double max_cc = 0;
605 
606  w1 = 0;
607  w2 = 0;
608 
609  if (do_split == 0)
610  {
611  size_t index = 0;
612  if (_DF.size() <= 5 )
613  {
614  //pcaAnalyzer.evaluateZScore(1,20);
615  for (size_t objId : _DF.ids())
616  {
617  _DF.getValue(MDL_MAXCC, max_cc, objId);
618  _DF.setValue(MDL_WEIGHT,max_cc, objId);
619  w1 += max_cc;
620  avg1() += img()*(max_cc);
621  index++;
622  }
623  }
624  else
625  {
626  pcaAnalyzer.evaluateZScore(1,20);
627  //We must tour the metadata again:
628  for (size_t objId : _DF.ids())
629  {
630  _DF.getValue(MDL_IMAGE, fn_img, objId);
631  _DF.getValue(MDL_ANGLE_PSI, psi, objId);
632  _DF.getValue(MDL_SHIFT_X, xshift, objId);
633  _DF.getValue(MDL_SHIFT_Y, yshift, objId);
634  if (do_mirrors)
635  _DF.getValue(MDL_FLIP, mirror, objId);
636  _DF.getValue(MDL_SCALE, scale, objId);
637 
638  _DF.getValue(MDL_MAXCC, max_cc, objId);
639 
640  img.read(fn_img);
641  img().setXmippOrigin();
642  img.setEulerAngles(0., 0., psi);
643  img.setShifts(-xshift, -yshift);
644 
645  if (do_mirrors)
646  img.setFlip(mirror);
647  img.setScale(scale);
648 
649  // Apply in-plane transformation
651  if (!A.isIdentity())
652  selfApplyGeometry(BSPLINE3, img(), A, IS_INV, DONT_WRAP);
653 
654  double score = pcaAnalyzer.getZscore(index);
655 
656  if (score < 5)
657  {
658  avg1() += img()*(5-score)*max_cc;
659  w1 +=(5-score)*max_cc;
660  _DF.setValue(MDL_WEIGHT,(5-score)*max_cc, objId);
661  }
662  else
663  _DF.setValue(MDL_WEIGHT,0, objId);
664 
665  index++;
666  }
667  }
668  }
669  else
670  {
671  pcaAnalyzerSplit1.evaluateZScore(1,20);
672  pcaAnalyzerSplit2.evaluateZScore(1,20);
673  size_t index = 0;
674  size_t index1 = 0;
675  size_t index2 = 0;
676 
677  for (size_t objId : _DF.ids())
678  {
679  isplit = exp_split[index];
680  _DF.getValue(MDL_IMAGE, fn_img, objId);
681  //this_image++;
682  _DF.getValue(MDL_ANGLE_PSI, psi, objId);
683  _DF.getValue(MDL_SHIFT_X, xshift, objId);
684  _DF.getValue(MDL_SHIFT_Y, yshift, objId);
685  if (do_mirrors)
686  _DF.getValue(MDL_FLIP, mirror, objId);
687  _DF.getValue(MDL_SCALE, scale, objId);
688 
689  _DF.getValue(MDL_MAXCC, max_cc, objId);
690 
691  img.read(fn_img);
692  img().setXmippOrigin();
693  img.setEulerAngles(0., 0., psi);
694  img.setShifts(-xshift, -yshift);
695 
696  if (do_mirrors)
697  img.setFlip(mirror);
698  img.setScale(scale);
699 
700  // Apply in-plane transformation
702  if (!A.isIdentity())
703  selfApplyGeometry(BSPLINE3, img(), A, IS_INV, DONT_WRAP);
704 
705  if (isplit == 0)
706  {
707  if (pcaAnalyzerSplit1.v.size() > 6 )
708  {
709  double score = pcaAnalyzerSplit1.getZscore(index1);
710  if (score < 5)
711  {
712  avg1() += img()*(5-score)*max_cc;
713  w1 +=(5-score)*max_cc;
714  index1++;
715  _DF.setValue(MDL_WEIGHT,(5-score)*max_cc, objId);
716  }
717  else
718  {
719  index1++;
720  _DF.setValue(MDL_WEIGHT,0, objId);
721  }
722  }
723  else
724  {
725  _DF.setValue(MDL_WEIGHT,max_cc, objId);
726  w1 += max_cc;
727  avg1() += img()*(w1);
728  index++;
729  }
730 
731  }
732  else
733  {
734  if (pcaAnalyzerSplit2.v.size() > 6 )
735  {
736  double score = pcaAnalyzerSplit2.getZscore(index2);
737  if (score < 5)
738  {
739  avg2() += img()*(5-score)*max_cc;
740  w2 +=(5-score)*max_cc;
741  index2++;
742  _DF.setValue(MDL_WEIGHT,(5-score)*max_cc, objId);
743  }
744  else
745  {
746  index2++;
747  _DF.setValue(MDL_WEIGHT,0, objId);
748  }
749  }
750  else
751  {
752  _DF.setValue(MDL_WEIGHT,max_cc, objId);
753  w2 += max_cc;
754  avg2() += img()*(w2);
755  index++;
756  }
757  }
758  index++;
759  }
760  }
761  }
762 #endif
763  // Re-alignment of the class
764  if (nr_iter > 0)
765  {
766  SFclass = SFclass1;
767  SFclass.unionAll(SFclass2);
768  avg() = avg1() + avg2();
769  w = w1 + w2;
770  avg.setWeight(w);
771 
772  // Reserve memory for output from class realignment
773  int reserve = DF.size();
774  auto *my_output=new double[AVG_OUPUT_SIZE * reserve + 1];
775 
776  reAlignClass(avg1, avg2, SFclass1, SFclass2, exp_imgs, exp_split,
777  exp_number, order_number, my_output);
778  w1 = avg1.weight();
779  w2 = avg2.weight();
780  delete []my_output;
781  }
782 
783  // Apply Wiener filters
784  if (fn_wien != "")
785  {
786  if (w1 > 0)
787  applyWienerFilter(avg1());
788  if (w2 > 0)
789  applyWienerFilter(avg2());
790  }
791 
792  // Output total and split averages and selfiles to disc
793  SFclass = SFclass1;
794  SFclass.unionAll(SFclass2);
795 
796  avg() = avg1() + avg2();
797  w = w1+w2;
798 #ifdef NEVERDEFINED
799 
800  double t1;
801  double t2;
802  double t;
803  if (noRef!=1)
804  {
805  img_ref().setXmippOrigin();
806  if (w1 != 0)
807  {
808  t1 = correlationIndex(img_ref(),avg1()/w1);
809  avg1()*=(t1/w1);
810  w1 = t1;
811  }
812  else
813  {
814  t1 = 0.;
815  w1 = 0.;
816  avg1().initZeros();
817  }
818 
819  if (w2 != 0)
820  {
821  t2 = correlationIndex(img_ref(),avg2()/w2);
822  avg2()*=(t2/w2);
823  w2 = t2;
824  }
825  else
826  {
827  t2 = 0.;
828  w2 = 0.;
829  avg2().initZeros();
830 
831  }
832 
833  if (w != 0)
834  {
835  t = correlationIndex(img_ref(),avg()/w);
836  avg()*=(t/w);
837  w=t;
838  }
839  else
840  {
841  t = 0.;
842  w = 0.;
843  avg().initZeros();
844  }
845  }
846 #endif
847  avg.setWeight(w);
848  avg1.setWeight(w1);
849  avg2.setWeight(w2);
850  //TODO ROB may I drop DFSCOre
851  DFscore.unionAll(_DF);
852  mpi_writeController(order_number, avg, avg1, avg2, SFclass, SFclass1, SFclass2,
853  SFclassDiscarded,_DF, w1, w2, w, lockIndex);
854 
855 }
void selfApplyGeometry(int Splinedegree, MultidimArray< std::complex< double > > &V1, const Matrix2D< double > &A, bool inv, bool wrap, std::complex< double > outside)
Rotation angle of an image (double,degrees)
void addVector(const MultidimArray< float > &_v)
Add vector.
Definition: basic_pca.h:100
void setScale(double scale, const size_t n=0)
void addAndQuery(MDQuery &query)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
constexpr int index_2DRef
constexpr int index_DefGroup
Just for debugging, situation that can&#39;t happens.
Definition: xmipp_error.h:120
bool getValue(MDObject &mdValueOut, size_t id) const override
constexpr int AVG_OUPUT_SIZE
double getZscore(int n)
Definition: basic_pca.h:140
Tilting angle of an image (double,degrees)
Shift for the image in the X axis (double)
void reAlignClass(Image< double > &avg1, Image< double > &avg2, MetaData &SFclass1, MetaData &SFclass2, std::vector< Image< double > > imgs, std::vector< int > splits, std::vector< int > numbers, size_t dirno, double *my_output)
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)
std::vector< MultidimArray< float > > v
Definition: basic_pca.h:66
double correlationIndex(const MultidimArray< T > &x, const MultidimArray< T > &y, const MultidimArray< int > *mask=NULL, MultidimArray< double > *Contributions=NULL)
void compose(const String &str, const size_t no, const String &ext="")
Special label to be used when gathering MDs in MpiMetadataPrograms.
doublereal * w
FileName removeAllExtensions() const
virtual IdIteratorProxy< false > ids()
constexpr int index_Count
double weight(const size_t n=0) const
constexpr int index_Order
double rnd_unif()
void setShifts(double xoff, double yoff, double zoff=0., const size_t n=0)
viol index
void evaluateZScore(int NPCA, int Niter, bool trained=false, const char *filename="temp.txt", int numdesc=0)
Definition: basic_pca.cpp:384
size_t addObject() override
Defocus group.
void setFlip(bool flip, const size_t n=0)
Flip the image? (bool)
void mpi_writeController(size_t dirno, Image< double > avg, Image< double > avg1, Image< double > avg2, const MetaDataDb &SFclass, const MetaDataDb &SFclass1, const MetaDataDb &SFclass2, const MetaDataDb &SFclassDiscarded, const MetaDataDb &_DF, double w1, double w2, double w, int lockIndex)
std::shared_ptr< MpiNode > node
Definition: xmipp_mpi.h:164
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
constexpr int index_3DRef
#define DIRECT_MULTIDIM_ELEM(v, n)
#define ROUND(x)
Definition: xmipp_macros.h:210
Maximum cross-correlation for the image (double)
scaling factor for an image or volume (double)
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const override
constexpr int index_Tilt
size_t size() const override
3D Class to which the image belongs (int)
void importObjects(const MetaData &md, const std::vector< size_t > &objectsToAdd, bool doClear=true) override
void setEulerAngles(double rot, double tilt, double psi, const size_t n=0)
void applyWienerFilter(MultidimArray< double > &img)
Class to which the image belongs (int)
bool setValue(const MDObject &mdValueIn, size_t id) override
Definition: metadata_db.cpp:90
double psi(const double x)
void clear()
Clear.
Definition: basic_pca.h:84
void unionAll(const MetaDataDb &mdIn)
void getTransformationMatrix(Matrix2D< double > &A, bool only_apply_shifts=false, const size_t n=0)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
Shift for the image in the Y axis (double)
void setWeight(double weight, const size_t n=0)
int * n
Name of an image (std::string)
void formatStringFast(String &str, const char *format,...)
constexpr int index_jobId
constexpr int index_Rot
< Score 4 for volumes

◆ mpi_process_loop()

void MpiProgAngularClassAverage::mpi_process_loop ( double *  Def_3Dref_2Dref_JobNo)

Process a job list (ref3d - ctfGroup - ref2d)

Definition at line 357 of file mpi_angular_class_average.cpp.

358 {
359  int size = ROUND(Def_3Dref_2Dref_JobNo[0]);
360 
361  for(int i=0;i<size;i++)
362  {
363  mpi_process(Def_3Dref_2Dref_JobNo+i*ArraySize+1);
364  }
365 
366 }
#define i
constexpr int ArraySize
#define ROUND(x)
Definition: xmipp_macros.h:210
void mpi_process(double *Def_3Dref_2Dref_JobNo)

◆ mpi_produceSideInfo()

void MpiProgAngularClassAverage::mpi_produceSideInfo ( )

Initialize

Definition at line 1020 of file mpi_angular_class_average.cpp.

1021 {
1022  node->barrierWait();
1023 
1024  //init with 0 by default through memset
1025 
1026  Iempty().resizeNoCopy(Xdim, Ydim);
1027  Iempty().setXmippOrigin();
1028  node->barrierWait();
1029 
1030  // Randomization
1031  if (do_split)
1033 
1034  if (Ri<1)
1035  Ri=1;
1036  if (Ro<0)
1037  Ro=(Xdim/2)-1;
1038  // Set up FFTW transformers
1039  //Is this needed if no alignment is required?
1040  MultidimArray<double> Maux;
1041  Polar<double> P;
1043 
1047  fourierTransformRings(P, fP, global_plans, false);
1051 
1052  // Set ring defaults
1053  if (Ri < 1)
1054  Ri = 1;
1055  if (Ro < 0)
1056  Ro = (Xdim / 2) - 1;
1057 }
void resizeNoCopy(const MultidimArray< T1 > &v)
int getSampleNoOuterRing() const
Definition: polar.h:386
void setReal(MultidimArray< double > &img)
Definition: xmipp_fftw.cpp:129
void getPolarFromCartesianBSpline(const MultidimArray< T > &M1, int first_ring, int last_ring, int BsplineOrder=3, double xoff=0., double yoff=0., double oversample1=1., int mode1=FULL_CIRCLES)
Definition: polar.h:625
void produceSplineCoefficients(int SplineDegree, MultidimArray< double > &coeffs, const MultidimArray< T > &V1)
std::shared_ptr< MpiNode > node
Definition: xmipp_mpi.h:164
void FourierTransform(T &v, T1 &V, bool getCopy=true)
Definition: xmipp_fftw.h:166
void fourierTransformRings(Polar< double > &in, Polar< std::complex< double > > &out, Polar_fftw_plans &plans, bool conjugated)
Definition: polar.cpp:34
FourierTransformer local_transformer
Definition: polar.h:794
unsigned int randomize_random_generator()
void calculateFftwPlans(Polar_fftw_plans &out)
Definition: polar.h:708

◆ mpi_write()

void MpiProgAngularClassAverage::mpi_write ( size_t  dirno,
int  ref3dIndex,
Image< double >  avg,
Image< double >  avg1,
Image< double >  avg2,
double  w1,
double  w2,
double  old_w,
double  old_w1,
double  old_w2 
)

Write output files

Definition at line 859 of file mpi_angular_class_average.cpp.

870 {
871  FileName fileNameXmd, fileNameStk;
872 
873  formatStringFast(fileNameStk, "%s_Ref3D_%03lu.stk", fn_out.c_str(), ref3dIndex);
874  mpi_writeFile(avg, dirno, fileNameStk, old_w);
875 
876  if (do_split)
877  {
878  if (w1 > 0)
879  {
880  formatStringFast(fileNameStk, "%s_Ref3D_%03lu.stk",
881  fn_out1.c_str(), ref3dIndex);
882  mpi_writeFile(avg1, dirno, fileNameStk, old_w1);
883  }
884  if (w2 > 0)
885  {
886  formatStringFast(fileNameStk, "%s_Ref3D_%03lu.stk",
887  fn_out2.c_str(), ref3dIndex);
888  mpi_writeFile(avg2, dirno, fileNameStk, old_w2);
889  }
890  }
891 }
void mpi_writeFile(Image< double > avg, size_t dirno, FileName fileNameStk, double w_old)
void formatStringFast(String &str, const char *format,...)

◆ mpi_writeController()

void MpiProgAngularClassAverage::mpi_writeController ( size_t  dirno,
Image< double >  avg,
Image< double >  avg1,
Image< double >  avg2,
const MetaDataDb SFclass,
const MetaDataDb SFclass1,
const MetaDataDb SFclass2,
const MetaDataDb SFclassDiscarded,
const MetaDataDb _DF,
double  w1,
double  w2,
double  w,
int  lockIndex 
)

Block output file to avoid concurrent writing

Definition at line 894 of file mpi_angular_class_average.cpp.

908 {
909 
910  double weight_old, weights1_old, weights2_old;
911  double lockWeightIndexes[lockWeightIndexesSize];
912  int ref3dIndex;
913  bool whileLoop = true;
914  while (whileLoop)
915  {
916 #ifdef DEBUG_MPI
917  std::cerr << "[" << node->rank << "] May I write. lockIndex: " << lockIndex <<std::endl;
918 #endif
919 
920  MPI_Send(&lockIndex, 1, MPI_INT, 0, TAG_MAY_I_WRITE, MPI_COMM_WORLD);
921  MPI_Probe(0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
922  switch (status.MPI_TAG)
923  {
924  case TAG_DO_NOT_DARE_TO_WRITE://I am free
925  MPI_Recv(nullptr, 0, MPI_INT, 0, MPI_ANY_TAG,
926  MPI_COMM_WORLD, &status);
927  //usleep(100000);//microsecond
928  break;
929  case TAG_YES_YOU_MAY_WRITE://I am free
930 
931  MPI_Recv(lockWeightIndexes, lockWeightIndexesSize, MPI_DOUBLE, 0, MPI_ANY_TAG,
932  MPI_COMM_WORLD, &status);
933 
934  lockIndex = ROUND(lockWeightIndexes[index_lockIndex]);
935 
936 #ifdef DEBUG_MPI
937 
938  std::cerr << "[" << node->rank << "] TAG_YES_YOU_MAY_WRITE.lockIndex: " << lockIndex <<std::endl;
939  std::cerr << "lockWeightIndexes[index_weight]" << lockWeightIndexes[index_weight]<<std::endl;
940 #endif
941 
942  weight_old = lockWeightIndexes[index_weight];
943  weights1_old = lockWeightIndexes[index_weights1];
944  weights2_old = lockWeightIndexes[index_weights2];
945  ref3dIndex = ROUND(lockWeightIndexes[index_ref3d]);
946 
947  mpi_write(dirno, ref3dIndex, avg, avg1, avg2, w1, w2, weight_old,
948  weights1_old, weights2_old);
949  whileLoop=false;
950  break;
951  default:
952  std::cerr << "process WRONG TAG RECEIVED at " << node->rank << std::endl;
953  break;
954  }
955  }
956 #ifdef DEBUG_MPI
957  std::cerr << "[" << node->rank << "] Finish writer " <<std::endl;
958 #endif
959 
960  lockWeightIndexes[index_lockIndex] = lockIndex;
961  //lockWeightIndexes[index_weight]= w1 + w2;
962  lockWeightIndexes[index_weight]= w;
963  lockWeightIndexes[index_weights1] = w1;
964  lockWeightIndexes[index_weights2] = w2;
965  lockWeightIndexes[index_ref3d] = ref3dIndex;
966 
967  MPI_Send(lockWeightIndexes, lockWeightIndexesSize, MPI_DOUBLE, 0, TAG_I_FINISH_WRITTING, MPI_COMM_WORLD);
968 
969 }
constexpr int index_lockIndex
void mpi_write(size_t dirno, int ref3dIndex, Image< double > avg, Image< double > avg1, Image< double > avg2, double w1, double w2, double old_w, double old_w1, double old_w2)
constexpr int TAG_YES_YOU_MAY_WRITE
constexpr int index_weights1
doublereal * w
constexpr int TAG_DO_NOT_DARE_TO_WRITE
constexpr int index_weight
constexpr int lockWeightIndexesSize
std::shared_ptr< MpiNode > node
Definition: xmipp_mpi.h:164
#define ROUND(x)
Definition: xmipp_macros.h:210
constexpr int TAG_MAY_I_WRITE
constexpr int TAG_I_FINISH_WRITTING
constexpr int index_ref3d
constexpr int index_weights2
MPI_Status status
Definition: xmipp_mpi.h:170

◆ mpi_writeFile()

void MpiProgAngularClassAverage::mpi_writeFile ( Image< double >  avg,
size_t  dirno,
FileName  fileNameStk,
double  w_old 
)

Called by mpi_write does the actual writing

Definition at line 972 of file mpi_angular_class_average.cpp.

977 {
978  FileName fn_tmp;
979  double w = avg.weight();
980  Image<double> old;
981 
982  if (w > 0.)
983  {
984  if (fileNameStk.exists())
985  {
986 
987  //std::cerr << "DEBUG_JM: Composing" << std::endl;
988  //std::cerr << "DEBUG_JM: dirno: " << dirno << std::endl;
989  //std::cerr << "DEBUG_JM: fileNameStk: " << fileNameStk << std::endl;
990  fn_tmp.compose(dirno, fileNameStk);
991  //std::cerr << "DEBUG_JM: fn_tmp: " << fn_tmp << std::endl;
992  old.read(fn_tmp);
993 
994  //w_old = old.weight();
995  //std::cerr << "DEBUG_JM: SECOND Imagew dirno old new master branch: " << fn_tmp << " " << dirno << " "
996  // << w_old << " "
997  // << w << " "
998  // << std::endl;
1000  {
1001  dAij(old(),i,j) = (w_old * dAij(old(),i,j) + dAij(avg(),i,j)) / (w_old + w);
1002  }
1003  old.setWeight(w_old + w);
1004  old.write(fileNameStk, dirno, true, WRITE_REPLACE);
1005  }
1006  else
1007  {
1008  //std::cerr << "DEBUG_JM: FIRST Imagew dirno old new master branch: " << fn_tmp << " " << dirno << " "
1009  // << w_old << " "
1010  // << w << " "
1011  // << std::endl;
1012  if (w != 1.)
1013  avg() /= w;
1014  avg.write(fileNameStk, dirno, true, WRITE_REPLACE);
1015  }
1016  }
1017 }
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY2D(m)
#define dAij(M, i, j)
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 compose(const String &str, const size_t no, const String &ext="")
doublereal * w
double weight(const size_t n=0) const
#define i
bool exists() const
#define j
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
void setWeight(double weight, const size_t n=0)

◆ readParams()

void MpiProgAngularClassAverage::readParams ( )
virtual

Redefine read

Reimplemented from XmippProgram.

Definition at line 44 of file mpi_angular_class_average.cpp.

45 {
47 
48  // Read command line
49  fn_out = getParam("-o");
50  fn_ref = getParam("--lib");
51 
52  col_select = getParam("--select");
53 
54  do_limit0 = checkParam("--limit0");
55  if (do_limit0)
56  limit0 = getDoubleParam("--limit0");
57  do_limitF = checkParam("--limitF");
58  if (do_limitF)
59  limitF = getDoubleParam("--limitF");
60 
61  inFile = getParam("-i");
62 #ifdef NEVERDEFINED
63  do_pcaSorting = false;
64  do_pcaSorting= checkParam("--pcaSorting");
65 #endif
66  do_limitRFclass = false;
67  do_limitR0class = false;
68  do_limitR0per = false;
69  do_limitRFper = false;
70  if (checkParam("--limitRclass"))
71  {
72  limitRclass = getDoubleParam("--limitRclass")/100.;
73  if (limitRclass < -1. || limitRclass > 1.)
75  "limitRclass should be a percentage: provide values between -100 and 100.");
76  if (limitRclass > 0.)
77  do_limitR0class = true;
78  else if (limitRclass < 0.)
79  {
80  limitRclass *= -1.;
81  do_limitRFclass = true;
82  }
83  }
84 
85 
86  if (checkParam("--limitRper"))
87  {
88  limitRper = getDoubleParam("--limitRper");
89  if (limitRper < -100. || limitRper > 100.)
91  "limitRper should be a percentage: provide values between -100 and 100.");
92  if (limitRper > 0.)
93  do_limitR0per = true;
94  else if (limitRper < 0.)
95  {
96  limitRper *= -1.;
97  do_limitRFper = true;
98  }
99  }
100 
102  (do_limitR0per && (do_limit0 || do_limitF )) ||
104  REPORT_ERROR(ERR_VALUE_INCORRECT, "You can not use different kind of limits at the same time.");
105 
106  // Perform splitting of the data?
107  do_split = checkParam("--split");
108 
109  // Perform Wiener filtering of average?
110  fn_wien = getParam("--wien");
111  pad = XMIPP_MAX(1.,getDoubleParam("--pad"));
112 
113  // Internal re-alignment of the class averages
114  Ri = getIntParam("--Ri");
115  Ro = getIntParam("--Ro");
116  nr_iter = getIntParam("--iter");
117  do_mirrors = true;
118 
119  do_save_images_assigned_to_classes = checkParam("--save_images_assigned_to_classes");
120  mpi_job_size = getIntParam("--mpi_job_size");
121 }
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
double getDoubleParam(const char *param, int arg=0)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
const char * getParam(const char *param, int arg=0)
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)
Incorrect value received.
Definition: xmipp_error.h:195

◆ reAlignClass()

void MpiProgAngularClassAverage::reAlignClass ( Image< double > &  avg1,
Image< double > &  avg2,
MetaData SFclass1,
MetaData SFclass2,
std::vector< Image< double > >  imgs,
std::vector< int >  splits,
std::vector< int >  numbers,
size_t  dirno,
double *  my_output 
)

Definition at line 1533 of file mpi_angular_class_average.cpp.

1537 {
1538  Polar<std::complex<double> > fPref, fPrefm, fPimg;
1539  std::vector<double> ccfs(splits.size());
1541  MultidimArray<double> Mimg, Mref, Maux;
1542  double maxcorr, new_xoff=0., new_yoff=0.;
1543  double w1=0., w2=0., opt_flip = 0., opt_psi = 0.;
1544  bool do_discard;
1545 
1546  SFclass1.clear();
1547  SFclass2.clear();
1548  Mref = avg1() + avg2();
1549  //#define DEBUG
1550 #ifdef DEBUG
1551 
1552  Image<double> auxImg;
1553  auxImg() = Mref;
1554  auxImg.write("ref.xmp");
1555 #endif
1556 
1557  for (int iter = 0; iter < nr_iter; iter++)
1558  {
1559  // Initialize iteration
1560  getPolar(Mref, fPref, true);
1561  getPolar(Mref, fPrefm, false);
1562  avg1().initZeros();
1563  avg2().initZeros();
1564  w1 = w2 = 0.;
1565 
1566 #ifdef DEBUG
1567 
1568  std::cerr<<" entering iter "<<iter<<std::endl;
1569 #endif
1570 
1571  for (size_t imgno = 0; imgno < imgs.size(); imgno++)
1572  {
1573  do_discard = false;
1574  maxcorr = -99.e99;
1575  // Rotationally align
1576  getPolar(imgs[imgno](), fPimg, false, (float) -imgs[imgno].Xoff(),
1577  (float) -imgs[imgno].Yoff());
1578  // A. Check straight image
1579  rotationalCorrelation(fPimg, fPref, ang, rotAux);
1580  for (size_t k = 0; k < XSIZE(corr); k++)
1581  {
1582  if (corr(k) > maxcorr)
1583  {
1584  maxcorr = corr(k);
1585  opt_psi = ang(k);
1586  opt_flip = 0.;
1587  }
1588  }
1589 
1590  // B. Check mirrored image
1591  rotationalCorrelation(fPimg, fPrefm, ang, rotAux);
1592  for (size_t k = 0; k < XSIZE(corr); k++)
1593  {
1594  if (corr(k) > maxcorr)
1595  {
1596  maxcorr = corr(k);
1597  opt_psi = realWRAP(360. - ang(k), -180., 180.);
1598  opt_flip = 1.;
1599  }
1600  }
1601 
1602  // Translationally align
1603  if (!do_discard)
1604  {
1605  if (opt_flip == 1.)
1606  {
1607  // Flip experimental image
1608  Matrix2D<double> A(3, 3);
1609  A.initIdentity();
1610  A(0, 0) *= -1.;
1611  A(0, 1) *= -1.;
1612  applyGeometry(xmipp_transformation::LINEAR, Mimg, imgs[imgno](), A, xmipp_transformation::IS_INV,
1613  xmipp_transformation::DONT_WRAP);
1614  selfRotate(xmipp_transformation::BSPLINE3, Mimg, opt_psi, xmipp_transformation::DONT_WRAP);
1615  }
1616  else
1617  rotate(xmipp_transformation::BSPLINE3, Mimg, imgs[imgno](), opt_psi, xmipp_transformation::DONT_WRAP);
1618  }
1619 
1620  if (!do_discard)
1621  {
1622  ccfs[imgno] = correlationIndex(Mref, Mimg);
1623  imgs[imgno].setPsi(opt_psi);
1624  imgs[imgno].setFlip(opt_flip);
1625  imgs[imgno].setShifts(new_xoff, new_yoff);
1626  if (opt_flip == 1.)
1627  imgs[imgno].setShifts(-new_xoff, new_yoff);
1628 
1629  // Add to averages
1630  if (splits[imgno] == 0)
1631  {
1632  w1 += 1.;
1633  avg1() += Mimg;
1634  }
1635  else if (splits[imgno] == 1)
1636  {
1637  w2 += 1.;
1638  avg2() += Mimg;
1639  }
1640  }
1641  else
1642  {
1643  splits[imgno] = -1;
1644  ccfs[imgno] = 0.;
1645  }
1646  }
1647  Mref = avg1() + avg2();
1648 
1649  }
1650 
1651  avg1.setWeight(w1);
1652  avg2.setWeight(w2);
1653 
1654  // Report the new angles, offsets and selfiles
1655  my_output[4] = imgs.size() * AVG_OUPUT_SIZE;
1656  for (size_t imgno = 0; imgno < imgs.size(); imgno++)
1657  {
1658  if (splits[imgno] < 0)
1659  my_output[imgno * AVG_OUPUT_SIZE + 5] = -numbers[imgno];
1660  else
1661  my_output[imgno * AVG_OUPUT_SIZE + 5] = numbers[imgno];
1662  my_output[imgno * AVG_OUPUT_SIZE + 6] = avg1.rot();
1663  my_output[imgno * AVG_OUPUT_SIZE + 7] = avg1.tilt();
1664  my_output[imgno * AVG_OUPUT_SIZE + 8] = imgs[imgno].psi();
1665  my_output[imgno * AVG_OUPUT_SIZE + 9] = imgs[imgno].Xoff();
1666  my_output[imgno * AVG_OUPUT_SIZE + 10] = imgs[imgno].Yoff();
1667  my_output[imgno * AVG_OUPUT_SIZE + 11] = (double) dirno;
1668  my_output[imgno * AVG_OUPUT_SIZE + 12] = imgs[imgno].flip();
1669  my_output[imgno * AVG_OUPUT_SIZE + 13] = ccfs[imgno];
1670 
1671  if (splits[imgno] == 0)
1672  {
1673  SFclass1.setValue(MDL_IMAGE, imgs[imgno].name(),
1674  SFclass1.addObject());
1675  }
1676  else if (splits[imgno] == 1)
1677  {
1678  SFclass2.setValue(MDL_IMAGE, imgs[imgno].name(),
1679  SFclass2.addObject());
1680  }
1681  }
1682 }
virtual size_t addObject()=0
virtual void clear()
constexpr int AVG_OUPUT_SIZE
void rotationalCorrelation(const Polar< std::complex< double > > &M1, const Polar< std::complex< double > > &M2, MultidimArray< double > &angles, RotationalCorrelationAux &aux)
Definition: polar.cpp:99
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)
double correlationIndex(const MultidimArray< T > &x, const MultidimArray< T > &y, const MultidimArray< int > *mask=NULL, MultidimArray< double > *Contributions=NULL)
double rot(const size_t n=0) const
glob_prnt iter
void selfRotate(int SplineDegree, MultidimArray< T > &V1, double ang, char axis='Z', bool wrap=xmipp_transformation::DONT_WRAP, T outside=0)
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 rotate(a, i, j, k, l)
double tilt(const size_t n=0) const
void getPolar(MultidimArray< double > &img, Polar< std::complex< double > > &fP, bool conjugated=false, float xoff=0., float yoff=0.)
#define XSIZE(v)
const char * name() const
bool setValue(const MDLabel label, const T &valueIn, size_t id)
Definition: polar.h:67
#define realWRAP(x, x0, xF)
Definition: xmipp_macros.h:304
void setWeight(double weight, const size_t n=0)
Name of an image (std::string)

◆ run()

void MpiProgAngularClassAverage::run ( )
virtual

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

Reimplemented from XmippProgram.

Definition at line 162 of file mpi_angular_class_average.cpp.

163 {
164  mpi_preprocess();
165 
166  int lockIndex;
167  size_t order_index;
168  int ref3d_index;
169 
170  double lockWeightIndexes[lockWeightIndexesSize];
171 
172  auto * jobListRows = new double[ArraySize * mpi_job_size + 1];
173 
174  if (node->rank == 0)
175  {
176  //for (int iCounter = 0; iCounter < nJobs; )//increase counter after I am free
177  size_t jobId = 0, size;
178  size_t finishedNodes = 1;
179  bool whileLoop = true;
180 
181  size_t order, count;
182  int ctfGroup, ref3d, ref2d;
183  auto __iterJobs = mdJobList.ids().begin();
184  while (whileLoop)
185  {
186  //wait until a worker is available
187  MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
188  switch (status.MPI_TAG)
189  {
190  case TAG_I_AM_FREE:
191 
192  size = 0;
193  for (size_t i=0;i<mpi_job_size && jobId < numberOfJobs;i++,size++,jobId++)
194  {
195  //Some test values for defocus, 3D reference and projection direction
196  mdJobList.getValue(MDL_REF3D, ref3d, *__iterJobs);
197  jobListRows[index_3DRef + ArraySize * i + 1] = (double) ref3d;
198  mdJobList.getValue(MDL_DEFGROUP, ctfGroup, *__iterJobs);
199  jobListRows[index_DefGroup + ArraySize * i + 1] = (double) ctfGroup;
200  mdJobList.getValue(MDL_ORDER, order, *__iterJobs);
201  jobListRows[index_Order + ArraySize * i + 1] = (double) order;
202  mdJobList.getValue(MDL_COUNT, count, *__iterJobs);
203  jobListRows[index_Count + ArraySize * i + 1] = (double) count;
204  mdJobList.getValue(MDL_REF, ref2d, *__iterJobs);
205  jobListRows[index_2DRef + ArraySize * i + 1] = (double) ref2d;
206  jobListRows[index_jobId + ArraySize * i + 1] = (double) *__iterJobs;
207  mdJobList.getValue(MDL_ANGLE_ROT, jobListRows[index_Rot + ArraySize * i + 1], *__iterJobs);
208  mdJobList.getValue(MDL_ANGLE_TILT, jobListRows[index_Tilt + ArraySize * i + 1], *__iterJobs);
209  ++__iterJobs;
210  }
211  jobListRows[0]=size;
212 
213  //read worker call just to remove it from the queue
214  MPI_Recv(nullptr, 0, MPI_INT, MPI_ANY_SOURCE, TAG_I_AM_FREE, MPI_COMM_WORLD,
215  &status);
216  if(size > 0)
217  {
218  //send work, first int defocus, second 3D reference, 3rd projection
219  // direction and job number
220  //#define DEBUG_MPI
221 #ifdef DEBUG_MPI
222  usleep(10000);
223  std::cerr << "Sending job to worker " << status.MPI_SOURCE <<std::endl;
224 #endif
225 
226  MPI_Send(jobListRows, ArraySize * mpi_job_size + 1, MPI_DOUBLE, status.MPI_SOURCE,
227  TAG_WORK, MPI_COMM_WORLD);
228  }
229  else
230  {
231  MPI_Send(nullptr, 0, MPI_INT, status.MPI_SOURCE, TAG_STOP, MPI_COMM_WORLD);
232  finishedNodes ++;
233  if (finishedNodes >= node->size)
234  whileLoop=false;
235  }
236  break;
237  case TAG_MAY_I_WRITE:
238  //where do you want to write?
239  MPI_Recv(&lockIndex, 1, MPI_INT, MPI_ANY_SOURCE, TAG_MAY_I_WRITE, MPI_COMM_WORLD, &status);
240 
241  mdJobList.getValue(MDL_ORDER, order_index, lockIndex);
242  mdJobList.getValue(MDL_REF3D, ref3d_index, lockIndex);
243 
244  //#define DEBUG_MPI
245 #ifdef DEBUG_MPI
246 
247  std::cerr << "Blocking. lockIndex: " << lockIndex << " | status.MPI_SOURCE: " << status.MPI_SOURCE
248  << " | lockArray[" << order_index<< "," <<ref3d_index<< "]: " << dAij(lockArray,order_index,ref3d_index) << std::endl;
249 #endif
250 
251  if (dAij(lockArray,order_index,ref3d_index))
252  {//Locked
253  MPI_Send(nullptr, 0, MPI_INT, status.MPI_SOURCE,
254  TAG_DO_NOT_DARE_TO_WRITE, MPI_COMM_WORLD);
255  }
256  else
257  {//Unlocked
258  //JV : mirar esto imprimiendo
259  dAij(lockArray,order_index,ref3d_index)=true;
260  // Send the old weight
261  lockWeightIndexes[index_lockIndex] = lockIndex;
262  lockWeightIndexes[index_weight] = dAkij(weightArray,0,order_index,ref3d_index);
263  lockWeightIndexes[index_weights1] = dAkij(weightArrays1,0,order_index,ref3d_index);
264  lockWeightIndexes[index_weights2] = dAkij(weightArrays2,0,order_index,ref3d_index);
265  lockWeightIndexes[index_ref3d] = ref3d_index;
266  //lockWeightIndexes[index_weight] = dAij(weightArray,order_index,ref3d_index);
267  //lockWeightIndexes[index_weights1] = dAij(weightArrays1,order_index,ref3d_index);
268  //lockWeightIndexes[index_weights2] = dAij(weightArrays2,order_index,ref3d_index);
269  //lockWeightIndexes[index_ref3d] = ref3d_index;
270 #ifdef DEBUG_MPI
271 
272  std::cerr << "[" << node->rank << "] TAG_YES_YOU_MAY_WRITE.lockIndex: " << lockIndex <<std::endl;
273  std::cerr << "lockWeightIndexes[index_weight]" << lockWeightIndexes[index_weight]<<std::endl;
274 #endif
275 #undef DEBUG_MPI
276 
277  MPI_Send(lockWeightIndexes, lockWeightIndexesSize, MPI_DOUBLE, status.MPI_SOURCE,
278  TAG_YES_YOU_MAY_WRITE, MPI_COMM_WORLD);
279  }
280  break;
282  //release which lock?
283  MPI_Recv(lockWeightIndexes, lockWeightIndexesSize, MPI_DOUBLE, MPI_ANY_SOURCE, TAG_I_FINISH_WRITTING,
284  MPI_COMM_WORLD, &status);
285 
286  lockIndex = (int)lockWeightIndexes[index_lockIndex];
287  //#define DEBUG_MPI
288 #ifdef DEBUG_MPI
289 
290  std::cerr << "Unblocking. lockIndex: " << lockIndex << " | status.MPI_SOURCE: " << status.MPI_SOURCE << std::endl;
291 #endif
292 
293  mdJobList.getValue(MDL_ORDER, order_index, lockIndex);
294  mdJobList.getValue(MDL_REF3D, ref3d_index, lockIndex);
295  dAij(lockArray,order_index,ref3d_index)=false;
296  //dAij(weightArray,order_index,ref3d_index) += lockWeightIndexes[index_weight];
297  //dAij(weightArrays1,order_index,ref3d_index) += lockWeightIndexes[index_weights1];
298  //dAij(weightArrays2,order_index,ref3d_index) += lockWeightIndexes[index_weights2];
299 
300  dAkij(weightArray,0,order_index,ref3d_index) += lockWeightIndexes[index_weight];
301  dAkij(weightArrays1,0,order_index,ref3d_index) += lockWeightIndexes[index_weights1];
302  dAkij(weightArrays2,0,order_index,ref3d_index) += lockWeightIndexes[index_weights2];
303  break;
304  default:
305  std::cerr << "WRONG TAG RECEIVED" << std::endl;
306  break;
307  }
308  }
309  }
310  else
311  {
312  bool whileLoop = true;
313  while (whileLoop)
314  {
315  //#define DEBUG_MPI
316 #ifdef DEBUG_MPI
317  std::cerr << "[" << node->rank << "] Asking for a job " <<std::endl;
318 #endif
319  //I am free
320  MPI_Send(nullptr, 0, MPI_INT, 0, TAG_I_AM_FREE, MPI_COMM_WORLD);
321  //wait for message
322  MPI_Probe(0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
323 
324  switch (status.MPI_TAG)
325  {
326  case TAG_STOP://I am free
327  MPI_Recv(nullptr, 0, MPI_INT, 0, TAG_STOP,
328  MPI_COMM_WORLD, &status);
329  whileLoop=false;
330  break;
331  case TAG_WORK://work to do
332  MPI_Recv(jobListRows, ArraySize * mpi_job_size + 1, MPI_DOUBLE, 0, TAG_WORK,
333  MPI_COMM_WORLD, &status);
334  mpi_process_loop(jobListRows);
335  break;
336  default:
337  break;
338  }
339  }
340  }
341  FileName gatherFile;
342  formatStringFast( gatherFile, "%s_GatherMetadata.xmd", fn_out.c_str());
343  node->gatherMetadatas(DFscore, gatherFile);
344 
345  if (node->rank == 0)
346  {
347  FileName fn = inFile.withoutExtension()+"_weight."+inFile.getExtension();
348  fn = "all_exp_images@"+fn.removeBlockName();
349  DFscore.write(fn);
350  mpi_postprocess();
351  }
352 
353  // MPI_Finalize();
354 }
Rotation angle of an image (double,degrees)
void mpi_process_loop(double *Def_3Dref_2Dref_JobNo)
constexpr int index_2DRef
constexpr int index_lockIndex
constexpr int index_DefGroup
#define dAij(M, i, j)
bool getValue(MDObject &mdValueOut, size_t id) const override
constexpr int TAG_YES_YOU_MAY_WRITE
Tilting angle of an image (double,degrees)
constexpr int index_weights1
virtual IdIteratorProxy< false > ids()
constexpr int index_Count
size_t numberOfJobs
Definition: xmipp_mpi.h:168
#define i
constexpr int TAG_DO_NOT_DARE_TO_WRITE
constexpr int TAG_STOP
constexpr int index_Order
String getExtension() const
MultidimArray< double > weightArray
MultidimArray< double > weightArrays1
#define TAG_WORK
Definition: mpi_run.cpp:31
Number of elements of a type (int) [this is a genereic type do not use to transfer information to ano...
constexpr int index_weight
Defocus group.
constexpr int lockWeightIndexesSize
std::shared_ptr< MpiNode > node
Definition: xmipp_mpi.h:164
#define dAkij(V, k, i, j)
constexpr int ArraySize
constexpr int index_3DRef
constexpr int TAG_MAY_I_WRITE
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const override
constexpr int index_Tilt
constexpr int TAG_I_FINISH_WRITTING
MultidimArray< double > weightArrays2
3D Class to which the image belongs (int)
constexpr int index_ref3d
constexpr int TAG_I_AM_FREE
constexpr int index_weights2
Class to which the image belongs (int)
MPI_Status status
Definition: xmipp_mpi.h:170
FileName removeBlockName() const
FileName withoutExtension() const
void formatStringFast(String &str, const char *format,...)
constexpr int index_jobId
constexpr int index_Rot

◆ saveDiscardedImages()

void MpiProgAngularClassAverage::saveDiscardedImages ( )

Save discarded images

Definition at line 1251 of file mpi_angular_class_average.cpp.

1252 {
1253 
1254  MetaDataDb auxDF, auxDFsort;
1255  FileName fileNameXmd;
1256  std::stringstream comment;
1257 
1258  auxDF.read(inFile);
1259 
1260  comment << "Discarded images";
1261  if (do_limit0)
1262  comment << ". Min value = " << limit0;
1263  if (do_limitF)
1264  comment << ". Max value = " << limitF;
1265  if (do_limitR0per)
1266  comment << ". Drop " << limitRper*100 << "% of images with lower " << col_select;
1267  if (do_limitRFper)
1268  comment << ". Drop " << limitRper*100 << "% of images with higher " << col_select;
1269  if (do_limitR0class)
1270  comment << ". Drop " << limitRclass*100 << "% of images (per class) with lower " << col_select
1271  << ". If the ROUND(num_images_per_class * limitRclass / 100) == 0 then images are randomly dropped"
1272  << " so the percentage is satisfied";
1273  if (do_limitRFclass)
1274  comment << ". Drop " << limitRclass*100 << "% of images (per class) with higher " << col_select
1275  << ". If the ROUND(num_images_per_class * limitRclass / 100) == 0 then images are randomly dropped"
1276  << " so the percentage is satisfied";
1277 
1278  auxDF.subtraction(DF,MDL_IMAGE);
1279  auxDF.setComment(comment.str());
1280  formatStringFast(fileNameXmd, "discarded@%s_discarded.xmd", fn_out.c_str());
1281 
1282  auxDFsort.sort(auxDF,MDL::str2Label(col_select));
1283  auxDFsort.write(fileNameXmd);
1284 
1285 }
void subtraction(const MetaDataDb &mdIn, const MDLabel label)
static MDLabel str2Label(const String &labelName)
virtual void setComment(const String &newComment="No comment")
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const override
void sort(MetaDataDb &MDin, const MDLabel sortLabel, bool asc=true, int limit=-1, int offset=0)
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=NULL, bool decomposeStack=true) override
Name of an image (std::string)
void formatStringFast(String &str, const char *format,...)

Member Data Documentation

◆ col_select

std::string MpiProgAngularClassAverage::col_select

Column numbers

Definition at line 87 of file mpi_angular_class_average.h.

◆ corr

MultidimArray<double> MpiProgAngularClassAverage::corr

Definition at line 130 of file mpi_angular_class_average.h.

◆ ctfNum

int MpiProgAngularClassAverage::ctfNum

number of Ctf groups

Definition at line 133 of file mpi_angular_class_average.h.

◆ DF

MetaDataDb MpiProgAngularClassAverage::DF

Input and library docfiles

Definition at line 81 of file mpi_angular_class_average.h.

◆ DFclassesExp

MetaDataDb MpiProgAngularClassAverage::DFclassesExp

metadata with classes which have experimental images applied to them

Definition at line 83 of file mpi_angular_class_average.h.

◆ DFlib

MetaDataDb MpiProgAngularClassAverage::DFlib

Definition at line 81 of file mpi_angular_class_average.h.

◆ DFscore

MetaDataDb MpiProgAngularClassAverage::DFscore

Definition at line 81 of file mpi_angular_class_average.h.

◆ do_add

bool MpiProgAngularClassAverage::do_add

Add output to existing files

Definition at line 105 of file mpi_angular_class_average.h.

◆ do_limit0

bool MpiProgAngularClassAverage::do_limit0

Flags wether to use limit0, limitF and limitR selection

Definition at line 91 of file mpi_angular_class_average.h.

◆ do_limitF

bool MpiProgAngularClassAverage::do_limitF

Definition at line 91 of file mpi_angular_class_average.h.

◆ do_limitR0class

bool MpiProgAngularClassAverage::do_limitR0class

Definition at line 91 of file mpi_angular_class_average.h.

◆ do_limitR0per

bool MpiProgAngularClassAverage::do_limitR0per

Definition at line 91 of file mpi_angular_class_average.h.

◆ do_limitRFclass

bool MpiProgAngularClassAverage::do_limitRFclass

Definition at line 91 of file mpi_angular_class_average.h.

◆ do_limitRFper

bool MpiProgAngularClassAverage::do_limitRFper

Definition at line 91 of file mpi_angular_class_average.h.

◆ do_mirrors

bool MpiProgAngularClassAverage::do_mirrors

Flag whether to apply mirror operations. By default set to True

Definition at line 93 of file mpi_angular_class_average.h.

◆ do_pcaSorting

bool MpiProgAngularClassAverage::do_pcaSorting

Perform PCA sorting to obtain the average classes

Definition at line 107 of file mpi_angular_class_average.h.

◆ do_save_images_assigned_to_classes

bool MpiProgAngularClassAverage::do_save_images_assigned_to_classes

Do write images assigned to each class

Definition at line 103 of file mpi_angular_class_average.h.

◆ do_split

bool MpiProgAngularClassAverage::do_split

Flag whether also to write out class averages of random halves of the data

Definition at line 95 of file mpi_angular_class_average.h.

◆ eps

double MpiProgAngularClassAverage::eps

Convergence criterion

Definition at line 122 of file mpi_angular_class_average.h.

◆ fn_out

FileName MpiProgAngularClassAverage::fn_out

Output rootnames

Definition at line 85 of file mpi_angular_class_average.h.

◆ fn_out1

FileName MpiProgAngularClassAverage::fn_out1

Definition at line 85 of file mpi_angular_class_average.h.

◆ fn_out2

FileName MpiProgAngularClassAverage::fn_out2

Definition at line 85 of file mpi_angular_class_average.h.

◆ fn_ref

FileName MpiProgAngularClassAverage::fn_ref

Definition at line 85 of file mpi_angular_class_average.h.

◆ fn_wien

FileName MpiProgAngularClassAverage::fn_wien

Definition at line 85 of file mpi_angular_class_average.h.

◆ global_plans

Polar_fftw_plans MpiProgAngularClassAverage::global_plans

transformers for all rings

Definition at line 128 of file mpi_angular_class_average.h.

◆ Iempty

Image<double> MpiProgAngularClassAverage::Iempty

One empty image with correct dimensions

Definition at line 101 of file mpi_angular_class_average.h.

◆ inFile

FileName MpiProgAngularClassAverage::inFile

Re-alignment of classes Input file

Definition at line 116 of file mpi_angular_class_average.h.

◆ limit0

double MpiProgAngularClassAverage::limit0

Upper and lower absolute and relative selection limits

Definition at line 89 of file mpi_angular_class_average.h.

◆ limitF

double MpiProgAngularClassAverage::limitF

Definition at line 89 of file mpi_angular_class_average.h.

◆ limitRclass

double MpiProgAngularClassAverage::limitRclass

Definition at line 89 of file mpi_angular_class_average.h.

◆ limitRper

double MpiProgAngularClassAverage::limitRper

Definition at line 89 of file mpi_angular_class_average.h.

◆ lockArray

MultidimArray<bool> MpiProgAngularClassAverage::lockArray

Definition at line 143 of file mpi_angular_class_average.h.

◆ master_seed

unsigned int MpiProgAngularClassAverage::master_seed

Definition at line 75 of file mpi_angular_class_average.h.

◆ max_psi_change

double MpiProgAngularClassAverage::max_psi_change

Definition at line 126 of file mpi_angular_class_average.h.

◆ max_shift

double MpiProgAngularClassAverage::max_shift

Search shift (shifts larger than this will be set to 0)

Definition at line 124 of file mpi_angular_class_average.h.

◆ max_shift_change

double MpiProgAngularClassAverage::max_shift_change

Maximum allowed shift in last iteration (shifts larger than this will be set to 0)

Definition at line 126 of file mpi_angular_class_average.h.

◆ mdJobList

MetaDataDb MpiProgAngularClassAverage::mdJobList

Definition at line 78 of file mpi_angular_class_average.h.

◆ mpi_job_size

size_t MpiProgAngularClassAverage::mpi_job_size

Divide the job in this number block with this number of images

Definition at line 140 of file mpi_angular_class_average.h.

◆ Mwien

MultidimArray<double> MpiProgAngularClassAverage::Mwien

Wiener filter image

Definition at line 109 of file mpi_angular_class_average.h.

◆ Ndim

size_t MpiProgAngularClassAverage::Ndim

Definition at line 137 of file mpi_angular_class_average.h.

◆ nr_iter

int MpiProgAngularClassAverage::nr_iter

Number of iterations

Definition at line 120 of file mpi_angular_class_average.h.

◆ pad

double MpiProgAngularClassAverage::pad

Padding factor

Definition at line 99 of file mpi_angular_class_average.h.

◆ paddim

size_t MpiProgAngularClassAverage::paddim

Image dimensions before and after padding (only for Wiener correction)

Definition at line 97 of file mpi_angular_class_average.h.

◆ ref3dNum

int MpiProgAngularClassAverage::ref3dNum

Number of 3D references

Definition at line 135 of file mpi_angular_class_average.h.

◆ refGroup

FileName MpiProgAngularClassAverage::refGroup

Definition at line 116 of file mpi_angular_class_average.h.

◆ Ri

int MpiProgAngularClassAverage::Ri

Inner and outer radius for rotational alignment

Definition at line 118 of file mpi_angular_class_average.h.

◆ Ro

int MpiProgAngularClassAverage::Ro

Definition at line 118 of file mpi_angular_class_average.h.

◆ rotAux

RotationalCorrelationAux MpiProgAngularClassAverage::rotAux

Definition at line 129 of file mpi_angular_class_average.h.

◆ SFclasses

MetaDataDb MpiProgAngularClassAverage::SFclasses

Selfiles containing all class averages

Definition at line 111 of file mpi_angular_class_average.h.

◆ SFclasses1

MetaDataDb MpiProgAngularClassAverage::SFclasses1

Definition at line 111 of file mpi_angular_class_average.h.

◆ SFclasses2

MetaDataDb MpiProgAngularClassAverage::SFclasses2

Definition at line 111 of file mpi_angular_class_average.h.

◆ weightArray

MultidimArray<double> MpiProgAngularClassAverage::weightArray

Definition at line 144 of file mpi_angular_class_average.h.

◆ weightArrays1

MultidimArray<double> MpiProgAngularClassAverage::weightArrays1

Definition at line 145 of file mpi_angular_class_average.h.

◆ weightArrays2

MultidimArray<double> MpiProgAngularClassAverage::weightArrays2

Definition at line 146 of file mpi_angular_class_average.h.

◆ Xdim

size_t MpiProgAngularClassAverage::Xdim

Image dimensions

Definition at line 137 of file mpi_angular_class_average.h.

◆ Ydim

size_t MpiProgAngularClassAverage::Ydim

Definition at line 137 of file mpi_angular_class_average.h.

◆ Zdim

size_t MpiProgAngularClassAverage::Zdim

Definition at line 137 of file mpi_angular_class_average.h.


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