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.xonnxruntime-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.

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

medics_ext_retinal_layer_segmentation-202608282347-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

medics_ext_retinal_layer_segmentation-202608282347-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

medics_ext_retinal_layer_segmentation-202608282347-cp311-cp311-macosx_10_9_universal2.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file medics_ext_retinal_layer_segmentation-202608282347-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for medics_ext_retinal_layer_segmentation-202608282347-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f0cd87419c11b25c31ac7e82b0dae85a473e6311b3ed49c45e86aecd773ce232
MD5 ee9344b6502b93a86378b6ea5ed5f08a
BLAKE2b-256 5829cd9d34c57c712e19aa96351be4fc5a746d22930134691b23234d6a917ac2

See more details on using hashes here.

File details

Details for the file medics_ext_retinal_layer_segmentation-202608282347-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for medics_ext_retinal_layer_segmentation-202608282347-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 560f915a06202afa44a09f6cca61d410779488725dc14c27422bcd379c888f71
MD5 21d2ead52f5e0acf0c645759eb072ee7
BLAKE2b-256 bec3ec586f2081f7958fff3dc3707f0d2b8b26515a57af58e07f1c6bbb4ccbc1

See more details on using hashes here.

File details

Details for the file medics_ext_retinal_layer_segmentation-202608282347-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for medics_ext_retinal_layer_segmentation-202608282347-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 5c7fedeaeb8f1b9defa3a76fd2f20f9db3edce261f0505a280e8c44c2e8b64b5
MD5 5f506fb213366d287bf1f074be349c10
BLAKE2b-256 ce5a4e4a885cc1498f15d2c774b03cafd1ef7ae63eab1090c86ca4d4d7a45e1e

See more details on using hashes here.

Release history Release notifications | RSS feed

202609012254

1 file

This release

202608282347 This release

3 files

202608250413

3 files

202608240142

3 files

20260823.438

3 files

2026.8.15

9 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