Localizing recording sites: Reconstructing explanted electrode arrays

While drive implants with adjustable electrodes bring many advantages, the use of movable electrodes adds one element of uncertainty to the data analysis: the precise depth of each electrode is not known with absolute certainty during recording.

By identifying landmarks along the electrode path and by keeping records of all drive adjustments, it is possible to reconstruct positions with good accuracy, but this method can not provide electrode positions with absolute certainty.

In most cases, microwire electrode arrays can be explanted post-perfusion with no bending of the electrodes (nichrome and tungsten wires are stiff enough to snap back to the same position unless they’re bent above a certain threshold), so by measuring the actual depths (and positions) of the electrodes in their final position, it is possible to verify the depths and combine these measurements with the information gained from the drive depth records and histology.

This is especially valuable as a safeguard against the rare cases where  individual electrodes get stuck somewhere in the lowering process.

The simplest approach to this would be to take pictures from two or three orthogonal angles, manually mark all electrode tips and some features on the drive bottom,  and stitch together the coordinates. However, in my relatively dense arrays (16 electrodes with ~250 micron spacing) I have issues identifying individual electrodes with their place in the array unless I look at it from multiple angles. Also, getting the orthogonal angles exactly right seems very hard, especially when not using telecentric optics.

The next simplest thing is to stick the array on a rotary table (such as a servo or a stepper motor), and take images from a large arc of different angles. This way, there are enough pictures to show the origin of each electrode sufficiently clearly to identify them, and because everything rotates on just one axis, there is no alignment do deal with.

I use a standard 16mm lens on an AVT pike camera with a ~10mm extension tube. While the image quality coming out of this setup is ok, it would be nicer to be able to get a better DOF, so either a lens with a smaller minimum aperture, or even a motorized focus would be ideal. If available, a telecentric lens should improve precision. The tests shown here are done with a standard RC servo motor driven by an arduino from matlab. The servo in my rig has some issues with angular precision, so i’d recommend getting a nice stepper motor instead. I also had some lateral motion on the servo, which I fixed by mounting the drive on an axle on two very large bearings that we had in lab.


After the images were acquired, I marked the electrode tips and some other features such as the drive base and skull screws for registration to histology, and a scale bar of known dimensions. I did this with a quick and dirty matlab program, but imageJ or some equivalent software should work just as well.

raw image overlayed with manually traced tracking points

raw image overlayed with manually traced tracking points

After marking all electrode tips I get a bunch of 2d-arcs that need to be turned into 3d coordinates:

raw x/y arcs to be used in model fitting

raw x/y arcs to be used in model fitting

In order to get this done without spending half a day debugging the math, I went with a very simple generative model (run points through camera matrix and use RMSE for cost) and found the parameters with fminunc. The camera angles and fov are set, and x/y/z of all the points, as well as camera elevation and rotation of the imaging plane are estimated.

3d reconstruction of electrode positions

3d reconstruction of electrode positions, bottom of guide tube array (black) and calibration target (grey)

For now, I verified the method by reconstructing one of the drives 3 times as well as measuring the depth of some long electrodes with calipers. After aligning the 3 independent reconstructions, each with different drive position on the rig and different camera angle, I aligned the coordinates using Babak Taati’s code:


The reconstructions all agree very well for all major electrodes, and only disagree for some electrodes that were not extended enough to be visible in more than a few frames each. The std across all 16 electrodes is 60.5±24.9μm, definitely better than what I am getting from eyeballing it with calipers under a microscope, and I avoid the risk of mixing up electrode identity.  Next up: aligning these coordinates to histological localizations.

I put the code up on the lab’s github (link). I spent no time making this pretty or testing it beyond my own data, so this is in no way intended as directly usable code. Use it as a starting point for implementing your own method and don’t trust any of the results unless you can verify them.

This entry was posted in Data analysis, Electrophysiology. Bookmark the permalink.

Comments are closed.