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

#include <tomo_map_back.h>

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

Public Member Functions

void readParams ()
 Read arguments. More...
 
void show () const
 Show. More...
 
void defineParams ()
 Define parameters. More...
 
void produce_side_info ()
 
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 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_tomo
 Input. More...
 
FileName fn_geom
 
FileName fn_ref
 
FileName fn_out
 
String modeStr
 
Image< double > tomo
 
Image< double > reference
 
MetaDataVec mdGeom
 
int mode
 
double K
 
double threshold
 
- 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

Map back parameters.

Definition at line 36 of file tomo_map_back.h.

Member Function Documentation

◆ defineParams()

void ProgTomoMapBack::defineParams ( )
virtual

Define parameters.

Reimplemented from XmippProgram.

Definition at line 61 of file tomo_map_back.cpp.

62 {
63  addUsageLine("This program takes a tomogram, a reference subtomogram and a metadata with geometrical parameters");
64  addUsageLine("(x,y,z) and places the reference subtomogram on the tomogram at the designated locations (map back).");
65  addUsageLine("The program has several 'painting' options:");
66  addUsageLine(" 1. Copying the reference onto the tomogram");
67  addUsageLine(" 2. Setting the region occupied by the reference in the tomogram to the average value of that region");
68  addUsageLine(" 3. Add the reference multiplied by a constant to the location specified");
69  addUsageLine(" 4. Copy a binarized version of the reference onto the tomogram");
70  addParamsLine(" -i <tomogram> : Original tomogram");
71  addParamsLine(" [-o <tomogram=\"\">] : Output tomogram mapped back");
72  addParamsLine(" --geom <geometry> : Subtomograms coordinates and rotation angles (it must be a metadata)");
73  addParamsLine(" --ref <reference> : Subtomogram reference");
74  addParamsLine(" [--method <mode=copy>] : Painting mode");
75  addParamsLine(" where <mode>");
76  addParamsLine(" copy");
77  addParamsLine(" avg <threshold=0.5>");
78  addParamsLine(" highlight <K=1>");
79  addParamsLine(" copy_binary <threshold=0.5>");
80 }
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ produce_side_info()

void ProgTomoMapBack::produce_side_info ( )

Produce side info.

Definition at line 83 of file tomo_map_back.cpp.

84 {
85  tomo.read(fn_tomo);
88  reference().setXmippOrigin();
89  const MultidimArray<double> &mReference=reference();
90 
91  if (modeStr=="copy")
92  mode=1;
93  else if (modeStr=="avg")
94  mode=2;
95  else if (modeStr=="highlight")
96  mode=3;
97  else if (modeStr=="copy_binary")
98  mode=4;
99 
100  if (mode==4 || mode==2)
101  {
102  FOR_ALL_ELEMENTS_IN_ARRAY3D(mReference)
103  A3D_ELEM(mReference,k,i,j)=(A3D_ELEM(mReference,k,i,j)>threshold) ? 1:0;
104  }
105 }
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
Image< double > tomo
Definition: tomo_map_back.h:45
#define i
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
Image< double > reference
Definition: tomo_map_back.h:45
#define A3D_ELEM(V, k, i, j)
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
FileName fn_geom
Definition: tomo_map_back.h:40
#define j
MetaDataVec mdGeom
Definition: tomo_map_back.h:46
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
FileName fn_tomo
Input.
Definition: tomo_map_back.h:40

◆ readParams()

void ProgTomoMapBack::readParams ( )
virtual

Read arguments.

Reimplemented from XmippProgram.

Definition at line 30 of file tomo_map_back.cpp.

31 {
32 
33  fn_tomo = getParam("-i");
34  fn_geom = getParam("--geom");
35  fn_ref = getParam("--ref");
36  fn_out = getParam("-o");
37  if (fn_out=="")
39  modeStr = getParam("--method");
40  if (modeStr=="highlight")
41  K=getDoubleParam("--method",1);
42  if (modeStr=="avg" || modeStr=="copy_binary")
43  threshold=getDoubleParam("--method",1);
44 }
double getDoubleParam(const char *param, int arg=0)
const char * getParam(const char *param, int arg=0)
FileName fn_geom
Definition: tomo_map_back.h:40
FileName fn_tomo
Input.
Definition: tomo_map_back.h:40

◆ run()

void ProgTomoMapBack::run ( )
virtual

Run

Reimplemented from XmippProgram.

Definition at line 118 of file tomo_map_back.cpp.

119 {
120  show();
122  int x,y,z;
123  const MultidimArray<double> &mReference=reference();
124  MultidimArray<double> &mTomo=tomo();
125  MultidimArray<double> referenceRotated;
127  A.initIdentity(4);
128 
129  for (const auto& row : mdGeom)
130  {
131  row.getValue(MDL_XCOOR,x);
132  row.getValue(MDL_YCOOR,y);
133  row.getValue(MDL_ZCOOR,z);
135  applyGeometry(xmipp_transformation::LINEAR, referenceRotated, mReference, A, xmipp_transformation::IS_NOT_INV, xmipp_transformation::DONT_WRAP);
136 
137  double avg=0, avgN=0;
138  if (mode==2)
139  {
140  FOR_ALL_ELEMENTS_IN_ARRAY3D(referenceRotated)
141  {
143  avg+=DIRECT_A3D_ELEM(mTomo,zp,yp,xp);
144  avgN+=1;
145  }
146  if (avgN>0)
147  avg/=avgN;
148  }
149 
150  FOR_ALL_ELEMENTS_IN_ARRAY3D(referenceRotated)
151  {
153  double val=A3D_ELEM(referenceRotated,k,i,j);
154  switch (mode)
155  {
156  case 1:
157  case 4:
158  DIRECT_A3D_ELEM(mTomo,zp,yp,xp)=val;
159  break;
160  case 2:
161  if (val>0)
162  DIRECT_A3D_ELEM(mTomo,zp,yp,xp)=avg;
163  break;
164  case 3:
165  DIRECT_A3D_ELEM(mTomo,zp,yp,xp)+=K*val;
166  break;
167  }
168  }
169  }
170 
171  tomo.write(fn_out);
172 }
Image< double > tomo
Definition: tomo_map_back.h:45
void geo2TransformationMatrix(const MDRow &imageGeo, Matrix2D< double > &A, bool only_apply_shifts)
static double * y
void applyGeometry(int SplineDegree, MultidimArray< std::complex< double > > &V2, const MultidimArray< std::complex< double > > &V1, const Matrix2D< double > &A, bool inv, bool wrap, std::complex< double > outside, MultidimArray< double > *BcoeffsPtr)
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)
doublereal * x
#define i
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
Image< double > reference
Definition: tomo_map_back.h:45
#define A3D_ELEM(V, k, i, j)
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
void show() const
Show.
X component (int)
#define GET_TOMO_COORD
double z
#define DIRECT_A3D_ELEM(v, k, i, j)
#define j
Z component (int)
MetaDataVec mdGeom
Definition: tomo_map_back.h:46
void produce_side_info()
Y component (int)
void initIdentity()
Definition: matrix2d.h:673

◆ show()

void ProgTomoMapBack::show ( ) const
virtual

Show.

Reimplemented from XmippProgram.

Definition at line 47 of file tomo_map_back.cpp.

48 {
49  if (verbose>0)
50  {
51  std::cout
52  << "Input tomogram : " << fn_tomo << std::endl
53  << "Input geometry : " << fn_geom << std::endl
54  << "Input reference : " << fn_ref << std::endl
55  << "Painting mode : " << modeStr << std::endl
56  ;
57  }
58 }
FileName fn_geom
Definition: tomo_map_back.h:40
int verbose
Verbosity level.
FileName fn_tomo
Input.
Definition: tomo_map_back.h:40

Member Data Documentation

◆ fn_geom

FileName ProgTomoMapBack::fn_geom

Definition at line 40 of file tomo_map_back.h.

◆ fn_out

FileName ProgTomoMapBack::fn_out

Definition at line 40 of file tomo_map_back.h.

◆ fn_ref

FileName ProgTomoMapBack::fn_ref

Definition at line 40 of file tomo_map_back.h.

◆ fn_tomo

FileName ProgTomoMapBack::fn_tomo

Input.

Definition at line 40 of file tomo_map_back.h.

◆ K

double ProgTomoMapBack::K

Definition at line 48 of file tomo_map_back.h.

◆ mdGeom

MetaDataVec ProgTomoMapBack::mdGeom

Definition at line 46 of file tomo_map_back.h.

◆ mode

int ProgTomoMapBack::mode

Definition at line 47 of file tomo_map_back.h.

◆ modeStr

String ProgTomoMapBack::modeStr

Definition at line 41 of file tomo_map_back.h.

◆ reference

Image<double> ProgTomoMapBack::reference

Definition at line 45 of file tomo_map_back.h.

◆ threshold

double ProgTomoMapBack::threshold

Definition at line 49 of file tomo_map_back.h.

◆ tomo

Image<double> ProgTomoMapBack::tomo

Definition at line 45 of file tomo_map_back.h.


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