MeVisLab Toolbox Reference
ml::Tools Class Reference

Class which collects some useful functions needed in many places of operator programming. More...

#include <mlTools.h>

Static Public Member Functions

static MLErrorCode scanInput (Module *op, MLint inIdx, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax)
 Analyzes the image at input inIdx of module op for min/max values with the scanImage function. More...
 
static MLErrorCode scanOutput (Module *op, MLint outIdx, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax)
 Analyzes the image at output outIdx of module op for min/max values with the scanImage function. More...
 
static MLErrorCode scanImage (PagedImage &img, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax, MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
 Analyzes the given image for min/max values. More...
 
static MLdouble calculateImageCheckSum (MLint outNum, Module &baseOp)
 Compute a checksum of the output outNum of Module baseOp. More...
 
static void separate (const std::string &stri, char sep, MLuint &num, std::string *&seps)
 Get a separation of the string into substrings which are separated by the character sep. More...
 
static void replace (std::string &s, char sch, char rep)
 Replaces all occurrences of character sch in s by rep. More...
 
static std::string toHex (MLint64 val, size_t minNumDigitSpace=1, bool useCapitals=true, bool isSigned=false)
 Returns hexadecimal string from val. More...
 
static std::string toString (MLint64 val, size_t minFieldSize=1, int align=1, size_t preSpaces=0, size_t postSpaces=0, int hex=0, size_t minNumDigitSpace=8, bool useCapitals=true)
 Returns val converted to a std::string. More...
 
static bool appendToLog (const std::string &path, const std::string &logString)
 Append message logString to the log file specified by path path. More...
 
static bool clearLogFile (const std::string &path, bool remove=false)
 If remove is false then the contents of log file specified by path are cleared, i.e. More...
 
static bool getVoxelValueRescale (MedicalImageProperties *img, double &slope, double &intercept, bool inverse=false)
 Return voxel value rescale parameters for img in slope and intercept, describing the transformation from stored voxel values to output voxel values (e.g. More...
 
static std::string getTypeInformation (MLDataType dt)
 Return a string representing an information table about the data type dt. More...
 
static void getLoopOrder (int dim, const SubImageBox &calcBox, std::vector< int > &loopOrder, std::vector< int > &loopStart, std::vector< int > &loopEnd)
 Return a suitable loop order, i.e., the order in which the six dimensions x,y,z,c,t,u are looped over, for filtering along dimension with index dim. More...
 

Static Protected Member Functions

static MLErrorCode scanImageWithGetTile (PagedImage &img, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax)
 Helper method that scans image using getTile(). More...
 
static MLErrorCode scanImageWithProcessAllPages (PagedImage &img, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax, MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
 Helper method that is used by scanInput and that uses processAllPages. More...
 
static std::string _separateBuffer (const std::string &str, const std::string &colSep, const std::string &lineSep)
 Return a string from str separated with column and line separator strings colSep and lineSep replacing spaces and tabs. More...
 

Detailed Description

Class which collects some useful functions needed in many places of operator programming.

Definition at line 48 of file mlTools.h.

Member Function Documentation

◆ _separateBuffer()

static std::string ml::Tools::_separateBuffer ( const std::string &  str,
const std::string &  colSep,
const std::string &  lineSep 
)
staticprotected

Return a string from str separated with column and line separator strings colSep and lineSep replacing spaces and tabs.

The returned string is useful for table views requiring such a format.

◆ appendToLog()

static bool ml::Tools::appendToLog ( const std::string &  path,
const std::string &  logString 
)
static

Append message logString to the log file specified by path path.

Return true on success and false on failure.

◆ calculateImageCheckSum()

static MLdouble ml::Tools::calculateImageCheckSum ( MLint  outNum,
Module baseOp 
)
static

Compute a checksum of the output outNum of Module baseOp.

If the entire image can be scanned then the sum is the sum of all voxel values multiplied with their corresponding image indices, otherwise 0. The voxel values are multiplied with their indices to make the check sum more variant to image translations and rotations.

◆ clearLogFile()

static bool ml::Tools::clearLogFile ( const std::string &  path,
bool  remove = false 
)
static

If remove is false then the contents of log file specified by path are cleared, i.e.

the file has size 0. If remove is true then the log file specified by path is removed. On success true is returned, otherwise false.

◆ getLoopOrder()

static void ml::Tools::getLoopOrder ( int  dim,
const SubImageBox calcBox,
std::vector< int > &  loopOrder,
std::vector< int > &  loopStart,
std::vector< int > &  loopEnd 
)
static

Return a suitable loop order, i.e., the order in which the six dimensions x,y,z,c,t,u are looped over, for filtering along dimension with index dim.

dim = 0 means the x dimension and dim = 5 means the u dimension. The inner loop should be over the given dimension dim, the order of the other dimensions does not matter but still needs to be specified. The indexes of the dimensions are returned in loopOrder, where loopOrder[5] is the inner loop. loopStart and loopEnd contain the start and end voxels for each dimension ordered according to loopOrder. The box of the page to be filtered is given as input in calcBox.

Parameters
dim[in]Dimension to be filtered. 0=x, 1=y, 2=z, 3=c, 4=t, 5=u.
calcBox[in]Coordinate box in which filtering should be applied.
loopOrder[out]Order in which the the dimensions are looped over.
loopStart[out]Start indexes for each dimension ordered according to loopOrder.
loopEnd[out]End indexes for each dimension ordered according to loopOrder.

◆ getTypeInformation()

static std::string ml::Tools::getTypeInformation ( MLDataType  dt)
static

Return a string representing an information table about the data type dt.

The line separator for the table is the character '
' and the column separator is '@'.

◆ getVoxelValueRescale()

static bool ml::Tools::getVoxelValueRescale ( MedicalImageProperties img,
double &  slope,
double &  intercept,
bool  inverse = false 
)
static

Return voxel value rescale parameters for img in slope and intercept, describing the transformation from stored voxel values to output voxel values (e.g.

Hounsfield units for CT) by output = stored * slope + intercept If inverse is true, the parameters for the inverse transform from output to stored values are returned. The rescale parameters are obtained from the DICOM tags Rescale Slope and Rescale Intercept. If these are not present, slope and intercept are set to 1 and 0, resp., and the function returns false. Otherwise, the function returns true.

◆ replace()

static void ml::Tools::replace ( std::string &  s,
char  sch,
char  rep 
)
static

Replaces all occurrences of character sch in s by rep.

◆ scanImage()

static MLErrorCode ml::Tools::scanImage ( PagedImage img,
MLdouble stdMin,
MLdouble stdMax,
MLdouble realMin,
MLdouble realMax,
MLRequestProgressCB progressCallback = nullptr,
void *  progressCallbackUserData = nullptr 
)
static

Analyzes the given image for min/max values.

stdMin and stdMax are set to the minimum/maximum of the image properties; realMin and realMax are set to the real minimum/maximum determined from image data if the return value is ML_RESULT_OK. Otherwise these values have undefined values. For details on progressCallback, see Host::getTile().

◆ scanImageWithGetTile()

static MLErrorCode ml::Tools::scanImageWithGetTile ( PagedImage img,
MLdouble stdMin,
MLdouble stdMax,
MLdouble realMin,
MLdouble realMax 
)
staticprotected

Helper method that scans image using getTile().

Currently not used because the scanInputImageWithProcessAllPages() is much faster with the new ML host.

◆ scanImageWithProcessAllPages()

static MLErrorCode ml::Tools::scanImageWithProcessAllPages ( PagedImage img,
MLdouble stdMin,
MLdouble stdMax,
MLdouble realMin,
MLdouble realMax,
MLRequestProgressCB progressCallback = nullptr,
void *  progressCallbackUserData = nullptr 
)
staticprotected

Helper method that is used by scanInput and that uses processAllPages.

◆ scanInput()

static MLErrorCode ml::Tools::scanInput ( Module op,
MLint  inIdx,
MLdouble stdMin,
MLdouble stdMax,
MLdouble realMin,
MLdouble realMax 
)
static

Analyzes the image at input inIdx of module op for min/max values with the scanImage function.

See documentation of scanImage for further information. Note that DummyOp::getGlobalInstance() is considered as an invalid input, i.e. its image as invalid image.

◆ scanOutput()

static MLErrorCode ml::Tools::scanOutput ( Module op,
MLint  outIdx,
MLdouble stdMin,
MLdouble stdMax,
MLdouble realMin,
MLdouble realMax 
)
static

Analyzes the image at output outIdx of module op for min/max values with the scanImage function.

See documentation of scanImage for further information. Note that DummyOp::getGlobalInstance() is considered as an invalid output, i.e. its image as an invalid image.

◆ separate()

static void ml::Tools::separate ( const std::string &  stri,
char  sep,
MLuint num,
std::string *&  seps 
)
static

Get a separation of the string into substrings which are separated by the character sep.

After the call num contains the number of found separations and seps the pointer to the separated substrings. The seps pointer will be overwritten without check of its content. seps must be deleted by the application after usage with delete []. Note that a separator directly after another one produces an additional empty string in seps. num=0 is returned on allocation failure for seps. Otherwise at least one string is returned (the original) if no separation symbol is found.

◆ toHex()

static std::string ml::Tools::toHex ( MLint64  val,
size_t  minNumDigitSpace = 1,
bool  useCapitals = true,
bool  isSigned = false 
)
static

Returns hexadecimal string from val.

Parameters
valis the value converted to a hexadecimal string.
useCapitalsif true then capital letters are used for hexadecimal numbers; otherwise lower characters are used; default is true.
minNumDigitSpaceis the minimum number of numeric characters returned as hexadecimal digits; if necessary the value is prefixed with "0"s or "f"s depending on the sign of val; default is 1.
isSignedif true then a leading "-" is used followed by the hexadecimal absolute value of val; default is false.

◆ toString()

static std::string ml::Tools::toString ( MLint64  val,
size_t  minFieldSize = 1,
int  align = 1,
size_t  preSpaces = 0,
size_t  postSpaces = 0,
int  hex = 0,
size_t  minNumDigitSpace = 8,
bool  useCapitals = true 
)
static

Returns val converted to a std::string.

Parameters
valis the value to be converted.
minFieldSizedefines the minimum size of entire returned string; default is 1. If necessary spaces are added dependent on centered settings.
aligndefaults to 1.
  • aligns left strings in minFieldSize if negative,
  • aligns centered strings in minFieldSize if zero,
  • aligns right strings in minFieldSize if positive.
preSpacesdefines the number of spaces added before value string if > 0, otherwise it's ignored.
postSpacesdefines the number of spaces appended to value string > 0, otherwise it's ignored.
hexif 0 then the number is printed normally. If negative then a signed hexadecimal number is created. If positive then an unsigned hexadecimal number is created.
useCapitalssee parameter description of toHex, only used if hex != 0.
minNumDigitSpacesee parameter description of toHex, only used if hex != 0.

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