|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
Classes | |
| class | BoxInteractor |
| nnInteractive interactor for drawing rectangular boxes. More... | |
| class | Interactor |
| Base class for all nnInteractive interactors. More... | |
| class | LassoInteractor |
| nnInteractive interactor for drawing contours. More... | |
| class | PointInteractor |
| nnInteractive interactor for placing individual points. More... | |
| class | ScribbleInteractor |
| nnInteractive interactor for freehand brushstrokes. More... | |
| struct | VersionCheckResult |
| Result of CheckInstalledVersion(): the verdict plus the version strings it was derived from (empty when not determined). More... | |
| struct | ModelInfo |
| A model checkpoint entry as reported by nnInteractive's model management. More... | |
| struct | ModelCheckResult |
| Result of CheckModelUpdate(). More... | |
Typedefs | |
| using | InteractionBoundingBox = std::array< std::array< int, 2 >, 3 > |
Enumerations | |
| enum class | InteractionType { Point , Box , Scribble , Lasso } |
| Specifies the types of interactions available. More... | |
| enum class | PromptType { Positive , Negative } |
| Specifies the types of prompts used in nnInteractive. More... | |
| enum class | Backend { CUDA , CPU } |
| Specifies the computation backends available for nnInteractive. More... | |
| enum class | ColorIntensity { Muted , Vibrant } |
| Specifies the intensity of the colors used in an interaction. More... | |
| enum class | VersionStatus { Unknown , BelowMinimum , UpdateAvailable , UpToDate } |
| Outcome of comparing the installed nnInteractive package against the version range this MITK build supports. More... | |
| enum class | ModelUpdateStatus { Unknown , UpToDate , UpdateAvailable } |
| Outcome of comparing the selected checkpoint against the library's recommended default. More... | |
| enum class | ModelListStatus { Ok , Empty , Failed } |
| Outcome of a ListModels() query, distinguishing an empty manifest from a hard failure. More... | |
| enum class | UpdatePromptChoice { Update , ContinueInstalled , Cancel } |
| The user's response to the version-update prompt. More... | |
Functions | |
| MITKPYTHONSEGMENTATION_EXPORT const std::string & | GetInteractionTypeAsString (InteractionType interactionType) |
| Converts an InteractionType to a corresponding string representation. More... | |
| MITKPYTHONSEGMENTATION_EXPORT const std::array< InteractionType, 4 > & | GetAllInteractionTypes () |
| Returns all possible interaction types. More... | |
| MITKPYTHONSEGMENTATION_EXPORT const std::string & | GetPromptTypeAsString (PromptType promptType) |
| Converts a PromptType to a corresponding string representation. More... | |
| MITKPYTHONSEGMENTATION_EXPORT const std::array< PromptType, 2 > & | GetAllPromptTypes () |
| Returns all possible prompt types. More... | |
| MITKPYTHONSEGMENTATION_EXPORT const std::string & | GetBackendAsString (Backend backend) |
| Converts a Backend type to a corresponding string representation. More... | |
| MITKPYTHONSEGMENTATION_EXPORT const std::array< Backend, 2 > & | GetAllBackends () |
| Returns all possible backend types. More... | |
| MITKPYTHONSEGMENTATION_EXPORT const Color & | GetColor (PromptType promptType, ColorIntensity colorIntensity) |
| Returns the color associated with a specific prompt type and color intensity. More... | |
| MITKPYTHONSEGMENTATION_EXPORT VersionCheckResult | CheckInstalledVersion (PythonContext &context, bool checkForUpdate=true, const std::string &distributionName="nnInteractive") |
| Compares the installed nnInteractive package against the supported version range, using the given Python context. More... | |
| MITKPYTHONSEGMENTATION_EXPORT VersionCheckResult | CheckInstalledVersion (bool checkForUpdate=true, const std::string &distributionName="nnInteractive") |
| Convenience overload for callers without a Python context. More... | |
| bool | ComputeStrokeBoundingBox (const Image *paintingSlice2D, const Image *referenceImage, InteractionBoundingBox &outBoundingBox) |
| Image::Pointer | BuildBoundingBoxMaskImage (const Image *paintingSlice2D, const PlaneGeometry *slicingPlane, const Image *referenceImage, const InteractionBoundingBox &boundingBox) |
| void | HideNodeIn3DRenderWindows (DataNode *node) |
| MITKPYTHONSEGMENTATIONUI_EXPORT PipInstallSpec | BuildInstallSpec (IPreferences *prefs, const std::string &venvName, bool clientOnly) |
| Builds the pip install spec for a fresh nnInteractive install. More... | |
| MITKPYTHONSEGMENTATIONUI_EXPORT PipInstallSpec | BuildUpgradeSpec (const std::string &venvName, bool clientOnly) |
| Builds the pip spec for an in-place update of an existing install. More... | |
| MITKPYTHONSEGMENTATIONUI_EXPORT std::vector< ModelInfo > | ListModels (const std::string &venvName, ModelListStatus *status=nullptr, QWidget *parent=nullptr) |
| Lists the model checkpoints known to nnInteractive's model management. More... | |
| MITKPYTHONSEGMENTATIONUI_EXPORT ModelCheckResult | CheckModelUpdate (const std::string &venvName, const std::string &selectedModelId, QWidget *parent=nullptr) |
| Checks whether a checkpoint newer than the selected one is recommended. More... | |
| MITKPYTHONSEGMENTATIONUI_EXPORT UpdatePromptChoice | ShowUpdatePrompt (QWidget *parent, const VersionCheckResult &result, bool modulesLoaded, bool inInitFlow) |
| Shows the standard nnInteractive version-status dialog and returns the user's choice. More... | |
Variables | |
| constexpr const char * | MINIMUM_VERSION |
| Minimum nnInteractive version this MITK build supports. More... | |
| constexpr const char * | MAXIMUM_VERSION_EXCLUSIVE |
| Exclusive upper bound on the supported nnInteractive version (the next major release is assumed to break compatibility). More... | |
| using mitk::nnInteractive::InteractionBoundingBox = typedef std::array<std::array<int, 2>, 3> |
Definition at line 26 of file mitknnInteractiveBoundingBox.h.
|
strong |
Specifies the computation backends available for nnInteractive.
Backends define the computational resources used, such as GPU (CUDA) or CPU for processing.
| Enumerator | |
|---|---|
| CUDA | CUDA backend for GPU computation (fast) |
| CPU | Backend for CPU computation (slow) |
Definition at line 105 of file mitknnInteractiveEnums.h.
|
strong |
Specifies the intensity of the colors used in an interaction.
| Enumerator | |
|---|---|
| Muted | Muted color intensity |
| Vibrant | Vibrant color intensity |
Definition at line 132 of file mitknnInteractiveEnums.h.
|
strong |
Specifies the types of interactions available.
Interaction types represent the different modes of interaction for prompting available in nnInteractive, each corresponding to a specific user action.
| Enumerator | |
|---|---|
| Point | Interaction for placing individual points |
| Box | Interaction for drawing rectangular boxes |
| Scribble | Interaction for freehand brushstrokes |
| Lasso | Interaction for drawing contours |
Definition at line 34 of file mitknnInteractiveEnums.h.
|
strong |
Outcome of a ListModels() query, distinguishing an empty manifest from a hard failure.
| Enumerator | |
|---|---|
| Ok | The query ran and returned at least one model. |
| Empty | The query ran but the manifest contains no models. |
| Failed | The query could not run (no environment, offline, no model management). |
Definition at line 63 of file mitknnInteractiveModel.h.
|
strong |
Outcome of comparing the selected checkpoint against the library's recommended default.
Definition at line 45 of file mitknnInteractiveModel.h.
|
strong |
Specifies the types of prompts used in nnInteractive.
Prompt types distinguish between positive and negative prompts, e.g., should the labeled region by an interaction be included in or excluded from the resulting segmentation.
| Enumerator | |
|---|---|
| Positive | Include region in segmentation |
| Negative | Exclude region from segmentation |
Definition at line 71 of file mitknnInteractiveEnums.h.
|
strong |
The user's response to the version-update prompt.
| Enumerator | |
|---|---|
| Update | Run the in-place update now. |
| ContinueInstalled | Keep using the installed version. |
| Cancel | Do nothing / abort the surrounding flow. |
Definition at line 27 of file mitknnInteractiveUpdatePrompt.h.
|
strong |
Outcome of comparing the installed nnInteractive package against the version range this MITK build supports.
Definition at line 31 of file mitknnInteractiveVersion.h.
| Image::Pointer mitk::nnInteractive::BuildBoundingBoxMaskImage | ( | const Image * | paintingSlice2D, |
| const PlaneGeometry * | slicingPlane, | ||
| const Image * | referenceImage, | ||
| const InteractionBoundingBox & | boundingBox | ||
| ) |
| MITKPYTHONSEGMENTATIONUI_EXPORT PipInstallSpec mitk::nnInteractive::BuildInstallSpec | ( | IPreferences * | prefs, |
| const std::string & | venvName, | ||
| bool | clientOnly | ||
| ) |
Builds the pip install spec for a fresh nnInteractive install.
Full mode installs PyTorch and nnInteractive and queues a post-install step that pre-downloads the model checkpoint (unless a local checkpoint folder is configured); client-only mode installs just the lightweight, torch-free nninteractive-client. On Windows the torch group uses the CUDA wheel index.
| [in] | prefs | Preferences used to resolve the model source and checkpoint for the pre-download step (may be nullptr to skip it). |
| [in] | venvName | Virtual environment to create and install into. |
| [in] | clientOnly | Whether to build a client-only (remote) install. |
| MITKPYTHONSEGMENTATIONUI_EXPORT PipInstallSpec mitk::nnInteractive::BuildUpgradeSpec | ( | const std::string & | venvName, |
| bool | clientOnly | ||
| ) |
Builds the pip spec for an in-place update of an existing install.
Reuses the resolve-then-install engine with –upgrade; the venv already exists, so pip is not upgraded first. On Windows the torch group is upgraded from the CUDA wheel index so a transitive torch bump cannot pull a non-CUDA wheel from PyPI.
| [in] | venvName | Existing virtual environment to upgrade in place. |
| [in] | clientOnly | Whether this upgrades nninteractive-client (vs nnInteractive). |
| MITKPYTHONSEGMENTATION_EXPORT VersionCheckResult mitk::nnInteractive::CheckInstalledVersion | ( | bool | checkForUpdate = true, |
| const std::string & | distributionName = "nnInteractive" |
||
| ) |
Convenience overload for callers without a Python context.
Creates and activates a transient Python context for the nnInteractive virtual environment, then forwards to the context-taking overload. If the context cannot be created (e.g. the virtual environment is missing or the interpreter fails to initialize), the result Status is Unknown.
| [in] | checkForUpdate | Whether to query PyPI for a newer release. |
| [in] | distributionName | The installed pip distribution to query ("nnInteractive" for a full install, "nninteractive-client" for a client-only install). |
| MITKPYTHONSEGMENTATION_EXPORT VersionCheckResult mitk::nnInteractive::CheckInstalledVersion | ( | PythonContext & | context, |
| bool | checkForUpdate = true, |
||
| const std::string & | distributionName = "nnInteractive" |
||
| ) |
Compares the installed nnInteractive package against the supported version range, using the given Python context.
Reads the installed version via importlib.metadata and compares it with MINIMUM_VERSION using packaging's version semantics. When checkForUpdate is true and the installed version meets the minimum, it additionally queries PyPI (best-effort, short timeout) for the newest release within the supported range to spot an available update; the query is skipped when the installed version is already below the minimum (it is going to be reinstalled anyway) and on any network failure, so the offline verdict is always fast and reliable. Pass false to do the offline minimum check only (the caller has already performed the update check this run, so the network round-trip would be wasted).
A successful update query sets VersionCheckResult::Latest to the newest in-range release (equal to the installed version when it is already the newest); a network failure leaves it empty. So an UpToDate result with a non-empty Latest means PyPI was actually reached, an empty one means it was not, which lets a caller distinguish a confirmed up-to-date verdict from an offline check.
| [in] | context | An activated Python context bound to the nnInteractive virtual environment. |
| [in] | checkForUpdate | Whether to query PyPI for a newer release. |
| [in] | distributionName | The installed pip distribution to query. The full install registers the distribution "nnInteractive"; a client-only install registers "nninteractive-client". The shared "nnInteractive" import namespace is the same for both, so the distribution name (not the import name) must be used here for importlib.metadata and the PyPI lookup. Only C++-controlled literals are ever passed. |
| MITKPYTHONSEGMENTATIONUI_EXPORT ModelCheckResult mitk::nnInteractive::CheckModelUpdate | ( | const std::string & | venvName, |
| const std::string & | selectedModelId, | ||
| QWidget * | parent = nullptr |
||
| ) |
Checks whether a checkpoint newer than the selected one is recommended.
Compares selectedModelId against get_default_model_id() (queried in a subprocess, see ListModels()): the result is UpdateAvailable when the default is non-empty and differs from the selection, UpToDate when they match (or when the selection is empty, i.e. already tracking the default), and Unknown on any failure (offline, no model management). It deliberately does not parse version suffixes; "newer" means "the library now recommends a different default
checkpoint".
While it runs, a modal progress dialog parented to parent keeps the UI responsive and lets the user cancel (a cancel is reported as Unknown).
| [in] | venvName | The nnInteractive virtual environment to query. |
| [in] | selectedModelId | The model id currently configured (may be empty to mean "use the recommended default"). |
| [in] | parent | Widget the modal progress dialog is parented to (may be nullptr). |
| bool mitk::nnInteractive::ComputeStrokeBoundingBox | ( | const Image * | paintingSlice2D, |
| const Image * | referenceImage, | ||
| InteractionBoundingBox & | outBoundingBox | ||
| ) |
| MITKPYTHONSEGMENTATION_EXPORT const std::array<Backend, 2>& mitk::nnInteractive::GetAllBackends | ( | ) |
Returns all possible backend types.
| MITKPYTHONSEGMENTATION_EXPORT const std::array<InteractionType, 4>& mitk::nnInteractive::GetAllInteractionTypes | ( | ) |
Returns all possible interaction types.
| MITKPYTHONSEGMENTATION_EXPORT const std::array<PromptType, 2>& mitk::nnInteractive::GetAllPromptTypes | ( | ) |
Returns all possible prompt types.
| MITKPYTHONSEGMENTATION_EXPORT const std::string& mitk::nnInteractive::GetBackendAsString | ( | Backend | backend | ) |
Converts a Backend type to a corresponding string representation.
| [in] | backend | The backend type to convert. |
| std::out_of_range | if the backend type is out of the valid range. |
| MITKPYTHONSEGMENTATION_EXPORT const Color& mitk::nnInteractive::GetColor | ( | PromptType | promptType, |
| ColorIntensity | colorIntensity | ||
| ) |
Returns the color associated with a specific prompt type and color intensity.
Use this function for color lookup to ensure a coherent color scheme across different interactors. Positive prompts use green tones, negative prompts use red tones.
| [in] | promptType | The prompt type determining the base color hue. |
| [in] | colorIntensity | The color intensity variant (muted or vibrant). |
| MITKPYTHONSEGMENTATION_EXPORT const std::string& mitk::nnInteractive::GetInteractionTypeAsString | ( | InteractionType | interactionType | ) |
Converts an InteractionType to a corresponding string representation.
| [in] | interactionType | The interaction type to convert. |
| std::out_of_range | if the interaction type is out of the valid range. |
| MITKPYTHONSEGMENTATION_EXPORT const std::string& mitk::nnInteractive::GetPromptTypeAsString | ( | PromptType | promptType | ) |
Converts a PromptType to a corresponding string representation.
| [in] | promptType | The prompt type to convert. |
| std::out_of_range | if the prompt type is out of the valid range. |
| void mitk::nnInteractive::HideNodeIn3DRenderWindows | ( | DataNode * | node | ) |
| MITKPYTHONSEGMENTATIONUI_EXPORT std::vector<ModelInfo> mitk::nnInteractive::ListModels | ( | const std::string & | venvName, |
| ModelListStatus * | status = nullptr, |
||
| QWidget * | parent = nullptr |
||
| ) |
Lists the model checkpoints known to nnInteractive's model management.
Runs nnInteractive.model_management.list_models() in a short-lived subprocess driven by the virtual environment's own Python interpreter, rather than the embedded interpreter. This keeps model management (and its transitive native dependencies, e.g. PyYAML) out of the host process, so it never maps libraries from the virtual environment that would block a later in-place update on Windows. The call refreshes the model manifest from Hugging Face (remote-first, with an offline cache fallback).
Returns an empty list when the virtual environment or its interpreter is missing, model management is unavailable (a client-only install), or the query fails, so callers can treat "no models" as "fall back to free-text
entry". Pass status to tell a genuinely empty manifest (Empty) apart from a failure to query at all (Failed); both yield an empty list.
While it runs, a modal progress dialog parented to parent keeps the UI responsive and lets the user cancel (a cancel is reported as Failed).
| [in] | venvName | The nnInteractive virtual environment to query. |
| [out] | status | Optional; set to Ok, Empty, or Failed (may be nullptr). |
| [in] | parent | Widget the modal progress dialog is parented to (may be nullptr). |
| MITKPYTHONSEGMENTATIONUI_EXPORT UpdatePromptChoice mitk::nnInteractive::ShowUpdatePrompt | ( | QWidget * | parent, |
| const VersionCheckResult & | result, | ||
| bool | modulesLoaded, | ||
| bool | inInitFlow | ||
| ) |
Shows the standard nnInteractive version-status dialog and returns the user's choice.
Handles the BelowMinimum and UpdateAvailable verdicts (read from result.Status); passing any other status is a usage error. The wording and the available buttons adapt to two flags:
modulesLoaded: nnInteractive is already imported into this process, so an in-place update would fail on Windows (locked files). The dialog then offers no "Update now" and asks the user to restart first.inInitFlow: shown during initialization, where declining still proceeds with the working installed version (offers "Continue with installed", which maps to ContinueInstalled). When false (the preferences page), declining simply closes the dialog.The application name used in the restart hint is read from QCoreApplication.
| [in] | parent | Dialog parent (may be nullptr). |
| [in] | result | Version check verdict; only BelowMinimum / UpdateAvailable. |
| [in] | modulesLoaded | Whether nnInteractive modules are loaded in-process. |
| [in] | inInitFlow | Whether the prompt is shown during initialization. |
|
inlineconstexpr |
Exclusive upper bound on the supported nnInteractive version (the next major release is assumed to break compatibility).
Definition at line 60 of file mitknnInteractiveVersion.h.
|
inlineconstexpr |
Minimum nnInteractive version this MITK build supports.
Used both to build the pip requirement at install time and to detect a too-old package left behind in a reused virtual environment (see CheckInstalledVersion()). Keep in sync with the install requirement.
Definition at line 55 of file mitknnInteractiveVersion.h.