Tutorial

Offline Ophthalmic Retina & Macular Degeneration Diagnostic Engine

Difficulty: Advanced Time: 25 min read

Introduction

Optical Coherence Tomography (OCT) retinal imaging provides micrometric cross-sectional scans essential for diagnosing age-related macular degeneration (AMD), diabetic macular edema (DME), and retinal vein occlusion. In this cookbook, we present RetinaNet-OCT-v1, an offline 3D deep learning model that automatically segments retinal layers, quantifies subretinal fluid (SRF) and intraretinal fluid (IRF), and stages AMD according to AREDS2 criteria on local ophthalmic clinic imaging hardware without cloud reliance.

Prerequisites

  • Python 3.9+
  • PyTorch & monai / torchvision
  • openphr-cli
  • High-resolution DICOM OCT volume scans (.dcm/.nii) or fundus images (.png/.jpg)

Step 1: Load Retinal OCT Volume Scan Telemetry

Load OCT B-scan slice sequences and extract volumetric layer spatial coordinates.

import openphr
from openphr.imaging import OCTVolumeLoader

# Load DICOM OCT B-scan stack from local clinic workstation
oct_volume = OCTVolumeLoader.load_dicom_directory("./oct_scans/patient_482/")
print(f"OCT Volume Metadata: {oct_volume.num_slices} slices, Resolution: {oct_volume.spacing} mm")

Step 2: Execute Local Retinal Layer & Fluid Segmentation

Run openphr-cli to segment drusen, subretinal fluid, and intraretinal fluid volumes:

openphr-cli run retinanet-oct-v1 \
    --input-oct ./oct_scans/patient_482/ \
    --areds-staging \
    --output-analysis ./retina_diagnostic_report.json

Expected Outcome

A detailed ophthalmic report providing retinal layer thickness maps, drusen volume quantification (mm³), fluid progression metrics, and AREDS2 AMD severity classification calculated completely on-device.