Monday, 2 September 2013

Life of an Electrophysiologist (de-noising)

For three weeks I have been banging my head against the wall. The reason? Tracking down a peculiar source of noise in my recordings. What I thought would be a brief period of systematically stripping-and-rebuilding my rig to identify the source turned into one of the biggest tests of my problem-solving abilities in this project so far. It certainly was a very frustrating time, but in retrospect I now consider this long journey as a rite of passage for an aspiring electrophysiologist.

In the post below I will outline my story but also try to explain some of the technical stuff hoping that some people with similar problems might find it useful. And if not, at least find solace in the knowledge that they are not alone with difficult problems. I'm only mentioning my major steps in resolving the problem here as I could fill an entire book if I explained _all_ the things I've done.

It all started when I decided that my current noise level was not good enough. Yes, a little bit of high-pass-filtering got rid of most of it, but bringing an engineering mindset to neuroscience meant that I wanted to find out where this noise is coming from and how it can be removed.

My initial assumption was that some component inside the Faraday-cage was trying to break my day so I first grounded everything that could potentially pick up noise. I started out by taking a multimeter to test the resistance between each component and ground. It turns out that the coating on metal components actually insulates them. For example, these post holders (in combination with a post of course) will not electrically connect to the table-top. Further I found out that the 'Signal Ground' connection on the back of the amplifier is continuous with the ground at the back of the headstage (at least thats the case for Molecular Instruments amplifiers). Sounds logical but my assumption was that shields, Faraday, etc would somehow be de-coupled as having multiple ground-paths could induce ground-loops. I proceeded testing every conductive part of my setup until I was confident that all components on my rig had a low-resistance path to ground.

At this point I noticed a peculiarity: despite my noise being in the kHz-range, setting the low-pass filter on the amplifier (down to 100Hz) didn't make any difference whatsoever. Wrapping the model-cell into grounded tin-foil didn't have any effect either. Even disconnecting the headstage from the amplifier entirely left the noise unchanged. This led me to believe that the problem must be somewhere between the amplifier and the PC or the amplifier itself.

Consequently, I spent the next days trying to figure out my National Instruments USB-6212 BNC digitizer (which I got second hand). After studying the manual and a few e-mails with tech support later I was pretty certain that the digitizer was functional. A software called NI Measurement and Automation Explorer (MAX) comes with the digitizer and allows you to set the analog input mode for each channel and record basic traces. Choosing the correct analog input setting for my circuit was very important but also something I didn't understand much at that point. If you now think "...the what?" you are probably not alone. Most digitizers, especially the ones designed for electrophysiology (e.g. HEKAMolecular Devices), will be pre-configured so that you only have to hook up your BNCs from the amplifier. My digitizer, however, is a general purpose one which gives you more flexibility but also assumes more knowledge. There are six possible input settings, and choosing the right one required some background reading (linklink and Figure 1). If you look at the specs of the above two digitizers you'll see that one uses differential, the other one single-ended input mode which of course didn't help me figuring out which one I needed.

I know now that Floating Signal Source (FS)/Differential is the right setting for my circuit, but back then FS/Referenced Single Ended (RSE) made more sense to me. After all, the output of the amplifier goes from 0-10V. There are many reasons for and against differential (see links above). In general, however, it simply means that the signal (inside) line of the BNC is referenced against the outside line. In my circuit the outside line acts as the 0V level and the signal line can't go below 0V which basically means its single-ended - my rationale for choosing RSE. Later, of course, that turned out to be less right (but not downright wrong). RSE can work fine and effectively allows you to double the number of analog input channels on the digitzer, but the grounding needs to be set up in the right way which was beyond my understanding.

Figure 1: Input modes for analog input on a USB-6212 digitizer. Reproduced without permission but I'm trying to explain their product so they shouldn't complain.

Thinking that I had ruled out the digitizer as my problem source I turned to the amplifier. To make sure it works correctly I took my beloved Axoclamp-2B to one of our in-vitro rigs and hooked it up. Result: works fine. Just to make sure though, I got a second, similar amplifier (Axoclamp-2A) and took both of them back to my rig to compare. With both of them good-to-go I wanted to get to the bottom of my noise by only plugging in the absolute minimum number of devices (i.e. amplifier and oscilloscope, Figure 2), and then, step-by-step, plug in one device after the other. At this point its worth mentioning that I identified two types of noise: One very high-frequency/high amplitude noise (>25kHz) and one that was drifting between 2 and 3kHz (Figure 3). To test the oscilloscope itself I turned on the recording PC (carefully monitoring my noise levels while doing so). It seemed that the very high frequency noise was coming from the oscilloscope which meant that from then on I monitored my noise from the PC. I'm not entirely sure what that noise is as I have encountered it again in later stages with the oscilloscope unplugged, but only when I pick up the headstage with my bare hands without grounding myself. Figure 4 and 5 show that noise, if anyone knows what it is, please let me know. I haven't followed it up, it looks like a positive feedback loop of some sort but it is not a problem unless I completely un-ground the headstage.

With the high frequency noise removed and the original Axoclamp-2B amplifier plugged in I realised that my 2-3kHz noise was still there. Only amplifier (which worked on the in-vitro rig), headstage with model-cell (of which I had two each to make sure they are not the source of my problem), digitizer and PC were plugged in. How could there still be noise? I proceeded to check which connection to the amplifier could be carrying the noise (Figure 3), but it proved inconclusive. 

Figure 2: Oscilloscope trace. This, and the amplifier lights were all I could see at the start.
Figure 3:Excerpt of my not entirely systematic protocol to figure out where the noise comes from
Figure 4: The low-noise portion of the trace shows the noise level when the oscilloscope is unplugged
Figure 5: Close up of the very high-frequency noise. This is sampled at 50kHz and what you see is 25kHz sine. The shape of the sine looks very much like an aliasing effect so disregard it. I didn't bother scanning it at a very high rate as I don't think knowing the frequency would make a difference.
I set up the second amplifier (Axoclamp-2A) to see whether I could re-produce the noise I found on the Axoclamp-2B. This would also serve as confirmation whether the amplifier is the culprit (despite that fact that I tested it on an in-vitro rig) or if the problem is further downstream. If they both show the same noise, I reasoned, its unlikely that the amplifier is the problem and the noise is picked up somewhere else. The amplifiers sat on top of each other so that I could just switch over all the connections between them without changing anything else on the rig. What I found was that the noise patterns looked very different despite being set up in exactly the same way (Figure 6 and 7). This led me to believe that it must have something to do with the amplifier, but I couldn't really make much sense of it. Nothing else in the room was running, so where do such different noise patterns come from? Thinking that it might be coming through the power supply I tracked down the people in our building who know how exactly the power lines have been installed in the labs, but it didn't help much either. Even if it was the mains line, the amplifiers surely would have a circuit in place that doesn't let that kind of noise through. And if it did, how can they be so different?

Figure 6: Noise on the Axoclamp-2B: drifting between 2 and 3kHz.
Figure 7: Noise on the Axoclamp-2A. Around 12Hz frequency. Expressing the amount of sense this made to me in per-cent: Zero %.

By now I had asked all the people with electrophysiology experience around me to have a look and see if they can help but no-one had seen this noise pattern before. A colleague then suggested that we had a temporarily unused HEKA ITC-18 digitizer I could test since the amplifier for that rig was being serviced. Even though I didn't think the digitizer was the source of my problem, nothing else made sense either, so I gave it a try. And finally there was a glimmer of hope: the signal on the ITC-18 was OK.

That night I sat down with manuals and specifications for both digitizers, knowing that the answer must be somewhere in those documents. The key difference I found was the input-mode for the analog input channels: My USB-6212 was set to FS/RSE whereas the ITC-18 was, by default, set to differential. Using MAX to set the input channel on the USB-6212 to FS/Differential showed me the same signal I saw on the ITC-18. To re-iterate: I tried differential on the USB-6212 before but thought it just white noise without any signal. Further, it was counter-intuitive that the analog input mode was the culprit if two very similar amplifiers show such different noise. My guess now is that they manage the signal grounding differently resulting in such big differences when the analog input channel is not set up in the right way.

However, no matter what setting I used in MAX, as soon as used my recording program, Axograph X, I was back to my old noise problem. After looking through all the options on how to set analog input channels in Axograph, MAX and the vast sea of NI support pages I eventually e-mailed the developer of Axograph. A brief e-mail exchange brought the problem to the surface: a small mistake in the Axograph source-code (i.e. a bug) meant that channels are automatically initialized as RSE, overriding any setting done in MAX, without giving the user an option to change it. This is because previous generations of NI digitizers have hardware switches to choose between single-ended and differential, thus, the recording software didn't have to care about it. Only the latest generation of NI digitizers have a software switch and Axograph simply hadn't caught up with that yet. The developer fixed the code, re-compiled the program and sent me the download link. A quick re-install and everything worked fine.

So, after weeks of figuring out the electric circuit of my rig, I finally found the answer. While it is certainly anything but fun, the understanding you gain of your recording hardware is irreplaceable. Otherwise the moral of the story is, if you want to do electrophysiology, especially on a novel experimental setup, you WILL go through a lot of pain. No pain no gain.

Wednesday, 17 July 2013

Guiding Light

After a 9-month hiatus it is high time to start updating my blog again. The reason for the lack of attention for this blog was, well, that I had to do science. Most of the technical aspects of my setup are finished and the current framework in which we conduct science unfortunately doesn't reward sharing scientific progress in real-time. For the remainder of my PhD however I am planning to update more regularly again, describing the components not on here yet and sharing more detail about the ones already mentioned.

In the meantime, Christoph Schmidt-Hieber (UCL) has started sharing some code for his/their virtual-reality setup (link). In his first batch of uploaded data he shares the code for reading mouse-input directly. I highly recommend having a look if you are interested in setting up such a system.

More Light! 

Since my last post I have improved my light-source a little more. The system I built here produces enough light, unfortunately it also introduces a lot of electric noise into the system as electronic components have to be placed close to the recording site. To get around this I ordered a light-guide and a condenser lens. These I have combined with a 7-LED assembly (using Luxeon Rebel LEDs) and a LED driver unit for easy power supply and dim-control.

Seven LEDs of this rating need an appropriate amount of cooling so the base-plate was mounted on a fairly big heat-sink. Again, my heat-dissipation assessment was done by keeping them on for a long time and seeing if the heat-sink becomes too hot.


Heat-sink, breakout board and condenser lens assembly.

Some Guidance 

Feeding light into a light-guide is a rather simple process if you don't care too much about leaking some in the process and since I've got enough light to illuminate a mid-sized apartment, I don't. The condenser-lens concentrates the beam at a 25mm distance and creates a waist of 12mm. To capture most of the light I chose a 1/2in (12.7mm) light-guide and mounted it at the appropriate distance. While there are certainly mores sophisticated ways to do this, a simple base-plate and cube of aluminium did the job.

The rather simplistic diagram that comes with the condenser lens. At 25mm distance we get a 12mm beam diameter. Diagram (c) Polymer Optics Ltd.

The assembly of heat-sink, LEDs, lens and light-guide. Not the prettiest solution and you get some stray-light which can be easily shielded though.

The initial idea for my light-source included having a well circumscribed spot so we can illuminate the craniotomy without shining too much light into the eyes of the mouse. For that end I use a focusing-assembly. It is provided by the same company as the light-guide so the parts fitted together without any hassle. The result is a very bright, well focused-spot, perfect for my purposes. Having the LEDs away from the recording site also means that there is no noticeable noise introduced into the system. Finally, the heat produced at the end of the light-guide is minimal so no IR-filter is necessary.

Output. The focusing assembly creates a well circumscribed spot.

Sunrise, Sunset 

The circuit for switching the light on and off as well as dimming is still in the same box I used before. I won't go into detail about the circuit for the LED-driver as the spec-sheet that comes with it contains all the information and also because I forgot to take a photo of it before boxing it up. I have, however, made sure again that it is simple to use and clean. An on/off switch and a dimmer knob are the only visible components.

Making the sun rise for my mice was never easier. On/off switch and a dimming knob are the only visible components.



Conclusion 

Yes, it could have been bought off the shelve and I can't blame anyone who does. However, there are some advantages: I couldn't have taken a commercial light-source and mount it into my system as easily as this. Further, the dimmer switch on my system is easily accessible and turns smoothly. My experience with commercial solutions is that the dimmer knob often takes some force to turn, making it difficult to operate with one hand while looking down a stereoscope. I use the dimmer-function quite often to keep the animals as undisturbed as possible during virtual foraging. I leave the lights off and, if I need light, keep the brightness down as much as possible. Finally, I could use LEDs of various wave-lengths, such as red, to disturb the animal even less.

This solution has been used in experiments and works very well. I can use it in its current form for all my experiment without having to move it in any way, an important point when it comes to streamlining experiments and keeping awake animals calm. This completes my 3-post series on making a light-source, I hope it is helpful for some.



PS: An even better Solution

A colleague who has helped me a lot over the past 2-3 years with all electronics-related things has picked up the idea. He happened to have a broken light source kicking around (after disassembling it turned out that only the power switch was broken. Oh well). He yanked out the insides and replaced them with the components described above, although he did refine the circuit a little bit. The result is a light-source that can't be distinguished from the original on the outside, only that it has higher brightness, higher efficiency, longer lifetime at a much smaller cost.

Custom light-source built into the box of a broken commercial one.