Skip to main content

MedICS Extension: Retinal Layer Segmentation

AI-based retinal layer segmentation for OCT volumes, built as a MedICS extension. It automatically detects the anatomical layers of the retina from OCT data and provides interactive tools to review, correct, quantify, and export the results.

Overview

This extension turns an OCT volume into a fully segmented retina. It runs a deep-learning model (ONNX, executed with ONNX Runtime) on each B-scan to detect up to 14 retinal boundaries, then reconstructs the boundaries into smooth layer curves, detects intraretinal fluid, and builds a 3D representation of the layers across the whole volume.

Everything runs inside a dedicated "OCT Analyzer" window:

  • Load data from the MedICS workspace, from files on disk, or by dragging files onto the window (OCT, OCTA and existing segmentation data).
  • Run AI segmentation with one click, optionally accelerated by a GPU (CUDA / DirectML / CoreML) with automatic CPU fallback.
  • Review and edit the detected boundaries with a curve editor, layer visibility toggles, and a manual corrector.
  • Interpolate the segmentation between sparse B-scans for a dense volume.
  • Visualize the result as B-scans with overlaid curves, en-face views, and an interactive 3D surface reconstruction (VTK).
  • Export the layer curves, fluid mask, and data back to the MedICS workspace or to files for downstream analysis.

The segmentation is computed locally — OCT/OCTA images never leave the machine.

Supported layer boundaries

The model detects the following anatomical boundaries in each B-scan:

# Boundary # Boundary
0 PVD* 7 ELM*
1 ILM 8 EZ
2 NFL/GCL 9 EZ/IZ*
3 GCL/IPL* 10 IZ/RPE
4 IPL/INL 11 RPE/BM
5 INL/OPL 12 SAT/HAL*
6 OPL/ONL 13 CHOROID

Note: * labeled boundaries are not implemented yet.

Each boundary can be toggled on/off individually for display and export, and any boundary may be edited manually after segmentation.

Features

  • One-click AI segmentation of OCT/OCTA volumes (ONNX Runtime).
  • Up to 14 automatically detected retinal layer boundaries.
  • Intraretinal fluid detection with an optional fluid volume mask.
  • Interactive curve editor for manual refinement of any boundary.
  • Layer-by-layer visibility control and "Select All" convenience.
  • Interpolation between sparse B-scans (configurable step) with restart.
  • 3D surface / en-face visualization of the segmented volume (VTK).
  • Preprocessing controls: flattening (None / Fitting / RPE-BM), axis permute, axis flip, ROI (manual or auto), and scan resolution update.
  • B-frame navigation across the volume (frame index, total frames).
  • Sparse data mode for memory-efficient processing of large volumes.
  • GPU acceleration via CUDA, DirectML, or CoreML, with CPU fallback and a device selector.
  • Drag-and-drop data loading, plus loading from the MedICS workspace or files.
  • Save results to files or transfer curves/masks back to the MedICS workspace.
  • Data resolution helper for aligning volumes acquired at different scales.

Installation

From PyPI

pip install medics-ext-retinal-layer-segmentation

Usage

  1. Install MedICS and this extension.
  2. Launch MedICS: medics.
  3. Open the extension from the Extensions menu (a valid, non-free MedICS token is required; free or invalid tokens are blocked with a warning dialog).
  4. Load an OCT volume — pick it from the workspace, click the file buttons on the File tab, or drag it onto the window. Optionally load matching OCTA or existing segmentation data as well. See the data source panel below.
  5. Optionally adjust preprocessing on the side panel (flatten, permute, flip, ROI, resolution).
  6. Click Run AI Segmentation in the side panel and choose the compute device.
  7. Review the detected boundaries, toggle layers on/off, and use the curve editor or corrector to refine any boundary if needed.
  8. Use Save to WS to transfer oct_data, octa_data, and seg_data back into the MedICS workspace, or Save to write results to files.

Data source panel

The Data Source panel at the top of the side bar has three tabs for loading input data: Workspace, File, and Save to WS.

File tab — OCT / OCTA / Segment buttons

Use the folder buttons next to each field to pick a file from disk, or type a path directly, then click Load Data to read everything at once. The checkbox next to OCTA lets you load OCT-only data by unchecking it.

Button Loads Supported formats
OCT OCT volume (B-scans) .foct, .oct, .dcm, .mat, .tif / .tiff
OCTA OCTA volume (angiography) .ssada, .octa, .dcm, .mat, .tif / .tiff
Segment Existing layer-segmentation curves (the layer curves detected in a previous run) .json, .dcm, .mat, .med

You can also drag and drop OCT / OCTA / segmentation files directly onto the Load Data button; dropped files are matched by filename pattern and routed to the right loader automatically.

Workspace tab

The OCT, OCTA, and Segment dropdowns list matching datasets that already exist in the current MedICS workspace. Pick one (or more) and they are used as the input volume, the co-registered angiography volume, and any previous segmentation curves, respectively. Use the refresh button to rescan the workspace.

Save to WS tab

The OCT, OCTA, and Segment rows transfer the currently loaded oct_data, octa_data, and seg_data back into the MedICS workspace under the names shown in the text fields (editable), so other MedICS tools can pick them up for further analysis.

Troubleshooting

GPU / CUDA not used, or segmentation crashes on Conv / cuDNN

AI segmentation uses ONNX Runtime with an optional NVIDIA CUDA provider. The stack only works when these three pieces match each other and your GPU architecture / driver:

Piece What to check
GPU + driver nvidia-smi — note the GPU name and the reported CUDA Version (max toolkit the driver supports).
onnxruntime-gpu Must be a GPU wheel (not CPU-only onnxruntime). Version chooses which CUDA major it expects.
CUDA / cuDNN Either system installs or the pip extras (onnxruntime-gpu[cuda,cudnn] + nvidia-cudnn-*). Major versions must match the ORT build.

Official compatibility matrix: ONNX Runtime CUDA Execution Provider

Typical symptoms

  • Log: CUDA unavailable (onnxruntime build has no CUDA provider); using CPU → CPU-only onnxruntime is installed. On Linux/Windows with an NVIDIA GPU, install onnxruntime-gpu (and uninstall plain onnxruntime so they do not conflict).
  • Log / crash: CUDNN_FE failure / CUDNN_BACKEND_API_FAILED / CUDNN_STATUS_EXECUTION_FAILED on a Conv node → CUDA loaded, but the cuDNN kernels do not support this GPU (common on older cards) or the cuDNN minor is incompatible with ORT.

Older GPUs (e.g. Pascal: GTX 10-series)

Cards such as the GTX 1080 (compute capability 6.1) are too old for current cuDNN 9 + recent onnxruntime-gpu Conv paths. NVIDIA dropped pre-Turing architectures in newer cuDNN releases, so even a working driver and CUDA toolkit may still fail at inference.

On this extension, that case is handled by automatic CPU fallback after a CUDA warm-up, so MedICS should not crash — but segmentation will run on CPU.

If you still want GPU on an older card, you must pick an older stack that still targets that architecture, for example:

  1. Read the ORT CUDA EP page for the ORT version → required CUDA / cuDNN.

  2. Confirm your driver supports that CUDA major (nvidia-smi).

  3. Install a matching wheel, e.g. try an older GPU build that predates cuDNN Frontend-heavy Conv (community reports often cite ~onnxruntime-gpu==1.18.x for Pascal). Example:

    pip uninstall -y onnxruntime onnxruntime-gpu
    pip install 'onnxruntime-gpu==1.18.0'
    
  4. Ensure CUDA/cuDNN libraries for that ORT major are on the library path (LD_LIBRARY_PATH on Linux, or use wheels that bundle them).

  5. Verify:

    python -c "import onnxruntime as ort; print(ort.__version__); print(ort.get_available_providers())"
    

    You want CUDAExecutionProvider listed. Then re-run AI segmentation.

Newer GPUs / drivers (quick guide)

  • Driver shows CUDA 12.x → prefer onnxruntime-gpu < 1.27 (CUDA 12 builds). ORT ≥ 1.27 defaults to CUDA 13 and needs a newer driver.
  • Driver shows CUDA 13.x → onnxruntime-gpu>=1.27 with matching nvidia-cudnn-cu13 (this project pins cuDNN 9.14 on Windows to avoid flaky Conv engines on some Ada GPUs).
  • When in doubt: match versions from the ORT docs table, then test providers and a short inference before processing a full volume.

Force CPU

Set MEDICS_EXT_DISABLE_GPU=1 to skip GPU entirely, or choose CPU in the extension device selector.

Metadata

Release files for medics-ext-retinal-layer-segmentation 202610082114

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for medics-ext-retinal-layer-segmentation 202610082114
File Interpreter ABI Platform
medics_ext_retinal_layer_segmentation-202610082114-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
medics_ext_retinal_layer_segmentation-202610082114-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
medics_ext_retinal_layer_segmentation-202610082114-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details

Total release size: 5.2 MB

Release files / medics_ext_retinal_layer_segmentation-202610082114-cp313-cp313-win_amd64.whl

Download URL medics_ext_retinal_layer_segmentation-202610082114-cp313-cp313-win_amd64.whl
Size 1.7 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
1155a520912e84d268f4a1d221eb764dc3703b11cdc57dbffe45f2e0eeaff882
BLAKE2b-256 checksum
How to use checksums
4ff8ae168808f0f4491ac91051bec300d0b2906e6f730ffa317e6f70e60df6cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / medics_ext_retinal_layer_segmentation-202610082114-cp312-cp312-win_amd64.whl

Download URL medics_ext_retinal_layer_segmentation-202610082114-cp312-cp312-win_amd64.whl
Size 1.7 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
1f930ecf152f2362ec3ddd28193853ad686470b592fe50c4adff5ac659065506
BLAKE2b-256 checksum
How to use checksums
7b40afb0a7c7adbdb687cbf24bb4dac1bcb2826ff9aee5b0e44c73c59c3024f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / medics_ext_retinal_layer_segmentation-202610082114-cp311-cp311-win_amd64.whl

Download URL medics_ext_retinal_layer_segmentation-202610082114-cp311-cp311-win_amd64.whl
Size 1.8 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
93772c8643902e36fb3b2289ba7c4c3dce9c0406c213689c33617fe940103481
BLAKE2b-256 checksum
How to use checksums
45dae9f33af362d1aef8b0814f5c2c7f06ed7dd305d04e01576f0710d8266ce7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14
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