Sunday, April 29, 2018

Indirect Ophthalmoscopy using a Raspberry Pi -- Part 1

Periodically your ophthalmologist will want to perform a dilated retinal exam on you. He or she will put a drop in each eye to dilate the pupils, wait about twenty minutes and then use a lens and light to examine your retina. The retina is the light sensitive tissue on the inside of the eye. Generally this is a screening exam for, among other things, diabetic retinopathy. Retinopathy is a disease of the retina, and thus diabetic retinopathy is such a disease caused by diabetes.

These are important examinations but are unpopular among patients for a few reasons. They require extra time for the eye drops to take effect, and then that effect lasts for several hours. During that time the eyes are particularly sensitive to light, and the vision is often blurry making it difficult to drive and to read.

My brother is an ophthalmologist and he pointed out to me an article written by a couple of doctors at the University of Illinois (here) in which they described building a non-mydriatic fundus camera. Mydriasis is the dilation of the pupil and in this case fundus refers to the inside back of the eye. These instruments are available but they are extremely expensive. The interesting thing about this article is that it describes building such a camera using a Raspberry Pi with a Pi Camera.

The key idea in the article is that instead of using a chemical to dilate the patient's pupil, the patient is placed in a darkened room and the pupil is allowed to dilate naturally. The problem with this approach is that in the dark the examiner cannot see to focus the camera, and because the dimensions involved are so small, the focus is critical. However, the article describes using a combination infrared and white LEDs for illumination. Generally, electronic cameras are sensitive to infrared light but human eyes are not. Thus, the examiner illuminates the eye in infrared light and viewing the image from the camera is able to focus, and then flashes the white LED to take the picture. The white light produces an image with good color rendition, an important factor in performing the exam, but the flash is so fast that the patient's pupil doesn't react until after the picture is taken.

A significant advantage of an inexpensive fundus camera is that the retina could be imaged in settings other than a doctor's office. Clinics, schools and so forth could capture the images and they could then be reviewed by a retina specialist at a later time. My brother suggested that we try to build one of these camera systems, and therein lies a tale.

One of the trickiest parts of taking a picture of the retina is the fact that it must be taken through the pupil. Even when dilated that is an opening of only a very few millimeters. Through this tiny opening light must be shone to illuminate the retina as well as the picture taken. That means that the light must be very close to the main axis of the camera lens. The University of Illinois group used a prototype of a tiny LED made by a Japanese company that can emit both IR light as well as white light. With the help of a Japanese friend of mine we undertook to obtain a few of these prototypes. Pending their arrival we did some experiments using a group of conventional LEDs and a partially silvered mirror (left). The idea was that the camera would take a picture of the eye as reflected in the front of the mirror while the eye was illuminated by LEDs behind the mirror. Thus the LEDs could be made precisely collinear with the camera.

Now, the way the retina is usually examined is that the ophthalmologist uses a 20D hand lens that he or she holds close to the patient's eye. At the same time the doctor observes the image in the hand lens using a light source and another magnifying lens that is often worn as a headlamp. Getting a good view is tricky business because it involves moving the two lenses and light such that the image is appropriately magnified, while maintaining an adequate field of view as well as having the image in focus. This is complicated by the fact that if the patient is near sighted or far sighted the correct position of the lenses changes. With practice doctors develop a good facility for this. As you might imagine, however, doing this with a camera, screen and light as well as the 20D condensing lens can be a challenge.

We built such a device and experimented around with it. We were completely unsuccessful at getting a clear view of the retina in IR light and thus could not get a good picture. Try as we might there were just too many variables, including the number of LEDs, the focus of the lens on the Pi Camera, the distances, the size of the device, etc., etc.

Around this time the Japanese LEDs arrived. We replaced the conventional LEDs that we had been using. These new LEDs were SMT (surface mount technology) and so had tiny solder pads and presented their own challenges but we were able to get them closer to collinear with the camera and so eliminated the partially silvered mirror. Nothing else changed, including our results.

We thought it might make sense to go back to first principles so we started from scratch. This time we built an optical bench that we could use to do more precise experimentation. I'll show you that in my next post.