12 #ifndef mitkMonaiLabelTool_h
13 #define mitkMonaiLabelTool_h
18 #include <unordered_map>
20 #include <nlohmann/json.hpp>
40 std::unordered_map<std::string, int>
labels;
43 std::unordered_map<bool, std::string>
config;
47 return (this->name == rhs.
name && this->type == rhs.
type);
52 return (
"deepgrow" ==
type ||
"deepedit" ==
type);
91 return (this->model == rhs.
model && this->hostName == rhs.
hostName && this->port == rhs.
port &&
109 void Activated()
override;
110 void Deactivated()
override;
111 void UpdatePrepare()
override;
117 void FetchOverallInfo(
const std::string &hostName,
const int &port);
129 const std::vector<MonaiModelInfo> GetAutoSegmentationModels(
const int dim = -1)
const;
135 const std::vector<MonaiModelInfo> GetInteractiveSegmentationModels(
const int dim = -1)
const;
141 const std::vector<MonaiModelInfo> GetScribbleSegmentationModels(
const int dim = -1)
const;
148 itkSetMacro(ModelName, std::string);
149 itkGetConstMacro(ModelName, std::string);
150 itkSetMacro(URL, std::string);
151 itkGetConstMacro(URL, std::string);
152 itkSetMacro(TempDir, std::string);
153 itkGetConstMacro(TempDir, std::string);
154 itkSetMacro(Timeout,
unsigned int);
155 itkGetConstMacro(Timeout,
unsigned int);
169 bool HasPicks()
const;
177 void ConnectActionsAndFunctions()
override;
183 virtual void WriteImage(
const Image *,
const std::string &)
const = 0;
221 int m_PointSetCount = 0;
229 std::unique_ptr<MonaiAppMetadata> m_InfoParameters;
235 std::pair<std::string, std::string> CreateTempDirs(
const std::string &filePattern)
const;
240 bool IsMonaiServerOn(
const std::string &hostName,
const int &port)
const;
252 void PostInferRequest(
const std::string &hostName,
const int &port,
const std::string &filePath,
const std::string &outFile,
255 std::string m_TempDir;
256 std::string m_ModelName;
259 unsigned int m_Timeout = 60;
260 const std::set<std::string> m_AUTO_SEG_TYPE_NAME = {
"segmentation"};
261 const std::set<std::string> m_SCRIBBLE_SEG_TYPE_NAME = {
"scribbles"};
262 const std::set<std::string> m_INTERACTIVE_SEG_TYPE_NAME = {
"deepgrow"};
263 const std::string m_TEMPLATE_FILENAME =
"XXXXXX_000_0000.nii.gz";
264 const std::string m_SERVER_503_ERROR_TEXT =
"A connection to MonaiLabel server cannot be established.";