MedICS Extension: Retinal Layer Segmentation
AI-based retinal layer segmentation for OCT / OCTA volumes, built as a MedICS extension. It automatically detects the anatomical layers of the retina from optical coherence tomography 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 |
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
Verifying Installation
To verify that the model file reassembly works correctly:
python test_reassembly.py
Usage
- Install MedICS and this extension.
- Launch MedICS:
python -m 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.
Model distribution (maintainers)
The model folder is published with the GitHub Actions workflow
.github/workflows/release-model.yml. It pushes the model folder to the
separate model_zoo repository
(https://github.com/Medical-Image-Computing-Suite/model_zoo.git) — no GitHub
release is created.
-
Set up the token (once): create a Personal Access Token with
reposcope that can write toMedical-Image-Computing-Suite/model_zoo, and store it as a repository secret namedMODEL_ZOO_TOKENin this repository's settings. -
Trigger the workflow (Actions → "Publish Model to model_zoo" → Run workflow), optionally changing the target
model_zoobranch (defaultmain). -
The workflow validates the chunk MD5 checksums against
layersegmodel.meta.json, clonesmodel_zoo, and replaces the model-specific directorymedics_ext_retinal_layer_segmentation/layersegmodel/(chunks + metadata) with this repo's, then commits & pushes. -
The download URL in
medics_ext_retinal_layer_segmentation/extension.jsonpoints at this model's own directory inmodel_zoo. It is stable and needs no per-release updates:"model_download_url": "https://raw.githubusercontent.com/Medical-Image-Computing-Suite/model_zoo/main/medics_ext_retinal_layer_segmentation/layersegmodel"
The extension downloads each
layersegmodel.part*chunk from this URL on first use and reassembleslayersegmodel.encfrom them. Only this model's chunks are fetched — the model_zoo repository stores many models side by side, each under its ownmedics_ext_retinal_layer_segmentation/<model>directory, so other models' files are never downloaded. The model must be pushed tomodel_zooat least once (run the workflow) before the download works.
The model is distributed as the individual chunk files (each well under GitHub's 100 MB per-file limit) rather than a single archive, because a ~107 MB zip cannot be committed to a GitHub repository. If you prefer to do it manually instead of using the workflow:
git clone https://github.com/Medical-Image-Computing-Suite/model_zoo.git
DEST=model_zoo/medics_ext_retinal_layer_segmentation/layersegmodel
rm -rf "$DEST"
mkdir -p "$DEST"
cp medics_ext_retinal_layer_segmentation/model/chunks/* "$DEST/"
cd model_zoo
git add -A
git commit -m "Update retinal layer segmentation model"
git push origin main
When the model weights change, regenerate the chunks and their MD5 metadata first:
python split_model_file.py # splits medics_ext_retinal_layer_segmentation/model/layersegmodel.enc
python -c "from medics_ext_retinal_layer_segmentation.utils.model_reassembly import ensure_model_ready; print(ensure_model_ready())"
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-2026.8.15-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-2026.8.15-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ca93fb414623b68daedc11431389ead6e2fd5e5b6b9562c2df6da223ec13f3c
|
|
| MD5 |
4b7e045bd80063e5c89b355e657c6786
|
|
| BLAKE2b-256 |
08a9ee8de963bfa2ce7c610e1c9f9361060f0953bc18815c679b8f8ea79732da
|
File details
Details for the file medics_ext_retinal_layer_segmentation-2026.8.15-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-2026.8.15-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.13, 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 |
41e9815eebdacf7fb49d5a591166f16e1faf0695c354eae6aeb60f64d31b5f20
|
|
| MD5 |
d67f6e1ac1d13fedc79fc8a81d39376e
|
|
| BLAKE2b-256 |
8bc211c4412fa16bea0b40d4ecd0498b6db423ce204049d261b54f4aae21bc3e
|
File details
Details for the file medics_ext_retinal_layer_segmentation-2026.8.15-cp313-cp313-macosx_10_13_universal2.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-2026.8.15-cp313-cp313-macosx_10_13_universal2.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.13, macOS 10.13+ 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 |
8fc39eea4a6e3773a9c0fae8ea9e1e0edb9b33655aa8f7dcb65e0c15f127282f
|
|
| MD5 |
b3af4dfdc7807aa0bdc3d14bd60d23ea
|
|
| BLAKE2b-256 |
c43e57e96e559354a2cecf86ee9c2ab325c0392611795415754e4731007848ce
|
File details
Details for the file medics_ext_retinal_layer_segmentation-2026.8.15-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-2026.8.15-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0269cd0d0aa10c89f5baa17e151f4dac55837c1ccc9ba8ff8dbf7dbac6ad9b6
|
|
| MD5 |
4c09b03f1678669a27ec362e4cc6769b
|
|
| BLAKE2b-256 |
bdd838c07fc5f38f742dce0c3d97f0ba0ba77b95df9c0265210b3c5923512512
|
File details
Details for the file medics_ext_retinal_layer_segmentation-2026.8.15-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-2026.8.15-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.12, 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 |
07b32e5d5845e4d4c5822d19e0f506503bb8225465936342993624b99e857c64
|
|
| MD5 |
dc70837f397bfb8ad117f04bdcd4490e
|
|
| BLAKE2b-256 |
5c8cb72d7133a14e34992af1db5113d87b4e8b7e14cf568ca0a6afdc19fab441
|
File details
Details for the file medics_ext_retinal_layer_segmentation-2026.8.15-cp312-cp312-macosx_10_13_universal2.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-2026.8.15-cp312-cp312-macosx_10_13_universal2.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.12, macOS 10.13+ 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 |
4a6b82004eeb1121367709f3a969c7d01d8be46a57168d9c72316831fe99544c
|
|
| MD5 |
4ddd364e0cac85c5dab455eefbbe59d9
|
|
| BLAKE2b-256 |
b72c9db854df25039a723e354b13f0a873a88543ca896f6d4d7bfe19b175c972
|
File details
Details for the file medics_ext_retinal_layer_segmentation-2026.8.15-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-2026.8.15-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.2 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 |
b1a80c88ccfdee7625378521550d2696b947171c1eb5757f1d3796a46885ad5b
|
|
| MD5 |
ed93f03462958c0bae7ed060947b3f5a
|
|
| BLAKE2b-256 |
bb8b2559c4eb75380da7efb2f319c72aaebc3f6f8a93e18eca1be60d7a796797
|
File details
Details for the file medics_ext_retinal_layer_segmentation-2026.8.15-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-2026.8.15-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.5 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 |
74a4e90a78ab8dd88ffbd6732874583daa4834b734a66d466d738e069d30b01c
|
|
| MD5 |
d84bd06b3ee380ae9dde019eeef776f1
|
|
| BLAKE2b-256 |
17b42ee7b5473486d8ef8d60a4ab4e3f0abe4a4c4e247967cd30c169a5759713
|
File details
Details for the file medics_ext_retinal_layer_segmentation-2026.8.15-cp311-cp311-macosx_10_9_universal2.whl.
File metadata
- Download URL: medics_ext_retinal_layer_segmentation-2026.8.15-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 2.5 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 |
dbfcbd31aa6138cafb72a76bed2c2f6e7a2776ac273bf8a856ec810a9cf23886
|
|
| MD5 |
a97bd473773bf596e4aaa5cda72189ae
|
|
| BLAKE2b-256 |
1d32cce7836b62a8a0deb8cac4db716689798d8e7b08ed89becfc210c2454976
|