.. _extensions: Extensions ########## This section explains the types of Kaapana :term:`extensions` and how they work. For descriptions of available workflow and application extensions, refer to the :ref:`extensions_workflows` and :ref:`extensions_applications`. To learn how to integrate custom components into the platform as extensions, refer to the :ref:`application_dev_guide` and :ref:`workflow_dev_guide`. The *Extension* functional unit in Kaapana serves as an app store. It allows users to install/uninstall applications, workflows, and even platforms (experimental feature). Technically, an extension is a `Helm chart `_. Each extension in the Kaapana repository consists of two folders: :code:`docker` and :code:`-chart`. For more information about the file structure, refer to the Helm Charts section :ref:`helm_charts`. There are two types of extensions: 1. :term:`Workflow Extensions`: Consist of single or multiple executable DAGs in `Apache Airflow `_. After installing a workflow extension, you can see the DAGs available under Workflow Execution menu. 2. :term:`Applications`: These provide additional functionalities such as opening a VS Code server, a JupyterLab notebook, or an MITK Workbench instance. In addition to the distinction in type, there is also an distinction in maturiy, namely *stable* or *experimental*. Stable extensions **have been tested and maintained**, while experimental extensions are not. The filters on the Extensions page allow users to filter extensions based on type, maturiy, and hardware requirements, i.e. GPU or CPU. The extension list is updated in real time based on the selected filters. The Extensions page also displays the current Helm and Kubernetes status of each extension, such as :code:`Running`, :code:`Completed`, :code:`Failed`, or :code:`Error`. .. note:: Kaapana supports multi-installable extensions, which will have a "Launch" button instead of "Install". Each time a multi-installable extension is launched, it is deployed as a separate Helm release. .. hint:: To install a specific version of an extension, use the dropdown in the version column. The section :ref:`workflow_dev_guide` also explains how to write and add your own extensions. Uploading Extensions to the Platform ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Kaapana also provides an experimental upload component for extensions. This allows users to upload both Docker images and Helm charts to the platform. Currently, this component only accepts two file types: ".tar" for exported images and ".tgz" for Helm charts. This feature is intended to be used by **developers who have knowledge about configuring Helm charts and Kubernetes resources**. It is strongly recommended to read the following sections before uploading anything to platform: :ref:`helm_charts` and :ref:`how_to_dockerfile` **Chart Upload:** * Uploaded chart files are checked for basic safety measures, such as whether they are running any resource under the admin namespace. * To create a zipped chart file that can be uploaded to Kaapana, run the following Helm command inside the chart folder: :: helm dep up helm package . .. hint:: * If the build step is already completed, all the chart tgz files -and their respective folders- should be available under `kaapana/build/kaapana-admin-chart/kaapana-extension-collection/charts`. The structure should be the same with the DAGs and services already available there. * For any Kubernetes resource yaml inside the templates folder (i.e. deployment, job), the image tag should be referenced correctly (`example field that needs to be changed `_). **Image Upload:** * To save an image as a .tar file, use `docker `_ or `podman `_. * Uploaded images are automatically imported into the microk8s ctr environment (for details see the `images import command here `_) . * A useful command to check if the image is imported with the correct tag into the container runtime is :code:`microk8s ctr images ls | grep ` .. hint:: Since the images uploaded via this component are not already available in a registry, the imagePullPolicy field in the corresponding Kubernetes resource yaml files (`example value to be changed `_) should be changed to :code:`IfNotPresent`. If you have any issues regarding the upload mechanism, check :ref:`extension_container_upload_fail`. Extension Parameters ^^^^^^^^^^^^^^^^^^^^ Introduced in version 0.2.0, Extensions support specifying parameters as environment variables. This functionality can be customized according to the requirements of the extension. Some examples of available parameters are :code:`task_ID`s for **nnUNet** and the :code:`service_type`` field for **MITK Workbench**. Parameters can be of type :code:`string`, :code:`boolean`, :code:`single_selectable`, or :code:`multi_selectable`. Parameters should be defined in the values.yaml file of the chart. Each of them should follow this structure: .. code-block:: extension_params: : default: definition: "definition of the parameter" type: oneof (string, bool, list_single, list_multi) value: .. _extensions_workflows: Workflows ^^^^^^^^^ This is a list of built-in workflow-extensions, that can be installed. .. note:: The list of executable workflows in the :ref:`Workflow Execution ` view is only refreshed once every minute. This interval is configurable as the parameter ``dag_dir_list_interval`` in the file `airflow.cfg `_. .. _extensions_clf_inference: classification-inference ------------------------ | **Workflow Overview** | A classification inference pipeline based on a trained model is executed. | 1) DICOM data is fetched from the PACS | 2) DICOM data is converted to .nifti | 3) Images are preprocessed: resampled and normalized | 4) The model runs inference on the input data | 5) DICOM SEG objects are sent to the internal platform PACS | **Input data:** | A trained classification model checkpoint .. _extensions_clf_training: classification-training ------------------------ | **Workflow Overview** | A classification training pipeline based on ResNet18 is executed. The labels should be custom tags that can be added in the Datasets view. | 1) DICOM data is fetched from the PACS | 2) DICOM data is converted to .nifti | 3) Images are preprocessed: resampled and normalized | 4) The model is trained on the input data | 5) DICOM SEG objects are sent to the internal platform PACS | **Input data:** | A dataset with DICOM images and tags that represent the labels for classification. The tags should be added to the dataset in the Datasets view. body-and-organ-analysis ----------------------- | **Method:** "BOA: Body and Organ Analysis" | **Authors:** Haubold, J., Baldini, G., Parmar, V., Schaarschmidt, B. M., Koitka, S., Kroll, L., van Landeghem, N., Umutlu, L., Forsting, M., Nensa, F., & Hosch, R. | **Cite as:** Haubold, J., Baldini, G., Parmar, V., Schaarschmidt, B. M., Koitka, S., Kroll, L., van Landeghem, N., Umutlu, L., Forsting, M., Nensa, F., & Hosch, R. (2023). BOA: A CT-Based Body and Organ Analysis for Radiologists at the Point of Care. Investigative radiology, 10.1097/RLI.0000000000001040. Advance online publication. https://doi.org/10.1097/RLI.0000000000001040 | **Code:** `https://github.com/UMEssen/Body-and-Organ-Analysis/tree/main `_ **Workflow Overview:** Runs inference on the CT images using all selected models. Submodels associated with the **"total"** model are only executed if they are explicitly selected **and** the **"total"** model is selected. For each input series, a dedicated workflow is started. For more information, check out their `repository `_. #. Converts the DICOM input to a NIfTI file. #. Executes the BOA command line tool on the input image. #. Verifies the outputs: - Checks for invalid results, such as images with only background. - If *strict mode* is enabled, all `expected outputs `_ must be present to continue. #. Converts all NIfTI segmentation results into a single DICOM SEG file. #. Uploads the results: - The DICOM SEG file is uploaded to the PACS. - All other output files are uploaded to MinIO at :code:`/body-and-organ-analysis/`. .. _extensions_nnunet: nnunet-predict -------------- | **Method:** "Automated Design of Deep Learning Methods for Biomedical Image Segmentation" | **Authors:** Fabian Isensee, Paul F. Jäger, Simon A. A. Kohl, Jens Petersen, Klaus H. Maier-Hein | **Cite as:** `arXiv:1904.08128 [cs.CV] `_ | **Workflow Overview** | A nnU-Net inference is executed. | 1) Model is downloaded | 2) DICOM is converted to .nifti files | 3) The model runs inference on the input data | 4) Segmentations are converted to DICOM Segmentation (DICOM SEG) objects | 5) DICOM SEG objects are sent to the internal platform PACS | **Input data:** | A trained nnU-Net model that is already installed via *nnunet-install-model* workflow. nnunet-training --------------- | **Method:** "Automated Design of Deep Learning Methods for Biomedical Image Segmentation" | **Authors:** Fabian Isensee, Paul F. Jäger, Simon A. A. Kohl, Jens Petersen, Klaus H. Maier-Hein | **Cite as:** `arXiv:1904.08128 [cs.CV] `_ | **Workflow Overview** | A nnU-Net training is executed. | 1) Segmentation objects are downloaded | 2) Referenced DICOM images are downloaded | 3) DICOM images are converted to .nifti files | 4) Segmentation masks are converted to .nifti files | 5) If specified in input form, segmentation masks are filtered based on keywords "Keep: