Xmipp  v3.23.11-Nereus
Macros | Functions
project.cpp File Reference
#include "project.h"
#include "directions.h"
#include "project_real_shears.h"
#include <data/fourier_projection.h>
#include "core/xmipp_image_generic.h"
#include "core/metadata_sql.h"
#include <core/args.h>
Include dependency graph for project.cpp:

Go to the source code of this file.

Macros

#define Nrot   prm.rot_range.samples
 
#define Ntilt   prm.tilt_range.samples
 
#define Npsi   prm.psi_range.samples
 
#define proj_number(base, irot, itilt, ipsi)   base+irot*Ntilt*Npsi+itilt*Npsi+ipsi
 

Functions

int translate_randomness (char *str)
 
void generate_angles (int ExtProjs, const Angle_range &range, MetaDataVec &DF, char ang_name, const ParametersProjection &prm)
 
void generate_even_angles (int ExtProjs, int Nrottilt, MetaDataVec &DF, const ParametersProjection &prm)
 
int count_even_angles (const ParametersProjection &prm)
 
int Assign_angles (MetaDataVec &DF, const ParametersProjection &prm, const FileName &fn_sym)
 
int PROJECT_Effectively_project (const FileName &fnOut, bool singleProjection, projectionType projType, double sampling_rate, const ParametersProjection &prm, PROJECT_Side_Info &side, const Crystal_Projection_Parameters &prm_crystal, Projection &proj, MetaData &SF)
 
int ROUT_project (ProgProject &prm, Projection &proj, MetaData &SF)
 

Macro Definition Documentation

◆ Npsi

#define Npsi   prm.psi_range.samples

Definition at line 558 of file project.cpp.

◆ Nrot

#define Nrot   prm.rot_range.samples

Definition at line 556 of file project.cpp.

◆ Ntilt

#define Ntilt   prm.tilt_range.samples

Definition at line 557 of file project.cpp.

◆ proj_number

#define proj_number (   base,
  irot,
  itilt,
  ipsi 
)    base+irot*Ntilt*Npsi+itilt*Npsi+ipsi

Definition at line 559 of file project.cpp.

Function Documentation

◆ Assign_angles()

int Assign_angles ( MetaDataVec DF,
const ParametersProjection prm,
const FileName fn_sym 
)

Definition at line 801 of file project.cpp.

803 {
804  int ExtProjs = 0, IntProjs = 0; // External and internal projections
805  int Nrottilt=0; // Number of evenly distributed
806 
807  // External generation mode
808  if (prm.fn_angle != "NULL")
809  {
810  DF.read(prm.fn_angle);
811  ExtProjs = DF.size();
812  }
813 
814  // Internal generation mode
815  if (prm.enable_angle_range)
816  {
818  if (prm.rot_range.randomness != ANGLE_EVENLY)
819  IntProjs = Nrot * Ntilt * Npsi;
820  else
821  {
822  if (fn_sym == "")
823  {
824  Nrottilt = count_even_angles(prm);
825  IntProjs = Nrottilt * Npsi;
826  }
827  else
828  IntProjs = 0;
829  }
830  if (prm.rot_range.randomness != ANGLE_EVENLY)
831  {
832  generate_angles(ExtProjs, prm.rot_range, DF, 'r', prm);
833  generate_angles(ExtProjs, prm.tilt_range, DF, 't', prm);
834  generate_angles(ExtProjs, prm.psi_range, DF, 'p', prm);
836  }
837  else
838  {
839  if (fn_sym == "")
840  generate_even_angles(ExtProjs, Nrottilt, DF, prm);
841  else
842  {
843  SymList SL;
844  if (fn_sym != "")
845  SL.readSymmetryFile(fn_sym);
846  std::vector<double> rotList, tiltList;
847  double rot_step_at_equator = (prm.rot_range.angF - prm.rot_range.ang0) /
848  (double)(Nrot - 1);
849  make_even_distribution(rotList, tiltList, rot_step_at_equator, SL, true);
850  size_t NN=rotList.size();
851  for (size_t n=0; n<NN; ++n)
852  {
853  if (tiltList[n]>=prm.tilt_range.ang0 && tiltList[n]<=prm.tilt_range.angF &&
854  rotList[n]>=prm.rot_range.ang0 && rotList[n]<=prm.rot_range.angF)
855  {
856  size_t DFid=DF.addObject();
857  DF.setValue(MDL_ANGLE_ROT,rotList[n],DFid);
858  DF.setValue(MDL_ANGLE_TILT,tiltList[n],DFid);
859  DF.setValue(MDL_ANGLE_PSI,0.0,DFid);
860  }
861  }
862  }
863  }
864  }
865 
866  // Exit
867  return ExtProjs + IntProjs;
868 }
bool enable_angle_range
Enable angle range mode (0 or 1)
Definition: project.h:169
Rotation angle of an image (double,degrees)
#define Npsi
Definition: project.cpp:558
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
Angle_range psi_range
Psi angle range.
Definition: project.h:175
void make_even_distribution(std::vector< double > &rotList, std::vector< double > &tiltList, double sampling, SymList &SL, bool include_mirror)
Make even distribution, taking symmetry into account.
Definition: directions.cpp:133
Angle_range tilt_range
Tilting angle range.
Definition: project.h:173
bool removeLabel(const MDLabel label) override
Tilting angle of an image (double,degrees)
int readSymmetryFile(FileName fn_sym, double accuracy=SYM_ACCURACY)
Definition: symmetries.cpp:33
void generate_even_angles(int ExtProjs, int Nrottilt, MetaDataVec &DF, const ParametersProjection &prm)
Definition: project.cpp:706
Special label to be used when gathering MDs in MpiMetadataPrograms.
size_t size() const override
FileName fn_angle
Document filename.
Definition: project.h:185
bool setValue(const MDObject &mdValueIn, size_t id)
size_t addObject() override
Angle_range rot_range
Rotational angle range.
Definition: project.h:171
double angF
final angular value
Definition: project.h:129
#define Ntilt
Definition: project.cpp:557
double ang0
initial angular value
Definition: project.h:127
int count_even_angles(const ParametersProjection &prm)
Definition: project.cpp:775
void generate_angles(int ExtProjs, const Angle_range &range, MetaDataVec &DF, char ang_name, const ParametersProjection &prm)
Definition: project.cpp:560
int randomness
Definition: project.h:141
#define ANGLE_EVENLY
Definition: project.h:136
unsigned int randomize_random_generator()
int * n
#define Nrot
Definition: project.cpp:556

◆ count_even_angles()

int count_even_angles ( const ParametersProjection prm)

Definition at line 775 of file project.cpp.

776 {
777  int N = 0;
778  int limit = prm.tilt_range.samples;
779  double rot_step_at_equator = (prm.rot_range.angF - prm.rot_range.ang0) /
780  (double)(Nrot - 1);
781  for (int i = 0; i < limit; i++)
782  {
783  double tilt = prm.tilt_range.ang0 +
784  (prm.tilt_range.angF - prm.tilt_range.ang0) /
785  (double)(Ntilt - 1) * i;
786  double rot_step;
787  if (tilt != 0 && tilt != 180)
788  rot_step = rot_step_at_equator / sin(DEG2RAD(tilt));
789  else
790  rot_step = prm.rot_range.angF - prm.rot_range.ang0 + 1;
791  int iterRot = static_cast<int>((prm.rot_range.angF - prm.rot_range.ang0) / rot_step);
792  N+=iterRot+1;
793  }
794  N++; // This shouldn't be necessary but some GCC optimization
795  // sometimes doesn't do well its work. For instance if we
796  // add std::cout << N after N++ in the loop, then it works perfectly
797  return N;
798 }
#define DEG2RAD(d)
Definition: xmipp_macros.h:312
Angle_range tilt_range
Tilting angle range.
Definition: project.h:173
int samples
No. of samples.
Definition: project.h:131
#define i
Angle_range rot_range
Rotational angle range.
Definition: project.h:171
double angF
final angular value
Definition: project.h:129
#define Ntilt
Definition: project.cpp:557
double ang0
initial angular value
Definition: project.h:127
#define Nrot
Definition: project.cpp:556

◆ generate_angles()

void generate_angles ( int  ExtProjs,
const Angle_range range,
MetaDataVec DF,
char  ang_name,
const ParametersProjection prm 
)

Definition at line 560 of file project.cpp.

562 {
563  double ang;
564  int N1=0, N2=0;
565  int i, j, k;
566  size_t iproj, idx=0;
567  int limit=0;
568  MetaDataVec DFaux=DF;
569 
570  // Select loop limit ....................................................
571  switch (range.randomness)
572  {
574  limit = range.samples;
575  break;
577  limit = range.samples;
578  break;
579  case ANGLE_RANGE_RANDOM :
580  limit = Nrot * Ntilt * Npsi;
581  break;
582  }
583 
584  // Which column to write in the document file ...........................
585  switch (ang_name)
586  {
587  case 'r':
588  idx = 0;
589  break;
590  case 't':
591  idx = 1;
592  break;
593  case 'p':
594  idx = 2;
595  break;
596  }
597 
598  double unif_min = cos(DEG2RAD(range.angF));
599  double unif_max = cos(DEG2RAD(range.ang0));
600  for (i = 0; i < limit; i++)
601  {
602  // Select angle .....................................................
604  {
605  if (range.samples > 1)
606  ang = range.ang0 +
607  (range.angF - range.ang0) / (double)(range.samples - 1) * i;
608  else
609  ang = range.ang0;
610  }
611  else
612  {
613  switch (ang_name)
614  {
615  case 'r':
616  case 'p':
617  ang = rnd_unif(range.ang0, range.angF);
618  break;
619  case 't':
620  ang = RAD2DEG(acos(rnd_unif(unif_min, unif_max)));
621  break;
622  }
623  }
624 
625  // Copy this angle to those projections belonging to this group .....
626  // If there is any group
627  if (range.randomness != ANGLE_RANGE_RANDOM)
628  {
629  switch (ang_name)
630  {
631  case 'r':
632  N1 = Ntilt;
633  N2 = Npsi;
634  break;
635  case 't':
636  N1 = Nrot;
637  N2 = Npsi;
638  break;
639  case 'p':
640  N1 = Nrot;
641  N2 = Ntilt;
642  break;
643  }
644  for (j = 0; j < N1; j++)
645  for (k = 0; k < N2; k++)
646  {
647  switch (ang_name)
648  {
649  case 'r':
650  iproj = proj_number(ExtProjs, i, j, k);
651  break;
652  case 't':
653  iproj = proj_number(ExtProjs, j, i, k);
654  break;
655  case 'p':
656  iproj = proj_number(ExtProjs, j, k, i);
657  break;
658  }
659  size_t idx_tmp=DFaux.firstObject(MDValueEQ(MDL_ORDER,iproj));
660  if (idx_tmp==BAD_OBJID)
661  {
662  idx_tmp=DFaux.addObject();
663  DFaux.setValue(MDL_ORDER,iproj,idx_tmp);
664  }
665  switch (idx)
666  {
667  case 0:
668  DFaux.setValue(MDL_ANGLE_ROT,ang,idx_tmp);
669  break;
670  case 1:
671  DFaux.setValue(MDL_ANGLE_TILT,ang,idx_tmp);
672  break;
673  case 2:
674  DFaux.setValue(MDL_ANGLE_PSI,ang,idx_tmp);
675  break;
676  }
677  }
678  }
679  else
680  {
681  size_t iproj=ExtProjs + i;
682  size_t dfidx=DFaux.firstObject(MDValueEQ(MDL_ORDER,iproj));
683  if (dfidx==BAD_OBJID)
684  {
685  dfidx=DFaux.addObject();
686  DFaux.setValue(MDL_ORDER,iproj,dfidx);
687  }
688  switch (idx)
689  {
690  case 0:
691  DFaux.setValue(MDL_ANGLE_ROT,ang,dfidx);
692  break;
693  case 1:
694  DFaux.setValue(MDL_ANGLE_TILT,ang,dfidx);
695  break;
696  case 2:
697  DFaux.setValue(MDL_ANGLE_PSI,ang,dfidx);
698  break;
699  }
700  }
701  }
702  DF.sort(DFaux,MDL_ORDER);
703 }
Rotation angle of an image (double,degrees)
#define Npsi
Definition: project.cpp:558
void sort(const MetaDataVec &MDin, const MDLabel sortLabel, bool asc=true, int limit=-1, int offset=0)
#define DEG2RAD(d)
Definition: xmipp_macros.h:312
#define ANGLE_RANGE_RANDOM
Definition: project.h:135
Tilting angle of an image (double,degrees)
int samples
No. of samples.
Definition: project.h:131
Special label to be used when gathering MDs in MpiMetadataPrograms.
size_t firstObject(const MDQuery &) const override
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
double rnd_unif()
bool setValue(const MDObject &mdValueIn, size_t id)
size_t addObject() override
double angF
final angular value
Definition: project.h:129
#define Ntilt
Definition: project.cpp:557
#define j
double ang0
initial angular value
Definition: project.h:127
#define proj_number(base, irot, itilt, ipsi)
Definition: project.cpp:559
#define ANGLE_RANGE_DETERMINISTIC
Definition: project.h:133
int randomness
Definition: project.h:141
#define RAD2DEG(r)
Definition: xmipp_macros.h:320
#define ANGLE_RANGE_RANDOM_GROUPS
Definition: project.h:134
#define Nrot
Definition: project.cpp:556
#define BAD_OBJID
Definition: metadata_base.h:55

◆ generate_even_angles()

void generate_even_angles ( int  ExtProjs,
int  Nrottilt,
MetaDataVec DF,
const ParametersProjection prm 
)

Definition at line 706 of file project.cpp.

708 {
709  // We will run over the tilt angle in a deterministic way
710  // then for every tilt angle, a rot_step is computed so that
711  // it keeps the same distance in the circle generated by tilt
712  // as the sample distance at the equator (tilt=90).
713  MetaDataVec DFaux;
714  int N = 0;
715  int limit = prm.tilt_range.samples;
716  double rot_step_at_equator = (prm.rot_range.angF - prm.rot_range.ang0) /
717  (double)(Nrot - 1);
718  for (int i = 0; i < limit; i++)
719  {
720  // Compute the corresponding deterministic tilt
721  double tilt = prm.tilt_range.ang0 +
722  (prm.tilt_range.angF - prm.tilt_range.ang0) /
723  (double)(Ntilt - 1) * i;
724  // Now compute the corresponding rotational angles
725  double rot_step;
726  if (tilt != 0 && tilt != 180)
727  rot_step = rot_step_at_equator / sin(DEG2RAD(tilt));
728  else
729  rot_step = prm.rot_range.angF - prm.rot_range.ang0 + 1;
730  int iterRot = static_cast<int>((prm.rot_range.angF - prm.rot_range.ang0) / rot_step);
731  for (int irot = 0; irot <= iterRot; irot ++)
732  {
733  double rot = prm.rot_range.ang0+irot*rot_step;
734  // Copy this angle to those projections belonging to this group .....
735  // If there is any group
736  for (int k = 0; k < Npsi; k++)
737  {
738  // Select psi
739  double psi;
741  {
742  if (prm.psi_range.samples > 1)
743  {
744  psi = prm.psi_range.ang0 +
745  (prm.psi_range.angF - prm.psi_range.ang0) /
746  (double)(prm.psi_range.samples - 1) * k;
747  }
748  else
749  psi = prm.psi_range.ang0;
750  }
751  else
752  psi = prm.psi_range.ang0 +
753  (prm.psi_range.angF - prm.psi_range.ang0) /
754  (double)(Npsi - 1) * k;
755 
756  size_t iproj = ExtProjs + N + Nrottilt * k;
757  size_t idx_tmp=DFaux.firstObject(MDValueEQ(MDL_ORDER,iproj));
758  if (idx_tmp==BAD_OBJID)
759  {
760  idx_tmp=DFaux.addObject();
761  DFaux.setValue(MDL_ORDER,iproj,idx_tmp);
762  }
763  DFaux.setValue(MDL_ANGLE_ROT,rot,idx_tmp);
764  DFaux.setValue(MDL_ANGLE_TILT,tilt,idx_tmp);
765  DFaux.setValue(MDL_ANGLE_PSI,psi,idx_tmp);
766  }
767  N++;
768  }
769  }
770  DF.sort(DFaux,MDL_ORDER);
772 }
Rotation angle of an image (double,degrees)
#define Npsi
Definition: project.cpp:558
void sort(const MetaDataVec &MDin, const MDLabel sortLabel, bool asc=true, int limit=-1, int offset=0)
Angle_range psi_range
Psi angle range.
Definition: project.h:175
#define DEG2RAD(d)
Definition: xmipp_macros.h:312
Angle_range tilt_range
Tilting angle range.
Definition: project.h:173
bool removeLabel(const MDLabel label) override
Tilting angle of an image (double,degrees)
int samples
No. of samples.
Definition: project.h:131
Special label to be used when gathering MDs in MpiMetadataPrograms.
size_t firstObject(const MDQuery &) const override
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
bool setValue(const MDObject &mdValueIn, size_t id)
size_t addObject() override
Angle_range rot_range
Rotational angle range.
Definition: project.h:171
double angF
final angular value
Definition: project.h:129
#define Ntilt
Definition: project.cpp:557
double ang0
initial angular value
Definition: project.h:127
#define ANGLE_RANGE_DETERMINISTIC
Definition: project.h:133
int randomness
Definition: project.h:141
double psi(const double x)
#define Nrot
Definition: project.cpp:556
#define BAD_OBJID
Definition: metadata_base.h:55

◆ PROJECT_Effectively_project()

int PROJECT_Effectively_project ( const FileName fnOut,
bool  singleProjection,
projectionType  projType,
double  sampling_rate,
const ParametersProjection prm,
PROJECT_Side_Info side,
const Crystal_Projection_Parameters prm_crystal,
Projection proj,
MetaData SF 
)

1 .5 NEAREST

Definition at line 939 of file project.cpp.

947 {
948  int NumProjs = 0;
949  SF.clear();
950  if (!fnOut.isInStack())
951  fnOut.deleteFile();
952  std::cerr << "Projecting ...\n";
953  init_progress_bar(side.DF.size());
954  SF.setComment("First set of angles=actual angles; Second set of angles=noisy angles");
955 
956  //#define DEBUG
957 #ifdef DEBUG
958 
959  MetaDataVec mdShifts;
960  MetaDataVec mdRotations;
980 #endif
981 
982  bool existFlip = false;
983  bool hasCTF=false;
984 
985  int projIdx=FIRST_IMAGE;
986  FileName fn_proj; // Projection name
987  RealShearsInfo *Vshears=nullptr;
988  FourierProjector *Vfourier=nullptr;
989  if (projType == SHEARS && side.phantomMode==PROJECT_Side_Info::VOXEL)
990  Vshears=new RealShearsInfo(side.phantomVol());
991  if (projType == FOURIER && side.phantomMode==PROJECT_Side_Info::VOXEL)
992  Vfourier=new FourierProjector(side.phantomVol(),side.paddFactor,side.maxFrequency,side.BSplineDeg);
994  fn_proj=fnOut;
995  if (side.doCrystal)
996  createEmptyFile(fn_proj, prm_crystal.crystal_Xdim, prm_crystal.crystal_Ydim,
997  1, side.DF.size(), true,WRITE_OVERWRITE);
998  else
999  createEmptyFile(fn_proj, prm.proj_Xdim, prm.proj_Ydim,
1000  1, side.DF.size(), true,WRITE_OVERWRITE);
1001 
1002  if (side.DF.containsLabel(MDL_FLIP))
1003  existFlip = true;
1004 
1005 
1006  for (size_t objId : side.DF.ids())
1007  {
1008  size_t DFmov_objId=SF.addObject();
1009  if (!singleProjection)
1010  fn_proj.compose(projIdx,fnOut);
1011  SF.setValue(MDL_IMAGE,fn_proj,DFmov_objId);
1012  SF.setValue(MDL_ENABLED,1,DFmov_objId);
1013 
1014  // Choose angles .....................................................
1015  double rot, tilt, psi, x=0, y=0; // Actual projecting angles
1016  bool flip=false;
1017  side.DF.getValue(MDL_ANGLE_ROT,rot,objId);
1018  side.DF.getValue(MDL_ANGLE_TILT,tilt,objId);
1019  side.DF.getValue(MDL_ANGLE_PSI,psi,objId);
1020 
1021  if (prm.applyShift)
1022  {
1023  if (side.DF.containsLabel(MDL_SHIFT_X))
1024  side.DF.getValue(MDL_SHIFT_X,x,objId);
1025  if (side.DF.containsLabel(MDL_SHIFT_Y))
1026  side.DF.getValue(MDL_SHIFT_Y,y,objId);
1027  }
1028  realWRAP(rot, 0, 360);
1029  realWRAP(tilt, 0, 360);
1030  realWRAP(psi, 0, 360);
1031 
1032  if (existFlip)
1033  side.DF.getValue(MDL_FLIP,flip,objId);
1034 
1035 
1036  SF.setValue(MDL_ANGLE_ROT,rot,DFmov_objId);
1037  SF.setValue(MDL_ANGLE_TILT,tilt,DFmov_objId);
1038  SF.setValue(MDL_ANGLE_PSI,psi,DFmov_objId);
1039 
1040  if ((NumProjs % XMIPP_MAX(1, side.DF.size() / 60)) == 0)
1041  progress_bar(NumProjs);
1042 
1043  // Choose Center displacement ........................................
1044  double shiftX = rnd_gaus(prm.Ncenter_avg, prm.Ncenter_dev)+x;
1045  double shiftY = rnd_gaus(prm.Ncenter_avg, prm.Ncenter_dev)+y;
1046  SF.setValue(MDL_SHIFT_X,shiftX,DFmov_objId);
1047  SF.setValue(MDL_SHIFT_Y,shiftY,DFmov_objId);
1048  //ROB: totally anoying behaviour in xmipp
1049  shiftX=-shiftX;
1050  shiftY=-shiftY;
1051 
1052  //If there is CTF information use it
1053  CTFDescription ctf;
1055  {
1056  //JV he tenido que tocar esta funcion para poder acceder al sampling rate
1057  hasCTF = true;
1058  MDRowVec row;
1059  side.DF.getRow(row,objId);
1060  ctf.readFromMdRow(row);
1061  ctf.produceSideInfo();
1062  }
1063 
1064 #ifdef DEBUG
1065 
1066  mdShifts.addObject();
1067  mdShifts.setValue(MDL_IMAGE,fn_proj,DFmov_objId);
1068  mdShifts.setValue(MDL_SHIFT_X,-shiftX,DFmov_objId);
1069  mdShifts.setValue(MDL_SHIFT_Y,-shiftY,DFmov_objId);
1070  mdShifts.setValue(MDL_ENABLED,1,DFmov_objId);
1071 
1072 
1073  mdRotations.addObject();
1074  mdRotations.setValue(MDL_IMAGE,fn_proj,DFmov_objId);
1075  mdRotations.setValue(MDL_ANGLE_ROT,-rot,DFmov_objId);
1076  mdRotations.setValue(MDL_ANGLE_TILT,-tilt,DFmov_objId);
1077  mdRotations.setValue(MDL_ANGLE_PSI,-psi,DFmov_objId);
1078 
1079 
1080 #endif
1081  // Really project ....................................................
1083  {
1084  if (projType == SHEARS)
1085  projectVolume(*Vshears, proj, prm.proj_Ydim, prm.proj_Xdim,
1086  rot, tilt, psi);
1087  else if (projType == FOURIER)
1088  projectVolume(*Vfourier, proj, prm.proj_Ydim, prm.proj_Xdim,
1089  rot, tilt, psi);
1090  else if (projType == REALSPACE)
1091  projectVolume(side.phantomVol(), proj, prm.proj_Ydim, prm.proj_Xdim,
1092  rot, tilt, psi);
1093 
1094  if (hasCTF)
1095  ctf.applyCTF(proj(),sampling_rate, prm.doPhaseFlip);
1096 
1097  hasCTF = false;
1098 
1099  Matrix1D<double> shifts(2);
1100  XX(shifts) = shiftX;
1101  YY(shifts) = shiftY;
1103  }
1104  else if (side.phantomMode==PROJECT_Side_Info::PDB)
1105  {
1106  PDBPhantom aux;
1107  aux=side.phantomPDB;
1108  aux.shift(shiftX,shiftY,0);
1109  projectPDB(side.phantomPDB, side.interpolator,
1110  proj, prm.proj_Ydim, prm.proj_Xdim,
1111  rot, tilt, psi);
1112  }
1113  else if (side.phantomMode==PROJECT_Side_Info::XMIPP)
1114  {
1115  Phantom aux;
1116  aux = side.phantomDescr;
1117  aux.shift(shiftX, shiftY, 0);
1118  if (prm_crystal.crystal_Xdim == 0)
1119  {
1120  // Project a single mathematical volume
1121  aux.project_to(proj,
1122  prm.proj_Ydim, prm.proj_Xdim,
1123  rot, tilt, psi);
1124  }
1125  else
1126  { // Project mathematical volume as a crystal
1127  project_crystal(aux, proj, prm, side, prm_crystal, rot, tilt, psi);
1128  }
1129  }
1130  if (flip)
1131  proj().selfReverseX();
1132 
1133  // Add noise in angles and voxels ....................................
1134  SF.setValue(MDL_ANGLE_ROT2,rot,DFmov_objId);
1135  SF.setValue(MDL_ANGLE_TILT2,tilt,DFmov_objId);
1136  SF.setValue(MDL_ANGLE_PSI2,psi,DFmov_objId);
1137  rot += rnd_gaus(prm.rot_range.Navg, prm.rot_range.Ndev);
1138  tilt += rnd_gaus(prm.tilt_range.Navg, prm.tilt_range.Ndev);
1139  psi += rnd_gaus(prm.psi_range.Navg, prm.psi_range.Ndev);
1140 
1141 
1142  SF.setValue(MDL_ANGLE_ROT,realWRAP(rot, 0, 360),DFmov_objId);
1143  SF.setValue(MDL_ANGLE_TILT,realWRAP(tilt, 0, 360),DFmov_objId);
1144  SF.setValue(MDL_ANGLE_PSI,realWRAP(psi, 0, 360),DFmov_objId);
1145 
1146  IMGMATRIX(proj).addNoise(prm.Npixel_avg, prm.Npixel_dev, "gaussian");
1147 
1148  // Save ..............................................................
1149  if (singleProjection)
1150  proj.write(fn_proj);
1151  else
1152  {
1153  proj.write(fn_proj,projIdx,true,WRITE_OVERWRITE);
1154  }
1155  projIdx++;
1156  NumProjs++;
1157  }
1158  progress_bar(side.DF.size());
1159 
1160 #ifdef DEBUG
1161 
1162  mdShifts.write("shifts.xmd");
1163  mdRotations.write("rotations.xmd");
1164 #endif
1165 #undef DEBUG
1166  // release memory
1167  delete Vshears;
1168  delete Vfourier;
1169 
1170  return NumProjs;
1171 }
void init_progress_bar(long total)
constexpr int FOURIER
Rotation angle of an image (double,degrees)
Defocus U (Angstroms)
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
virtual size_t addObject()=0
Tilting angle of an image (double,degrees)
int proj_Ydim
Projection Ydim.
Definition: project.h:163
void projectPDB(const PDBPhantom &phantomPDB, const AtomInterpolator &interpolator, Projection &proj, int Ydim, int Xdim, double rot, double tilt, double psi)
Definition: pdb.cpp:1603
double Ndev
Stddev of the noise that must be added to the definition of the angle.
Definition: project.h:145
virtual void clear()
Angle_range psi_range
Psi angle range.
Definition: project.h:175
Angle_range tilt_range
Tilting angle range.
Definition: project.h:173
int BSplineDeg
The type of interpolation (NEAR.
Definition: project.h:237
Tilting angle of an image (double,degrees)
static double * y
Phantom phantomDescr
Phantom mathematical description.
Definition: project.h:227
PDBPhantom phantomPDB
Phantom PDB.
Definition: project.h:229
Shift for the image in the X axis (double)
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)
PhantomType phantomMode
Projecting from a voxel volume, Xmipp description or PDB?
Definition: project.h:223
Special label to be used when gathering MDs in MpiMetadataPrograms.
Name for the CTF Model (std::string)
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
int proj_Xdim
Projection Xdim.
Definition: project.h:161
double maxFrequency
The maximum frequency for pixels.
Definition: project.h:235
void shift(double shiftX, double shiftY, double shiftZ)
Definition: phantom.cpp:2479
double Npixel_avg
Bias to be applied to each pixel grey value */.
Definition: project.h:188
virtual IdIteratorProxy< false > ids()
#define IMGMATRIX(I)
std::unique_ptr< MDRow > getRow(size_t id) override
AtomInterpolator interpolator
Atom interpolator.
Definition: project.h:231
Definition: project.h:42
doublereal * x
size_t size() const override
Is this image enabled? (int [-1 or 1])
virtual void setComment(const String &newComment="No comment")
double Ncenter_avg
Bias to apply to the image center.
Definition: project.h:193
Rotation angle of an image (double,degrees)
Image< double > phantomVol
Phantom Xmipp volume.
Definition: project.h:225
#define XX(v)
Definition: matrix1d.h:85
void applyCTF(MultidimArray< std::complex< double > > &FFTI, const MultidimArray< double > &I, double Ts, bool absPhase=false)
Apply CTF to an image.
Definition: ctf.cpp:1521
void selfTranslate(int SplineDegree, MultidimArray< T > &V1, const Matrix1D< double > &v, bool wrap=xmipp_transformation::WRAP, T outside=0)
bool setValue(const MDObject &mdValueIn, size_t id)
double paddFactor
The padding factor for Fourier projection.
Definition: project.h:233
size_t addObject() override
FileName fnOut
Flip the image? (bool)
Angle_range rot_range
Rotational angle range.
Definition: project.h:171
void progress_bar(long rlen)
Structure for holding a volume.
double Ncenter_dev
Standard deviation of the image center.
Definition: project.h:195
void projectVolume(FourierProjector &projector, Projection &P, int Ydim, int Xdim, double rot, double tilt, double psi, const MultidimArray< double > *ctf)
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
Definition: ctf.cpp:1172
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 shift(double x, double y, double z)
Apply a shift to all atoms.
Definition: pdb.cpp:514
int crystal_Xdim
Crystal X dimension.
Psi angle of an image (double,degrees)
void deleteFile() const
#define YY(v)
Definition: matrix1d.h:93
bool getValue(MDObject &mdValueOut, size_t id) const override
bool setValue(const MDLabel label, const T &valueIn, size_t id)
MetaDataVec DF
Document File for the projecting angles. Order: rot, tilt, psi.
Definition: project.h:219
int crystal_Ydim
Crystal Y dimension.
double Navg
Mean of the noise that must be added to the definition of the angle.
Definition: project.h:143
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
double psi(const double x)
double rnd_gaus()
#define realWRAP(x, x0, xF)
Definition: xmipp_macros.h:304
void project_crystal(Phantom &phantom, Projection &P, const ParametersProjection &prm, PROJECT_Side_Info &side, const Crystal_Projection_Parameters &prm_crystal, float rot, float tilt, float psi)
#define FIRST_IMAGE
Shift for the image in the Y axis (double)
bool containsLabel(const MDLabel label) const override
void project_to(Projection &P, int Ydim, int Xdim, double rot, double tilt, double psi, const Matrix2D< double > *A=nullptr) const
Definition: phantom.cpp:2511
Name of an image (std::string)
double Npixel_dev
Standard deviation of the noise to be added to each pixel grey value.
Definition: project.h:190
bool doCrystal
Is this a crystal projection.
Definition: project.h:239
bool isInStack() const

◆ translate_randomness()

int translate_randomness ( char *  str)

Definition at line 189 of file project.cpp.

190 {
191  if (str == nullptr)
193  if (strcmp(str, "random_group") == 0)
195  if (strcmp(str, "random") == 0)
196  return ANGLE_RANGE_RANDOM;
197  if (strcmp(str, "even") == 0)
198  return ANGLE_EVENLY;
200  (String)"Prog_Project_Parameters::read: Not recognized randomness: "
201  + str);
202 }
Parameter incorrect.
Definition: xmipp_error.h:181
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define ANGLE_RANGE_RANDOM
Definition: project.h:135
#define ANGLE_RANGE_DETERMINISTIC
Definition: project.h:133
#define ANGLE_EVENLY
Definition: project.h:136
std::string String
Definition: xmipp_strings.h:34
#define ANGLE_RANGE_RANDOM_GROUPS
Definition: project.h:134