Skip to main content

MedICS Extension SDK

PyPI version Python License: MIT

Python SDK for building extensions for the MedICS (Medical Image Computing and Segmentation) platform. Provides base classes, API utilities, and a CLI scaffolding tool.


Installation

pip install medics-extension-sdk

With Qt support (required for widget-based extensions):

pip install medics-extension-sdk[qt]      # PySide6 (recommended)
pip install medics-extension-sdk[pyqt6]   # PyQt6
pip install medics-extension-sdk[qt5]     # PyQt5 (legacy)

Development tools:

pip install medics-extension-sdk[dev]

Quick Start

1. Create an extension class

from medics_extension_sdk import BaseExtension

class MyExtension(BaseExtension):
    def __init__(self, parent=None):
        super().__init__(
            parent=parent,
            extension_name="My Extension",
            author_name="Your Name",
        )

    def get_version(self) -> str:
        return "1.0.0"

    def get_description(self) -> str:
        return "Does something useful with medical images"

    def get_category(self) -> str:
        return "Analysis"

    def create_widget(self, parent=None, **kwargs):
        from PySide6.QtWidgets import QLabel
        return QLabel("Hello from My Extension!")

The extension id is automatically derived: "your_name.my_extension".

2. Access platform services

# Inside any extension method:
self.log_message("Processing started")
value = self.get_config_value("my_ext", "threshold", 0.5)
self.set_config_value("my_ext", "threshold", 0.8)
self.send_event("processing_done", {"status": "ok"})
workspace = self.get_component("workspace_manager")

3. Expose a programmatic API

Decorate public methods with @api_method so they are auto-discovered at runtime:

from medics_extension_sdk import BaseExtension, api_method

class MyExtension(BaseExtension):
    ...

    @api_method(description="Run analysis and return results", category="Processing")
    def run_analysis(self, threshold: float = 0.5) -> dict:
        return {"threshold": threshold, "result": "ok"}

Retrieve the API from an instance:

ext = MyExtension()
api = ext.get_instance_api()   # returns apiDict of decorated callables
api.run_analysis(threshold=0.7)

Scaffolding

Generate a new extension template with the CLI:

medics-create-extension "My Segmentation Tool" \
    --author "Jane Doe" \
    --category "Segmentation" \
    --output ./extensions

This creates a fully-structured extension directory with a main class, widget, API methods, config file, and README.


API Reference

BaseExtension

Member Type Description
id str (read-only) Auto-generated from author_name.extension_name
extension_name str (read-only) Set in __init__
author_name str (read-only) Set in __init__
app_context Any Injected by the platform on initialize()
get_version() abstract Return version string
get_description() abstract Return short description
get_category() str Extension category (default: "General")
create_widget(parent, **kwargs) QWidget Override to provide Qt UI
initialize(app_context) bool Called by platform at load time
cleanup() None Called by platform at unload time
get_instance_api() apiDict Returns dict of @api_method callables

ID format: {author_name}.{extension_name} — lowercased, spaces removed, non-alphanumeric characters replaced with _.

@api_method(description, category)

Marks a method for auto-discovery via get_instance_api().

apiDict

dict subclass with dot-notation attribute access.


Extension Categories

Standard categories for organizing extensions in the platform UI:

  • "Analysis" — measurement and analysis tools
  • "Segmentation" — segmentation algorithms
  • "Visualization" — rendering and display
  • "Processing" — image filters and transforms
  • "Import/Export" — data I/O utilities
  • "Workflow" — automation and pipeline tools
  • "Utilities" — general helpers
  • "Research" — experimental tools

Testing

import pytest
from medics_extension_sdk import BaseExtension

class MyExtension(BaseExtension):
    def __init__(self):
        super().__init__(extension_name="My Ext", author_name="Author")
    def get_version(self): return "1.0.0"
    def get_description(self): return "Test"

def test_id_readonly():
    ext = MyExtension()
    assert ext.id == "author.my_ext"
    with pytest.raises(AttributeError):
        ext.id = "hacked"

Run:

pytest tests/

Project Layout

Recommended structure for a published extension package:

my_extension/
+-- __init__.py          # exports Extension = MyExtensionClass
+-- my_extension.py      # main extension class
+-- icons/               # optional icon assets
+-- config.ini           # default configuration
+-- README.md

License

MIT - see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

medics_extension_sdk-2026.7.7.tar.gz (111.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

medics_extension_sdk-2026.7.7-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file medics_extension_sdk-2026.7.7.tar.gz.

File metadata

  • Download URL: medics_extension_sdk-2026.7.7.tar.gz
  • Upload date:
  • Size: 111.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for medics_extension_sdk-2026.7.7.tar.gz
Algorithm Hash digest
SHA256 483241841e454220f1fb9a8a3883525851471c59315b4ea46df45f4cfcec36d6
MD5 357d47bb0565877b715dc5cf3d4514ac
BLAKE2b-256 c94cf1203f0dc7af58d7d8caad45033500b429470cb9f2cc8a230993b4998a08

See more details on using hashes here.

File details

Details for the file medics_extension_sdk-2026.7.7-py3-none-any.whl.

File metadata

File hashes

Hashes for medics_extension_sdk-2026.7.7-py3-none-any.whl
Algorithm Hash digest
SHA256 db422cbeac7fb1b86cac36d6b15b65d8b2088a1fdc99a421fe04429391e119d7
MD5 f9f2450afa2a56b44b498c90dd526dcf
BLAKE2b-256 3cc0a36201410821d5d242d2bda74fe18e8f2b6a5d918dfd5c7393b1c1ae748e

See more details on using hashes here.

Release history Release notifications | RSS feed

2026.7.7.4

2 files

This release

2026.7.7 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page