Xmipp  v3.23.11-Nereus
Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members

#include <normalize.h>

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

Public Attributes

double mu0
 
double sigma0
 
- 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
 

Protected Types

enum  NormalizationMode {
  NONE, OLDXMIPP, NEAR_OLDXMIPP, NEWXMIPP,
  MICHAEL, NEWXMIPP2, ROBUST, RANDOM,
  RAMP, NEIGHBOUR, TOMOGRAPHY, TOMOGRAPHY0
}
 
enum  BackgroundMode { NOBACKGROUND, FRAME, CIRCLE }
 

Protected Member Functions

void defineParams ()
 
void readParams ()
 
void show ()
 
void preProcess ()
 
void processImage (const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
 
- Protected Member Functions inherited from XmippMetadataProgram
virtual void initComments ()
 
virtual void postProcess ()
 
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

NormalizationMode method
 
bool volume
 
BackgroundMode background_mode
 
int r
 
double aF
 
double a0
 
double bF
 
double b0
 
bool invert_contrast
 
bool clip
 
bool tiltMask
 
bool remove_black_dust
 
bool remove_white_dust
 
double thresh_black_dust
 
double thresh_white_dust
 
double thresh_neigh
 
MultidimArray< int > bg_mask
 
MultidimArray< int > bg_mask_bck
 
bool enable_mask
 
Mask mask_prm
 
- 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
 

Additional Inherited Members

- 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 ()
 

Detailed Description

Definition at line 201 of file normalize.h.

Member Enumeration Documentation

◆ BackgroundMode

Possible background modes

Enumerator
NOBACKGROUND 
FRAME 
CIRCLE 

Definition at line 231 of file normalize.h.

◆ NormalizationMode

Possible normalization modes

Enumerator
NONE 
OLDXMIPP 
NEAR_OLDXMIPP 
NEWXMIPP 
MICHAEL 
NEWXMIPP2 
ROBUST 
RANDOM 
RAMP 
NEIGHBOUR 
TOMOGRAPHY 
TOMOGRAPHY0 

Definition at line 205 of file normalize.h.

Member Function Documentation

◆ defineParams()

void ProgNormalize::defineParams ( )
protectedvirtual

Function in which the param of each Program are defined.

Reimplemented from XmippMetadataProgram.

Reimplemented in BasicMpiMetadataProgram< ProgNormalize >.

Definition at line 520 of file normalize.cpp.

521 {
523  allow_apply_geo = true;
524  save_metadata_stack = true;
525  keep_input_columns = true;
526  addUsageLine("Change the range of intensity values of pixels.");
527  addUsageLine("In general, most of the methods requires a background to separate "
528  "particles from noise");
529  addKeywords("mask,normalization,normalize");
531  addParamsLine(" [--method <mth=NewXmipp>] : Normalizing method.");
532  addParamsLine(" where <mth>");
533  addParamsLine(" OldXmipp : I=(I-m(I))/stddev(I)");
534  addParamsLine(" : Avg(I)=0, Stddev(I)=1, does not need background");
535  addParamsLine(" Near_OldXmipp : I=(I-m(I))/stddev(bg)");
536  addParamsLine(" NewXmipp : I=(I-m(bg))/stddev(bg)");
537  addParamsLine(" : Avg(bg)=0, Stddev(I)=1");
538  addParamsLine(" : Positivity constraints can be added in reconstruction");
539  addParamsLine(" Tomography : I=(I-mean(I))/(stddev(I)*cos(tilt))");
540  addParamsLine(" : does not need background, it assumes the tilt series is vertically aligned");
541  addParamsLine(" : Similar to OldXmipp but with an extra division by the cos(tilt)");
542  addParamsLine(" Tomography0 : I=(I-mean(I(0 degrees)))/(stddev(I)*cos(tilt))");
543  addParamsLine(" : does not need background");
544  addParamsLine(" : Similar to Tomography but the average at 0 degrees is used for all images");
545  addParamsLine(" NewXmipp2 : I=(I-m(bg))/(m(I)-m(bg))");
546  addParamsLine(" Robust : I=(I-m(bg))/P95(I)");
547  addParamsLine(" Michael : I=(I-m(bg))/stddev(bg)");
548  addParamsLine(" None : Used for removing only dust");
549  addParamsLine(" Random : I=aI+b");
550  addParamsLine(" Ramp : Subtract ramp and then NewXmipp");
551  addParamsLine(" Neighbour : Replace pixels in the background with random noise");
552  addParamsLine(" [--invert] : Invert contrast.");
553  addParamsLine(" [--thr_black_dust <sblack=-3.5>] : Remove black dust particles with sigma threshold sblack.");
554  addParamsLine(" [--thr_white_dust <swhite=3.5>] : Remove white dust particles with sigma threshold swhite.");
555  addParamsLine(" [--thr_neigh <value=1.2>] : Sigma threshold for neighbour removal.");
556  addParamsLine(" [--prm <a0> <aF> <b0> <bF>] : Requires --method Random. I=aI+b.");
557  addParamsLine(" [--clip] : Requires --method Robust. Constrain maximum values in normalize volume.");
558  // addParamsLine(" requires -method Random;");
559  addParamsLine(" [--tiltMask] : Apply a mask depending on the tilt");
560  addParamsLine(" : requires --method Tomography or Tomography0");
561  addParamsLine(" [--background <mode>] ");
562  addParamsLine(" where <mode>");
563  addParamsLine(" frame <r> : Rectangular background of r pixels.");
564  addParamsLine(" circle <r> : Circular background outside radius r.");
565  mask_prm.defineParams(this,INT_MASK, "or", "Use an alternative type of background mask.");
566  addExampleLine("Normalize using OldXmipp method",false);
567  addExampleLine("xmipp_transform_normalize -i images.sel --method OldXmipp",true);
568  addExampleLine("Normalize 64x64 images using NewXmipp method",false);
569  addExampleLine("xmipp_transform_normalize -i images.sel --method NewXmipp --background circle 29",true);
570  addExampleLine("Normalize 64x64 images using NewXmipp method and a crown mask",false);
571  addExampleLine("xmipp_transform_normalize -i images.sel --method NewXmipp --mask crown 29 32",true);
572  addExampleLine("Normalize a volume to have zero mean and unit variance",false);
573  addExampleLine("xmipp_transform_normalize -i volume.vol --method OldXmipp",true);
574  addExampleLine("Normalize a volume so that the noise outside a sphere of radius 29 has zero mean and unit variance",false);
575  addExampleLine("xmipp_transform_normalize -i volume.vol --background circle 29",true);
576 }
static void defineParams(XmippProgram *program, int allowed_data_types=ALL_KINDS, const char *prefix=nullptr, const char *comment=nullptr, bool moreOptions=false)
Definition: mask.cpp:1203
void addKeywords(const char *keywords)
void addExampleLine(const char *example, bool verbatim=true)
bool save_metadata_stack
Save the associated output metadata when output file is a stack.
#define INT_MASK
Definition: mask.h:385
bool keep_input_columns
Keep input metadata columns.
bool each_image_produces_an_output
Indicate that an output is produced for each image in the input.
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ preProcess()

void ProgNormalize::preProcess ( )
protectedvirtual

Reimplemented from XmippMetadataProgram.

Reimplemented in BasicMpiMetadataProgram< ProgNormalize >.

Definition at line 769 of file normalize.cpp.

770 {
771  if (!enable_mask)
772  {
775 
776  switch (background_mode)
777  {
778  case FRAME:
779  BinaryFrameMask(bg_mask, xdimOut - 2 * r, ydimOut - 2 * r, zdimOut - 2 * r,
780  OUTSIDE_MASK);
781  break;
782  case CIRCLE:
783  if (r>(int)(xdimOut/2))
784  REPORT_ERROR(ERR_ARG_INCORRECT,"Given radius is larger than half the output size");
786  break;
787  case NOBACKGROUND:
788  break;
789  }
790  }
791  else
792  {
795  }
796  // backup a copy of the mask for apply_geo mode
798 
799  //#define DEBUG
800 #ifdef DEBUG
801 
802  Image<int> tt;
803  tt()=bg_mask;
804  tt.write("PPPmask.xmp");
805  std::cerr<<"DEBUG info: written PPPmask.xmp"<<std::endl;
806 #endif
807 
808  // Get the parameters from the 0 degrees
809  if (method==TOMOGRAPHY0)
810  {
811  // Look for the image at 0 degrees
812  double bestTilt=1000;
813  double tiltTemp;
814  FileName bestImage;
815  FileName fn_img;
816  ImageGeneric Ig;
817  MetaData * md = getInputMd();
818  for (size_t objId: md->ids())
819  {
820  md->getValue(image_label, fn_img, objId);
821 
822  if (fn_img.empty())
823  break;
824 
825  if (!md->getValue(MDL_ANGLE_TILT,tiltTemp, objId))
826  {
827  Ig.readMapped(fn_img);
828  tiltTemp = ABS(Ig.tilt());
829  }
830  if (tiltTemp < bestTilt)
831  {
832  bestTilt = tiltTemp;
833  bestImage = fn_img;
834  }
835  }
836  if (bestImage=="")
837  REPORT_ERROR(ERR_VALUE_EMPTY,"Cannot find the image at 0 degrees");
838 
839  // Compute the mu0 and sigma0 for this image
840  Image<double> I;
841  I.read(bestImage);
843  }
844 }
Empty value.
Definition: xmipp_error.h:194
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double mu0
Definition: normalize.h:298
void resizeNoCopy(const MultidimArray< T1 > &v)
double sigma0
Definition: normalize.h:299
void BinaryCircularMask(MultidimArray< int > &mask, double radius, int mode, double x0, double y0, double z0)
Definition: mask.cpp:193
void normalize_tomography(MultidimArray< double > &I, double tilt, double &mui, double &sigmai, bool tiltMask, bool tomography0, double mu0, double sigma0)
Definition: normalize.cpp:77
Tilting angle of an image (double,degrees)
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)
virtual IdIteratorProxy< false > ids()
virtual bool getValue(MDObject &mdValueOut, size_t id) const =0
double tilt(const size_t n=0) const
NormalizationMode method
Definition: normalize.h:224
Incorrect argument received.
Definition: xmipp_error.h:113
bool enable_mask
Definition: normalize.h:290
#define ABS(x)
Definition: xmipp_macros.h:142
MDLabel image_label
MDLabel to be used to read/write images, usually will be MDL_IMAGE.
BackgroundMode background_mode
Definition: normalize.h:240
MultidimArray< int > bg_mask
Definition: normalize.h:288
void generate_mask(bool apply_geo=false)
Definition: mask.cpp:1577
MultidimArray< int > bg_mask_bck
Definition: normalize.h:289
constexpr int OUTSIDE_MASK
Definition: mask.h:48
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
MultidimArray< int > imask
Definition: mask.h:499
int readMapped(const FileName &name, size_t select_img=ALL_IMAGES, int mode=WRITE_READONLY)
void BinaryFrameMask(MultidimArray< int > &mask, int Xrect, int Yrect, int Zrect, int mode, double x0, double y0, double z0)
Definition: mask.cpp:309
double tilt(const size_t n=0) const

◆ processImage()

void ProgNormalize::processImage ( const FileName fnImg,
const FileName fnImgOut,
const MDRow rowIn,
MDRow rowOut 
)
protectedvirtual

Implements XmippMetadataProgram.

Definition at line 846 of file normalize.cpp.

847 {
848  Image<double> I;
849  if (apply_geo)
850  I.readApplyGeo(fnImg, rowIn);
851  else
852  I.read(fnImg);
853 
854  I().setXmippOrigin();
855 
856  MultidimArray<double> &img=I();
857 
858  if (apply_geo)
859  {
861  // Applygeo only valid for 2D images for now...
862  img.checkDimension(2);
863 
865  // get copy of the mask
867  typeCast(bg_mask_bck, tmp);
868 
869  double outside = DIRECT_A2D_ELEM(tmp, 0, 0);
870 
871  // Instead of IS_INV for images use IS_NOT_INV for masks!
873  selfApplyGeometry(xmipp_transformation::BSPLINE3, tmp, A, xmipp_transformation::IS_NOT_INV, xmipp_transformation::DONT_WRAP, outside);
874 
876  dAi(bg_mask,n)=(int)round(dAi(tmp,n));
877  }
878 
879  double a;
880  double b;
881  if (invert_contrast)
882  img *= -1.;
883 
885  {
886  double avg=0.;
887  double stddev=0.;
888  double min=0.;
889  double max=0.;
890  double zz;
891  img.computeStats(avg, stddev, min, max);
892 
893  if ((min - avg) / stddev < thresh_black_dust && remove_black_dust)
894  {
896  {
897  zz = (A3D_ELEM(img, k, i, j) - avg) / stddev;
898  if (zz < thresh_black_dust)
899  A3D_ELEM(img, k, i, j) = rnd_gaus(avg,stddev);
900  }
901  }
902 
903  if ((max - avg) / stddev > thresh_white_dust && remove_white_dust)
904  {
906  {
907  zz = (A3D_ELEM(img, k, i, j) - avg) / stddev;
908  if (zz > thresh_white_dust)
909  A3D_ELEM(img, k, i, j) = rnd_gaus(avg,stddev);
910  }
911  }
912  }
913 
914  double mui;
915  double sigmai;
916  switch (method)
917  {
918  case OLDXMIPP:
919  normalize_OldXmipp(img);
920  break;
921  case NEAR_OLDXMIPP:
923  break;
924  case NEWXMIPP:
926  break;
927  case NEWXMIPP2:
929  break;
930  case ROBUST:
932  break;
933  case RAMP:
934  normalize_ramp(img, &bg_mask);
935  break;
936  case NEIGHBOUR:
938  break;
939  case TOMOGRAPHY:
940  normalize_tomography(img, I.tilt(), mui, sigmai, tiltMask);
941  break;
942  case TOMOGRAPHY0:
943  normalize_tomography(img, I.tilt(), mui, sigmai, tiltMask,
944  true, mu0, sigma0);
945  break;
946  case MICHAEL:
948  break;
949  case RANDOM:
950  a = rnd_unif(a0, aF);
951  b = rnd_unif(b0, bF);
953  A3D_ELEM(img, k, i, j) = a * A3D_ELEM(img, k, i, j) + b;
954  break;
955  case NONE:
956  break;
957  }
958  I.write(fnImgOut);
959 }
void selfApplyGeometry(int Splinedegree, MultidimArray< std::complex< double > > &V1, const Matrix2D< double > &A, bool inv, bool wrap, std::complex< double > outside)
#define dAi(v, i)
void min(Image< double > &op1, const Image< double > &op2)
void normalize_NewXmipp(MultidimArray< double > &I, const MultidimArray< int > &bg_mask)
Definition: normalize.cpp:255
void normalize_Michael(MultidimArray< double > &I, const MultidimArray< int > &bg_mask)
Definition: normalize.cpp:230
double mu0
Definition: normalize.h:298
void resizeNoCopy(const MultidimArray< T1 > &v)
double sigma0
Definition: normalize.h:299
void normalize_tomography(MultidimArray< double > &I, double tilt, double &mui, double &sigmai, bool tiltMask, bool tomography0, double mu0, double sigma0)
Definition: normalize.cpp:77
void computeStats(double &avg, double &stddev, T &minval, T &maxval) const
void normalize_Near_OldXmipp(MultidimArray< double > &I, const MultidimArray< int > &bg_mask)
Definition: normalize.cpp:43
#define DIRECT_A2D_ELEM(v, i, j)
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)
int readApplyGeo(const FileName &name, const MDRow &row, const ApplyGeoParams &params=DefaultApplyGeoParams)
#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
double tilt(const size_t n=0) const
double rnd_unif()
#define A3D_ELEM(V, k, i, j)
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
doublereal * b
NormalizationMode method
Definition: normalize.h:224
void normalize_ramp(MultidimArray< double > &I, MultidimArray< int > *bg_mask)
Definition: normalize.cpp:333
void normalize_remove_neighbours(MultidimArray< double > &I, const MultidimArray< int > &bg_mask, const double &threshold)
Definition: normalize.cpp:427
double thresh_white_dust
Definition: normalize.h:282
void normalize_Robust(MultidimArray< double > &I, const MultidimArray< int > &bg_mask, bool clip)
Definition: normalize.cpp:265
void max(Image< double > &op1, const Image< double > &op2)
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
MultidimArray< int > bg_mask
Definition: normalize.h:288
bool invert_contrast
Definition: normalize.h:264
#define j
bool remove_black_dust
Definition: normalize.h:276
int round(double x)
Definition: ap.cpp:7245
MultidimArray< int > bg_mask_bck
Definition: normalize.h:289
void typeCast(const Matrix1D< T1 > &v1, Matrix1D< T2 > &v2)
Definition: matrix1d.h:1227
void normalize_NewXmipp2(MultidimArray< double > &I, const MultidimArray< int > &bg_mask)
Definition: normalize.cpp:315
double rnd_gaus()
double thresh_black_dust
Definition: normalize.h:281
void getTransformationMatrix(Matrix2D< double > &A, bool only_apply_shifts=false, const size_t n=0)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
void normalize_OldXmipp(MultidimArray< double > &I)
Definition: normalize.cpp:33
int * n
doublereal * a
bool remove_white_dust
Definition: normalize.h:277
double thresh_neigh
Definition: normalize.h:286

◆ readParams()

void ProgNormalize::readParams ( )
protectedvirtual

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

Reimplemented from XmippMetadataProgram.

Reimplemented in BasicMpiMetadataProgram< ProgNormalize >.

Definition at line 578 of file normalize.cpp.

579 {
581 
582  // Get normalizing method
583  std::string aux;
584  aux = getParam("--method");
585 
586  if (aux == "OldXmipp")
587  method = OLDXMIPP;
588  else if (aux == "Near_OldXmipp")
590  else if (aux == "NewXmipp")
591  method = NEWXMIPP;
592  else if (aux == "NewXmipp2")
593  method = NEWXMIPP2;
594  else if (aux == "Robust")
595  method = ROBUST;
596  else if (aux == "Michael")
597  method = MICHAEL;
598  else if (aux == "Random")
599  method = RANDOM;
600  else if (aux == "None")
601  method = NONE;
602  else if (aux == "Ramp")
603  method = RAMP;
604  else if (aux == "Neighbour")
605  method = NEIGHBOUR;
606  else if (aux == "Tomography")
607  method = TOMOGRAPHY;
608  else if (aux == "Tomography0")
610  else
611  REPORT_ERROR(ERR_VALUE_INCORRECT, "Normalize: Unknown normalizing method");
612 
613  // Invert contrast?
614  invert_contrast = checkParam("--invert");
615 
616  // Constrain values?
617  clip = checkParam("--clip");
618 
619  // Apply a mask depending on the tilt
620  tiltMask = checkParam("--tiltMask");
621 
622  // Remove dust particles?
623  remove_black_dust = checkParam("--thr_black_dust");
624  remove_white_dust = checkParam("--thr_white_dust");
625  thresh_black_dust = getDoubleParam("--thr_black_dust");
626  thresh_white_dust = getDoubleParam("--thr_white_dust");
627  thresh_neigh = getDoubleParam("--thr_neigh");
628 
629  // Get background mask
631  if (method == NEWXMIPP || method == NEWXMIPP2 || method == MICHAEL ||
633  {
634  enable_mask = checkParam("--mask");
635  if (enable_mask)
636  {
638  mask_prm.readParams(this);
639  }
640  else
641  {
642  if (!checkParam("--background"))
644  "Normalize: --background or --mask parameter required.");
645 
646  aux = getParam("--background",0);
647  r = getIntParam("--background",1);
648 
649  if (aux == "frame")
651  else if (aux == "circle")
653  else
654  REPORT_ERROR(ERR_VALUE_INCORRECT, "Normalize: Unknown background mode");
655  }
656  }
657 
658  if (method == ROBUST)
659  {
660  enable_mask = checkParam("--mask");
661  if (enable_mask)
662  {
664  mask_prm.readParams(this);
665  }
666  }
667 
668  if (method == RANDOM)
669  {
670  if (!checkParam("--prm"))
672  "Normalize_parameters: -prm parameter required.");
673 
674  a0 = getDoubleParam("--prm", 0);
675  aF = getDoubleParam("--prm", 1);
676  b0 = getDoubleParam("--prm", 2);
677  bF = getDoubleParam("--prm", 3);
678  }
679 }
Argument missing.
Definition: xmipp_error.h:114
double getDoubleParam(const char *param, int arg=0)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
int allowed_data_types
Definition: mask.h:495
NormalizationMode method
Definition: normalize.h:224
const char * getParam(const char *param, int arg=0)
double thresh_white_dust
Definition: normalize.h:282
bool enable_mask
Definition: normalize.h:290
void readParams(XmippProgram *program)
Definition: mask.cpp:1284
BackgroundMode background_mode
Definition: normalize.h:240
bool invert_contrast
Definition: normalize.h:264
bool remove_black_dust
Definition: normalize.h:276
#define INT_MASK
Definition: mask.h:385
double thresh_black_dust
Definition: normalize.h:281
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)
Incorrect value received.
Definition: xmipp_error.h:195
bool remove_white_dust
Definition: normalize.h:277
double thresh_neigh
Definition: normalize.h:286

◆ show()

void ProgNormalize::show ( )
protected

Definition at line 681 of file normalize.cpp.

682 {
684 
685  std::cout << "Normalizing method: ";
686  switch (method)
687  {
688  case OLDXMIPP:
689  std::cout << "OldXmipp\n";
690  break;
691  case NEAR_OLDXMIPP:
692  std::cout << "Near_OldXmipp\n";
693  break;
694  case NEWXMIPP:
695  std::cout << "NewXmipp\n";
696  break;
697  case NEWXMIPP2:
698  std::cout << "NewXmipp2\n";
699  break;
700  case ROBUST:
701  std::cout << "Robust\n";
702  break;
703  case MICHAEL:
704  std::cout << "Michael\n";
705  break;
706  case NONE:
707  std::cout << "None\n";
708  break;
709  case RAMP:
710  std::cout << "Ramp\n";
711  break;
712  case NEIGHBOUR:
713  std::cout << "Neighbour\n";
714  break;
715  case TOMOGRAPHY:
716  std::cout << "Tomography\n";
717  break;
718  case TOMOGRAPHY0:
719  std::cout << "Tomography0\n";
720  break;
721  case RANDOM:
722  std::cout << "Random a=[" << a0 << "," << aF << "], " << "b=[" <<
723  b0 << "," << bF << "]\n";
724  break;
725  }
726 
727  if (method == NEWXMIPP || method == NEWXMIPP2 ||
728  method == NEAR_OLDXMIPP || method == MICHAEL ||
729  method == RAMP || method == NEIGHBOUR || method == ROBUST)
730  {
731  std::cout << "Background mode: ";
732  switch (background_mode)
733  {
734  case NOBACKGROUND :
735  std::cout << "None\n";
736  break;
737  case FRAME:
738  std::cout << "Frame, width=" << r << std::endl;
739  std::cout << "Apply transformation to mask: " << apply_geo <<
740  std::endl;
741  break;
742  case CIRCLE:
743  std::cout << "Circle, radius=" << r << std::endl;
744  std::cout << "Apply transformation to mask: " << apply_geo <<
745  std::endl;
746  break;
747  }
748  }
749 
750  if (invert_contrast)
751  std::cout << "Invert contrast "<< std::endl;
752 
753  if (tiltMask)
754  std::cout << "Applying a mask depending on tilt "<< std::endl;
755 
756  if (remove_black_dust)
757  std::cout << "Remove black dust particles, using threshold " <<
758  floatToString(thresh_black_dust) << std::endl;
759 
760  if (remove_white_dust)
761  std::cout << "Remove white dust particles, using threshold " <<
762  floatToString(thresh_white_dust) << std::endl;
763 
764  if (method == NEWXMIPP && enable_mask)
765  mask_prm.show();
766 }
String floatToString(float F, int _width, int _prec)
NormalizationMode method
Definition: normalize.h:224
double thresh_white_dust
Definition: normalize.h:282
bool enable_mask
Definition: normalize.h:290
BackgroundMode background_mode
Definition: normalize.h:240
bool invert_contrast
Definition: normalize.h:264
bool remove_black_dust
Definition: normalize.h:276
void show() const override
double thresh_black_dust
Definition: normalize.h:281
void show() const
Definition: mask.cpp:1021
bool remove_white_dust
Definition: normalize.h:277

Member Data Documentation

◆ a0

double ProgNormalize::a0
protected

Lower limit of a in y=ax+b.

Definition at line 252 of file normalize.h.

◆ aF

double ProgNormalize::aF
protected

Upper limit of a in y=ax+b.

Definition at line 248 of file normalize.h.

◆ b0

double ProgNormalize::b0
protected

Lower limit of b in y=ax+b.

Definition at line 260 of file normalize.h.

◆ background_mode

BackgroundMode ProgNormalize::background_mode
protected

Background mode. Valid modes are NONE, FRAME, CIRCLE.

Definition at line 240 of file normalize.h.

◆ bF

double ProgNormalize::bF
protected

Upper limit of b in y=ax+b.

Definition at line 256 of file normalize.h.

◆ bg_mask

MultidimArray<int> ProgNormalize::bg_mask
protected

Definition at line 288 of file normalize.h.

◆ bg_mask_bck

MultidimArray<int> ProgNormalize::bg_mask_bck
protected

Definition at line 289 of file normalize.h.

◆ clip

bool ProgNormalize::clip
protected

Flag for clipping

Definition at line 268 of file normalize.h.

◆ enable_mask

bool ProgNormalize::enable_mask
protected

Definition at line 290 of file normalize.h.

◆ invert_contrast

bool ProgNormalize::invert_contrast
protected

Flag for inverting contrast

Definition at line 264 of file normalize.h.

◆ mask_prm

Mask ProgNormalize::mask_prm
protected

Definition at line 294 of file normalize.h.

◆ method

NormalizationMode ProgNormalize::method
protected

Normalizing method. Valid methods are OLDXMIPP, NEAR_OLDXMIPP, NEWXMIPP, NEWXMIPP2, MICHAEL, NONE, RANDOM, RAMP, NEIGHBOUR, TOMOGRAPHY, TOMOGRAPHY0.

Definition at line 224 of file normalize.h.

◆ mu0

double ProgNormalize::mu0

Definition at line 298 of file normalize.h.

◆ r

int ProgNormalize::r
protected

Frame width or circle radius.

Definition at line 244 of file normalize.h.

◆ remove_black_dust

bool ProgNormalize::remove_black_dust
protected

Flags for removing balck/white spots due to dust.

Definition at line 276 of file normalize.h.

◆ remove_white_dust

bool ProgNormalize::remove_white_dust
protected

Definition at line 277 of file normalize.h.

◆ sigma0

double ProgNormalize::sigma0

Definition at line 299 of file normalize.h.

◆ thresh_black_dust

double ProgNormalize::thresh_black_dust
protected

Threshold for removing black/white (dust) spots.

Definition at line 281 of file normalize.h.

◆ thresh_neigh

double ProgNormalize::thresh_neigh
protected

Sigma threshold for neighbour removal.

Definition at line 286 of file normalize.h.

◆ thresh_white_dust

double ProgNormalize::thresh_white_dust
protected

Definition at line 282 of file normalize.h.

◆ tiltMask

bool ProgNormalize::tiltMask
protected

Flag for applying a mask depending on the tilt

Definition at line 272 of file normalize.h.

◆ volume

bool ProgNormalize::volume
protected

Normalization of volumes.

Definition at line 228 of file normalize.h.


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