Medical Imaging Interaction Toolkit  2023.12.99-77685e7b
Medical Imaging Interaction Toolkit
mitkTotalSegmentatorTool.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 #ifndef MITKTOTALSEGMENTATORTOOL_H
13 #define MITKTOTALSEGMENTATORTOOL_H
14 
15 #include "mitkSegWithPreviewTool.h"
17 #include "mitkProcessExecutor.h"
18 
19 
20 namespace us
21 {
22  class ModuleResource;
23 }
24 
25 namespace mitk
26 {
27 
37  {
38  public:
40  itkFactorylessNewMacro(Self);
41  itkCloneMacro(Self);
42 
43  const char *GetName() const override;
44  const char **GetXPM() const override;
45  us::ModuleResource GetIconResource() const override;
46  void Activated() override;
47 
48  itkSetMacro(MitkTempDir, std::string);
49  itkGetConstMacro(MitkTempDir, std::string);
50 
51  itkSetMacro(SubTask, std::string);
52  itkGetConstMacro(SubTask, std::string);
53 
54  itkSetMacro(PythonPath, std::string);
55  itkGetConstMacro(PythonPath, std::string);
56 
57  itkSetMacro(GpuId, unsigned int);
58  itkGetConstMacro(GpuId, unsigned int);
59 
60  itkSetMacro(Fast, bool);
61  itkGetConstMacro(Fast, bool);
62  itkBooleanMacro(Fast);
63 
69  static void onPythonProcessEvent(itk::Object *, const itk::EventObject &e, void *);
70 
71  protected:
74 
89  void DoUpdatePreview(const Image* inputAtTimeStep, const Image* oldSegAtTimeStep, LabelSetImage* previewImage, TimeStepType timeStep) override;
90  void UpdatePrepare() override;
91 
92  private:
93 
98  void run_totalsegmentator(ProcessExecutor*, const std::string&, const std::string&, bool, bool, unsigned int, const std::string&);
99 
104  void MapLabelsToSegmentation(const mitk::LabelSetImage*, mitk::LabelSetImage*, std::map<mitk::Label::PixelType, std::string>&);
105 
111  void ParseLabelMapTotalDefault();
112 
118  std::string GetLabelMapPath();
119 
129  LabelSetImage::Pointer AgglomerateLabelFiles(std::vector<std::string>& filePaths, const unsigned int* dimension, mitk::BaseGeometry* geometry);
130 
131  std::string m_MitkTempDir;
132  std::string m_PythonPath;
133  std::string m_SubTask = "total";
134  unsigned int m_GpuId = 0;
135  std::map<mitk::Label::PixelType, std::string> m_LabelMapTotal;
136  bool m_Fast = true;
137  const std::string TEMPLATE_FILENAME = "XXXXXX_000_0000.nii.gz";
138  const std::string DEFAULT_TOTAL_TASK = "total";
139  const std::unordered_map<std::string, std::vector<std::string>> SUBTASKS_MAP =
140  {
141  {"body", { "body.nii.gz", "body_trunc.nii.gz", "body_extremities.nii.gz", "skin.nii.gz"}},
142  {"hip_implant", {"hip_implant.nii.gz"}},
143  {"cerebral_bleed", {"intracerebral_hemorrhage.nii.gz"}},
144  {"coronary_arteries", {"coronary_arteries.nii.gz"}},
145  {"lung_vessels", {"lung_vessels.nii.gz", "lung_trachea_bronchia.nii.gz"}},
146  {"pleural_pericard_effusion", {"pleural_effusion.nii.gz", "pericardial_effusion.nii.gz"}}
147  };
148  }; // class
149 } // namespace
150 #endif
mitk::SegWithPreviewTool
Base class for any auto segmentation tool that provides a preview of the new segmentation.
Definition: mitkSegWithPreviewTool.h:38
mitkProcessExecutor.h
us
Definition: mitkAbstractFileReader.h:29
mitkSegWithPreviewTool.h
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
itk::SmartPointer< Self >
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::EventStateMachine
‍**
Definition: mitkEventStateMachine.h:111
mitk::BaseGeometry
BaseGeometry Describes the geometry of a data object.
Definition: mitkBaseGeometry.h:94
MITKSEGMENTATION_EXPORT
#define MITKSEGMENTATION_EXPORT
Definition: MitkSegmentationExports.h:15
us::ModuleResource
Definition: usModuleResource.h:55
mitk::TimeStepType
std::size_t TimeStepType
Definition: mitkTimeGeometry.h:27
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
MitkSegmentationExports.h
mitk::ProcessExecutor
You may register an observer for an ExternalProcessOutputEvent, ExternalProcessStdOutEvent or Externa...
Definition: mitkProcessExecutor.h:67
mitk::LabelSetImage
LabelSetImage class for handling labels and layers in a segmentation session.
Definition: mitkLabelSetImage.h:43
mitk::TotalSegmentatorTool
TotalSegmentator segmentation tool.
Definition: mitkTotalSegmentatorTool.h:36