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.

1 comment:

  1. Thank you for this meaningful article~ I am looking for setting a new system for electrophysiology.

    ReplyDelete