-
-
Notifications
You must be signed in to change notification settings - Fork 419
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 Fourier transform playground example #5872
Conversation
Liking this very much!! FFT visualization often benefits from taking the log, to avoid large changes in amplitude. Something like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say I was very confused about where the animation was coming from... Then I saw the sneaky time()
call way inside wave_2d
! That'll learn me to read docstrings 😂 Personally, I would prefer for wave_2d
to be purely functional, take in the current time, and the higher-level loop (update_viewer
) to pass in the time. But I wouldn't hold up the PR for it.
At any rate, I played with it, and it's so mesmerising.... I love it. 😍 😵💫 😃
Codecov Report
@@ Coverage Diff @@
## main #5872 +/- ##
==========================================
+ Coverage 89.99% 90.01% +0.02%
==========================================
Files 618 618
Lines 52699 52831 +132
==========================================
+ Hits 47424 47556 +132
Misses 5275 5275 |
Nice! I settled on Speaking of which, I fixed the phase, since I was doing it wrong before: I was taking only the imaginary part instead of getting the angle of the complex number. I also moved out the time component from the base function, which I agree makes things cleaner. Should be good to go! |
This is great! It reminds me very strongly of Grant Jensen's image Fourier transform talk, which is part of his incredible Cryo-EM lecture series (seriously you should go look, it's brilliant and there are several other fourier transform videos in that series as well as the one I linked above) Can we add links to those in the text description as well? I think that would really help boost people's understanding. |
The docs build is failing, I presume because some of the threading / interactive examples need to be excluded from running in the gallery. (But tbh I don't know, the fail log doesn't offer much of a clue...) I can't remember how this works... @melissawm any ideas? 😬 🙏 |
Yeah, that's part of the go-to lecture series we always suggest to newbies (me included :P) here :) Being able to interact with it is so much better though. Explaining aliasing by moving a slider and seing the peaks in the power spectrum "bounce" on the edges is so satisfying :) |
I tested locally and couldn't find any issues (docs build just fine), but I restarted the CI job yesterday and was watching - it seems like the examples grow progressively slower after this new one, maybe something is leaking? Not sure how to debug locally as I don't see any issues but will try to poke around. Sorry I'm not too familiar with the threading stuff! |
Adding |
viewer.window.add_dock_widget(wdg, area='bottom') | ||
wdg() | ||
|
||
napari.run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be protected by if __name__ == '__main__':
, too? I'm a bit confused why it even works LOL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that to define some of the callbacks, the thread needs to already be spawned... so I would have to stick a lot of stuff inside the if __name__
block... not sure that helps much :P
# Description Adds a new example to play around with 2D sine waves and fourier transforms. I made it to better visualise and explain how power spectrum and phase behave depending on the fourier components. The example is also a nice showcase of two-way threading communication :P Here's what it looks like: https://github.com/napari/napari/assets/23482191/522f3e8d-cbe5-41c4-9c78-9da05d751adc
# Description Adds a new example to play around with 2D sine waves and fourier transforms. I made it to better visualise and explain how power spectrum and phase behave depending on the fourier components. The example is also a nice showcase of two-way threading communication :P Here's what it looks like: https://github.com/napari/napari/assets/23482191/522f3e8d-cbe5-41c4-9c78-9da05d751adc
# Description Adds a new example to play around with 2D sine waves and fourier transforms. I made it to better visualise and explain how power spectrum and phase behave depending on the fourier components. The example is also a nice showcase of two-way threading communication :P Here's what it looks like: https://github.com/napari/napari/assets/23482191/522f3e8d-cbe5-41c4-9c78-9da05d751adc
# Description Adds a new example to play around with 2D sine waves and fourier transforms. I made it to better visualise and explain how power spectrum and phase behave depending on the fourier components. The example is also a nice showcase of two-way threading communication :P Here's what it looks like: https://github.com/napari/napari/assets/23482191/522f3e8d-cbe5-41c4-9c78-9da05d751adc
Description
Adds a new example to play around with 2D sine waves and fourier transforms. I made it to better visualise and explain how power spectrum and phase behave depending on the fourier components.
The example is also a nice showcase of two-way threading communication :P
Here's what it looks like:
ft_playground.mp4