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

#include <image_rotational_spectra.h>

Inheritance diagram for ProgMakeSpectra:
Inheritance graph
[legend]
Collaboration diagram for ProgMakeSpectra:
Collaboration graph
[legend]

Public Member Functions

void defineParams ()
 
void readParams ()
 
void show ()
 
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 ()
 

Public Attributes

FileName fn_in
 
FileName fn_out
 
Rotational_Spectrum rot_spt
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Additional Inherited Members

- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- 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

Make spectra parameters.

Definition at line 41 of file image_rotational_spectra.h.

Member Function Documentation

◆ defineParams()

void ProgMakeSpectra::defineParams ( )
virtual

Define parameters

Reimplemented from XmippProgram.

Definition at line 30 of file image_rotational_spectra.cpp.

31 {
32  addUsageLine("Computes the rotational spectrum of a set of images.");
33  addUsageLine("+This program generates a Fourier-Bessel decomposition of each image listed ");
34  addUsageLine("+in an image collection. For each one, it creates a vector with the armonic ");
35  addUsageLine("+energy percentage as a function of the radius. ");
36  addUsageLine("+ ");
37  addUsageLine("+The rotational spectrum is computed around the point (x0,y0), by default the center of the image.");
38  addUsageLine("+The length of the rotational spectrum is defined by the lowest and highest harmonic.");
39  addUsageLine("+Each harmonic is calculated by the integration of the image over a ring defined by r1 and r2.");
40  addUsageLine("+ ");
41  addUsageLine("+The rotational spectrum was defined in Crowther, R.A., and Amos, L.A. ");
42  addUsageLine("+Harmonic analysis of electron microscopy images with rotational symmetry.");
43  addUsageLine("+J. Mol. Biol.: 60, 123-130 (1971).");
44  addSeeAlsoLine("classify_kerdensom, image_vectorize");
45  addParamsLine(" -i <file> : Input image, selfile or stack");
46  addParamsLine(" -o <metadata> : Output vector metadata");
47  addParamsLine(" [--r1 <lowRadius=15>] : Lowest Integration radius (as a percentage of the total radius)");
48  addParamsLine(" [--r2 <highRadius=80>] : Highest Integration radius (as a percentage of the total radius)");
49  addParamsLine(" [--x0 <xcenter=-1>] : In physical units.");
50  addParamsLine(" [--y0 <ycenter=-1>] : By default, the Xmipp origin");
51  addParamsLine(" [--low <lowerHarmonic= 1>] : Lower harmonic to compute");
52  addParamsLine(" [--high <higherHarmonic=15>] : Higher harmonic to compute");
53  addExampleLine("xmipp_image_rotational_spectra -i images.stk -o spectra.xmd");
54 }
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 ProgMakeSpectra::readParams ( )
virtual

Read parameters from command line.

Reimplemented from XmippProgram.

Definition at line 57 of file image_rotational_spectra.cpp.

58 {
59  fn_in = getParam("-i");
60  fn_out = getParam("-o");
61  rot_spt.rl = getIntParam("--r1");
62  rot_spt.rh = getIntParam("--r2");
63  rot_spt.dr = 1;
64  rot_spt.x0 = getDoubleParam("--x0");
65  rot_spt.y0 = getDoubleParam("--y0");
66  rot_spt.numin = getIntParam("--low");
67  rot_spt.numax = getIntParam("--high");
68 }
int numax
Maximum harmonics.
double rh
Maximum integration radius.
double getDoubleParam(const char *param, int arg=0)
Rotational_Spectrum rot_spt
const char * getParam(const char *param, int arg=0)
int numin
Minimum harmonics.
double y0
Center of symmetry (y).
double dr
Integration increment.
double x0
Center of symmetry (x).
int getIntParam(const char *param, int arg=0)
double rl
Minimum integration radius.

◆ run()

void ProgMakeSpectra::run ( )
virtual

Run.

Reimplemented from XmippProgram.

Definition at line 83 of file image_rotational_spectra.cpp.

84 {
85  MetaDataVec vectorContent, vectorHeader;
86  vectorHeader.setColumnFormat(false);
87  bool first=true;
88  size_t order=0;
89  FileName fnImg;
90  Image<double> I;
91  MetaDataVec MD;
92  MD.read(fn_in);
93  std::ofstream fhOutRaw;
94  MultidimArray<float> spectrum;
95  FileName fnOutRaw=fn_out.withoutExtension()+".vec";
96  fnOutRaw.deleteFile();
97 
98  // Convert the radii from percentages to actual pixels
99  size_t Xdim, Ydim, Zdim, Ndim;
100  getImageSize(MD,Xdim,Ydim,Zdim,Ndim);
101  rot_spt.rl=(int)((rot_spt.rl/100.0)*Xdim/2);
102  rot_spt.rh=(int)((rot_spt.rh/100.0)*Xdim/2);
103 
104  for (auto& row : MD)
105  {
106  MD.getValue(MDL_IMAGE,fnImg, row.id());
107  I.readApplyGeo(fnImg,MD, row.id());
110  fhOutRaw.open(fnOutRaw.c_str(),std::ios::app | std::ios::binary);
111  if (!fhOutRaw)
112  REPORT_ERROR(ERR_IO_NOWRITE,fnOutRaw);
113  typeCast(rot_spt.rot_spectrum,spectrum);
114  fhOutRaw.write((char*)MULTIDIM_ARRAY(spectrum),XSIZE(spectrum)*sizeof(float));
115  fhOutRaw.close();
116 
117  // Create header
118  if (first)
119  {
120  size_t vectorSize=MULTIDIM_SIZE(rot_spt.rot_spectrum);
121  size_t outId=vectorHeader.addObject();
122  vectorHeader.setValue(MDL_XSIZE,XSIZE(I()),outId);
123  vectorHeader.setValue(MDL_YSIZE,YSIZE(I()),outId);
124  vectorHeader.setValue(MDL_ZSIZE,ZSIZE(I()),outId);
125  vectorHeader.setValue(MDL_COUNT,MD.size(),outId);
126  vectorHeader.setValue(MDL_CLASSIFICATION_DATA_SIZE,vectorSize,outId);
127  vectorHeader.write(formatString("vectorHeader@%s",fn_out.c_str()));
128  first=false;
129  }
130 
131  // Save this image in the output metadata
132  row.setValue(MDL_ORDER, order++);
133  vectorContent.addRow(dynamic_cast<MDRowVec&>(row));
134  }
135  vectorContent.write(formatString("vectorContent@%s",fn_out.c_str()),MD_APPEND);
136 }
Z size (int)
double rh
Maximum integration radius.
#define YSIZE(v)
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
#define MULTIDIM_SIZE(v)
Couldn&#39;t write to file.
Definition: xmipp_error.h:140
MultidimArray< double > rot_spectrum
Rotational spectrum.
void getImageSize(const MetaData &md, size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim, MDLabel image_label)
#define MULTIDIM_ARRAY(v)
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
Rotational_Spectrum rot_spt
int readApplyGeo(const FileName &name, const MDRow &row, const ApplyGeoParams &params=DefaultApplyGeoParams)
size_t addRow(const MDRow &row) override
Y size (int)
glob_log first
Number of elements of a type (int) [this is a genereic type do not use to transfer information to ano...
bool setValue(const MDObject &mdValueIn, size_t id)
size_t addObject() override
Size of data vectors for classification (int)
#define XSIZE(v)
#define ZSIZE(v)
void deleteFile() const
virtual void setColumnFormat(bool column)
double dr
Integration increment.
X size (int)
FileName withoutExtension() const
void typeCast(const Matrix1D< T1 > &v1, Matrix1D< T2 > &v2)
Definition: matrix1d.h:1227
String formatString(const char *format,...)
void compute_rotational_spectrum(MultidimArray< double > &img, double xr1, double xr2, double xdr, double xr)
Name of an image (std::string)
double rl
Minimum integration radius.

◆ show()

void ProgMakeSpectra::show ( )

Show parameters.

Definition at line 71 of file image_rotational_spectra.cpp.

72 {
73  if (verbose==0)
74  return;
75  std::cout
76  << "Input file: " << fn_in << std::endl
77  << "Output file: " << fn_out << std::endl
78  ;
79  std::cout << rot_spt << std::endl;
80 }
Rotational_Spectrum rot_spt
int verbose
Verbosity level.

Member Data Documentation

◆ fn_in

FileName ProgMakeSpectra::fn_in

Input file

Definition at line 45 of file image_rotational_spectra.h.

◆ fn_out

FileName ProgMakeSpectra::fn_out

Output file

Definition at line 48 of file image_rotational_spectra.h.

◆ rot_spt

Rotational_Spectrum ProgMakeSpectra::rot_spt

Rotational spectrum.

Definition at line 52 of file image_rotational_spectra.h.


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