Main Content

Find and Track Ridges Using Reassigned Spectrogram

Load a datafile containing an echolocation pulse emitted by a big brown bat (Eptesicus fuscus) and measured with a sample rate of 7 microseconds. Create a MATLAB® timetable using the signal and the time information.

load batsignal

t = (0:length(batsignal)-1)*DT;
sg = timetable(seconds(t)',batsignal);

Open Signal Analyzer and drag the timetable from the Workspace Browser to the Signal table. Click Display Grid to create two side-by-side displays. Select each display and, in the Display tab, click Time-Frequency to add a spectrogram view.

Drag the timetable to both displays.

Select the Spectrogram tab. For each display:

  • Set the power limits to –45 dB and –20 dB.

  • Specify the time resolution as 280 microseconds and the overlap between adjoining segments as 85%.

  • Use the Leakage slider to increase the leakage until the RBW is about 4.5 kHz.

For the display at right, check Reassign.

The reassigned spectrogram clearly shows three time-frequency ridges. To track the ridges, select the display at right. On the Display tab, click Generate Script and select Spectrogram Script. The script appears in the Editor.

% Compute spectrogram

% Generated by MATLAB(R) 9.13 and Signal Processing Toolbox 9.1.
% Generated on: 15-Jun-2022 12:02:38

% Parameters
timeLimits = seconds([0 0.002793]); % seconds
frequencyLimits = [0 71428.57]; % Hz
leakage = 0.9;
timeResolution = 0.00028; % seconds
overlapPercent = 85;
reassignFlag = true;

%%
% Index into signal time region of interest
sg_batsignal_ROI = sg(:,'batsignal');
sg_batsignal_ROI = sg_batsignal_ROI(timerange(timeLimits(1),timeLimits(2),'closed'),1);

% Compute spectral estimate
% Run the function call below without output arguments to plot the results
[P,F,T] = pspectrum(sg_batsignal_ROI, ...
    'spectrogram', ...
    'FrequencyLimits',frequencyLimits, ...
    'Leakage',leakage, ...
    'TimeResolution',timeResolution, ...
    'OverlapPercent',overlapPercent, ...
    'Reassign',reassignFlag);

Run the script. Plot the reassigned spectrogram.

mesh(seconds(T),F,P)
xlabel("Time")
ylabel("Frequency")
axis tight
view(2)
colormap pink

Figure contains an axes object. The axes object contains an object of type surface.

Use the tfridge function to track the ridges.

[fridge,~,lridge] = tfridge(P,F,0.01,NumRidges=3,NumFrequencyBins=10);

hold on
plot3(seconds(T),fridge,P(lridge),":",linewidth=3)
hold off

Figure contains an axes object. The axes object contains 4 objects of type surface, line.

Thanks to Curtis Condon, Ken White, and Al Feng of the Beckman Center at the University of Illinois for the bat data and permission to use it in this example.

See Also

Apps

Functions

Related Examples

More About