Physiological measurements from an unrestrained, untethered, and freely moving animal permit analyses of neural states correlated to naturalistic behaviors of interest. Precise and reliable remote measurements remain technically challenging due to animal movement, which perturbs the relative geometries between the animal and sensors. Pulse-type electric fish generate a train of discrete and stereotyped electric organ discharges (EOD) to sense their surroundings actively, and rapid modulation of the discharge rate occurs while free swimming in Gymnotus sp. The modulation of EOD rates is a useful indicator of the fish's central state such as resting, alertness, and learning associated with exploration. However, the EOD pulse waveforms remotely observed at a pair of dipole electrodes continuously vary as the fish swims relative to the electrodes, which biases the judgment of the actual pulse timing. To measure the EOD pulse timing more accurately, reliably, and noninvasively from a free-swimming fish, we propose a novel method based on the principles of waveform reshaping and spatial averaging. Our method is implemented using envelope extraction and multichannel summation, which is more precise and reliable compared with other widely used threshold- or peak-based methods according to the tests performed under various source-detector geometries. Using the same method, we constructed a real-time electronic pulse detector performing an additional online pulse discrimination routine to enhance further the detection reliability. Our stand-alone pulse detector performed with high temporal precision (<10 μs) and reliability (error <1 per 106 pulses) and permits longer recording duration by storing only event time stamps (4 bytes/pulse).
- pulse detection
- envelope extraction
- temporal precision
a freely moving animal exhibits a wide range of natural behaviors that are often not possible to study in a restrained animal (Fee and Leonardo 2001; McCasland 1987; O'Keefe and Dostrovsky 1971). Hence, the study of freely moving animals is becoming an actively researched topic in neuroscience despite the technical challenges associated with simultaneous neural and behavioral recordings. The use of restrained or immobilized animals has been generally preferred for studying neural correlates of behaviors to minimize movement-induced recording artifacts. Although this approach might be suitable for addressing classic problems of sensory and motor coding, some of the modern problems in cognitive and behavioral neuroscience can only be addressed by studying freely behaving animal subjects. Naturalistic behaviors such as exploration or foraging can be best observed from nonrestrained, freely behaving animals. However, a measurement system must limit artifacts caused by animals' own movements to achieve sufficient precision and reliability. Addressing this challenge, we designed a precise and reliable pulse-timing measurement system to observe an active sensory sampling behavior of a free-swimming, pulse-type electric fish.
Weakly electric fish can electrolocate obstacles and prey under conditions of poor visibility (e.g., in a murky river or in darkness) by generating an electric field around their body and perceiving electric images of the surroundings (Assad et al. 1999; Babineau et al. 2007; Caputi et al. 2005; Chen et al. 2005). Weakly electric fish species can be categorized to two types according to their electric waveforms: wave species discharge continuous pseudosinusoidal waves, and pulse species discharge trains of discrete pulses (Moller 1995). The rate of electric organ discharge (EOD) in pulse fish such as Gymnotus sp. is influenced by its self-generated movements and the novelty of the fish's surroundings (Bullock 1969). The EOD rate is increased in situations demanding higher sensory sampling rate (Caputi et al. 2003) or during free swimming (Fig. 1A). Changes in interpulse interval sequences (ΔIPI) occur over a temporal scale on the order of tens of microseconds for a resting and free-swimming Gymnotus sp. (Fig. 1B). Thus a pulse measurement method sensitive down to 10 μs is required to reveal fine temporal structures in IPI sequences. In particular, we are investigating spatial learning in Gymnotus sp. and have found that the temporal structure of IPI sequences changes as a function of learning and can thus give insight into the fish's knowledge of its spatial environment. The high temporal resolution of EOD timing required for these studies spurred the development of the tools described in this paper.
EOD pulses are generated by a population of electrocytes arranged along the body, each discharging with its own stereotyped waveforms and delays from the moment when a spinal electromotor neuron discharge command is generated (Caputi et al. 2005; Rodríguez-Cattaneo et al. 2008). Therefore, the electric potential observed at a distant recording electrode can be a superposition of spatially distributed electrocyte action potentials, each contributing current with magnitude inversely proportional to its distance to the electrode. The electric field generated by a fish is approximated by a current dipole source because the head and tail ends generate opposite current flows by either sourcing or sinking currents. Thus the observed pulse amplitude depends approximately on the distance from the recording electrodes and the orientation of the fish according to the formula (Chen et al. 2005): (1) where I is the current generated by the dipole, d is the length of the dipole, θ is the angle formed between the lines connecting the current source end of the dipole, the center of the dipole, and the detector location, σ is the water conductivity, and r is the distance between the dipole center to the detector location.
The geometric relation between a fish and recording electrodes defines a source-detector geometry. Fish motion introduces variations of the source-detector geometry, which in turn change the observed pulse waveforms and amplitudes. Typical swimming movements such as turning and forward-and-backward scanning maneuvers (Lannoo and Lannoo 1993) result in large changes in pulse amplitude at each electrode (Fig. 2B) and distort multiple lobes within a single pulse waveform [Fig. 2A; roughly triphasic in some Gymnotus genus (Rodríguez-Cattaneo et al. 2008)], which leads to poor temporal precision in the pulse detection.
The temporal scale of IPI variation (ΔIPI) during rest and free swimming is in the order of tens of microseconds (σΔIPI = 67 μs during resting; Fig. 1B), but many commonly used basic pulse detection methods fail to capture such a time scale due to movement-induced artifacts and waveform distortion resulting from body posture changes. A pulse detection method based on a fixed threshold is ill-suited for fast changing amplitudes and waveforms because the chance of missing a pulse is still high for any choice of thresholds. Artificial jumps in IPI measurement are more frequent during free swimming because the order of lobe amplitudes haphazardly switches, and a threshold crossing does not occur consistently at a given lobe. Pulse detection using feature points such as the peak or a zero-crossing point will become unreliable when the relative amplitudes between the constituent lobes vary, which typically occurs when fish come close to a recording electrode. Such movement artifacts could be reduced by locally attaching recording electrodes on fish to maintain a constant source-detector geometry; however, the tethered wires interfere with the free-swimming motion (Bell et al. 1974; Graff 1987).
In this paper, we propose a novel EOD pulse detection method based on the principle of spatiotemporal averaging, which operates by summing the waveforms received and rectified from multiple recording electrodes and extracting the envelope of the summed pulse. Our spatiotemporal averaging-based pulse detection is highly precise (<10 μs) and reliable (error < 1 per 106 pulses), according to the tests performed with restrained fish under various source-detector geometries and also with free-swimming fish. Furthermore, we implemented a stand-alone electronic pulse detector featuring a real-time, noise-tolerant event discriminator using a Programmable-System-on-Chip (PSoC) microcontroller.
Microcontrollers can be programmed to perform application-specific tasks and offer a number of embedded peripherals to enable a single chip to perform many customized functions. A typical modern microcontroller offers an analog-to-digital converter (ADC) and timers, which are needed to track changing pulse amplitudes and IPIs, and provides a sufficiently fast central processing unit (CPU) to run a pulse discrimination algorithm in real-time. We chose PSoC 5 (CY8C5588AXI-060 ES1; Cypress Semiconductor, San Jose, CA) to perform pulse discrimination in real-time because the PSoC offers a large variety of analog and digital on-chip modules, thus allowing all of the necessary features to be integrated into a single chip (Ashby 2005; Mavoori et al. 2005). High-precision recording is generally possible for only short durations because the raw signals need to be continuously digitized at high speed, thus demanding a large storage space. In comparison, our real-time operation enables a long-duration and high-precision recording by storing a small time stamp (4 bytes) for each pulse event.
MATERIALS AND METHODS
The field measurements of fish were made in a custom-built circular aquarium (1.5 m in diameter, filled to 15 cm in depth) constructed to study foraging, spatial learning, and changes in sensory sampling during the learning that occurs in free-swimming Gymnotus sp. (23 cm in length, unknown sex and species). The native tropical environment of central South American fresh water (Lovejoy et al. 2010) was simulated by conditioning the aquarium water with matching conductivity (100 μS/cm, pH 7.0), using a stock salt solution (Knudsen 1975). The water temperature was maintained at 25°C by an electrically shielded floor heater (ThermoTile; ThermoSoft, Buffalo Grove, IL). The whole setup was surrounded by a lightproof Faraday enclosure to block external sources of light and radio frequency noise. All measurements were taken under dimly lit conditions. All experiments described below were approved by the University of Ottawa Animal Care Committee.
Signals were recorded from eight equally spaced graphite rods (Mars Carbon 2-mm type HB; Staedtler), glued to the circular perimeter wall using silicone, and electrically coupled to BNC connectors (RG174) using heat-shrink tubing. The signals from four opposite-facing electrodes were differentially amplified to suppress the common-mode noise (Fig. 3). The Faraday cage surrounding the whole aquarium was used as a common ground. No ground electrode was placed in the aquarium for the duration of the recordings because it could distort the field symmetry. However, the aquarium water and the Faraday cage made electric contact shortly before starting the measurement recordings to neutralize the charge build-up caused by evaporation. Raw signals from the four recording dipoles were alternating current (AC)-coupled and amplified without filtering (30× gain; Intronix 2015F; Bolton, Ontario, Canada) and then synchronously digitized using a 16-bit ADC sampled at 200 kS/s per channel (CED 1401 mkII; Cambridge Electronic Design, Cambridge, United Kingdom). The recordings were processed using Spike2 software (Cambridge Electronic Design) and MATLAB (The MathWorks, Natick, MA) to simulate different signal processing stages and to compare their performances. The waveform was sampled every 5 μs, and the final pulse time stamps were estimated to 1-μs precision using cubic spline interpolation of the waveform.
To reproduce the most commonly occurring variations in the source-detector geometry, we designed a holding frame, inspired by Knudsen (1975), to fixate the location and orientation of fish. Fish were immobilized in the holding frame by a tightly stretched net, built from a fine nylon mesh pocket surrounded by V-shaped coarse Mylar grids, and submerged at the middle of the tank depth. Floating foam blocks supported the holding frame above the water to minimize the underwater field distortions (Fig. 4). To simulate a wide range of locations and orientations, the holding frame, guided by a wire attached to the circular fence, traveled from one end to the other end of the recording dipole A and rotated with respect to the guiding wire. Two recording electrodes were locally installed in the holding frame and maintained at 2.5 cm from the head and tail of the fish, respectively, to provide a geometry-invariant reference for the pulses observed at the external recording dipoles A–D attached to the fence. The signal from the local dipole electrodes was amplified (10× gain; Intronix 2015F) and concurrently recorded along with the signals received from the four external recording dipoles.
Method of spatial averaging by rectified summing.
At least one out of the four recording dipoles received strong EOD pulses at any location and orientation of the fish; thus summing signals from multiple channels provides a good signal reception at any source-detector geometry given that the pulses are rectified (Fig. 5-2) before summing (Kramer 1974). The rectification of signals prevents the canceling effects from adding signals of opposite polarity, and the polarity reversal begins to occur once the angle between the fish and the recording dipole exceeds 90°. Although the pulse detection reliability is enhanced by the spatial averaging effect of the multichannel rectified summing, this processing alone is not sufficient to achieve a high temporal precision. The rectified pulse waveform still contains multiple lobes; even though fish produces a stereotyped pulse waveform, these waveforms vary relative to one another under free-swimming conditions. The two most distant peaks within a single pulse from Gymnotus sp. are typically separated by 500 μs; thus a pulse timing detected at the maximum point will contain a timing error up to 500 μs, which is much greater than the natural time scale of ΔIPI (σΔIPI = 67 μs; Fig. 1B).
Method of temporal averaging by envelope extraction.
The envelope extraction transforms a multilobed pulse waveform to a unimodal shape by extracting the envelope outline using temporal averaging so that the pulse timing can be unambiguously resolved at the envelope peak (Fig. 5-3). Temporal processing is entirely performed in the analog domain to generate precise output in real-time and to lower the cost of implementation compared with the digital domain processing. The envelope of a pulse waveform is extracted using a combination of full-wave rectifier (Fig. 5-2) and low-pass filter (Fig. 5-3), which is equivalent to performing the Hilbert transformation in the digital domain (Rangayyan 2002). The envelope peak is detected in the analog domain by taking advantage of the slope-peak relationship. First, the envelope waveform is differentiated using the band-limited differentiator (Fig. 5-4) and then low-pass filtered (Fig. 5-5) to prevent amplifying high-frequency noise (Clayton and Winder 2003). Second, a zero-crossing point that immediately follows a falling threshold crossing is detected using a comparator with hysteresis. Comparator output triggered by background noise is ignored while the signal amplitude is under the detection threshold.
Online pulse discrimination algorithm.
Real-time operation must generate highly reliable output because errors cannot be corrected after recording; thus the pulse detector output must be validated in real-time. An event discriminator can selectively discriminate true pulse events from spurious noise spikes. The detection reliability can be enhanced by minimizing the number of false positives and by maximizing the detection sensitivity. An online event discriminator determines whether to approve or block the incoming pulse in real-time based on a set of discrimination criteria. The discrimination criteria also need to be updated in real-time, particularly for an input signal with a large dynamic range. Noise spikes are discriminated from true pulses based on clues such as the pulse amplitudes and IPIs. For instance, an output pulse is suppressed if incoming pulse amplitude lies outside of a typical range of true pulses or when a pulse is observed much sooner than expected given the mean IPI. The discrimination criteria are updated by tracking the running averages of pulse amplitudes and IPIs, which continually change due to free motion of fish.
The event discriminator receives two inputs: the differentiated envelope waveform sent from the signal filtering stages and the zero-crossing comparator output. It outputs a transistor-transistor logic (TTL) pulse with 0.5-ms duration once a valid pulse is detected (Fig. 6B). Figure 6A illustrates the online pulse discrimination algorithm implemented in the PSoC firmware. The wait timeout prevents an infinite waiting condition caused by incorrectly setting the threshold too high or setting the gain too low. If a timeout occurs, the PSoC resets and recalculates the threshold and gain values.
The gain value of the on-chip amplifier (programmable gain amplifier, PGA) is automatically adjusted to maintain the peak amplitude within the range of ADC, thus preventing the signal from saturating the ADC when a fish comes too close to the recording electrodes. We used a signed 8-bit DelSig ADC providing a balance between the sampling resolution (255 levels from −128 to 127) and speed (64 μs/sample). The waveform peak is targeted at around the half (64) of the ADC limit by halving the gain if the upper limit (94) was exceeded and doubling the gain if the peak fell below the lower limit (31). The gain is allowed to vary between 1 and 32 in powers of 2 to prevent overamplifying the background noise or saturating the digitizer.
The pulse discriminator outputs a TTL pulse precisely 1.5 ms after a rising edge transition of the zero-crossing comparator output. During this 1.5-ms delay, the firmware validates incoming pulse input and suppresses TTL pulse output if a noise spike is detected. To generate the time delay with a precision better than 1 μs, the rising edge electronically triggers an on-chip pulse-width modulator (PWM) module to generate the TTL output instead of using the CPU, which is prone to time jitter.
Electronic implementation of a real-time pulse detector.
This section describes the construction of a stand-alone pulse detector circuit, which performs the signal filtering and the pulse detection and discrimination tasks in real-time. Raw signals from the four recording dipole channels are individually amplified and filtered in parallel in a manner similar to Crampton et al. (2007; Fig. 7A). First, the raw signals from the recording electrodes are capacitively coupled to instrumentation amplifiers (INA128PA; Texas Instruments, Dallas, TX) with an initial gain of 100. Second, the amplified signals are high-pass filtered using 2nd order Butterworth filters [characteristic frequency (fc) = 650 Hz] to improve the temporal precision by maximally attenuating the 60-Hz line noise and its higher harmonics. Third, the filtered signals are absolute-value transformed using a precision full-wave rectifier circuit (Clayton and Winder 2003), and the intrinsic limitations of a diode (finite forward voltage drop and a nonlinear current-voltage relationship) are corrected with an opamp-diode combination to prevent signal distortion and clipping.
All analog stages are constructed using low-noise quad-opamps (TLV2264AIN; Texas Instruments) to achieve high precision. Afterward, the rectified signals from the four recording dipole channels are summed using a voltage-adder circuit (Fig. 7B; Clayton and Winder 2003). The summed signal is then low-pass filtered (fc = 1 kHz, 2nd order Butterworth) to extract a unimodal envelope, differentiated by a band-limited differentiator, and then low-pass filtered again (fc = 1 kHz) to suppress the high-frequency noise amplified by the differentiator.
The envelope-differentiated signal is routed to the PSoC event discriminator and the external comparator for zero-crossing detection (Fig. 7C). An external precision comparator (LM393; National Semiconductor, Austin, TX) offers higher temporal precision (<1-μs transition jitter) than the on-chip comparators, and the use of a Schmidt trigger further improves the precision by suppressing noise-induced multiple zero crossings. If enabled by a jumper setting, the PSoC sends text messages to report the discrimination criteria, pulse amplitudes, and IPI via RS232 for the purpose of monitoring and debugging (see supplemental material for the serial communication protocol, available online at the Journal of Neurophysiology web site). The PSoC 5 chip is only available in a surface-mount package that requires special soldering equipment. Hence, we used an inexpensive, readily built development board by Cypress (CY8CKIT-014) that offers two rows of pins with 0.1-in. spacing for the external input and output interface. We added two rows of mounting sockets on our circuit board to fit exactly the PSoC board. We custom-built our circuit board using a toner-transfer method that allowed us to fabricate inexpensively a printed circuit board (PCB) with commonly available tools such as a laser printer and a laminator (see supplemental material for PCB layout, bill of materials, and the PSoC firmware). Total cost of implementation was <200 USD, and most of the integrated circuit (IC) could be obtained as free samples for academic institutions from the manufacturers.
The analog circuits excluding the PSoC board are powered by a miniature lead acid battery instead of the AC supply line to reduce the power noise. A virtual ground IC eliminates the need for two batteries to provide positive and negative supply voltages by splitting a single battery voltage to exactly half. A rail-splitter virtual ground IC (TLE2426IP; Texas Instruments) splits 12-V voltage input from a lead-acid battery and produces a signal ground, 6 V above the negative terminal of the battery, and dual supply voltages, which are ±6 V with respect to the signal ground (Fig. 7D). All electronic components except the PSoC board consume <10 mA at 12-V input voltage. The PSoC board consumed ∼100 mA between 5- and 12-V supply voltage range and is separately powered by an AC adapter to conserve battery without injecting power noise to the signal. The PSoC board is equipped with an internal 3.3-V voltage regulator, which accepts a voltage input between 5 and 12 V. The use of a decoupled power source for the PSoC eliminated occasional contamination of analog signal by digital signal from the PSoC board.
Method of testing from free-swimming fish.
The real-time pulse detector was tested with fish under restrained and free-swimming conditions. The test with restrained fish allowed us to control precisely the location and orientation of fish to explore systematically a wide variety of source-detector geometries. It was also easier to place locally fixed reference electrodes with restrained fish, and the local electrodes remained stable for a long time. In addition to the tests with restrained fish, we performed a set of tests under a realistic free-swimming condition to ensure correct operation of the real-time detector. Pulse waveform during free swimming varies more dynamically due to body bending, change of depth and pitch angle, touching the recording electrodes, and even jumping in rare cases. These factors could compromise reliability and precision of the pulse detector; hence, we designed two tests to assess independently the precision and reliability of our pulse detector.
The precision test was performed to measure the temporal precision by taking the difference between time stamps obtained from the external and the local reference electrodes. The local reference electrodes were tethered on the fish's body to provide a location- and movement-independent reference for pulse timing. A pair of local electrodes was constructed from short (1-cm) segments of graphite electrode (2 mm in diameter) tethered to a pair of twisted (3–4 mm per turn) magnet wire [38 American Wire Gauge (AWG)]. The graphite electrode was wrapped with exposed magnet wire, and then heat shrink was applied to couple them tightly. The graphite electrodes were attached to small buttons with four holes (9 mm in diameter) by looping a short segment of wire insulation through two holes, and the other two holes were used to suture the button on the fish's skin. The fish were anesthetized with bath-applied MS222 (0.1–0.2 g/l tricaine methanesulfonate; Sigma, St. Louis, MO), and two graphite electrodes were sutured and glued with dental tissue adhesive (PeriAcryl Tissue Adhesive; Citagenix, Laval, Québec, Canada) on the fish's back. One electrode was sutured above the gills, and another electrode was attached 5 cm caudally. Throughout the suturing procedure, the fish was artificially respirated with oxygenated solution containing light concentration of MS222. After the suturing, oxygenated deionized water was perfused through the gills until the fish could respire itself. All fish recovered well after the anesthetic procedure described above. The signal from the local electrodes was differentially amplified by a custom-built headstage (INA128; 20× gain; Texas Instruments) located at the center of the ceiling. Because of frequent rotation of fish, the tethering wire was manually unwound, and the local electrodes were checked for detachment before starting each recording session.
The movement onset and ending times determined by this analysis were verified with a concurrent video recording. All of these tests were carried out under infrared illumination (850 nm) provided by four near-infrared sources (S8100-60-B/C-IR; Scene Electronics). Infrared illumination allowed observations of fish swimming behavior in darkness (Nelson and MacIver 1999). The four infrared sources pointed toward the ceiling of the aquarium enclosure to provide even illumination. The ceiling was constructed from a white corrugated plastic sheet with matte finish to reduce reflection and glare on the surface of water, and a white sheet was laid underneath the glass aquarium to provide high-contrast background. Video recordings were made using a near-infrared sensitive camera (Guppy F-036B; Allied Vision Technologies, Stadtroda, Germany) with a wide-angle lens (T2616FICS-3; Computar, Tokyo, Japan). The camera was placed right above the center of the ceiling, and the lens was exposed through a narrow hole. A light guard was installed around the lens to prevent glare from the infrared sources. Images were recorded at 15 frames/s at Video Graphics Array (VGA) resolution and stored as image sequences. The frame-capture TTL events were captured with the EOD signals for synchronization.
We determined the temporal precision for stationary and swimming conditions. The onset of movement was determined by tracking changes in the peak pulse amplitudes, which we now refer to as the movement index. The movement index was calculated by the following steps: first, a series of peak pulse amplitudes was smoothed with a Hamming filter (window size of 32 pulses); second, differences between adjacent pulse amplitudes were computed; third, the moving average was computed (window size of 200 pulses with no overlap). Once the movement index was determined, a threshold was manually set to a value that clearly separated the movement states from the resting states.
In addition to the temporal precision, we tested pulse detection reliability from an untethered free-swimming fish for an extended period of time. The real-time pulse detector output (TTL pulse and envelope-differentiated waveform) were digitized at a slower rate (ADC rate of 20 kS/s and TTL temporal resolution of 10 μs) to permit longer recording duration (∼6 h). The TTL pulse output was compared against the continuous waveform recording to check for any missed pulses. The aquarium filters and bubblers were turned off during all recording sessions to minimize electric interferences. However, the floor heater remained powered because it did not contribute to noise due to effective electric shielding between the heater and the aquarium.
Overview of test from restrained fish under various source-detector geometries.
We validated our pulse detection methods by measuring the temporal precision and detection reliability under various source-detector geometries. We digitized raw EOD waveforms and determined EOD pulse timings using several different pulse detection methods. EOD pulse detections were initially performed in the digital domain to find the optimum parameter values such as the cutoff frequencies and gain values and to compare performances of different pulse detection methods. We implemented digital signal processing stages for different pulse detectors in Spike2 software that drives the ADC hardware. The digitally filtered output closely matched the analog electronics output with use of equivalent filters and operations. For each filtered pulse waveform, pulse timing was measured at different feature points (zero crossing, maximum, minimum, and absolute maximum); also, the peak-to-peak amplitudes were measured for the nonrectified waveforms (peak amplitudes for the rectified waveforms).
We physically varied the source-detector geometry by adjusting three parameters: the distance from the center of the aquarium to the fish (ρfish), the orientation of the fish (θfish), and the orientation of the dipole recording electrodes (φelec). The pulse waveforms were recorded for each uniformly spaced sample point in the parameter space. ρfish was varied from −55 to 55 cm in 5-cm steps, θfish was varied from 0 to 180° in 15° steps, and φelec was chosen at 4 orientations (0, 45, 90, and 135°), yielding a combined total of 1,196 independent observations (23 linear steps × 13 angular steps × 4 dipole orientations). All angles (θfish, φelec) were measured with respect to the orientation of dipole A (Fig. 3). To estimate the unobserved gaps in the parametric space, the raw measurements were interpolated 10× using 2-dimensional cubic spline (interp2 function in MATLAB) in the dimensions of ρfish and θfish and converted to polar coordinates (Fig. 8).
At each measurement step, EOD pulses were recorded for 3 s. We then sorted pulses by their peak amplitudes measured at the local recording dipole and selected 100 pulses closest to the mean. Pulses far from the mean were discarded because they resulted from occasional gill and fin movements of the restrained fish. The selected pulse waveforms were then filtered and detected by 5 methods to be compared in the next section. The pulse amplitudes and timings were measured for each pulse detection method, and their statistics (μ and σ) were derived from the interpolated parametric space in polar coordinates. The statistical samples were uniformly chosen from the polar parametric space to represent fairly larger radial distances (ρfish) covering greater areas.
Envelope detection offers the best temporal precision.
The envelope extraction-based pulse detection was tested and compared with the three commonly used basic pulse detection methods. Results shown here demonstrate the effect of temporal processing based on single channels instead of using multiple channels to separate the effect of spatial averaging (described in the next section). The effect of the source-detector geometry variation on detection reliability and precision was measured and compared for five pulse detection methods: three basic (max, z-c, and |max|) and two envelope detection-based (env and env-diff). Pulse-timing markers for each method were selected as indicated by their names: max uses a maximum positive peak; z-c uses a falling zero-crossing point between two neighboring peaks of opposite polarity; |max| uses an absolute maximum peak; env uses an envelope peak; and env-diff uses a falling zero-crossing point of the differentiated envelope waveform.
Figure 9A compares the timing errors of the five pulse detection methods. The bars represent the timing errors that were determined from the SD of the pulse-timing difference (σΔT) between the externally and the locally determined pulses. The local dipole-derived pulse timing served as a geometry-invariant reference. The statistics were pooled over all geometric variations and the four recording dipole orientations (channels A–D) and computed separately for five pulse detection methods. In summary, the envelope detection-based methods showed the highest temporal precision (24 ± 3 μs for env and 24 ± 4 μs for env-diff) among all of the methods we tested. Two of the basic pulse detection methods (z-c and |max|) performed particularly poorly because their performance is vulnerable to the polarity reversal of the EOD pulse waveforms.
Multichannel summing offers high detection reliability and temporal precision.
The multichannel summing operation was tested for different numbers of channels recruited for summing. Its effect on the detection reliability and the temporal precision was thus measured. The detection reliability was largely determined by the pulse amplitude stability; thus reliability was indirectly measured from the amplitude variability under geometric changes. For instance, a missing pulse could occur when pulse amplitude drops too quickly below a threshold, even when the threshold was set adaptively. Three channel-summing modes (single, dual, and quad) are compared here and determined by the following: single mode recruits four separate recording dipoles (channels A, B, C, and D), dual mode recruits two sets of two perpendicularly arranged recording dipoles summed together (channels A+C and B+D), and quad mode recruits four equally spaced recording dipoles summed together (channels A+B+C+D).
Figure 9D shows the geometry-dependent pulse amplitudes as a function of ρfish and θfish for the four recording dipoles differently oriented (φelec). The amplitudes were separately normalized by the maximum amplitude observed at each dipole. The four single-channel amplitude plots show the maxima where θfish becomes parallel to φelec at each dipole, A–D, and the minima at the perpendicular orientations as expected from a dipole-like current source. The four single-channel plots approximately appear bilaterally symmetric along the body orientation axis (θfish), but they are in fact distinct because the fish's head and tail ends generate different waveforms (Rodríguez-Cattaneo et al. 2008). For the same reason, the pulse-timing plots from Fig. 9B appear more asymmetric along θfish.
Figure 9C compares the magnitude and variation of the summed pulse amplitudes for the three channel-summing modes. The bars represent the mean amplitudes of the summed pulses averaged over various source-detector geometries, each normalized by the maximum amplitudes in its respective channel-summing mode. The bar plot shown was generated from measuring pulse amplitudes after the env pulse detection method; other methods (|max| and env-diff) produced virtually identical results (Table 1). Recruiting more channels for summing increased the amplitude stability or reduced the amplitude variation under geometry changes (σAmpl. = 15% in single-, 13% in dual-, and 6% in quad modes), and the mean pulse amplitudes were increased as well (μAmpl. = 27% in single-, 52% in dual-, and 82% in quad modes; Fig. 9C).
Figure 10 shows that the temporal precision is further enhanced using additional channels, particularly when the multichannel summing (Fig. 9C) is combined with the envelope detection (Fig. 9A). The envelope detection method (env) outperformed the best basic pulse detection method (|max|) by 57% in dual- and 65% in quad channel-summing modes and produced temporal precisions (σΔT) of 23.5 μs in single-, 1.9 μs in dual-, and 1.2 μs in quad channel-summing modes (Table 1). env-diff Performed virtually identically to env in quad channel-summing mode, but it was easier to implement in analog electronics.
Real-time electronic pulse detector performance.
The timing error was measured for our real-time electronic pulse detector, which employs the quad summing and env-diff pulse detection methods. The time difference was taken between the TTL pulse output of the electronic detector and the reference pulse derived from the concurrently recorded local dipole, and the timing error was determined from the SD of the time difference over various source-detector geometries. Figure 10 shows that the temporal precision of the electronic pulse detector (2.7 μs) is 1.3 μs higher than the precision of the equivalent digitally implemented counterpart (quad env-diff). The higher error in the electronic detector could be due to the thermal noise contributed by circuit elements and nonideal filter behaviors resulting from nonmatched passive component values (resistor precision ≤ 1%, capacitor precision ≤ 5%). The maximum timing error reported by the electronic detector from restrained fish was 16 μs, closely matching the maximum error from the equivalently configured digital pulse detector (15 μs; Table 1).
Figure 11 compares the geometry-dependent timing errors between the electronic detector and the equivalent digital pulse detector. Although they share some common features on the top and bottom of the plots, these two plots generally appear different. This could be due to slight variations in the construction of the four parallel stages (Fig. 7A), causing timing offsets dependent on φelec. Manufacturing variability of the components used to construct the electronic detector was the main source of this discrepancy. In summary, our electronic pulse detector performed with a high temporal precision as expected from the equivalent digital pulse detector, whereas a longer recording duration is made possible by the online operation.
Pulse detection precision and reliability during free swimming.
Temporal precision of the real-time electronic detector was measured from tethered free-swimming fish, and the body-attached electrodes were used as a timing reference. Timing errors were separately analyzed based on the state of movement. Timing errors increased with movement for all pulse detection methods (Fig. 12A), but some pulse detection methods were more resilient to movement compared with others. Envelope-based pulse detection methods (env, env-diff, and eDetector) were much less affected by movement (by a factor of 1.4) compared with the |max| method, for which the timing error increased by a factor of 56.5 (Table 2). Timing error increased with visible movement because the vertical position of the fish, body posture, and yaw and pitch angles were simultaneously varied, causing large waveform distortions and fast fluctuations in pulse amplitude. The |max| method performed particularly poorly during visible movement because the peak point of a pulse waveform often switches from one lobe to another during free swimming when externally measured.
The timing errors measured from tethered fish (Fig. 12A) were generally larger than those from fixed fish (Fig. 10). However, the time difference between the local and the external recording dipoles changed little between two successive EOD pulses because the fish moved only slightly for this short duration. Thus the pulse interval was more precisely determined compared with the pulse timing due to mutual cancellation of the timing bias (Fig. 12B). The pulse intervals determined by the envelope-based methods showed close agreement between the local and external electrodes during free swimming. The SD of the pulse interval difference (σΔIPI) or the IPI errors were below the measurement resolution (ADC sampling interval of 5 μs) for the envelope-based methods, but |max| method produced much greater IPI error during visible movements. The maximum IPI error (49 μs) for the electronic detector occurred when fish contacted one of the recording electrodes and saturated an amplifier (Table 2). This contact occurred rarely, and the maximum IPI error excluding the gain saturation events was 15 μs.
Reliability of the real-time electronic pulse detector was tested from an untethered fish for an extended time (6 h), and no missing pulses were detected out of 1,191,371 pulses captured (<1 ppm; Fig. 12D). The pulse interval range was between 7.90 and 21.14 ms (Fig. 12C), indicating no missing pulse or noise spikes. The largest IPI difference (−5.74 ms) occurred during a large novelty event (Fig. 12D, inset) and was not due to an insertion of a noise spike event.
Measuring EOD pulses from free-swimming electric fish requires specialized signal processing to resolve the pulse timing precisely and reliably because the self-motion of fish alters the geometric relation between the source (fish) and the detectors (recording electrodes), which in turn varies the observed pulse amplitudes and waveforms. Basic pulse detection methods such as threshold crossing or peak detection from the raw pulse waveforms may perform well for stationary fish, but their performance deteriorates once fish swim freely. In contrast, our multichannel summing envelope detection method performs reliably and precisely even under a free-swimming condition. Our real-time electronic pulse detector achieved temporal resolution under 10 μs from free-swimming fish and operated with high reliability (error < 1 ppm). Based on the present results, the methods should be adequate for addressing how the fish's sampling rate changes during exploratory behavior and spatial learning.
Animals may reveal an interesting repertoire of behaviors (including some rare ones) from a long-term observation. To permit a long-term recording, our real-time electronic pulse detector demands little storage space (4 bytes/pulse) to store the EOD pulse time stamps. In contrast, a full waveform recording demands much larger storage space to offer a comparable temporal precision. To provide 5-μs temporal precision using a noninterpolated peak detection, ∼2,000 times larger storage space is required by sampling at 200 kS/s and 16 bits/sample. Such a high storage requirement only permits short EOD recording durations (<15 min per 2 gigabytes). Precision of measurement is generally limited by noise, often originating from the AC supply line or radio frequency-coupled sources; thus we physically blocked the noise sources by choosing a battery as a power source instead of the supply line and by shielding the whole aquarium with a Faraday cage. Furthermore, a range of frequencies exhibiting low signal-to-noise ratio (SNR) was filtered out; the low and high cutoff frequencies were determined by comparing the power spectra of the aquarium with and without fish.
Modern microcontrollers enable experimentalists to construct quickly high-performance and low-cost instruments by offering numerous analog and digital capabilities and easy-to-use design software. Inspired by Mavoori et al. (2005), we chose the PSoC to implement an online pulse discriminator because it offers all of the necessary analog (e.g., PGA, ADC, and filters) and digital (e.g., PWM, RS232 serial communication, and timer) modules to implement the discriminator. The analog and digital modules in the PSoC can distribute a task load by performing independently from the CPU yet can still be reconfigured by firmware during run time for flexible operations. By taking advantage of these unique capabilities, we constructed a versatile yet inexpensive (≤200 USD; see supplemental material) pulse detector, which is capable of updating the discrimination criteria in real-time to process a dynamically varying input signal via an adaptive threshold and an automated gain control.
Sources of error and limitations.
The local recording dipole provided for a geometry-independent timing reference. Because it is fixed with respect to the fish, the local pulse waveform was assumed to be constant over the geometric changes. However, the local pulse amplitudes slightly varied (σAmpl. = 3%), and decreased as the fish approached the circular boundary, because the plastic fences distorted the field. Also, the fish could have slightly repositioned itself within the holding frame over the duration of the recordings, thus slowly changing its position with respect to the local electrodes. The spinal pulse-discharge command may be a better reference for pulse timing because the discharge waveform is independent of the external geometry changes. However, recording this signal requires an invasive surgical procedure that may alter the natural course of EOD production and free-swimming behavior. It is also technically challenging to record from a spinal cord from a freely swimming fish for an extended period of time. Hence, we attached electrodes on the fish's body to approximate the timing of the spinal discharge action potential. The attached electrodes did not directly contact the fish skin to avoid recording myogenic potentials and were placed sufficiently far away from the tail to minimize waveform distortion during tail bending. Although the electrodes were stably attached, pulse amplitude and waveform recorded from the attached local dipole varied during free swimming (amplitude varied up to 20%), particularly when the fish bent its body and closely approached the water surface and the circular fence. The effect of movement on the attached local dipole may have inaccurately exaggerated the actual timing error by corrupting the local reference pulse timing.
The analog signal filtering stages introduce a constant time delay much greater (hundreds of microseconds) than the precision of the electronic pulse detector (≤10 μs), but the delays can be corrected after the recording session by advancing the pulse time stamps. This postprocessing task may not even be necessary when the EOD recording needs to be synchronized with much slower varying signals such as a video recording. Most importantly, the constant time delay does not affect the IPI, which is our main quantity of interest.
Temporal precision of pulse detection was significantly degraded when fish directly contacted one of the recording electrodes and saturated the amplifier. Lowering the gain could have prevented the saturation, but this will reduce the signal amplitude when the fish is sufficiently far away from the recording electrodes. Alternatively, one could protect the graphite electrodes by surrounding them with fine nylon mesh to prevent direct contact.
Although we simulated and systematically changed the source-detector geometry using three spatial parameters (ρfish, θfish, and φelec), we could not parametrically study other possible effects such as body bending, tilt and yaw, change of fish's depth, and fish contacting a recording electrode. This is mainly due to the difficulties in making quantitative measurements. Instead, we observed from a tethered (short-term) and an untethered free-swimming fish (long-term) to study their aggregated effects on the performance of our real-time pulse detector.
All measurements from restrained fish were taken from one individual of an unknown species of the Gymnotus genus collected within the same day. Pulse waveforms vary between different individuals, thus a single restrained fish was used to ensure that the pulse waveforms varied only as a function of the source-detector geometry. It was not possible to determine exactly the species of our fish due to nearly indistinguishable external appearances and pulse waveforms of numerous Gymnotus species (Crampton et al. 2003; Crampton and Albert 2003; Rodríguez-Cattaneo et al. 2008). The sex could not be determined by external appearance alone, and a dissection was not performed. However, our pulse detection method does not depend on particular pulse waveform shapes because the envelope extraction filter converts multilobed original waveforms to a unimodal shape. Thus, in principle, our method is applicable to other pulse species of the gymnotid and mormyrid families after determining the optimal low-pass cutoff frequency for the envelope extraction.
The current electronic pulse detector was designed for a lab setting and operates with a separate time-stamp logger. However, a future version could incorporate a flash memory-based logging capability for an all-in-one operation suitable for field deployment. A field-deployable EOD pulse detector unit may record from a larger body of water, and modifications to our current design for a scalable deployment may include an increased number of recording channels and an optimized spatial distribution of the recording electrodes to increase the signal reception strength. Because each channel contributes noise, inclusion of channels with low SNR deteriorates the measurement precision. Thus, to address this issue, an online channel selection algorithm could be implemented to exclude the channels containing low SNR automatically. Social interaction and electric communication between two or more pulse fish (same species) is an active research area in neuroethology (Perrone et al. 2009; Wong and Hopkins 2007), and the future version may be able to recognize pulses from different individuals by tracking a spatial location of each fish using triangulation from multiple channels. It may also be possible to modify our methodology to automate analysis of the frequency modulations used by wave-type gymnotiform fish during naturalistic social interaction (Hupé and Lewis 2008).
Texas Instruments and Cypress Semiconductor supplied us product samples at no cost. This research was supported by the Natural Sciences and Engineering Research Council of Canada (Postgraduate Scholarship D) and the Canadian Institutes of Health Research.
No conflicts of interest, financial or otherwise, are declared by the author(s).
J.J.J., A.L., and L.M. conception and design of research; J.J.J. performed experiments; J.J.J. analyzed data; J.J.J., A.L., and L.M. interpreted results of experiments; J.J.J. prepared figures; J.J.J. drafted manuscript; J.J.J., A.L., and L.M. edited and revised manuscript; A.L. and L.M. approved final version of manuscript.
We acknowledge Bill Ellis for the maintenance of fish and Drs. Crampton and Caputi for insightful discussions. We are grateful to two anonymous reviewers for their generous advice.
- Copyright © 2012 the American Physiological Society