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.4.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.4-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for medics_extension_sdk-2026.7.7.4.tar.gz
Algorithm Hash digest
SHA256 247cd18e5fa0ba65f93347062b8785624924454cd38f3f617e3812e5d6a2e219
MD5 c53aa8280453fb42ba75f79aabd75086
BLAKE2b-256 1406bff6a1643d39146ecad63218aad588a178c40f6effe8b8cc20645e3d565e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for medics_extension_sdk-2026.7.7.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a182d7df64e3d35fe05eea89567e3a971fc813475926ed129462edfa04bcdf69
MD5 53036c000289fd55db82b0d2bfda5df1
BLAKE2b-256 c6a7ca0d2356b1d0729efaae9a62c202e4b92e2867a4e16c2602460ec3b126aa

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2026.7.7.4 This release

2 files

2026.7.7

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