Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gcc (generalized cross correlation) function and tests #693

Merged
merged 15 commits into from
Apr 18, 2023

Conversation

louisfh
Copy link
Member

@louisfh louisfh commented Apr 14, 2023

This PR adds an implementation of generalized cross correlation. There are some things that should be changed - either before in PR or in a later release.

  • The correlation_lags function outputs the lag corresponding to each cross-correlation value in the output of gcc. Our correlation_lags are different so scipy.signal.correlation_lags, because the elements of their cross-correlation function are in a different order. We should instead standardize our output of gcc, so that the order of the elements matches the order of lags used by scipy.signal.correlation_lags. This may just require reversing one of the signals before convolution. I just need to test this.
  • Our gcc function is, slow. We should test if we can use scipy.signal.convolve in our implementation, and if it is any faster.

Copy link
Collaborator

@sammlapp sammlapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are two bugs in the filters. If you agree, I can fix them - but I want you to confirm.

sammlapp added 14 commits April 15, 2023 09:55
outputs need to be swapped around, and trimmed to remove padded regions. This results in equivalent outputs to scipy.signal.correlate and np.correlate. Because of this, we can use scipy.signal.correlation_lags rather than implementing a different version.
we just use 'n' to "pad" the rfft for "full" mode, then trim the results afterwards
adds function to estimate time difference of arrival (tdoa) of two discrete-time signals.
numpy -> torch
use optimal length fft
added arg for `radius` but haven't implemented (raises NotImplementedError if not None)
still needs tests - and might not be necessary/useful.
updates variable names in signal_processing.tdoa and audio.estimate_delay to be more intuitive: signal, reference. (If first arrives earlier, delay is negative; if second arrives earlier, delay is positive).
also adds a test for this functionality
HT filter had two mistakes
- gamma denominator had Gxx*Gxy instead of Gxx*Gyy
- phi denominator had coherence instead of (1-coherence) where coherence is |gamma| ^2
@sammlapp sammlapp merged commit 2c33ae6 into develop Apr 18, 2023
@sammlapp sammlapp deleted the feat_generalized_cross_correlation branch May 6, 2023 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants