Xmipp  v3.23.11-Nereus
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ProgMicrographScissor Class Reference
Inheritance diagram for ProgMicrographScissor:
Inheritance graph
[legend]
Collaboration diagram for ProgMicrographScissor:
Collaboration graph
[legend]

Public Member Functions

void run ()
 
- Public Member Functions inherited from XmippProgram
const char * getParam (const char *param, int arg=0)
 
const char * getParam (const char *param, const char *subparam, int arg=0)
 
int getIntParam (const char *param, int arg=0)
 
int getIntParam (const char *param, const char *subparam, int arg=0)
 
double getDoubleParam (const char *param, int arg=0)
 
double getDoubleParam (const char *param, const char *subparam, int arg=0)
 
float getFloatParam (const char *param, int arg=0)
 
float getFloatParam (const char *param, const char *subparam, int arg=0)
 
void getListParam (const char *param, StringVector &list)
 
int getCountParam (const char *param)
 
bool checkParam (const char *param)
 
bool existsParam (const char *param)
 
void addParamsLine (const String &line)
 
void addParamsLine (const char *line)
 
ParamDefgetParamDef (const char *param) const
 
virtual void quit (int exit_code=0) const
 
virtual int tryRun ()
 
void initProgress (size_t total, size_t stepBin=60)
 
void setProgress (size_t value=0)
 
void endProgress ()
 
void processDefaultComment (const char *param, const char *left)
 
void setDefaultComment (const char *param, const char *comment)
 
virtual void initComments ()
 
void setProgramName (const char *name)
 
void addUsageLine (const char *line, bool verbatim=false)
 
void clearUsage ()
 
void addExampleLine (const char *example, bool verbatim=true)
 
void addSeeAlsoLine (const char *seeAlso)
 
void addKeywords (const char *keywords)
 
const char * name () const
 
virtual void usage (int verb=0) const
 
virtual void usage (const String &param, int verb=2)
 
int version () const
 
virtual void show () const
 
virtual void read (int argc, const char **argv, bool reportErrors=true)
 
virtual void read (int argc, char **argv, bool reportErrors=true)
 
void read (const String &argumentsLine)
 
 XmippProgram ()
 
 XmippProgram (int argc, const char **argv)
 
virtual ~XmippProgram ()
 

Protected Member Functions

void defineParams ()
 
void readParams ()
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 

Protected Attributes

FileName fn_micrograph
 
FileName fn_out
 
FileName fn_tilted
 
FileName fn_out_tilted
 
FileName fn_angles
 
FileName fn_tilt_pos
 
FileName fn_orig
 
FileName fn_pos
 
bool pair_mode
 
int Ydim
 
int Xdim
 
bool reverse_endian
 
bool compute_transmitance
 
bool compute_inverse
 
double down_transform
 
bool rmStack
 
bool fillBorders
 
int Nnoise
 
bool extractNoise
 
- 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
 

Additional Inherited Members

- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Detailed Description

Definition at line 32 of file micrograph_scissor.cpp.

Member Function Documentation

◆ defineParams()

void ProgMicrographScissor::defineParams ( )
inlineprotectedvirtual

Function in which the param of each Program are defined.

Reimplemented from XmippProgram.

Definition at line 37 of file micrograph_scissor.cpp.

38  {
39  addUsageLine ("Extract particles from a micrograph");
40  addSeeAlsoLine("micrograph_mark");
41 
42  addParamsLine(" == General Options == ");
43  addParamsLine(" -i <input_untilted_micrograph> : From which the untilted images will be cutted");
44  addParamsLine(" alias --untilted;");
45  addParamsLine(" [--orig <original_micrograph>] : unless this parameter is specified");
46  addParamsLine(" -o <output_stack> : Name for the particle images");
47  addParamsLine(" :+ Two files will be created: output_stack with the particles in a Spider stack an output_stack.xmd with the list of image names, the micrograph they were taken from, and their coordinates");
48  addParamsLine(" alias --untiltfn;");
49  addParamsLine(" [--pos <position_file>] : file with particle coordinates");
50  addParamsLine(" alias --untiltPos;");
51  addParamsLine(" [--extractNoise <n=-1>] : extract noise particles instead of true particles");
52  addParamsLine(" : n is the number of noise particles to extract");
53  addParamsLine(" : If n=-1, then the number of noise particles is the number of coordinates in the pos file");
54  addParamsLine(" : The input posfile WILL be rewritten with the noise coordinates");
55 
56  addParamsLine(" == Processing Options == ");
57  addParamsLine(" --Xdim <window_X_dim> : In pixels");
58  addParamsLine(" [--downsampling <float=1.>] : The positions were determined with this downsampling rate");
59  addParamsLine(" [--Ydim <window_Y_dim>] : If not given Ydim=Xdim");
60  addParamsLine(" [--invert] : Invert contrast");
61  addParamsLine(" [--log] : Take logarithm (compute transmitance)");
62  addParamsLine(" [--appendToStack] : The output stack is deleted.");
63  addParamsLine(" : Use this option to add the new images to the stack");
64  addParamsLine(" [--fillBorders] : If the box is outside the micrograph, fill the missing pixels");
65  addParamsLine(" : instead of setting the whole image to blank");
66 
67  addParamsLine(" == Options for tilt pairs == ");
68  addParamsLine(" [-t <input_tilted_micrograph>] : From which the tilted images will be cutted");
69  addParamsLine(" alias --tilted;");
70  addParamsLine(" [--tiltfn <output_stack>] : Name for tilted images (Stack FileName)");
71  addParamsLine(" requires --untiltfn; ");
72  addParamsLine(" [--tiltAngles <angles_file>] : Name of the estimated tilt angles");
73  addParamsLine(" : Angle from the Y axis to the tilt axis. Both (tilted and untilted) must be cut with its corresponding angle. Cut images are rotated so that the tilt axis is parallel to Y axis.");
74  addParamsLine(" requires --tiltfn; ");
75  addParamsLine(" [--tiltPos <position_file>] : file with particle coordinates");
76  addParamsLine(" requires --tiltfn; ");
77  addParamsLine(" [--ctfparam <ctfparam>] : metadata with ctf parameters for the micrograph.");
78 
79  addExampleLine (" xmipp_micrograph_scissor -i g7107.raw --pos g7107.raw.Common.pos --oroot images --Xdim 64");
80  addExampleLine (" xmipp_micrograph_scissor --untilted Preprocessing/untilt/down1_untilt.raw --tilted Preprocessing/tilt/down1_tilt.raw --untiltfn untilt --tiltfn tilt --Xdim 60 --tiltAngles ParticlePicking/down1_untilt.raw.angles.txt --pos ParticlePicking/down1_untilt.raw.Common.pos --tiltPos ParticlePicking/down1_untilt.raw.tilted.Common.pos");
81  }
void addSeeAlsoLine(const char *seeAlso)
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgMicrographScissor::readParams ( )
inlineprotectedvirtual

Function in which each program will read parameters that it need. If some error occurs the usage will be printed out.

Reimplemented from XmippProgram.

Definition at line 96 of file micrograph_scissor.cpp.

97  {
98  fn_micrograph = getParam ("-i");
99  pair_mode = checkParam("--tilted");
100  fn_out = getParam ("-o");
101  fn_pos = getParam ("--pos");
102  Xdim = getIntParam("--Xdim");
103  if (checkParam("--Ydim"))
104  Ydim = getIntParam("--Ydim");
105  else
106  Ydim = Xdim;
107 
108  compute_inverse = checkParam("--invert");
109  compute_transmitance = checkParam("--log");
110  rmStack = !checkParam("--appendToStack");
111 
112  if (!pair_mode)
113  {
114  if (checkParam("--orig"))
115  fn_orig = getParam("--orig");
116  }
117  else
118  {
119  fn_out_tilted = getParam("--tiltfn");
120  fn_tilted = getParam("--tilted");
121  fn_angles = getParam("--tiltAngles");
122  fn_tilt_pos = getParam("--tiltPos");
123  }
124  down_transform = getDoubleParam("--downsampling");
125  fillBorders = checkParam("--fillBorders");
126  extractNoise = checkParam("--extractNoise");
127  if (extractNoise)
128  {
130  Nnoise = getIntParam("--extractNoise",0);
131  }
132  }
double getDoubleParam(const char *param, int arg=0)
const char * getParam(const char *param, int arg=0)
bool checkParam(const char *param)
unsigned int randomize_random_generator()
int getIntParam(const char *param, int arg=0)

◆ run()

void ProgMicrographScissor::run ( )
inlinevirtual

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

Reimplemented from XmippProgram.

Definition at line 134 of file micrograph_scissor.cpp.

135  {
136  if (!pair_mode)
137  {
138  Micrograph m;
141  m.read_coordinates(0, fn_pos);
142  if (down_transform != 1.)
144  m.add_label("");
147 
148  if (checkParam("--ctfparam"))
149  {
150  MetaDataVec ctfparam(getParam("--ctfparam"));
151  MDRowVec ctfRow;
152  ctfparam.getRow(ctfRow, ctfparam.firstRowId());
153  m.set_ctfparams(ctfRow);
154  }
156  if (extractNoise)
157  {
158  MDRowVec row=firstRow(fn_pos);
159  size_t micId=0;
161  row.getValue(MDL_MICROGRAPH_ID,micId);
162 
163  // Rewrite the input posfile with the true noise coordinates
164  MetaDataVec MD;
165  for (size_t i=0; i<m.coords.size(); i++)
166  {
167  size_t id=MD.addObject();
168  MD.setValue(MDL_XCOOR, m.coords[i].X, id);
169  MD.setValue(MDL_YCOOR, m.coords[i].Y, id);
170  MD.setValue(MDL_MICROGRAPH_ID, micId, id);
171  }
172  MD.write(fn_pos);
173  }
174  }
175  else
176  {
177  MetaDataVec auxMd;
178  // Read angles
179  double alpha_u, alpha_t, tilt_angle;
180  auxMd.read(fn_angles);
181  size_t objId = auxMd.firstRowId();
182  auxMd.getValue(MDL_ANGLE_Y, alpha_u, objId);
183  auxMd.getValue(MDL_ANGLE_Y2, alpha_t, objId);
184  auxMd.getValue(MDL_ANGLE_TILT, tilt_angle, objId);
185 
186  // Generate the images for the untilted image
187  Micrograph m;
190  m.read_coordinates(0, fn_pos);
191  m.add_label("");
194  m.produce_all_images(0, -1, fn_out, "", alpha_u, rmStack);
195  m.close_micrograph();
196 
197  // Generate the images for the tilted image
198  Micrograph mt;
202  mt.add_label("");
205  mt.produce_all_images(0, -1, fn_out_tilted, "", 0., rmStack);
206  mt.close_micrograph();
207  }
208  }
void set_ctfparams(const MDRowVec &ctf)
Definition: micrograph.h:153
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
void read_coordinates(int label, const FileName &fn_coords)
Definition: micrograph.cpp:216
Tilting angle of an image (double,degrees)
std::vector< Particle_coords > coords
Definition: micrograph.h:118
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
void produce_all_images(int label, double minCost, const FileName &fn_root, const FileName &fn_image="", double ang=0, bool rmStack=false, bool fillBorders=false, bool extractNoise=false, int Nnoise=-1)
Definition: micrograph.cpp:317
bool containsLabel(MDLabel label) const override
void set_window_size(int _X_window_size, int _Y_window_size)
Definition: micrograph.h:209
int add_label(const std::string &label)
Definition: micrograph.h:501
Angle between y-axis and tilt-axis (double, degrees) for tilted micrographs.
#define i
void open_micrograph(const FileName &fn_micrograph)
Definition: micrograph.cpp:61
T & getValue(MDLabel label)
void scale_coordinates(const double &c)
Definition: micrograph.cpp:270
const char * getParam(const char *param, int arg=0)
bool setValue(const MDObject &mdValueIn, size_t id)
size_t addObject() override
size_t firstRowId() const override
Angle between y-axis and tilt-axis (double, degrees) for untilted micrographs.
X component (int)
Micrograph unique id for reference (MDL_ITEM_ID should be used for Micrographs list) ...
int mt
int m
bool getValue(MDObject &mdValueOut, size_t id) const override
void close_micrograph()
Definition: micrograph.cpp:135
void set_transmitance_flag(bool flag_value)
Definition: micrograph.h:220
bool checkParam(const char *param)
Y component (int)
MDRowVec firstRow(const FileName &fnMetadata)
void set_inverse_flag(bool flag_value)
Definition: micrograph.h:244

Member Data Documentation

◆ compute_inverse

bool ProgMicrographScissor::compute_inverse
protected

Definition at line 89 of file micrograph_scissor.cpp.

◆ compute_transmitance

bool ProgMicrographScissor::compute_transmitance
protected

Definition at line 88 of file micrograph_scissor.cpp.

◆ down_transform

double ProgMicrographScissor::down_transform
protected

Definition at line 90 of file micrograph_scissor.cpp.

◆ extractNoise

bool ProgMicrographScissor::extractNoise
protected

Definition at line 94 of file micrograph_scissor.cpp.

◆ fillBorders

bool ProgMicrographScissor::fillBorders
protected

Definition at line 92 of file micrograph_scissor.cpp.

◆ fn_angles

FileName ProgMicrographScissor::fn_angles
protected

Definition at line 83 of file micrograph_scissor.cpp.

◆ fn_micrograph

FileName ProgMicrographScissor::fn_micrograph
protected

Definition at line 82 of file micrograph_scissor.cpp.

◆ fn_orig

FileName ProgMicrographScissor::fn_orig
protected

Definition at line 84 of file micrograph_scissor.cpp.

◆ fn_out

FileName ProgMicrographScissor::fn_out
protected

Definition at line 82 of file micrograph_scissor.cpp.

◆ fn_out_tilted

FileName ProgMicrographScissor::fn_out_tilted
protected

Definition at line 83 of file micrograph_scissor.cpp.

◆ fn_pos

FileName ProgMicrographScissor::fn_pos
protected

Definition at line 84 of file micrograph_scissor.cpp.

◆ fn_tilt_pos

FileName ProgMicrographScissor::fn_tilt_pos
protected

Definition at line 83 of file micrograph_scissor.cpp.

◆ fn_tilted

FileName ProgMicrographScissor::fn_tilted
protected

Definition at line 83 of file micrograph_scissor.cpp.

◆ Nnoise

int ProgMicrographScissor::Nnoise
protected

Definition at line 93 of file micrograph_scissor.cpp.

◆ pair_mode

bool ProgMicrographScissor::pair_mode
protected

Definition at line 85 of file micrograph_scissor.cpp.

◆ reverse_endian

bool ProgMicrographScissor::reverse_endian
protected

Definition at line 87 of file micrograph_scissor.cpp.

◆ rmStack

bool ProgMicrographScissor::rmStack
protected

Definition at line 91 of file micrograph_scissor.cpp.

◆ Xdim

int ProgMicrographScissor::Xdim
protected

Definition at line 86 of file micrograph_scissor.cpp.

◆ Ydim

int ProgMicrographScissor::Ydim
protected

Definition at line 86 of file micrograph_scissor.cpp.


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