Medical Imaging Interaction Toolkit  2025.08.99-f7084adb
Medical Imaging Interaction Toolkit
mitknnInteractiveTool.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 
13 #ifndef mitknnInteractiveTool_h
14 #define mitknnInteractiveTool_h
15 
16 #include <mitkSegWithPreviewTool.h>
17 #include <mitknnInteractiveEnums.h>
18 
19 #include <optional>
20 
21 namespace mitk::nnInteractive
22 {
23  class Interactor;
24 }
25 
26 namespace mitk
27 {
28  class PythonContext;
29 
31  {
32  public:
34  {
35  std::string Name;
36  int Major;
37  int Minor;
39  };
40 
42  itkFactorylessNewMacro(Self)
43 
44  const char* GetName() const override;
45  const char** GetXPM() const override;
46  us::ModuleResource GetIconResource() const override;
47  bool CanHandle(const BaseData* referenceData, const BaseData* workingData) const override;
48  void Deactivated() override;
49 
50  using InteractorMap = std::unordered_map<nnInteractive::InteractionType, std::unique_ptr<nnInteractive::Interactor>>;
51  const InteractorMap& GetInteractors() const;
52  const nnInteractive::Interactor* GetInteractor(nnInteractive::InteractionType interactionType) const;
53 
54  void EnableInteractor(nnInteractive::InteractionType nextInteractionType, nnInteractive::PromptType promptType);
55  void DisableInteractor(std::optional<nnInteractive::InteractionType> interactionType = std::nullopt);
56  void ResetInteractions();
57  bool HasInteractions() const;
58 
59  bool GetAutoZoom() const;
60  void SetAutoZoom(bool autoZoom);
61 
62  bool GetAutoRefine() const;
63  void SetAutoRefine(bool autoRefine);
64 
65  std::optional<nnInteractive::Backend> GetBackend() const;
66 
67  std::string GetVirtualEnvName() const;
68  bool CreatePythonContext();
69  PythonContext* GetPythonContext() const;
70  bool IsInstalled() const;
71  bool GetCUDADeviceInfo(CUDADeviceInfo& info) const;
72  void StartSession();
73  void EndSession();
74  bool IsSessionRunning() const;
75  void InitializeSessionWithMask(Image* mask);
76 
78 
79  protected:
81  ~nnInteractiveTool() override;
82 
83  void SetToolManager(ToolManager* toolManager) override;
84  void DoUpdatePreview(const Image* inputAtTimeStep, const Image* oldSegAtTimeStep, MultiLabelSegmentation* previewImage, TimeStepType timeStep) override;
85  void Notify(InteractionEvent* event, bool isHandled) override;
86  void ConfirmCleanUp() override;
87 
88  private:
89  class Impl;
90  std::unique_ptr<Impl> m_Impl;
91  };
92 }
93 
94 #endif
mitk::SegWithPreviewTool
Base class for any auto segmentation tool that provides a preview of the new segmentation.
Definition: mitkSegWithPreviewTool.h:38
mitk::InteractionEvent
Definition: mitkInteractionEvent.h:26
mitk::nnInteractive
Definition: mitknnInteractiveBoxInteractor.h:23
mitk::Message1< bool >
mitk::nnInteractiveTool::CUDADeviceInfo::Major
int Major
Definition: mitknnInteractiveTool.h:36
mitkSegWithPreviewTool.h
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
mitk::nnInteractive::PromptType
PromptType
Specifies the types of prompts used in nnInteractive.
Definition: mitknnInteractiveEnums.h:72
mitk::nnInteractiveTool::CUDADeviceInfo::Name
std::string Name
Definition: mitknnInteractiveTool.h:35
mitk::nnInteractiveTool::ConfirmCleanUpEvent
Message1< bool > ConfirmCleanUpEvent
Definition: mitknnInteractiveTool.h:77
mitk::nnInteractive::InteractionType
InteractionType
Specifies the types of interactions available.
Definition: mitknnInteractiveEnums.h:34
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::ToolManager
Manages and coordinates instances of mitk::Tool.
Definition: mitkToolManager.h:78
mitk::EventStateMachine
‍**
Definition: mitkEventStateMachine.h:111
MITKPYTHONSEGMENTATION_EXPORT
#define MITKPYTHONSEGMENTATION_EXPORT
Definition: MitkPythonSegmentationExports.h:15
mitknnInteractiveEnums.h
mitk::nnInteractiveTool::CUDADeviceInfo::Minor
int Minor
Definition: mitknnInteractiveTool.h:37
mitk::MultiLabelSegmentation
MultiLabelSegmentation class for handling labels and layers in a segmentation session.
Definition: mitkLabelSetImage.h:43
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
mitk::PythonContext
Definition: mitkPythonContext.h:24
us::ModuleResource
Definition: usModuleResource.h:55
mitk::nnInteractiveTool::CUDADeviceInfo::TotalMemoryMB
int TotalMemoryMB
Definition: mitknnInteractiveTool.h:38
mitk::nnInteractive::Interactor
Base class for all nnInteractive interactors.
Definition: mitknnInteractiveInteractor.h:57
mitk::TimeStepType
std::size_t TimeStepType
Definition: mitkTimeGeometry.h:27
mitk::nnInteractiveTool::InteractorMap
std::unordered_map< nnInteractive::InteractionType, std::unique_ptr< nnInteractive::Interactor > > InteractorMap
Definition: mitknnInteractiveTool.h:50
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::nnInteractiveTool::CUDADeviceInfo
Definition: mitknnInteractiveTool.h:33
mitk::nnInteractiveTool
Definition: mitknnInteractiveTool.h:30