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

Public Member Functions

void defineParams ()
 
void readParams ()
 
void show ()
 
void preProcess ()
 
void processImage (const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
 
void postProcess ()
 
- Public Member Functions inherited from XmippMetadataProgram
MetaDatagetInputMd ()
 
MetaDataVecgetOutputMd ()
 
 XmippMetadataProgram ()
 Empty constructor. More...
 
virtual int tryRead (int argc, const char **argv, bool reportErrors=true)
 
virtual void init ()
 
virtual void setup (MetaData *md, const FileName &o="", const FileName &oroot="", bool applyGeo=false, MDLabel label=MDL_IMAGE)
 
virtual ~XmippMetadataProgram ()
 
void setMode (WriteModeMetaData _mode)
 
void setupRowOut (const FileName &fnImgIn, const MDRow &rowIn, const FileName &fnImgOut, MDRow &rowOut) const
 Prepare rowout. More...
 
virtual void wait ()
 Wait for the distributor to finish. More...
 
virtual void checkPoint ()
 For very long programs, it may be needed to write checkpoints. More...
 
virtual void run ()
 Run over all images. More...
 
- 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)
 
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 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

DocFile DF_out
 
String action
 
String ang1
 
String ang2
 
String ang3
 
bool new_style
 
int currentImage
 
ApplyGeoParams params
 
bool ReadImg
 
- Public Attributes inherited from XmippMetadataProgram
FileName fn_in
 Filenames of input and output Metadata. More...
 
FileName fn_out
 
FileName baseName
 
FileName pathBaseName
 
FileName oextBaseName
 
bool apply_geo
 Apply geo. More...
 
size_t ndimOut
 Output dimensions. More...
 
size_t zdimOut
 
size_t ydimOut
 
size_t xdimOut
 
DataType datatypeOut
 
size_t mdInSize
 Number of input elements. More...
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Additional Inherited Members

- Protected Member Functions inherited from XmippMetadataProgram
virtual void initComments ()
 
virtual bool getImageToProcess (size_t &objId, size_t &objIndex)
 
void show () const override
 
virtual void startProcessing ()
 
virtual void finishProcessing ()
 
virtual void writeOutput ()
 
virtual void showProgress ()
 
virtual void defineLabelParam ()
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- Protected Attributes inherited from XmippMetadataProgram
WriteModeMetaData mode
 Metadata writing mode: OVERWRITE, APPEND. More...
 
FileName oext
 Output extension and root. More...
 
FileName oroot
 
MDLabel image_label
 MDLabel to be used to read/write images, usually will be MDL_IMAGE. More...
 
bool produces_an_output
 Indicate that a unique final output is produced. More...
 
bool produces_a_metadata
 Indicate that the unique final output file is a Metadata. More...
 
bool each_image_produces_an_output
 Indicate that an output is produced for each image in the input. More...
 
bool allow_apply_geo
 
bool decompose_stacks
 Input Metadata will treat a stack file as a set of images instead of a unique file. More...
 
bool delete_output_stack
 Delete previous output stack file prior to process images. More...
 
bool get_image_info
 Get the input image file dimensions to further operations. More...
 
bool save_metadata_stack
 Save the associated output metadata when output file is a stack. More...
 
bool track_origin
 Include the original input image filename in the output stack. More...
 
bool keep_input_columns
 Keep input metadata columns. More...
 
bool remove_disabled
 Remove disabled images from the input selfile. More...
 
bool allow_time_bar
 Show process time bar. More...
 
bool input_is_metadata
 Input is a metadata. More...
 
bool single_image
 Input is a single image. More...
 
bool input_is_stack
 Input is a stack. More...
 
bool output_is_stack
 Output is a stack. More...
 
bool create_empty_stackfile
 
bool delete_mdIn
 
size_t time_bar_step
 Some time bar related counters. More...
 
size_t time_bar_size
 
size_t time_bar_done
 
- 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 29 of file metadata_convert_to_spider.cpp.

Member Function Documentation

◆ defineParams()

void ProgSpiderTranslate::defineParams ( )
inlinevirtual

Function in which the param of each Program are defined.

Reimplemented from XmippMetadataProgram.

Definition at line 39 of file metadata_convert_to_spider.cpp.

40  {
41  produces_an_output = true;
42  addUsageLine("Extracts information from a Xmipp selfile into a Spider docfile");
44  addParamsLine("--action <action> : Choose one of the following choices");
45  addParamsLine(" where <action>");
46  addParamsLine(" extract_selfile <style=new> : Valid styles are new or old");
47  addParamsLine(" : The old style is 0=not selected, 1=selected");
48  addParamsLine(" : The new style contains the numbers");
49  addParamsLine(" : corresponding to the selected images");
50  addParamsLine(" extract_angles <ang1=psi> <ang2=rot> <ang3=tilt> : Specify the order");
51  addParamsLine(" : in which the angles should be written");
52  addParamsLine(" generate_count : Generate a count file with as many");
53  addParamsLine(" : numbers as enabled files in the metadata");
54  addParamsLine("[--disregard_disabled] : Disregard disabled images from the metadata");
55  addParamsLine("[--do_not_read_img] : Ignore image label");
56  }
bool produces_an_output
Indicate that a unique final output is produced.
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ postProcess()

void ProgSpiderTranslate::postProcess ( )
inlinevirtual

Reimplemented from XmippMetadataProgram.

Definition at line 160 of file metadata_convert_to_spider.cpp.

161  {
163  }
void write(const FileName &_name="")
Definition: docfile.cpp:389

◆ preProcess()

void ProgSpiderTranslate::preProcess ( )
inlinevirtual

Reimplemented from XmippMetadataProgram.

Definition at line 94 of file metadata_convert_to_spider.cpp.

95  {
96  DF_out.clear();
97  DF_out.append_comment((std::string)"Translation for Spider of " + fn_in);
98  currentImage=1;
99  if (action=="extract_angles")
100  {
101  checkAngle(ang1);
102  checkAngle(ang2);
103  checkAngle(ang3);
104  DF_out.append_comment((std::string)"Angle order: " + ang1 + " " + ang2 + " " + ang3);
105  }
106  }
FileName fn_in
Filenames of input and output Metadata.
void checkAngle(const String &str)
void clear()
Definition: docfile.cpp:181
void append_comment(const std::string &comment)
Definition: docfile.cpp:1005

◆ processImage()

void ProgSpiderTranslate::processImage ( const FileName fnImg,
const FileName fnImgOut,
const MDRow rowIn,
MDRow rowOut 
)
inlinevirtual

Implements XmippMetadataProgram.

Definition at line 108 of file metadata_convert_to_spider.cpp.

109  {
110  if (action=="extract_selfile")
111  {
112  bool store = true;
113  int enabled;
114  Matrix1D<double> aux(1); // Auxiliary vector to be added to the docfile
115  if (!rowIn.getValue( MDL_ENABLED, enabled))
116  enabled=1;
117  if (enabled == 1)
118  aux(0) = new_style ? currentImage : 1;
119  else
120  {
121  if (new_style)
122  store = false;
123  else
124  aux(0) = 0;
125  }
126  if (store)
128  }
129  else if (action=="extract_angles")
130  {
131  double rot,tilt,psi;
132  if (ReadImg)
133  {
134  Image<double> img;
135  img.readApplyGeo(fnImg,rowIn, params);
136  rot = img.rot();
137  tilt =img.tilt();
138  psi =img.psi();
139  }
140  else
141  {
142  rowIn.getValue(MDL_ANGLE_ROT, rot);
143  rowIn.getValue(MDL_ANGLE_TILT, tilt);
144  rowIn.getValue(MDL_ANGLE_PSI, psi);
145  }
146 
147  DF_out.append_angles(rot,tilt,psi,
148  ang1, ang2, ang3);
149 
150  }
151  else if (action=="generate_count")
152  {
153  Matrix1D<double> aux(1); // Auxiliary vector to be added to the docfile
154  aux(0) = currentImage;
156  }
157  currentImage++;
158  }
Rotation angle of an image (double,degrees)
double psi(const size_t n=0) const
Tilting angle of an image (double,degrees)
int append_angles(double rot, double tilt, double psi, const std::string &ang1, const std::string &ang2, const std::string &ang3)
Definition: docfile.cpp:1014
Special label to be used when gathering MDs in MpiMetadataPrograms.
double rot(const size_t n=0) const
int readApplyGeo(const FileName &name, const MDRow &row, const ApplyGeoParams &params=DefaultApplyGeoParams)
Is this image enabled? (int [-1 or 1])
double tilt(const size_t n=0) const
T & getValue(MDLabel label)
int append_data_line(int no_lines_to_append=1)
Definition: docfile.cpp:975
double psi(const double x)

◆ readParams()

void ProgSpiderTranslate::readParams ( )
inlinevirtual

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

Reimplemented from XmippMetadataProgram.

Definition at line 58 of file metadata_convert_to_spider.cpp.

59  {
60  remove_disabled=checkParam("--disregard_disabled");
62  action=getParam("--action");
63  ReadImg = true;
64  ReadImg=!checkParam("--do_not_read_img");
65  if (action=="extract_selfile")
66  {
67  String style=getParam("--action",1);
68  new_style = style=="new";
69  }
70  else if (action=="extract_angles")
71  {
72  ang1=getParam("--action",1);
73  ang2=getParam("--action",2);
74  ang3=getParam("--action",3);
75  }
77  }
const char * getParam(const char *param, int arg=0)
bool remove_disabled
Remove disabled images from the input selfile.
std::string String
Definition: xmipp_strings.h:34
bool checkParam(const char *param)

◆ show()

void ProgSpiderTranslate::show ( )
inline

Definition at line 79 of file metadata_convert_to_spider.cpp.

80  {
81  if (!verbose)
82  return;
83 
84  std::cout
85  << "Input Selfile = " << fn_in << std::endl
86  << "Output Selfile = " << fn_out << std::endl
87  << "Action = " << action << std::endl;
88  if (action=="extract_selfile")
89  std::cout << "New style = " << new_style << std::endl;
90  else if (action=="extract_angles")
91  std::cout << "Angle order = " << ang1 << " " << ang2 << " " << ang3 << std::endl;
92  }
FileName fn_in
Filenames of input and output Metadata.
int verbose
Verbosity level.

Member Data Documentation

◆ action

String ProgSpiderTranslate::action

Definition at line 33 of file metadata_convert_to_spider.cpp.

◆ ang1

String ProgSpiderTranslate::ang1

Definition at line 33 of file metadata_convert_to_spider.cpp.

◆ ang2

String ProgSpiderTranslate::ang2

Definition at line 33 of file metadata_convert_to_spider.cpp.

◆ ang3

String ProgSpiderTranslate::ang3

Definition at line 33 of file metadata_convert_to_spider.cpp.

◆ currentImage

int ProgSpiderTranslate::currentImage

Definition at line 35 of file metadata_convert_to_spider.cpp.

◆ DF_out

DocFile ProgSpiderTranslate::DF_out

Definition at line 32 of file metadata_convert_to_spider.cpp.

◆ new_style

bool ProgSpiderTranslate::new_style

Definition at line 34 of file metadata_convert_to_spider.cpp.

◆ params

ApplyGeoParams ProgSpiderTranslate::params

Definition at line 36 of file metadata_convert_to_spider.cpp.

◆ ReadImg

bool ProgSpiderTranslate::ReadImg

Definition at line 37 of file metadata_convert_to_spider.cpp.


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