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
- Install MedICS and this extension.
- Launch MedICS:
medics. - 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).
- 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.
- Optionally adjust preprocessing on the side panel (flatten, permute, flip, ROI, resolution).
- Click Run AI Segmentation in the side panel and choose the compute device.
- Review the detected boundaries, toggle layers on/off, and use the curve editor or corrector to refine any boundary if needed.
- Use Save to WS to transfer
oct_data,octa_data, andseg_databack into the MedICS workspace, or Save to write results to files.
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-onlyonnxruntimeis installed. On Linux/Windows with an NVIDIA GPU, installonnxruntime-gpu(and uninstall plainonnxruntimeso they do not conflict). - Log / crash:
CUDNN_FE failure/CUDNN_BACKEND_API_FAILED/CUDNN_STATUS_EXECUTION_FAILEDon aConvnode → 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:
-
Read the ORT CUDA EP page for the ORT version → required CUDA / cuDNN.
-
Confirm your driver supports that CUDA major (
nvidia-smi). -
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.xfor Pascal). Example:pip uninstall -y onnxruntime onnxruntime-gpu pip install 'onnxruntime-gpu==1.18.0'
-
Ensure CUDA/cuDNN libraries for that ORT major are on the library path (
LD_LIBRARY_PATHon Linux, or use wheels that bundle them). -
Verify:
python -c "import onnxruntime as ort; print(ort.__version__); print(ort.get_available_providers())"
You want
CUDAExecutionProviderlisted. 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.27with matchingnvidia-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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file medics_ext_retinal_layer_segmentation-202608240142-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-202608240142-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a36acc24b5f941f3530b9a441e3510290409d7fb9d77fd217986f3faff3068fc
|
|
| MD5 |
28e7e4f4db0d5bf06730982ce96e6bd1
|
|
| BLAKE2b-256 |
83f3d899ec0eaa2e27e976406e1426331b5c32b3ef14ddff88620290aa1e252c
|
File details
Details for the file medics_ext_retinal_layer_segmentation-202608240142-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-202608240142-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d54f2a74a38499c8ead9e13ac5a115973a1a400d07f07b14d5868c161dc9682
|
|
| MD5 |
e02dcaeaf8d3366b411665345a3b56d7
|
|
| BLAKE2b-256 |
c51cc727f4366b145551d273494cdf8c29be089629453d220692691541107b56
|
File details
Details for the file medics_ext_retinal_layer_segmentation-202608240142-cp311-cp311-macosx_10_9_universal2.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-202608240142-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49d6ce9aa92d9b5e7e72e328110bcf6008b093b9e8b7a11148a2edab9e5c9c8b
|
|
| MD5 |
c5e5b56dc559a5c4ebbab61ad917a683
|
|
| BLAKE2b-256 |
58d628866e3308c82314cf3358c82959b20bc9cb0415836d2dc1bb4f9027650d
|