MeVisLab Toolbox Reference
|
A collection of miscellaneous tool functions. More...
Enumerations | |
enum | MonotonicTypes { Empty = 1 , Singular = 2 , Irregular = 4 , Uniform = 8 , StrictlyMonotonicDecreasing = 16 , MonotonicDecreasing = 32 , MonotonicIncreasing = 64 , StrictlyMonotonicIncreasing = 128 } |
An enumerator describing whether elements of a vector have a monotonic order. More... | |
Functions | |
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector | split (const std::string &value, const std::string &sep=LineSeparator) |
Subdivides value at all positions of sep and returns all values in the vector. | |
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector | filterWithRegExVector (const ReleaseToolsIO::StringVector &strVec, const ReleaseToolsIO::StringVector ®ExpressionsVec, std::vector< size_t > *matchedRegExIdxVec=nullptr) |
Filter list of strings in strVec by regular expressions in regExpressionsVec and return list of matching strings. | |
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector | filterWithRegExVector (const ReleaseToolsIO::StringVector &strVec, const std::string ®Ex) |
Convenience version of filterWithRegExVector(strVec, regExpressionsVec, matchedRegExIdxVec) where regExpressionsVec is constructed with one entry built from regEx. | |
MLRELEASE_TOOLS_EXPORT std::string | filterLinesWithRegEx (const std::string &str, const std::string ®Ex, const std::string &sep=LineSeparator) |
Decompose str into lines with split(str, sep), filter them with filterWithRegExVector(strLines, regEx) and return a string composed of all matching lines. | |
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector | filterLines (const ReleaseToolsIO::StringVector &inLines, const bool useRegularExpression, const std::string &firstExpression, const std::string &lineEnd, const MLint index, std::string *errorInfos=nullptr) |
Searches lines in inLines which match given strings/expression to extract string value(s). | |
MLRELEASE_TOOLS_EXPORT MLErrorCode | copyBitSubImagesToUInt8SubImage (SubImage &outSubImage, const std::vector< SubImage > &frameSubImgs, MLint zTranslate=0, MLuint8 value=1, bool orValue=false) |
Decompose packed bit data from packed single pixel data in frameSubImgs to a normal MLuint8Type'd subimage. | |
MLRELEASE_TOOLS_EXPORT bool | isEquidistant (const std::vector< double > &dblVec, double eps=10e-5) |
Returns true if the number of elements in dblVec is <= 1 or if each dblVec[i]-dblVec[i-1] equals dblVec[1]-dblVec[0] (comparisons are made with the given eps). | |
MLRELEASE_TOOLS_EXPORT int | getMonotonicProperties (const std::vector< double > &dblVec, double eps=10e-5) |
Returns a bit mask contains bits defined in MonotonicTypes which describe properties of the elements in dblVec; comparisons are performed with the precision given by eps. | |
MLRELEASE_TOOLS_EXPORT MLErrorCode | calculateAverageOfSumOfSquaredDifferences (const SubImage &subImg1, const SubImage &subImg2, double &avrOfSumOfSquaredDiffs) |
Determines the average of pixel-wise sum of squared differences between the overlapping regions of subImage1 and subImage2. | |
template<typename DT1 , typename DT2 > | |
double | calculateAverageOfSumOfSquaredDifferences (TSubImage< DT1 > &img1, TSubImage< DT2 > &img2, SubImageBox box) |
Compares the average of the sum of squared differences over all voxels in the given box in corresponding and overlapping regions in subimg1 and subimg2. | |
MLRELEASE_TOOLS_EXPORT std::string | toBase64 (const std::string &inString) |
Converts inString including the terminating null character to a Base64 coded string, thus even an empty string always results to a non-empty coded and returned string. | |
MLRELEASE_TOOLS_EXPORT std::string | fromBase64 (const std::string &inString) |
Converts inString from a Base64 coded string to a decoded original string, assuming that the string has been encoded with toBase64. | |
MLRELEASE_TOOLS_EXPORT std::string | createHashFromBytes (const unsigned char *data, size_t numBytes, const std::string &hashAlgorithm="SHA1") |
Creates a hash string for the numBytes bytes data pointed to by data; nullptr data and numBytes == 0 are also allowed as arguments; 0-chars in data are also included in hash calculation and are not regarded as terminators. | |
Variables | |
MLRELEASE_TOOLS_EXPORT const std::string | LineSeparator |
The default line separator used for line endings. | |
A collection of miscellaneous tool functions.
An enumerator describing whether elements of a vector have a monotonic order.
Definition at line 151 of file mlReleaseToolsMisc.h.
MLRELEASE_TOOLS_EXPORT MLErrorCode ml::ReleaseToolsMisc::calculateAverageOfSumOfSquaredDifferences | ( | const SubImage & | subImg1, |
const SubImage & | subImg2, | ||
double & | avrOfSumOfSquaredDiffs ) |
Determines the average of pixel-wise sum of squared differences between the overlapping regions of subImage1 and subImage2.
Overlapping regions of subImage1 and subImage2 must be non-empty(), both must have same and scalar voxel types.
subImg1 | The first subImage for which the difference shall be calculated. |
subImg2 | The second subImage for which the difference shall be calculated. |
avrOfSumOfSquaredDiffs | Returns -1 is case of failure or non-overlapping regions otherwise the average >= 0 of the sum of squared differences between voxels in overlapping region. |
References calculateAverageOfSumOfSquaredDifferences().
Referenced by calculateAverageOfSumOfSquaredDifferences(), and calculateAverageOfSumOfSquaredDifferences().
|
inline |
Compares the average of the sum of squared differences over all voxels in the given box in corresponding and overlapping regions in subimg1 and subimg2.
Returns -1 if the box is empty or has no appropriate overlaps with the subimages.
Definition at line 186 of file mlReleaseToolsMisc.h.
References calculateAverageOfSumOfSquaredDifferences(), ml::TSubImageBox< intT >::getNumVoxels(), ml::TSubImageBox< intT >::intersect(), ml::TSubImageBox< intT >::isEmpty(), mlrange_cast(), ml::TSubImageBox< intT >::v1, and ml::TSubImageBox< intT >::v2.
MLRELEASE_TOOLS_EXPORT MLErrorCode ml::ReleaseToolsMisc::copyBitSubImagesToUInt8SubImage | ( | SubImage & | outSubImage, |
const std::vector< SubImage > & | frameSubImgs, | ||
MLint | zTranslate = 0, | ||
MLuint8 | value = 1, | ||
bool | orValue = false ) |
Decompose packed bit data from packed single pixel data in frameSubImgs to a normal MLuint8Type'd subimage.
Note that the data allocations of the input frameSubImgs don't need to be valid input subimages regarding the data size, because their data is expected to be packed bit pixel data which is not supported by other ML functionality.
outSubImage | The SubImage to be filled with unpacked single bit mask information; its voxel type shall be MLuint8Type and data must already be allocated according to its box and data type description. |
frameSubImgs | A vector of subimages containing one or multiple data frames from the DICOM pixel data. In this case the data is expected to have at least (rounded up to next byte position) 1/8th of the normal size of an MLuint8 typed subimage. The data is considered a packed bit image where a voxel is a single bit, and with lsb = lowest x-position, msb = highest bit position. All frame subimages shall be of MLuint8Type and their overlapping region must have at least the x/y extent of the destination outSubImage. From each frameSubImg only the box.v1.z position is read independent of its real z-extent. |
zTranslate | An offset added to the z-position of a voxel in outSubImage to determine the index into frameSubImgs for the source subimage. For example if zTranslate is 3 then a voxel at z-Position 8 in outSubImage is read from frameSubImgs[11]. Default is 0. |
value | The value to be set or ORed to the voxel of the output subimage. |
orValue | If true the the value is ORed to the output subimage otherwise it will be set. |
References copyBitSubImagesToUInt8SubImage().
Referenced by copyBitSubImagesToUInt8SubImage().
MLRELEASE_TOOLS_EXPORT std::string ml::ReleaseToolsMisc::createHashFromBytes | ( | const unsigned char * | data, |
size_t | numBytes, | ||
const std::string & | hashAlgorithm = "SHA1" ) |
Creates a hash string for the numBytes bytes data pointed to by data; nullptr data and numBytes == 0 are also allowed as arguments; 0-chars in data are also included in hash calculation and are not regarded as terminators.
data | buffer of any unsigned char values which must contain at least numBytes accessible characters. |
numBytes | number of accessible characters in data. |
hashAlgorithm | allowed values are only "SHA1", "SHA256", and "SHA512", all others will return an empty result string. |
References createHashFromBytes().
Referenced by createHashFromBytes().
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector ml::ReleaseToolsMisc::filterLines | ( | const ReleaseToolsIO::StringVector & | inLines, |
const bool | useRegularExpression, | ||
const std::string & | firstExpression, | ||
const std::string & | lineEnd, | ||
const MLint | index, | ||
std::string * | errorInfos = nullptr ) |
Searches lines in inLines which match given strings/expression to extract string value(s).
inLines | The set of lines to be filtered. |
useRegularExpression | If true then firstExpression is used as regular expression to match lines and to extract values; if false then the value between firstExpression and lineEnd is extracted matched. |
firstExpression | If useRegularExpression is false then this must exactly match the line start before the value; otherwise if will be used as regular expression to determine match results. |
lineEnd | If useRegularExpression is false then this must exactly the end of the line after the value, otherwise it is ignored. |
index | 0 returns the result from the first matching line, -1 the last one, or any other inside of found values; if it is larger than the number of matching lines then the return vector will be empty. |
errorInfos | If errorInfos is not nullptr then errors such as failing regular expression evaluations will return an error description in *errorInfos or it will be set to "" on success. If this pointer is nullptr then errors will be reported with ML_PRINT_ERROR. |
References filterLines().
Referenced by filterLines().
MLRELEASE_TOOLS_EXPORT std::string ml::ReleaseToolsMisc::filterLinesWithRegEx | ( | const std::string & | str, |
const std::string & | regEx, | ||
const std::string & | sep = LineSeparator ) |
Decompose str into lines with split(str, sep), filter them with filterWithRegExVector(strLines, regEx) and return a string composed of all matching lines.
References filterLinesWithRegEx().
Referenced by filterLinesWithRegEx().
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector ml::ReleaseToolsMisc::filterWithRegExVector | ( | const ReleaseToolsIO::StringVector & | strVec, |
const ReleaseToolsIO::StringVector & | regExpressionsVec, | ||
std::vector< size_t > * | matchedRegExIdxVec = nullptr ) |
Filter list of strings in strVec by regular expressions in regExpressionsVec and return list of matching strings.
strVec | List of strings to be filtered. |
regExpressionsVec | A container with strings containing regular expressions; empty strings and strings starting with # are ignored; all others are considered as regular expressions. If a string starts with a "!" the expression result of the rest of the string is negated. The used expression parser is boost::regex::extended; expressions causing boost exceptions will be ignored and will not lead to a match even if they carry a leading "!". |
matchedRegExIdxVec | If passed non nullptr then for each returned element in the returned vector the index to the matching regular expression is returned. On no matches the vector is returned empty. |
References filterWithRegExVector().
Referenced by filterWithRegExVector(), and filterWithRegExVector().
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector ml::ReleaseToolsMisc::filterWithRegExVector | ( | const ReleaseToolsIO::StringVector & | strVec, |
const std::string & | regEx ) |
Convenience version of filterWithRegExVector(strVec, regExpressionsVec, matchedRegExIdxVec) where regExpressionsVec is constructed with one entry built from regEx.
References filterWithRegExVector().
MLRELEASE_TOOLS_EXPORT std::string ml::ReleaseToolsMisc::fromBase64 | ( | const std::string & | inString | ) |
Converts inString from a Base64 coded string to a decoded original string, assuming that the string has been encoded with toBase64.
References fromBase64().
Referenced by fromBase64().
MLRELEASE_TOOLS_EXPORT int ml::ReleaseToolsMisc::getMonotonicProperties | ( | const std::vector< double > & | dblVec, |
double | eps = 10e-5 ) |
Returns a bit mask contains bits defined in MonotonicTypes which describe properties of the elements in dblVec; comparisons are performed with the precision given by eps.
References getMonotonicProperties().
Referenced by getMonotonicProperties().
MLRELEASE_TOOLS_EXPORT bool ml::ReleaseToolsMisc::isEquidistant | ( | const std::vector< double > & | dblVec, |
double | eps = 10e-5 ) |
Returns true if the number of elements in dblVec is <= 1 or if each dblVec[i]-dblVec[i-1] equals dblVec[1]-dblVec[0] (comparisons are made with the given eps).
References isEquidistant().
Referenced by isEquidistant().
MLRELEASE_TOOLS_EXPORT ReleaseToolsIO::StringVector ml::ReleaseToolsMisc::split | ( | const std::string & | value, |
const std::string & | sep = LineSeparator ) |
Subdivides value at all positions of sep and returns all values in the vector.
value | The string to be subdivided. |
sep | The character sequence used to separate string segments. |
MLRELEASE_TOOLS_EXPORT std::string ml::ReleaseToolsMisc::toBase64 | ( | const std::string & | inString | ) |
Converts inString including the terminating null character to a Base64 coded string, thus even an empty string always results to a non-empty coded and returned string.
References toBase64().
Referenced by toBase64().
|
extern |
The default line separator used for line endings.