The DSP Behind Bat Echolocation
A couple weeks ago, Dr. Bruce Patterson (the curator of mammals at The Field Museum in Chicago) was kind enough to send me some very high quality recordings of bat vocalizations captured during his recent expedition to Kenya. Bats use a lot of the same DSP techniques that sonar and radar use, and I thought it would be interesting to take a closer look.
Having the original recordings is really useful for doing analysis because I know that they haven’t been shifted down into the human hearing range and they haven’t been resampled or compressed, so all of the original data is there. Bats produce sounds that are anywhere from 14 kHz to over 100 kHz, so that means to collect bat recordings, you need a microphone with a good frequency response at those frequencies and you need to be sampling fast enough to accurately capture it. The files I analyzed were captured at 384 kHz, which means they should be able to unambiguously represent frequencies up to 192 kHz. The files were all uncompressed WAVs and were recorded with microphones that were capable of capturing ultrasonic frequencies.
A note on bat biology
Not all bats echolocate. There are two classes (the correct taxonomic term would be suborders) of bats: microbats and megabats. Microbats (suborder Microchiroptera) are usually the smaller of the two, but there are exceptions. Microbats all use echolocation and have a few morphological differences from megabats, the most important for this discussion being larger ears for their size and smaller eyes. Megabats (suborder Megachiroptera, family Pteropodidae), don’t echolocate, with the exception of one species, Rousettus aegyptiacus.
The bats I got recordings of were Cardioderma cor (the Heart-Nosed bat), Lavia frons (the Yellow Winged bat), Nycteris thebaica (the Egyptian Slit-Faced bat), Rhinolophus clivosus (Geoffroy’s Horseshoe bat), and Rhinolopgus eloquens (the Eloquent Horseshoe bat). Not all bat vocalizations are purely for hunting or localization. There are also social calls, and it’s possible some of the calls seen here have a social component to them, but I focused mainly on hunting and localization calls.
Echolocation in the frequency domain
A naive way to do active sonar is to simply send out a flat, single tone for a fixed amount of time, and then stop transmitting, start counting, and listen for a reflection. Because we know the speed of sound and when we started and stopped transmitting, figuring out the distance is just the speed of sound multiplied by the time the signal took to come back, divided by two. But if we’re clever about the kind of signal we initially transmit, we can significantly improve performance. Bats do this in several ways. For example, different bats use different frequencies depending on their prey and environment. Euderma maculatum chirps at about 12.7 kHz, which is low enough that cannot be heard by moths. To see other examples, let’s dig into some real signals. First, we’ll look at the Heart-Nosed bat. Here’s what it looks like:
These guys have really tall ears that almost look like rabbit ears. Here’s what they sound like when shifted into the human hearing range:
Here’s what their sound looks like:
This spectrogram was generated using Baudline. The Y axis is time and the X axis is frequency. This plot spans about 6 seconds. The calls start off fairly far apart, and then rapidly get close together in what is know as the “terminal buzz”.
Side note: this could also be explained by a Doppler shift, if the bat were flying toward the microphone and chirping at a steady rate. I don’t think that’s what’s happening here though, because the footage I saw of the researchers recording calls all had the bats flying away from them, and the speed needed to achieve a Doppler shift to produce a fake terminal buzz is faster than any bat can fly. There is undoubtedly some Doppler shift in these recordings caused by the movement of the bat relative to the microphone, but it shouldn’t matter much for our purposes.
When a bat approaches an object or prey, it starts sending out calls much faster to help improve accuracy at the expense of range. Also notice that the intensity of the sound decreases a little at the end of this recording. By adjusting how loud each chirp is, the bat can effectively set a limit on how far away he wants to “look”. However, I’m not sure if the intensity decrease here is due to the bat adjusting his volume or the microphone getting further away. To prove to you that it does happen though, listen to this YouTube recording of a bat (unshifted, you’re just hearing the part of his chirps that is below 20 kHz). Listen for the change in volume as well as the terminal buzz:
Let’s go back to our original recording and zoom in a bit:
Notice the spectrum plot at the bottom. The call has quite a large bandwidth of about 76 kHz. For reference, the human voice has a bandwidth of about 3 kHz, and that’s not even the continuous bandwidth.
There’s an interesting artifact in the Heart-Nosed bat call if we take a note from CSI and ZOOM! ENHANCE! If we set the equalization to to an X-curve and adjust the level to -40 dB, as well as use a Kaiser window with beta=5.31, here’s what we see:
If you look carefully, you can see what looks like a twisting pattern in these signals. Here it is a little closer:
At first, I thought I might be seeing a Doppler shift as the bat flew away from the microphone, but these nulls in the signal move backwards over the course of only a few milliseconds. The resulting speed you get if you do the math is about 25.5 m/s, which is faster than any bat I could find. My other guess was that it may be a feature of the larynx or some other biological structure within the bat that is resonating. But I think it’s actually frequency modulation. To me, it looks like there are three frequency ranges that are shifted downward in the course of about 3 milliseconds. So perhaps the biological structure that produces these vibrations resonates at those three frequencies or there are three different structures that almost overlap, but leave a tiny hole between each range. Frequency modulation like this, where a tone is swept over a range, is known as a chirp. It’s a very specific mathematical definition, and here’s what one sounds like:
As you can see, the Heart-Nosed bat sends out a relatively large bandwidth chirp that lasts for about 3 to 5 milliseconds. The bat then changes how often it sends this chirp out based on how close it thinks it is to its prey or an obstacle. This way, the bat gets more frequent updates on the location and characterization of the object. By sending such a large bandwidth signal, it may be able to identify different insects and objects by listening to how the frequency changes when the echo returns. Some objects may resonate at a particular frequency, causing that frequency to be attenuated in the reflection. By knowing what objects and insects attenuate which frequencies, the bat may be able to identify them.
The plots above show the results of a simulation of echos off of an insect. Each of the four plots represents an insect with different body and wing proportions. You can see that the spectrum changes a lot, even for small physical dimension changes. Bats can use this information to help classify targets. This may also be aided by using simple amplitude return information. For example, a baffle like the leaves of tree may disperse the sound, resulting in a weaker echo. A flat, hard object like the side of a building will reflect really well and return something much closer to the original amplitude.
Let’s look at another bat: the Yellow Winged bat. Here’s what he looks like:
Here’s what he sounds like in the human hearing range:
And here’s what his sound looks like:
Recognize the terminal buzz? The Yellow Winged bat has different frequency characteristics than his Heart-Nosed relative, however. The Yellow Winged bat has a bandwidth of about 55 kHz that spans from ~33 kHz to ~88 kHz in this recording. The Heart-Nosed bat has a bandwidth of about 74 kHz that spans from ~38.5 kHz to ~112.5 kHz. The chirps on both bats last for about the same amount of time, 5 ms. As far as we know, all bats of the same species have the same chirps, and most species have their own chirps, but you can’t always identify a bat based solely on its chirps. The Yellow Winged bat chirp has a lot in common with the Heart-Nosed bat though. Both signals have a large bandwidth and don’t appear to change bands over time. Let’s look at one more bat that has this same structure, the Egyptian Slit-Nosed bat:
That’s a rather dramatic picture, but his sounds look familiar:
Notice that the chirps are shifted up from the Yellow Winged bat and closer to the Heart-Nosed bat. These chirps span from 64 kHz to 186 kHz, and are 122 kHz wide (although there are components that go up even higher until they’re limited at 192 kHz because of the sample rate). This bat’s chirps also have the same unusual frequency shifting artifacts:
Alright, now let’s look at my favorite bat chirps from the Rhinolophus family. First, Geoffroy’s Horseshoe bat.
Their sounds look totally different!
This bat is using two techniques. First of all, notice that the chirps are produced in groups, rather than one at a time. In each chirp, there is one fundamental frequency at about 100 kHz, then another one at about 50 kHz, and two more above it at 150 kHz and 182 kHz. Let’s look at the structure more closely.
First, a frequency modulated signal is produced, followed by a continuous frequency, and then another frequency modulated signal. A single, continuous frequency helps the bat determine the velocity of the object it’s tracking, as well as whether or not the object has wings. If a moth is flying away from the bat, the echos that reflect off of it will be Doppler shifted down, meanings that the bat will hear his call echo back at a lower pitch. Additionally, the fluttering wings of moths and other insects will cause small amplitude changes and Doppler shifts that the bat can use to help identify the object. 0If a bat is tracking a particularly fast moving object, the resulting Doppler shift may be so large that it lands outside of the bat’s hearing range. To combat this, bats that use continuous frequencies are able to change the pitch their initial chirp to ensure that the shifted returning echo stays within their hearing range. The other advantage to using continuous frequencies is increased range. Notice that the duration of continuous frequency calls are much longer than the frequency modulated calls. A longer duration followed by a longer listening period means that there is more time for echos from further away objects to come back. If the initial chirp was frequency modulated, the returning Doppler shifted echo might overlap the transmitting frequencies, but if all the energy of the call is concentrated in a single narrow band, there’s a lower chance that the returning echo will overlap the initial frequency. Because the continuous frequency technique is ideal for greater range, bats tend to use it when they are flying or perching in open, clutter free environments.
A frequency modulated signal has its own advantages. Because the bat can correlate frequency as well as simple reflection time, the spacial resolution is much better than simple continuous frequency methods. One experiment showed that bats using frequency modulation can distinguish two objects as close together as half a millimeter! Additional harmonics in the call can improve this even further. One disadvantage of frequency modulation is that the effective range of detectable objects is much shorter. This is in part because the energy of the call is spread out over a larger frequency range.
There are some bats that use only continuous frequency, and some that use only frequency modulation, but bats in the Rhinolophus family like Geoffrey’s Horseshoe bat use both. This is one of the most complex biosonars that we know of.
Let’s look at another species of Rhinolophus, the Eloquent Horseshoe bat.
You can see that this species uses more harmonics than Geoffrey’s Horseshoe bat, and the primary frequencies are different. There are some other interesting artifacts if we zoom in closer.
This is the spectrum for the CF part of the call, and here’s the spectrum for the first FM chirp:
And here’s the spectrum for the bottom FM call:
The waveform looks like it’s got lots of other continuous frequency harmonics. I’m not sure what those are from. It may have something to do with the resonating properties of the biological mechanism that creates these sounds. They don’t look strong enough to be used for improving localization, but I could be wrong. I spotted another unusual artifact in this same species:
Here you can see harmonics more clearly as well as shorter, weaker, and more periodic CF pulses. For comparison, here’s what a clean chirp from this species looks like:
Signal Processing Anatomy
Most bat ears have fairly similar anatomy to human ears. There are a few special differences though. Some species have muscles in their inner ear that tighten during chirping to decouple the eardrum, preventing the bat from damaging its own ears. Bats in the Rhinolophus family, like the last two bats we looked at, have different structures for handling the continuous frequency part of their calls.The basilar membrane is a thin structure that runs along the cochlea and resonates with incident sound waves. Human ears have this membrane too, and it’s part of what determines which frequencies we are most sensitive too. Rhinolophus bats have a basilar membrane that is much larger in areas that correspond to about 83 kHz, which is the frequency at which the bat calls.
The auditory cortex of the bat brain is highly sensitive to time. Bats can distinguish sounds that are as close as 500 ns apart. The neurons in this part of the brain retain their sensitivity to time even as the intensity of the signal changes, a behavior that is not seen in non-echolocating animals. This is possible because the interneurons in the auditory cortex will only fire one or two action potentials when stimulated. They also have a very low activation threshold, meaning they can continue to function even the presence of weak signals. Bats with FM calls have neurons that are tuned for specific frequencies within the frequency shift. What’s really cool is that those neurons are mapped to a grid within the bat’s brain. Each row is a frequency and each column in a time (see Nobuo Suga’s work if you want more detail on this). This same structure also exists in bats that use continuous frequency calls.
A mathematical perspective
A number of biologists believe that bats may use a technique called coherent cross-correlation. If correct, it would mean that bats use the phase of the sound waves to continually compare the signal they are hearing with the signal they are creating. The latest research suggests that bats don’t use coherence, but they do use cross-correlation. To see how this works, let’s first examine the FM chirp in eloquens and clivosas, the two Horseshoe bats. These chirps use hyperbolic frequency modulation. It can be modeled as:
where Q is the inverse of the fractional bandwidth. So why don’t bats use linear frequency modulation? Because a Doppler shifted hyperbolic frequency modulated signal has the same form as the original (this isn’t true for linear FM). This makes cross-correlation much easier.
Plot “a” shows the time domain waveform of an original chirp. Plot “b” shows the time domain echo after being Doppler shifted. Plot “c” shows the frequency domain version of the original linear FM signal and the echo. Notice how the echo has been delayed and the slope has changed. Plot “d’ shows the frequency domain of a hyperbolic FM signal along with the echo. The signal is shifted again, but this time it’s shifted along the same curve, which makes cross-correlation much more effective.
Cross-correlation is defined as
If that reminds you of convolution, there’s a reason for that. Convolution is defined as
Wikipedia has a nice diagram visually explaining these two functions.
Both of these functions are essentially summing up the area under the intersection of two functions as they slide by each other. In the case of cross-correlation, when the two functions match, the cross-correlation is maximized. That’s why it’s so important that the echo of the original signal have a similar structure to the original, hence the use of hyperbolic FM.
Believe it or not, echolocation countermeasures are practiced in the wild. One species of Tiger moth, Bertholdia trigona, produces its own ultrasonic clicks in the same band as its predator, preventing the bat from discerning between echos and tones generated by the moth. Here’s what it looks like:
This same technique has been used in electronic countermeasure systems for radar and sonar. Other moths simply produce ultrasonic tones as a sort of sonic equivalent to bright markings on their wings, designed to warn their bat predators that they won’t taste very good. But just as in warfare, electronic counter-countermeasures exist, which are designed to resist jamming attempts. Some species of bats can shift their chirping frequency in response to noise. This switch can take place almost instantly. Despite these countermeasures, Bertholdia trigona has been shown to have an almost 10x higher survival rate than other moths, proving how effective even simple jamming techniques can be.
Bats can use interference patterns and multipath effects to determine elevation. If you’d like a deeper look at the math, I highly recommend The Physics of Bat Echolocation. Additionally, many bats appear to be able to focus their ultrasonic emissions using complex baffles on their faces.
These shapes have a beamforming effect and are thought to increase the ability of the bat to resolve prey. Some work has been done in 3D modeling and simulating the effect of these baffles, but there is still a lot of interesting work to be done. There is a huge amount of diversity in bats, and that includes the various ear and nose shapes. Here’s a selection of different bat ears and noses:
And here are the various -3 dB contour maps for some different ears. Frequency is encoded by shading: lower frequencies are darker.
These images are from this paper, which I recommend if you’d like more detail.
Bats are amazing
There are people who spend their entire career doing this kind of analysis, and this is just the tip of the iceberg. There’s so much we have to learn about life on our planet. If you want to dig into more detail, check out the links below. They give a lot more information about both the biological side of things and the mathematical/signal processing side of things. I’m grateful to Dr. Patterson and Dr. Webala for collecting and sending me the bat vocalization recordings that got me into all of this. And thanks to The Field Museum and Emily Graslie for setting up the Bats of Kenya event in the first place!