1 Introduction

Analyzing electrical and contractile signals from the gastrointestinal system has been performed since the early days of investigation of this organ system [2, 5, 6]. Similarly, because long periods of recordings were often required to monitor fasting and post-prandial activities, many attempts were made to automate the identification of significant features in those signals. Such developments include analysis of contractile signals [3, 9, 19], analysis of electrical signals [7, 17, 21] or both [8, 15, 18]. As usual, these attempts were initiated but also limited by the available technologies such as amplifiers, digitizers and processing units.

In recent years, by using multi-electrode recording techniques in vitro and in vivo, new concepts have emerged as to the propagation of action potentials (=spikes) and their relation to slow waves. Two types of spikes have been described, longitudinal and circular oriented spikes: each type is characterized by the waveform, by the location on the intestinal tract, and by the pattern of propagation [12]. However, little is known about the relationship between these spikes, the slow waves and the state of the intestines such as during a migrating myoelectric complex (MMC), the fasting state or post-prandially.

In order to obtain more insight into these relationships, a project was initiated to develop and implant sets of mini-electrode arrays to map the propagation of electrical signals with high temporal and spatial resolution in the small intestine of conscious dogs [22]. This approach allows the simultaneous recording of 24 electrograms from the serosal surface of the intestine. In a second part of this project, a computer algorithm was developed to analyze in real time the occurrence of individual slow waves and spikes at every electrode location.

2 Methods

2.1 Surgery

As described previously [22], four sets of six electrodes each were implanted in a row on the serosal surface of the canine duodenum or of the antrum using full anesthesia and standard anti-septic procedures. The connecting wires were tunnelled to the back and exteriorized at the base of the neck where the wires ended in a connector. After surgery, the dogs were allowed a 2-week recovery period before recordings were made. Experimental procedures were approved by the institutional ethical committee in accordance with EU directives.

2.2 Data acquisition

Twenty-four raw signals were acquired simultaneously using a 32-channel amplifier card (National Instrument; SCXI-1102C). Sampling frequencies were set at 200 or 1,000 Hz and a frequency range of 2–400 Hz was used [22]. After removal of a potential DC-offset, the signals were continuously stored on disk and displayed on screen. For the display, the signals were first smoothed with a running average to remove 50 Hz noise (20 point when sampling at 1,000 or 5 point when sampling at 200 Hz; [11]).

2.3 Real time signal analysis

A custom-developed program (EMGUT, ElectroMyography of the GUT) written in Labview 7.0 performed the automated analysis. The overall diagram of EMGUT is shown in Fig. 1. Upon acquisition of the signals, and while the signals are displayed on screen and saved on disk, the algorithm works its way through each of the 24 signals to determine if spikes occur at a particular moment in a signal or not. If these are detected then the Spike Detection Module analyzes that part of the signal, otherwise the Slow Wave Detection Module analyzes the signal.

Fig. 1
figure 1

Principles of the on-line detection of slow waves and spikes in signals obtained from canine small intestine in vivo. Each of the individual signals were led through a series of modules the first of which decides whether or not one or more spikes were contained in the signal. If this is the case, then the signal was diverted to the spike detection module otherwise it was led to the slow wave detection module. In both modules, the timings of either the spikes or the slow waves were determined and these values plotted onto the displays (cf. Fig. 5) of the original signals and stored on disc

2.4 Slow wave/spike discriminator

In order to discriminate between the slow wave and the spike waveforms the following algorithm was used (Fig. 2). After normalization of the signal (range 0–1), a high pass filter (usually set at 30 Hz) removed the entire slow wave component and the low-frequency components of the spikes while leaving the high-frequency component of the spikes intact. The next series of steps were performed to optimize the signal and to reduce the contribution of the noise. First the signal was converted to absolute values, which shifts the noise to one side of the scale (Fig. 2 signal C). A running mean was calculated from this signal and the median value subtracted from this, again to shift the noise away from the relevant signal, thereby creating series of smoothed peaks (Fig. 2 signal D). If this running mean exceeded the median multiplied by a user-selectable detection factor, then this indicated a period of spike activities. When this threshold was reached, that portion of the signal was diverted to the spike detection algorithm; otherwise it proceeded to the slow wave detection module. In this manner, the signal was essentially chopped into a “slow wave containing” signal and a “spike containing” signal. The chopped out sections were padded with blanks to convert the chopped signals into two continuous signals: one containing the slow waves (Fig. 2 signal F) and one containing the spikes (Fig. 2 signal G). These two separate but continuous signals were further processed in the two corresponding detection modules.

Fig. 2
figure 2

Diagram of the principles used to differentiate between the slow wave and the spike component in one electrogram recorded from the canine duodenum in vivo. Lower panels illustrate a typical signal and its derivatives as it is modified through this module. See text for more detailed description

2.5 Slow wave detection

In the slow wave detection module, the signal was differentiated (dy/dt; Fig. 3) and inverted, as we are interested in the negative flank of the signal [11]. The algorithm shown on the right-hand side of the slow wave detection module was again used to optimize the “slow wave” signal in order to suppress noise as much as possible. First the signal was differentiated with an amplitude-sensitive differentiator (y × dy/dt) that enhanced the relevant component of the signal (Fig. 3 signal D). The signal was then converted to absolute values which shifted the noise to one side of the scale (Fig. 3 signal E). Its running median value was subtracted from this, again to shift the noise away. This transformation was especially required to remove the high-frequency peaks resulting from the sudden transition of the blanked signal back to the original signal (arrowheads in Fig. 3, signal E). As in Fig. 2, but now without the spike waveforms, this created a series of smoothed peaks (Fig. 3 signal F). These rhythmic fluctuations in turn produced a sequence of windows during which the peak detector was allowed to search for a peak in the original inverted signal (Fig. 3 signal C). The timing of these peaks indicated the timing of the negative flank of the slow wave in the original signal. This timing is then plotted on the electrogram display and saved on disk.

Fig. 3
figure 3

Diagram of the slow wave detection module (upper panel), with the signal at different steps in the module illustrating the principles used (lower panel). The original signal is shown in Fig. 2. The asterisks in signal E illustrate the high-frequency peak that occurred in the transition from padded blanks to the original signal. These peaks were filtered out in the next step by the running mean (signal F): this signal unambiguously displays the slow waves from the original signal (arrows). See text for more detailed description

2.6 Spike wave detection

The spike detection algorithm (Fig. 4) is similar to the slow wave detection module except for the fact that the algorithm searches for peaks in the “spike” signal from which the slow wave fluctuations have been removed. The principles used are the same and the outcome, timing of the negative flank of each spike, is displayed and saved on disk.

Fig. 4
figure 4

Diagram of the spike detection module with, as shown in the lower panel, signals at different steps in the module illustrating the principles used. The original signal is shown in Fig. 2. The dashed vertical lines indicate the detected peaks (signal C) and their corresponding timing in the original signal (signal A). See text for more detailed description

2.7 Post detection processing

A difference between the functioning of the two detection modules was the use of an inhibition window in the slow wave detection but not in the spike detection module (not shown in the diagrams). Slow waves never occur at an interval shorter than half the previous interval [14], and this period was used to set the length of a slow wave inhibition window. After detecting a slow wave, the slow wave detection module was inhibited during half the preceding slow wave interval. This was necessary to avoid occasional double marking of slow waves that had two peaks in their differentiated signals. In the spike module, an inhibition window was not used as spikes often occur in bursts [13]. Such bursts are important to detect and to monitor as they indicate enhanced muscle contractions. As shown in Fig. 4, the spike detection module works fast enough to detect repeated firing in a signal (second spike complex).

Finally, after having detected the timing of the rapid flanks of the slow wave and spike waveforms, both peak detectors plot these values on-line as colour markers during the continuous display of the original signals (Fig. 5). There was no phase-shift as all filters in these LabView modules used dual phase compensation.

Fig. 5
figure 5

Examples of real time automated detection of slow waves and spike waveforms. In panel a, three electrograms from the antrum and nine from the duodenum are plotted for a period of 10 s in panel a and for 60 s in panel b. In panel a, the vertical green lines indicate when EMGUT detected slow waves and the red lines the timing of individual spikes. In panel b, the green bars have been left out for the sake of clarity to show that spikes in the duodenum seem to occur predominantly in the two to three duodenal intervals that occur after an antral activation. (Colors will be seen in online version only)

3 Experimental results

A total of 11 dogs have been implanted with sets of 24 mini-electrodes and their signals recorded and analyzed with the software described in this paper. Electrograms were obtained simultaneously from all 24 recording sites at high sampling frequencies of 200 or 1,000 Hz. These recording conditions generated a 1.1 or 5.7 Mb/min data stream respectively. Examples of the results achieved with the EMGUT software are shown in Figs. 5 and 6. In Fig. 5, four mini-electrode sets had been implanted: one on the distal antrum and three on the proximal duodenum; a row of 12 signals was plotted for a period of 10 s (panel A) and 60 s (panel B). The green marks indicate the timings when EMGUT detected a slow wave and the red marks when spikes were detected. In this period of time, all slow waves and most of the spikes were detected and adequately timed. A few spikes, especially those with low amplitude were missed. However, it should be appreciated that some of the signals also displayed a cardiac signal (ECG) that obviously should not be detected.

Fig. 6
figure 6

Results of the automated analysis of one electrogram from canine duodenum in vivo for a period of 3 h. The three panels display from top to bottom the slow wave intervals, the slow wave amplitudes and the number of spikes per slow wave. During this 3-h period, there were two migrating myoelectric complexes, as seen by the increase in number of spikes per slow wave that consistently decreased the slow wave intervals and amplitude. The dashed vertical line indicates that the maximal decrease in slow wave interval occurred after the termination of all spiking activity during the MMC

EMGUT not only analyzes and stores the individual timings of slow waves and spikes from each signal. A certain amount of data analysis is also performed while the signals are being recorded and processed. The data currently obtained on-line relates to the slow wave intervals and its amplitude and the number of spikes following each slow wave. This can be done for each electrogram individually or for the whole set, or a subset, of 24 electrograms. These data are then plotted in running graphs or histograms during the course of the experiment.

An example of this on-line analysis is shown in Fig. 6 in which a recording period of 3 h was performed. The three panels display the slow wave intervals, the slow wave amplitudes and the number of spikes after every slow wave as a function of time. During this 3-h period, two migrating myoelectric complexes (MMC’s) occurred in this part of the canine duodenum that led to two clusters of spikes. The number of spikes per slow wave interval during these two MMC’s ranged from 1 to 6 (average approximately 3.5) which is very similar to that reported in an in vitro study [13]. Furthermore, during this enhanced spike incidence, the slow wave intervals gradually shortened from 3.1 to 2.8 s (frequency increased) and the amplitude decreased in parallel. This is opposite to what was reported earlier [4, 24, 25] which could have been due to the disappearance of the slow wave signals in earlier records. The maximal increase in slow wave frequency was achieved some time after the spike activity had stopped and the MMC had passed.

Another offshoot of this program is the generation of ladder diagrams to illustrate the sequence of slow wave propagation over longer periods of time. Figure 7 shows the example of ten electrodes implanted on the anterior surface of a canine stomach, along a line located halfway between the greater and lesser curvatures. Control recordings showed uniform and stable aboral propagation in the stomach. Injection of glucagon (0.4 mg/kg IV) induced episodes of antral retrograde slow wave conduction and several bursts of tachygastria (panel C), one of which is illustrated in panel B.

Fig. 7
figure 7

Electromyographic signals from ten implanted electrodes located along a line halfway between the greater and lesser curvature (inset). Lines were drawn to connect slow wave deflections in signals from adjacent electrodes. This illustrates the stable and normal aboral propagation pattern during control (panel a), while injection of glucagon at the indicated time induced several bursts of tachygastria and retrograde slow waves as shown in the ladder diagram. The electrograms recording during one burst are shown in panel b

4 Discussion and conclusions

There have been a number of studies that have developed systems to automate the analysis of gastrointestinal signals. Both contractile and electrical signals have been used for this purpose and they all used the technological advances of their day. The same is also the case in our study in which we could use a more powerful computing power of personal computers and a more advanced acquisition technology than ever before. This enables the real time analysis and display of results for a large number of simultaneously recorded electrograms over a prolonged period of time.

The approach that was used resembles to a large extent what was used by others. Several studies have concentrated on differentiating between the slow wave and the spike component of the electrical signals and many have used the frequency differences between the two waveforms [1, 7, 10] as was done in the current study. Wang and Chen [23] has used a different approach of blind separation to differentiate between the two waveforms. Aside from the fact that their sampling frequency was much lower (20 Hz instead of 1,000 Hz) and their use of bipolar instead of unipolar recordings, their analysis was performed off-line.

Another significant difference between the current algorithm and those described in previous studies is the fact that we are identifying individual spikes and not spike bursts. This is important because spike bursts as such, especially when measured at one location, only describes a temporal phenomenon, the variability of which is quite limited [13]. There is need for much more detailed information concerning individual spikes both in the temporal and in the spatial dimension. The temporal dimension has often been addressed in several studies [16, 21]. With more raw computing powers, we can now expand towards the spatial dimension and analyze in greater detail the temporal and spatial relation between slow waves and individual spikes [20]. For example, with the data now obtained, a spatial frequency distribution of spikes in the wake of a slow wave could be constructed, similar to the slow wave propagation maps described in a previous study [22]. In addition, the recent description of two different spikes, longitudinal and circular, and the fact that they differ significantly in their waveforms would make it possible to differentiate between these two, for example by template matching. With closer inter-electrode distance [22], it would even be possible to map the propagation of these spikes as was done with the slow wave.

Finally, the results of the primary on-line analysis of slow wave interval, slow wave amplitude and spike incidence per slow wave allow for further off-line analysis and data reduction. These include averaged data on slow wave parameters and spike incidence per functional group of electrodes and/or per time period, slow wave propagation velocity and direction, beat-to-beat variability analysis, size of spike patches etc. In this way, the effects of particular interventions such as a meal, (patho)physiological stimuli or a drug administration on these parameters can be accurately assessed. The current computing power and data storage capacity enables continuous recording for many hours. The only limitation currently is that the animals need to be physically connected to the amplifiers by wires: telemetry does not yet allow for more than three to five signals to be captured (at least not at an affordable price). This precludes studies in freely moving dogs and thus implies that the animals need to be studied in Pavlov frames. Hence, continuous recording periods are limited to 5–8 h and interference from the laboratory environment with animal behaviour cannot be excluded. Nevertheless, the current model already generates many opportunities that were previously technically not possible.

In summary, an algorithm was developed that allows for the acquisition of large numbers of monopolar serosal electrical signals at high sampling frequencies from the stomach and small intestine in conscious dogs and for the real time analysis of the timing and the location of individual slow waves and of spikes in every signal. With these new tools, we shall be able to characterize in much more detail the subtle differences in behaviour of the intestines under a variety of experimental conditions such as day–night rhythm, fasting state, post-prandially, diseased states of disturbed motility, and the effects of drugs on the gastrointestinal system.