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

[FEATURE REQUEST] add Hilbert transform #436

Open
labodezao opened this issue Aug 30, 2021 · 9 comments
Open

[FEATURE REQUEST] add Hilbert transform #436

labodezao opened this issue Aug 30, 2021 · 9 comments
Labels
enhancement New feature or request

Comments

@labodezao
Copy link

Hi,
I wonder if it's possible to implement the hilbert transform with micropython ulab.
Best regards

@labodezao labodezao added the enhancement New feature or request label Aug 30, 2021
@v923z
Copy link
Owner

v923z commented Aug 31, 2021

I assume, you want the implementation of https://docs.scipy.org/doc/scipy/reference/generated/scipy.fftpack.hilbert.html. However, before we add that, I wanted to ask, whether you could already calculate the Hilbert transform via the Fourier transform by applying the relation: Relationship with the Fourier transform.

@v923z v923z changed the title [FEATURE REQUEST] [FEATURE REQUEST] add Hilbert transform Jan 2, 2022
@labodezao
Copy link
Author

Hi, this is the right feature.
It's certainly possible to code this manually, yes, but some of my tries where hazardous :)

@v923z
Copy link
Owner

v923z commented Jan 2, 2022

OK, but the question is, whether this has to be implemented, if the same functionality can be gotten with the already available tools. In order to keep the flash size small, I would rather implement things with some python wrapper. https://github.com/v923z/micropython-ulab/tree/master/snippets

@labodezao
Copy link
Author

Hmm yes i did not think about it :)

@v923z
Copy link
Owner

v923z commented Jan 29, 2022

@labodezao I am not sure, where this issue stands now. Do you want to implement this functionality as a snippet, or should we close it?

@labodezao
Copy link
Author

This could be a good idea, but I don't have the knoloedge to modify the code :)

@v923z
Copy link
Owner

v923z commented Jan 29, 2022

This could be a good idea, but I don't have the knowledge to modify the code :)

But if it is supposed to be a snippet, then you would write the code in python, so you would not have to change anything in the code base. That's the beauty of it.

@labodezao
Copy link
Author

labodezao commented Jan 29, 2022 via email

@v923z
Copy link
Owner

v923z commented Jan 29, 2022

You have access to the Fourier transform, and then you use what is written in https://en.wikipedia.org/wiki/Hilbert_transform#Relationship_with_the_Fourier_transform. You can calculate the phase of your signal by calling np.atan2, and then shift the phase by +/-90 degrees. This all can be done in python.

EDIT: if this is performance-critical, we could move the calculations to C, but first I would like to see a working implementation in python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants