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

#include <project_crystal.h>

Collaboration diagram for Crystal_Projection_Parameters:
Collaboration graph
[legend]

Public Member Functions

 Crystal_Projection_Parameters ()
 
void read (const FileName &fn_crystal, double scale=1.0)
 
void write (const FileName &fn_crystal)
 

Public Attributes

int crystal_Xdim
 Crystal X dimension. More...
 
int crystal_Ydim
 Crystal Y dimension. More...
 
bool orthogonal
 Orthogonalize projections. More...
 
Matrix1D< double > a
 Crystal vector a. More...
 
Matrix1D< double > b
 Crustal vector b. More...
 
double Nshift_avg
 Bias to apply to the magnitude shift. More...
 
double Nshift_dev
 Standard deviation of the magnitude shift. More...
 
double disappearing_th
 Disappearing threshold. More...
 
FileName fn_shift
 file with shifts More...
 
MetaDataVec DF_shift
 Document File for shifts. Order: H K x_SHIFT y_SHIFT z_SHIFT. More...
 
bool DF_shift_bool
 is doc file with shifts available More...
 

Detailed Description

Crystal Projecting parameters. This class reads a set of projection parameters in a file (see the user guide of the projection program for more information about the file structure) and extract the useful information from it. This class allows also to write in the same file format, for doing so you must first introduce the right values in the class fields, and the call to the procedure write.

A crystal is supposed to have two lattice vectors: a and b as follows

^ b
|
|
|
-----------> a

Definition at line 56 of file project_crystal.h.

Constructor & Destructor Documentation

◆ Crystal_Projection_Parameters()

Crystal_Projection_Parameters::Crystal_Projection_Parameters ( )

Empty constructor

Definition at line 32 of file project_crystal.cpp.

33 {
34  crystal_Xdim = 0;
35  crystal_Ydim = 0;
36  orthogonal = false;
37  a.clear();
38  b.clear();
39  Nshift_avg = 0;
40  Nshift_dev = 0;
41  disappearing_th = 0;
42  DF_shift_bool = false;
43  DF_shift.clear();
44 }
void clear()
Definition: matrix1d.cpp:67
Matrix1D< double > b
Crustal vector b.
bool orthogonal
Orthogonalize projections.
Matrix1D< double > a
Crystal vector a.
bool DF_shift_bool
is doc file with shifts available
MetaDataVec DF_shift
Document File for shifts. Order: H K x_SHIFT y_SHIFT z_SHIFT.
void clear() override
double disappearing_th
Disappearing threshold.
double Nshift_dev
Standard deviation of the magnitude shift.
int crystal_Xdim
Crystal X dimension.
int crystal_Ydim
Crystal Y dimension.
double Nshift_avg
Bias to apply to the magnitude shift.

Member Function Documentation

◆ read()

void Crystal_Projection_Parameters::read ( const FileName fn_crystal,
double  scale = 1.0 
)

Read projection parameters from a file. An exception is thrown if the file is not found or any of the parameters is not found in the right place.

Definition at line 47 of file project_crystal.cpp.

48 {
49  MetaDataVec MD;
50  size_t objId;
51  FileName fn_crystal = fn.removeBlockName();
52  MD.read(formatString("crystal@%s", fn_crystal.c_str()));
53  if (MD.isEmpty())
55  (String)"Prog_Project_Parameters::read: There is a problem "
56  "opening the file " + fn_crystal);
57 
58  std::vector <double> ParamVec;
59  objId = MD.firstRowId();
60  MD.getValue(MDL_DIMENSIONS_2D, ParamVec, objId);
61  crystal_Xdim = (int)ParamVec[0];
62  crystal_Ydim = (int)ParamVec[1];
63  crystal_Xdim = ROUND(scale * crystal_Xdim);
64  crystal_Ydim = ROUND(scale * crystal_Ydim);
65  MD.getValue(MDL_CRYSTAL_LATTICE_A, ParamVec, objId);
66  a.resize(3);
67  XX(a) = scale * ParamVec[0];
68  YY(a) = scale * ParamVec[1];
69  ZZ(a) = 0;
70  MD.getValue(MDL_CRYSTAL_LATTICE_B, ParamVec, objId);
71  b.resize(3);
72  XX(b) = scale * ParamVec[0];
73  YY(b) = scale * ParamVec[1];
74  ZZ(b) = 0;
75  MD.getValue(MDL_CRYSTAL_NOISE_SHIFT,ParamVec, objId);
76  Nshift_dev = scale * ParamVec[0];
77  if (ParamVec.size() < 2)
78  Nshift_avg = 0;
79  else
80  Nshift_avg = scale * ParamVec[1];
83  if (MD.getValue(MDL_CRYSTAL_SHFILE, fn_shift, objId))
84  DF_shift_bool = true;
85  //#define DEBUG
86 #ifdef DEBUG
87 
88  std::cerr << "crystal_Xdim" << crystal_Xdim<<std::endl;
89  std::cerr << "crystal_Ydim" << crystal_Ydim<<std::endl;
90  std::cerr << "a vector" << a <<std::endl;
91  std::cerr << "b vector" << b <<std::endl;
92  std::cerr << "Nshift_devr" << Nshift_dev <<std::endl;
93  std::cerr << "Nshift_avg" << Nshift_avg <<std::endl;
94 #endif
95 #undef DEBUG
96 }
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Matrix1D< double > b
Crustal vector b.
bool orthogonal
Orthogonalize projections.
Matrix1D< double > a
Crystal vector a.
< Lattice vector for projection (vector double)
bool DF_shift_bool
is doc file with shifts available
bool isEmpty() const override
double disappearing_th
Disappearing threshold.
noise if center of unit cell (vector double)
#define XX(v)
Definition: matrix1d.h:85
< Shift file for crystal projection
size_t firstRowId() const override
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
#define ROUND(x)
Definition: xmipp_macros.h:210
double Nshift_dev
Standard deviation of the magnitude shift.
int crystal_Xdim
Crystal X dimension.
#define YY(v)
Definition: matrix1d.h:93
bool getValue(MDObject &mdValueOut, size_t id) const override
File cannot be open.
Definition: xmipp_error.h:137
int crystal_Ydim
Crystal Y dimension.
FileName removeBlockName() const
< Lattice vector for projection (vector double)
std::string String
Definition: xmipp_strings.h:34
FileName fn_shift
file with shifts
String formatString(const char *format,...)
< Disappearing threshold (double)
#define ZZ(v)
Definition: matrix1d.h:101
double Nshift_avg
Bias to apply to the magnitude shift.

◆ write()

void Crystal_Projection_Parameters::write ( const FileName fn_crystal)

Write projection parameters to a file. The projection parameters are written into a file wth the same structure as always. If the file cannot be openned for output an exception is thrown.

Definition at line 99 of file project_crystal.cpp.

100 {
101  if (fn_crystal.isMetaData())
102  {
103  MetaDataVec MD1; //MetaData for crystal projection parameters
104  std::vector<double> FCVect(2); //For the center of feature
105  size_t id;
106  std::vector<double> TVector; //For general use
107  MD1.setColumnFormat(false);
108  id = MD1.addObject();
109  TVector[0] = crystal_Xdim;
110  TVector[1] = crystal_Ydim;
111  MD1.setValue(MDL_DIMENSIONS_2D, TVector, id);
112  TVector[0] = XX(a);
113  TVector[1] = YY(a);
114  MD1.setValue(MDL_CRYSTAL_LATTICE_A, TVector, id);
115  TVector[0] = XX(b);
116  TVector[1] = YY(b);
117  MD1.setValue(MDL_CRYSTAL_LATTICE_B, TVector, id);
118  TVector[0] = Nshift_dev;
119  TVector[1] = Nshift_avg;
120  MD1.setValue(MDL_NOISE_PIXEL_LEVEL, TVector, id);
123  MD1.setValue(MDL_CRYSTAL_SHFILE, fn_shift.c_str(), id);
124  //MD1.write(fn_crystal, MD_OVERWRITE);
125  }
126  else
127  {
128  FILE *fh_param;
129 
130  if ((fh_param = fopen(fn_crystal.c_str(), "w")) == nullptr)
132  (std::string)"Prog_Project_Parameters::write: There is a problem "
133  "opening the file " + fn_crystal + " for output");
134 
135  fprintf(fh_param, "# Crystal dimensions (X, Y)\n");
136  fprintf(fh_param, "%d %d\n", crystal_Xdim, crystal_Ydim);
137  fprintf(fh_param, "# Crystal a lattice vector (X, Y)\n");
138  fprintf(fh_param, "%f %f\n", XX(a), YY(a));
139  fprintf(fh_param, "# Crystal b lattice vector (X, Y)\n");
140  fprintf(fh_param, "%f %f\n", XX(b), YY(b));
141 
142  fprintf(fh_param, "# Noise (and bias) applied to the magnitude shift\n");
143  fprintf(fh_param, "%f ", Nshift_dev);
144  if (Nshift_avg != 0)
145  fprintf(fh_param, "%f \n", Nshift_avg);
146  else
147  fprintf(fh_param, "\n");
148 
149  fprintf(fh_param, "# Disappearing threshold\n");
150  fprintf(fh_param, "%f\n", disappearing_th);
151 
152  fprintf(fh_param, "# Orthogonal Projections\n");
153  if (orthogonal)
154  fprintf(fh_param, "Yes\n");
155  else
156  fprintf(fh_param, "No\n");
157 
158  // fprintf(fh_param,"# Grid relative size\n");
159 
160  fprintf(fh_param, "# File with shifts for each unit cell\n");
161  fprintf(fh_param, "%s", fn_shift.c_str());
162 
163  fclose(fh_param);
164  }
165 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Matrix1D< double > b
Crustal vector b.
bool orthogonal
Orthogonalize projections.
Matrix1D< double > a
Crystal vector a.
< Lattice vector for projection (vector double)
double disappearing_th
Disappearing threshold.
#define XX(v)
Definition: matrix1d.h:85
< Shift file for crystal projection
bool setValue(const MDObject &mdValueIn, size_t id)
size_t addObject() override
Noise description for pixels&#39; gray level (when projecting)
double Nshift_dev
Standard deviation of the magnitude shift.
int crystal_Xdim
Crystal X dimension.
#define YY(v)
Definition: matrix1d.h:93
File cannot be open.
Definition: xmipp_error.h:137
virtual void setColumnFormat(bool column)
int crystal_Ydim
Crystal Y dimension.
bool isMetaData(bool failIfNotExists=true) const
< Lattice vector for projection (vector double)
FileName fn_shift
file with shifts
fprintf(glob_prnt.io, "\)
< Disappearing threshold (double)
double Nshift_avg
Bias to apply to the magnitude shift.

Member Data Documentation

◆ a

Matrix1D<double> Crystal_Projection_Parameters::a

Crystal vector a.

Definition at line 66 of file project_crystal.h.

◆ b

Matrix1D<double> Crystal_Projection_Parameters::b

Crustal vector b.

Definition at line 68 of file project_crystal.h.

◆ crystal_Xdim

int Crystal_Projection_Parameters::crystal_Xdim

Crystal X dimension.

Definition at line 60 of file project_crystal.h.

◆ crystal_Ydim

int Crystal_Projection_Parameters::crystal_Ydim

Crystal Y dimension.

Definition at line 62 of file project_crystal.h.

◆ DF_shift

MetaDataVec Crystal_Projection_Parameters::DF_shift

Document File for shifts. Order: H K x_SHIFT y_SHIFT z_SHIFT.

Definition at line 78 of file project_crystal.h.

◆ DF_shift_bool

bool Crystal_Projection_Parameters::DF_shift_bool

is doc file with shifts available

Definition at line 80 of file project_crystal.h.

◆ disappearing_th

double Crystal_Projection_Parameters::disappearing_th

Disappearing threshold.

Definition at line 74 of file project_crystal.h.

◆ fn_shift

FileName Crystal_Projection_Parameters::fn_shift

file with shifts

Definition at line 76 of file project_crystal.h.

◆ Nshift_avg

double Crystal_Projection_Parameters::Nshift_avg

Bias to apply to the magnitude shift.

Definition at line 70 of file project_crystal.h.

◆ Nshift_dev

double Crystal_Projection_Parameters::Nshift_dev

Standard deviation of the magnitude shift.

Definition at line 72 of file project_crystal.h.

◆ orthogonal

bool Crystal_Projection_Parameters::orthogonal

Orthogonalize projections.

Definition at line 64 of file project_crystal.h.


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