MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlTools.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_TOOLS_H
14#define ML_TOOLS_H
15
16
18
19// ML-includes
20#include "MLToolsSystem.h"
21#include <mlModuleIncludes.h>
22
23// BitImage class.
24#include "mlBitImage.h"
25
26// VirtualVolume class.
27#include "mlVirtualVolume.h"
28#include "mlTVirtualVolume.h"
29
30// Geometric primitives.
31#include "mlDisc.h"
32#include "mlSphere.h"
33
34// These are included from MLLinearAlgebra:
35#include "mlLine.h"
36#include "mlPlane.h"
37#include "mlRotation.h"
38
39// Additional fields.
40#include "mlMultiFields.h"
41
43
44//----------------------------------------------------------------------
47//----------------------------------------------------------------------
49{
50
51public:
52 //----------------------------------------------------------------------
58 //----------------------------------------------------------------------
61
62 //----------------------------------------------------------------------
68 //----------------------------------------------------------------------
71
72 //----------------------------------------------------------------------
79 //----------------------------------------------------------------------
82 void* progressCallbackUserData = nullptr);
83
84 //----------------------------------------------------------------------
90 //----------------------------------------------------------------------
92
93 //----------------------------------------------------------------------
104 //----------------------------------------------------------------------
105 static void separate(const std::string& stri, char sep, MLuint& num, std::string*& seps);
106
107 //----------------------------------------------------------------------
109 //----------------------------------------------------------------------
110 static void replace(std::string& s, char sch, char rep);
111
112 //----------------------------------------------------------------------
125 //----------------------------------------------------------------------
126 static std::string toHex(MLint64 val, size_t minNumDigitSpace = 1, bool useCapitals = true, bool isSigned = false);
127
128 //----------------------------------------------------------------------
147 //----------------------------------------------------------------------
148 static std::string toString(MLint64 val, size_t minFieldSize = 1, int align = 1, size_t preSpaces = 0,
149 size_t postSpaces = 0, int hex = 0, size_t minNumDigitSpace = 8, bool useCapitals = true);
150
151 //-------------------------------------------------------------------------------
154 //-------------------------------------------------------------------------------
155 static bool appendToLog(const std::string& path, const std::string& logString);
156
157 //-------------------------------------------------------------------------------
162 //-------------------------------------------------------------------------------
163 static bool clearLogFile(const std::string& path, bool remove = false);
164
165 //-------------------------------------------------------------------------------
176 //-------------------------------------------------------------------------------
177#ifndef BUILD_WITHOUT_DICOM_DEPENDENCY
178 static bool getVoxelValueRescale(MedicalImageProperties* img, double& slope, double& intercept, bool inverse = false);
179#endif
180 //-------------------------------------------------------------------------------
184 //-------------------------------------------------------------------------------
185 static std::string getTypeInformation(MLDataType dt);
186
187 //----------------------------------------------------------------------------------
202 //----------------------------------------------------------------------------------
203
204 static void getLoopOrder(int dim, const SubImageBox& calcBox, std::vector<int>& loopOrder,
205 std::vector<int>& loopStart, std::vector<int>& loopEnd);
206
207protected:
213
218 void* progressCallbackUserData = nullptr);
219
220 //----------------------------------------------------------------------
224 //----------------------------------------------------------------------
225 static std::string _separateBuffer(const std::string& str, const std::string& colSep, const std::string& lineSep);
226};
227
229
230#endif // __mlTools_H
#define MLTOOLS_EXPORT
Resolves system dependencies for this project.
This class encapsulates basic medical image properties:
Base class for an image processing module of the ML.
Definition mlModule.h:150
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
Class which collects some useful functions needed in many places of operator programming.
Definition mlTools.h:49
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.
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 replacin...
static MLErrorCode scanImageWithGetTile(PagedImage &img, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax)
Helper method that scans image using getTile().
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.
static std::string getTypeInformation(MLDataType dt)
Return a string representing an information table about the data type dt.
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.
static MLdouble calculateImageCheckSum(MLint outNum, Module &baseOp)
Compute a checksum of the output outNum of Module baseOp.
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 f...
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....
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.
static void replace(std::string &s, char sch, char rep)
Replaces all occurrences of character sch in s by rep.
static std::string toHex(MLint64 val, size_t minNumDigitSpace=1, bool useCapitals=true, bool isSigned=false)
Returns hexadecimal string from val.
static bool appendToLog(const std::string &path, const std::string &logString)
Append message logString to the log file specified by path path.
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.
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.
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,...
MLint32 MLDataType
MLDataType.
Definition mlTypeDefs.h:592
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:772
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
void MLRequestProgressCB(void *usrData, double progress)
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition mlTypeDefs.h:505
double MLdouble
Definition mlTypeDefs.h:217
INT64 MLint64
Include 64-bit integer support for Windows or Unix.
Definition mlTypeDefs.h:411
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:489