← Back to list

Restoring Sight with Code: Building a Retinal Prosthesis Simulator in Google Colab

How do you teach a computer to see like a bionic eye?

Ronit Chaudhari · 2026-02-27 20:48 · 0 claps · 4.4 min read
#artificial-intelligence #neuroscience #machine-learning #neural-interface #biomedical-engineering
Open on Medium ↗
Wiki topics: ML · Machine Learning AI · AI · General NEU · Neuroscience EDU · Education & Learning 🔬 · Science · General

Restoring Sight with Code: Building a Retinal Prosthesis Simulator in Google Colab

How do you teach a computer to see like a bionic eye?

Over the past few decades, retinal prostheses — often called bionic eyes — have moved from science fiction to clinical reality. Devices like Argus II and PRIMA attempt to restore partial vision to people blinded by retinal degeneration.

But one question fascinated me:

What does the world actually look like through a retinal implant?

So I built a Retinal Prosthesis Simulator in Google Colab — a computational pipeline that converts images into neural spike signals and reconstructs prosthetic perception.

This project bridges:

  • Biomedical engineering
  • Computational neuroscience
  • Neural encoding
  • Machine learning

Let’s walk through how it works

The Complete Pipeline

At its core, the simulator models the journey from light to perception:

Image → Electrode Grid → Electrical Pulses → Neural Spikes → Reconstruction → Recognition

This mirrors real retinal prosthesis systems:

  1. A camera captures the scene
  2. The image is converted into stimulation signals
  3. Electrodes activate surviving retinal neurons
  4. Signals travel through the optic nerve
  5. The brain interprets patterns as vision

The simulator replicates this entire chain computationally.

Step 1: Resolution — The Core Limitation

The human retina contains ~6 million photoreceptors.

Compare that to implants:

  • Argus II → 60 electrodes
  • PRIMA → 378 electrodes

My simulator uses:

16 × 16 grid = 256 electrodes

That means:

  • 67% of visual information is removed
  • Images become blocky and pixelated
  • Fine detail disappears

In code, this is simply downsampling:

cv2.resize(image, (16,16))

But biologically, this represents the physical constraint of electrode arrays.

And here’s the key insight:

Resolution — not spike noise — is the primary bottleneck in prosthetic vision.

Step 2: Converting Brightness to Electrical Pulses

Retinal implants don’t transmit images.

They transmit electrical stimulation patterns.

I modeled this using Pulse-Width Modulation (PWM):

  • Dark pixel → no pulse
  • Medium pixel → 50% duty cycle
  • Bright pixel → long pulse

This mimics how implants control stimulation energy delivered to retinal tissue.

Brightness becomes pulse duration.

Pulse duration becomes neural activation.

Step 3: Neural Spike Encoding

Neurons don’t communicate in grayscale values.

They communicate in spikes.

So I modeled two encoding strategies:

1️⃣ Rate Coding

Firing rate = Intensity × Max Rate

Bright pixels → more spikes Dim pixels → fewer spikes

Spikes are generated using a Poisson distribution, which matches real retinal ganglion cell statistics.

2️⃣ Temporal (Latency) Coding

The retina also uses timing:

  • Bright stimulus → early spike
  • Dim stimulus → delayed spike

This allows fast recognition — often under 100 ms in biological systems.

The simulator reproduces this mechanism.

Step 4: Reconstructing Perception

Once spikes are generated, I reverse the process:

  1. Count spikes
  2. Convert to firing rate
  3. Map back to intensity
  4. Rebuild the image

This simulates how the brain decodes prosthetic signals.

Then I measure distortion using mean squared error.

Step 5: Can AI Recognize Prosthetic Vision?

To quantify functional vision, I trained neural networks on three conditions:

Vision Condition Accuracy Normal (28×28)~96.5%

Prosthetic (16×16)~88.3%

Spike-Encoded~87.9%

The surprising result:

Spike noise only adds ~0.4% additional error.

The real loss comes from reduced spatial resolution.

Perceptual Patterns

Easier digits:

  • 0, 1, 7 → simple shapes → ~95%+

Harder digits:

  • 3, 5, 8, 9 → curved and similar → ~80–85%

Interestingly, real prosthesis patients report similar confusions when reading letters.

The simulation aligns with clinical experience.

Why This Matters

1️⃣ Biomedical Engineering

This project demonstrates real design trade-offs:

  • More electrodes increase resolution
  • But current spread limits effective improvement
  • Higher firing rates increase power consumption
  • Temporal coding may reduce energy demands

2️⃣ Computational Neuroscience

The simulator illustrates:

  • Poisson spike statistics
  • Rate vs latency encoding
  • Information loss under dimensionality reduction

It connects neural coding theory to clinical technology.

3️⃣ Neural Interfaces Beyond Vision

The same principles apply to:

  • Cochlear implants
  • Brain-computer interfaces
  • Deep brain stimulation
  • Neuromorphic computing

This isn’t just about sight.

It’s about how machines speak the language of neurons.

Experiments You Can Run

The simulator lets you test:

  • 8×8 vs 16×16 vs 20×20 electrode grids
  • 25 Hz vs 100 Hz firing rates
  • 50 ms vs 200 ms integration windows

It becomes a research sandbox for prosthetic design.

Final Reflection

What started as a coding experiment became something much deeper.

By simulating the entire path from photons to spikes to perception, you gain insight into:

  • The promise of artificial vision
  • The constraints of current implants
  • The importance of smarter encoding strategies

Restoring sight isn’t just a hardware challenge.

It’s a neuroscience challenge.

An encoding challenge.

A learning challenge.

And we’re just getting started.

If You’d Like to Connect

I’m building at the intersection of AI, neuroscience, and biomedical engineering.

If you’re working on neural interfaces, prosthetic vision, or spike-based systems — I’d love to connect and collaborate.

Let’s build the future of neurotechnology.

www.linkedin.com/in/RonitChaudhari


메타데이터
post_id
e9450c343bbf
slug
restoring-sight-with-code-building-a-retinal-prosthesis-simulator-in-google-colab-e9450c343bbf
url
https://medium.com/@ronitchaudhari369/restoring-sight-with-code-building-a-retinal-prosthesis-simulator-in-google-colab-e9450c343bbf
canonical_url
https://medium.com/@ronitchaudhari369/restoring-sight-with-code-building-a-retinal-prosthesis-simulator-in-google-colab-e9450c343bbf
author_url
https://medium.com/@ronitchaudhari369
status
ok
fetched_at
2026-06-09 15:37:30