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

#include <tomo_remove_fluctuations.h>

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

Public Member Functions

void readParams ()
 Read parameters from command line. More...
 
void defineParams ()
 Define params. More...
 
void produceSideInfo ()
 Produce side info. More...
 
void show () const
 Show parameters. More...
 
void run ()
 Run. 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)
 
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 fnIn
 Input images. More...
 
FileName fnOut
 Rootname for the output. More...
 
double maxFreq
 Cutoff frequency of the lowpass filter (<0.5) More...
 
MetaDataVec SF
 
Image< double > V
 
- 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

Parameters for the program removing the fluctuations

Definition at line 38 of file tomo_remove_fluctuations.h.

Member Function Documentation

◆ defineParams()

void ProgTomoRemoveFluctuations::defineParams ( )
virtual

Define params.

Reimplemented from XmippProgram.

Definition at line 39 of file tomo_remove_fluctuations.cpp.

40 {
41  addUsageLine("Remove the flickering in a tilt series. This is a phenomenon rather ");
42  addUsageLine("common in X-ray microscopy. For doing so, a low-pass filter of a given ");
43  addUsageLine("frequency (normalized to 0.5) is applied across the time series, i.e., a ");
44  addUsageLine("line is formed with all the lines at the same position along the tilt series. ");
45  addUsageLine("This time series is the filtered and put back into the tilt series. ");
46  addParamsLine(" -i <file> : Input images (selfile or stack)");
47  addParamsLine(" -o <outputStack> : Output stack");
48  addParamsLine(" [--lpf <f=0.25>] : Low pass filter");
49  addParamsLine(" : Frequency is normalized to 0.5");
50 }
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ produceSideInfo()

void ProgTomoRemoveFluctuations::produceSideInfo ( )

Produce side info.

Definition at line 53 of file tomo_remove_fluctuations.cpp.

54 {
55  // Read the selfile into a volume
56  SF.read(fnIn);
57  size_t Zdim, dummy, Ydim, Xdim, Ndim;
58  Zdim=SF.size();
59  getImageSize(SF,Xdim,Ydim,dummy,Ndim);
60  V().setMmap(true);
61  V().initZeros(Zdim,Ydim,Xdim);
62  int k=0;
63  Image<double> I;
64  FileName fnImg;
65  for (size_t objId : SF.ids())
66  {
67  SF.getValue(MDL_IMAGE,fnImg,objId);
68  I.read(fnImg);
69  V().setSlice(k,I());
70  k++;
71  }
72 }
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
void getImageSize(const MetaData &md, size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim, MDLabel image_label)
virtual IdIteratorProxy< false > ids()
size_t size() const override
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
double dummy
bool getValue(MDObject &mdValueOut, size_t id) const override
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
Name of an image (std::string)

◆ readParams()

void ProgTomoRemoveFluctuations::readParams ( )
virtual

Read parameters from command line.

Reimplemented from XmippProgram.

Definition at line 31 of file tomo_remove_fluctuations.cpp.

32 {
33  fnIn = getParam("-i");
34  fnOut = getParam("-o");
35  maxFreq = getDoubleParam("--lpf");
36 }
double getDoubleParam(const char *param, int arg=0)
double maxFreq
Cutoff frequency of the lowpass filter (<0.5)
FileName fnOut
Rootname for the output.
const char * getParam(const char *param, int arg=0)

◆ run()

void ProgTomoRemoveFluctuations::run ( )
virtual

Run.

Reimplemented from XmippProgram.

Definition at line 87 of file tomo_remove_fluctuations.cpp.

88 {
90 
91  // Filter each line in the series
93  int maxPixel=CEIL(ZSIZE(mV)*maxFreq);
94  FourierTransformer transformer;
95  if (verbose>=1)
99  std::complex<double> zero=0;
100  line.initZeros(ZSIZE(mV));
101  for (size_t i=0; i<YSIZE(mV); i++)
102  {
103  for (size_t j=0; j<XSIZE(mV); j++)
104  {
105  // Get line
106  for (size_t k=0; k<ZSIZE(mV); k++)
107  DIRECT_A1D_ELEM(line,k)=DIRECT_A3D_ELEM(mV,k,i,j);
108 
109  // Fourier transform
110  transformer.setReal(line);
111  transformer.FourierTransform();
112 
113  // Filter
114  transformer.getFourierAlias(lineFourier);
115  for (size_t k=maxPixel; k<XSIZE(lineFourier); k++)
116  DIRECT_A1D_ELEM(lineFourier,k)=zero;
117 
118  // Inverse Fourier transform and back to the volume
119  transformer.inverseFourierTransform();
120  for (size_t k=0; k<ZSIZE(mV); k++)
121  DIRECT_A3D_ELEM(mV,k,i,j)=DIRECT_A1D_ELEM(line,k);
122  }
123  if (verbose>=1)
124  progress_bar(i+1);
125  }
126  if (verbose>=1)
127  progress_bar(YSIZE(mV));
128 
129  // Write the results
130  mV.setDimensions(XSIZE(mV),YSIZE(mV),1,ZSIZE(mV));
131  V.write(fnOut,ALL_IMAGES,true);
132 }
void init_progress_bar(long total)
#define YSIZE(v)
double maxFreq
Cutoff frequency of the lowpass filter (<0.5)
void inverseFourierTransform()
Definition: xmipp_fftw.cpp:329
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)
FileName fnOut
Rootname for the output.
#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
#define DIRECT_A1D_ELEM(v, i)
void setReal(MultidimArray< double > &img)
Definition: xmipp_fftw.cpp:129
#define CEIL(x)
Definition: xmipp_macros.h:225
void produceSideInfo()
Produce side info.
#define XSIZE(v)
void progress_bar(long rlen)
#define ZSIZE(v)
int verbose
Verbosity level.
#define DIRECT_A3D_ELEM(v, k, i, j)
void FourierTransform(T &v, T1 &V, bool getCopy=true)
Definition: xmipp_fftw.h:166
void setDimensions(int Xdim, int Ydim, int Zdim, size_t Ndim)
#define j
void getFourierAlias(T &V)
Definition: xmipp_fftw.h:207
#define ALL_IMAGES
void initZeros(const MultidimArray< T1 > &op)
ql0001_ & zero(ctemp+1),(cvec+1),(a+1),(b+1),(bl+1),(bu+1),(x+1),(w+1), &iout, ifail, &zero,(w+3), &lwar2,(iw+1), &leniw, &glob_grd.epsmac

◆ show()

void ProgTomoRemoveFluctuations::show ( ) const
virtual

Show parameters.

Reimplemented from XmippProgram.

Definition at line 75 of file tomo_remove_fluctuations.cpp.

76 {
77  if (verbose==0)
78  return;
79  std::cout << "Removing fluctuations from a tilt series\n";
80  std::cout << "Input series: " << fnIn << std::endl
81  << "Output root: " << fnOut << std::endl
82  << "Max freq (LPF): " << maxFreq << std::endl
83  ;
84 }
double maxFreq
Cutoff frequency of the lowpass filter (<0.5)
FileName fnOut
Rootname for the output.
int verbose
Verbosity level.

Member Data Documentation

◆ fnIn

FileName ProgTomoRemoveFluctuations::fnIn

Input images.

Definition at line 42 of file tomo_remove_fluctuations.h.

◆ fnOut

FileName ProgTomoRemoveFluctuations::fnOut

Rootname for the output.

Definition at line 45 of file tomo_remove_fluctuations.h.

◆ maxFreq

double ProgTomoRemoveFluctuations::maxFreq

Cutoff frequency of the lowpass filter (<0.5)

Definition at line 48 of file tomo_remove_fluctuations.h.

◆ SF

MetaDataVec ProgTomoRemoveFluctuations::SF

Definition at line 51 of file tomo_remove_fluctuations.h.

◆ V

Image<double> ProgTomoRemoveFluctuations::V

Definition at line 54 of file tomo_remove_fluctuations.h.


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