52 if (degree ==
"nearest")
54 else if (degree ==
"linear")
56 else if (degree ==
"bspline")
65 if (doParams && doAngles)
67 else if (!doParams && !doAngles)
93 addUsageLine(
"This program is able to generate a set of projections from a volume. ");
94 addUsageLine(
"++The projection is done using the information directly or from a file.");
97 addParamsLine(
" -i <volume_file> : Voxel volume, PDB or description file");
99 addParamsLine(
" [--sampling_rate <Ts=1>] : It is only used for PDB phantoms");
100 addParamsLine(
" [--high_sampling_rate <highTs=0.08333333>] : Sampling rate before downsampling. It is only used for PDB phantoms");
101 addParamsLine(
" [--method <method=real_space>] : Projection method");
103 addParamsLine(
" real_space : Makes projections by ray tracing in real space");
105 addParamsLine(
" :+This algorithm is slower but more accurate. For a full description see");
106 addParamsLine(
" fourier <pad=2> <maxfreq=0.25> <interp=bspline> : Takes a central slice in Fourier space");
110 addParamsLine(
" : maxfreq: is the maximum frequency for the pixels and by default ");
111 addParamsLine(
" : pixels with frequency more than 0.25 are not considered.");
113 addParamsLine(
" : interp: is the method for interpolation and the values can be: ");
121 addParamsLine(
" [--params <parameters_file>] : File containing projection parameters");
122 addParamsLine(
" : Check the manual for a description of the parameters");
123 addParamsLine(
" : tilt angle should be in the range [0-180]");
124 addParamsLine(
" [--sym <sym_file>] : It is used for computing the asymmetric unit");
125 addParamsLine(
" [--only_create_angles] : Do not create projections");
127 addParamsLine(
" [--angles <rot> <tilt> <psi> <x=0.> <y=0.>]: Angles and shifts for a single projection");
128 addParamsLine(
" [--xdim <size=-1>] : Size of the projection");
129 addParamsLine(
" : For geometric descriptions and voxel volumes");
131 addExampleLine(
"Generating a set of projections using fourier method",
false);
132 addExampleLine(
"xmipp_phantom_project -i volume.vol -o images.stk --method fourier 3 0.25 bspline --params uniformProjection_xmd.param");
133 addExampleLine(
"Generating a set of projections using shears method",
false);
134 addExampleLine(
"xmipp_phantom_project -i volume.vol -o images.stk --method shears --params uniformProjection_xmd.param");
136 addExampleLine(
"xmipp_phantom_project -i volume.vol -o image.xmp --angles 0 0 0");
138 addExampleLine(
"xmipp_phantom_project -i volume.vol -o image.xmp --angles 90 90 0");
140 addExampleLine(
"xmipp_phantom_project -i volume.vol -o image.xmp --angles 0 90 0");
141 addExampleLine(
"+++In the following links you can find some examples of projection parameter files",
false);
143 addExampleLine(
"+++http://sourceforge.net/p/testxmipp/code/ci/master/tree/input/phantomProject.param?format=raw",
false);
145 addExampleLine(
"+++http://sourceforge.net/p/testxmipp/code/ci/master/tree/input/uniformProjection_xmd.param?format=raw",
false);
147 addExampleLine(
"+++http://sourceforge.net/p/testxmipp/code/ci/master/tree/input/clusterProjection_xmd.param?format=raw",
false);
150 addExampleLine(
"+In order to create a 2D crystal, you can pass --params as a projection file with a second block for crystal projection.: ",
false);
151 addExampleLine(
"+xmipp_phantom_project -i cylinder_with_axis.descr --oroot MRCproj --params MRCCrystalProj_xmd.param");
152 addExampleLine(
"+++In the following links you can find some examples of projection parameter files",
false);
154 addExampleLine(
"+++http://sourceforge.net/p/testxmipp/code/ci/master/tree/input/Crystal/MRCCrystalProj_xmd.param?format=raw",
false);
156 addExampleLine(
"+++ http://sourceforge.net/p/testxmipp/code/ci/master/tree/input/Crystal/cylinder_with_axis.descr?format=raw",
false);
158 addExampleLine(
"+++http://sourceforge.net/p/testxmipp/code/ci/master/tree/input/Crystal/MRC_crystal_projection_xmd.param?format=raw",
false);
161 addExampleLine(
"+++Figures (a) and (b) show the achievable resolution for different methods of projection. ",
false);
163 addExampleLine(
"+++<img width='100%' alt='Test_Resolution_Small.jpg' src='%ATTACHURLPATH%/Test_Resolution_Small.jpg' height='100%' />");
165 addExampleLine(
"+++(a) The achievable resolution for different methods for a volume of size 64*64",
false);
167 addExampleLine(
"+++ <img width='100%' alt='Test_Resolution_Big.jpg' src='%ATTACHURLPATH%/Test_Resolution_Big.jpg' height='100%' />");
169 addExampleLine(
"+++(b) The achievable resolution for different methods for a volume of size 400*400",
false);
171 addExampleLine(
"+++As it can be seen in these two figures, Fourier method with cubic B-Spline interpolation for both padding two and padding one provides the best resolution. However, there is a preference on padding one because of less memory and time complexity.",
false);
193 if (strcmp(str,
"random_group") == 0)
195 if (strcmp(str,
"random") == 0)
197 if (strcmp(str,
"even") == 0)
200 (
String)
"Prog_Project_Parameters::read: Not recognized randomness: " 226 MD.
read(fn_proj_param);
234 (
String)
"Prog_Project_Parameters::read: There is a problem " 237 std::vector <double> ParamVec;
245 proj_Xdim = (int)ParamVec[0];
246 proj_Ydim = (int)ParamVec[1];
249 else if (fn_angle !=
"NULL")
250 if (!fn_angle.exists())
252 "file " + fn_angle +
" doesn't exist");
256 doPhaseFlip = !doPhaseFlip;
258 doCTFCorrection = !doCTFCorrection;
264 enable_angle_range =
true;
265 rot_range.ang0 = ParamVec[0];
266 if (ParamVec.size() == 1)
268 rot_range.angF = rot_range.ang0;
269 rot_range.samples = 1;
273 rot_range.angF = ParamVec[1];
274 rot_range.samples = (int)ParamVec[2];
275 if (rot_range.ang0 == rot_range.angF)
276 rot_range.samples = 1;
282 RandChar =
new char[RandStr.length() + 1];
283 strcpy(RandChar, RandStr.c_str());
287 tilt_range.ang0 = ParamVec[0];
288 if (ParamVec.size() == 1)
290 tilt_range.angF = tilt_range.ang0;
291 tilt_range.samples = 1;
295 tilt_range.angF = ParamVec[1];
296 tilt_range.samples = (int)ParamVec[2];
297 if (tilt_range.ang0 == tilt_range.angF)
298 tilt_range.samples = 1;
304 RandChar =
new char[RandStr.length() + 1];
305 strcpy(RandChar, RandStr.c_str());
309 psi_range.ang0 = ParamVec[0];
310 if (ParamVec.size() == 1)
312 psi_range.angF = psi_range.ang0;
313 psi_range.samples = 1;
317 psi_range.angF = ParamVec[1];
318 psi_range.samples = (int)ParamVec[2];
319 if (psi_range.ang0 == psi_range.angF)
320 psi_range.samples = 1;
326 RandChar =
new char[RandStr.length() + 1];
327 strcpy(RandChar, RandStr.c_str());
332 enable_angle_range =
false;
336 rot_range.Ndev = ParamVec[0];
337 if (ParamVec.size()<2)
340 rot_range.Navg = ParamVec[1];
343 rot_range.Ndev = rot_range.Navg =0.;
347 tilt_range.Ndev = ParamVec[0];
348 if (ParamVec.size()<2)
351 tilt_range.Navg = ParamVec[1];
354 tilt_range.Ndev = tilt_range.Navg =0.;
358 psi_range.Ndev = ParamVec[0];
359 if (ParamVec.size()<2)
362 psi_range.Navg = ParamVec[1];
365 psi_range.Ndev = psi_range.Navg =0.;
369 Npixel_dev = ParamVec[0];
370 if (ParamVec.size() < 2)
373 Npixel_avg = ParamVec[1];
376 Npixel_dev = Npixel_avg =0.;
380 Ncenter_dev = ParamVec[0];
381 if (ParamVec.size() < 2)
384 Ncenter_avg = ParamVec[1];
387 Ncenter_dev = Ncenter_avg =0.;
399 (
String)
"Prog_Project_Parameters::read: There is a problem " 401 while (fgets(line, 200, fh_param) != NULL)
419 if (fn_angle ==
"NULL")
421 else if (!fn_angle.exists())
423 "file " + fn_angle +
" doesn't exist");
429 if (strcmp(auxstr,
"NULL") != 0)
431 enable_angle_range =
true;
434 if (auxstr ==
nullptr)
438 rot_range.angF = rot_range.ang0;
439 rot_range.samples = 1;
445 if (rot_range.ang0 == rot_range.angF)
446 rot_range.samples = 1;
453 enable_angle_range =
false;
460 if (auxstr ==
nullptr)
464 tilt_range.angF = tilt_range.ang0;
465 tilt_range.samples = 1;
471 if (tilt_range.ang0 == tilt_range.angF)
472 tilt_range.samples = 1;
480 if (auxstr ==
nullptr)
484 psi_range.angF = psi_range.ang0;
485 psi_range.samples = 1;
491 if (psi_range.ang0 == psi_range.angF)
492 psi_range.samples = 1;
500 if (auxstr !=
nullptr)
509 if (auxstr !=
nullptr)
518 if (auxstr !=
nullptr)
527 if (auxstr !=
nullptr)
536 if (auxstr !=
nullptr)
546 "couldn't read all parameters from file %s, only read %d lines",
fn_proj_param.c_str(), lineNo));
556 #define Nrot prm.rot_range.samples 557 #define Ntilt prm.tilt_range.samples 558 #define Npsi prm.psi_range.samples 559 #define proj_number(base,irot,itilt,ipsi) base+irot*Ntilt*Npsi+itilt*Npsi+ipsi 600 for (i = 0; i < limit; i++)
644 for (j = 0; j < N1; j++)
645 for (k = 0; k < N2; k++)
681 size_t iproj=ExtProjs +
i;
718 for (
int i = 0;
i < limit;
i++)
726 if (tilt != 0 && tilt != 180)
727 rot_step = rot_step_at_equator / sin(
DEG2RAD(tilt));
731 for (
int irot = 0; irot <= iterRot; irot ++)
754 (
double)(Npsi - 1) *
k;
756 size_t iproj = ExtProjs + N + Nrottilt *
k;
781 for (
int i = 0;
i < limit;
i++)
787 if (tilt != 0 && tilt != 180)
788 rot_step = rot_step_at_equator / sin(
DEG2RAD(tilt));
804 int ExtProjs = 0, IntProjs = 0;
811 ExtProjs = DF.
size();
825 IntProjs = Nrottilt *
Npsi;
846 std::vector<double> rotList, tiltList;
850 size_t NN=rotList.size();
851 for (
size_t n=0;
n<NN; ++
n)
867 return ExtProjs + IntProjs;
879 size_t DFid=DF.addObject();
903 for (
int i=0;
i<phantomPDB.atomList.size();
i++)
923 phantomVol().setXmippOrigin();
942 double sampling_rate,
952 std::cerr <<
"Projecting ...\n";
954 SF.
setComment(
"First set of angles=actual angles; Second set of angles=noisy angles");
982 bool existFlip =
false;
1006 for (
size_t objId : side.
DF.
ids())
1009 if (!singleProjection)
1010 fn_proj.compose(projIdx,fnOut);
1015 double rot, tilt,
psi,
x=0,
y=0;
1100 XX(shifts) = shiftX;
1101 YY(shifts) = shiftY;
1108 aux.
shift(shiftX,shiftY,0);
1117 aux.
shift(shiftX, shiftY, 0);
1131 proj().selfReverseX();
1149 if (singleProjection)
1150 proj.
write(fn_proj);
1162 mdShifts.
write(
"shifts.xmd");
1163 mdRotations.
write(
"rotations.xmd");
1204 for (
size_t objId : crystal_proj_prm.
DF_shift.
ids())
1206 double xcell, ycell;
1243 proj_prm, side, crystal_proj_prm, proj, SF);
1248 stackName = prm.
fnOut;
1253 proj_prm, side, crystal_proj_prm, proj, SF);
1254 SF.
setComment(
"Angles rot,tilt and psi contain noisy projection angles and rot2,tilt2 and psi2 contain actual projection angles");
void init_progress_bar(long total)
double highTs
High sampling rate: Only used for PDB projections.
Errors on command line parameters.
void produce_Side_Info(ParametersProjection &prm, ProgProject &prog_prm)
bool enable_angle_range
Enable angle range mode (0 or 1)
char * firstWord(char *str)
int ROUT_project(ProgProject &prm, Projection &proj, MetaData &SF)
void read(const FileName &fn_crystal, double scale=1.0)
projectionType projType
Type of projection algorithm.
double getDoubleParam(const char *param, int arg=0)
virtual void read(int argc, const char **argv, bool reportErrors=true)
double paddFactor
The padding factor for Fourier projection.
int proj_Ydim
Projection Ydim.
void projectPDB(const PDBPhantom &phantomPDB, const AtomInterpolator &interpolator, Projection &proj, int Ydim, int Xdim, double rot, double tilt, double psi)
double Ndev
Stddev of the noise that must be added to the definition of the angle.
#define REPORT_ERROR(nerr, ErrormMsg)
Angle_range psi_range
Psi angle range.
bool singleProjection
Single projection.
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.
Angle_range tilt_range
Tilting angle range.
#define ANGLE_RANGE_RANDOM
int BSplineDeg
The type of interpolation (NEAR.
int Assign_angles(MetaDataVec &DF, const ParametersProjection &prm, const FileName &fn_sym)
Phantom phantomDescr
Phantom mathematical description.
PDBPhantom phantomPDB
Phantom PDB.
int samples
No. of samples.
int readSymmetryFile(FileName fn_sym, double accuracy=SYM_ACCURACY)
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?
void generate_even_angles(int ExtProjs, int Nrottilt, MetaDataVec &DF, const ParametersProjection &prm)
void from_prog_params(const ProgProject &prog_prm)
int proj_Xdim
Projection Xdim.
double maxFrequency
The maximum frequency for pixels.
FileName removeAllExtensions() const
void shift(double shiftX, double shiftY, double shiftZ)
double Npixel_avg
Bias to be applied to each pixel grey value */.
projectionType
Type of projection.
double maxFrequency
The maximum frequency for Fourier projection.
int translate_randomness(char *str)
AtomInterpolator interpolator
Atom interpolator.
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
FileName fnOut
Output filename (used for a singleProjection or a stack)
void addSeeAlsoLine(const char *seeAlso)
bool DF_shift_bool
is doc file with shifts available
double tiltSingle
Tilt angle of a single projection.
double Ncenter_avg
Bias to apply to the image center.
MetaDataVec DF_shift
Document File for shifts. Order: H K x_SHIFT y_SHIFT z_SHIFT.
String getExtension() const
FileName fn_proj_param
Filename with the Projection_Parameters.
Image< double > phantomVol
Phantom Xmipp volume.
FileName fn_angle
Document filename.
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)
const char * getParam(const char *param, int arg=0)
double rotSingle
Rotational angle of a single projection.
void applyCTF(MultidimArray< std::complex< double > > &FFTI, const MultidimArray< double > &I, double Ts, bool absPhase=false)
Apply CTF to an image.
double paddFactor
The padding factor for Fourier projection.
float textToFloat(const char *str)
double psiSingle
Psi angle of a single projection.
Angle_range rot_range
Rotational angle range.
void progress_bar(long rlen)
FileName fn_sym
Symmetry file.
void read(const FileName &fn_proj_param)
Structure for holding a volume.
double angF
final angular value
double Ncenter_dev
Standard deviation of the image center.
void addExampleLine(const char *example, bool verbatim=true)
File or directory does not exist.
void projectVolume(FourierProjector &projector, Projection &P, int Ydim, int Xdim, double rot, double tilt, double psi, const MultidimArray< double > *ctf)
bool only_create_angles
Only create angles, do not project.
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
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.
#define STR_EQUAL(str1, str2)
int crystal_Xdim
Crystal X dimension.
int BSplineDeg
The type of interpolation (NEAR.
double ang0
initial angular value
#define proj_number(base, irot, itilt, ipsi)
#define ANGLE_RANGE_DETERMINISTIC
int count_even_angles(const ParametersProjection &prm)
MetaDataVec DF
Document File for the projecting angles. Order: rot, tilt, psi.
int crystal_Ydim
Crystal Y dimension.
bool isMetaData(bool failIfNotExists=true) const
void generate_angles(int ExtProjs, const Angle_range &range, MetaDataVec &DF, char ang_name, const ParametersProjection &prm)
double Navg
Mean of the noise that must be added to the definition of the angle.
void produceSideInfo()
Produce Side information.
double psi(const double x)
FileName fn_shift
file with shifts
String formatString(const char *format,...)
int textToInteger(const char *str)
#define realWRAP(x, x0, xF)
char * firstToken(const char *str)
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)
bool checkParam(const char *param)
void addUsageLine(const char *line, bool verbatim=false)
unsigned int randomize_random_generator()
bool hasStackExtension() const
void project_to(Projection &P, int Ydim, int Xdim, double rot, double tilt, double psi, const Matrix2D< double > *A=nullptr) const
double samplingRate
Sampling rate: Only used for PDB projections.
int getIntParam(const char *param, int arg=0)
String nextToken(const String &str, size_t &i)
int projSize
Projection size when fnOut is given.
#define ANGLE_RANGE_RANDOM_GROUPS
double Npixel_dev
Standard deviation of the noise to be added to each pixel grey value.
bool doCrystal
Is this a crystal projection.
void addParamsLine(const String &line)