Show4DSTEM - Python widget for real-time 4D-STEM explorer and virtual detectors #146
Show4DSTEM - Python widget for real-time 4D-STEM explorer and virtual detectors #146bobleesj wants to merge 31 commits intoelectronmicroscopy:widgetfrom
Show4DSTEM - Python widget for real-time 4D-STEM explorer and virtual detectors #146Conversation
|
@dasol-yoon has agreed to test the API/features. Keeping it as a draft PR since folder clean-up is needed but it's a good starting point since the very basic features are done - virtual detectors, zoom, pan, color map, reset, zip, length, laster animation |
|
-Both sides have independent color controls, for cmap, vmin, vmax (and maybe linear/log/power scaling). |
|
@cophus Thanks and superb feedback from the very first alpha tester! Generous enough to even show mock designs as well. Will do:
Another layer of comments
|
- Add VI ROI for real-space region selection (circle/square/rect) - Add summed DP computation from VI ROI positions - Add dp_stats/vi_stats for mean/min/max/std display on both panels - Add scale modes (linear/log/power) for DP panel - Auto-detect center and BF radius on initialization - Move FFT toggle to VI header row - Hide crosshair when VI ROI is active - Fix annular slider overflow with smaller thumbs - Set reasonable initial sizes for VI ROI (~15% of scan) - Mask DC component for DP stats by default
- Python now sends raw float32 data for frame_bytes and virtual_image_bytes - JavaScript handles all display transformations (scale mode, colormap, vmin/vmax) - Scale mode (linear/log/power) changes are now instant without Python round-trip - Fix VI bytes parsing to correctly handle float32 data - Fix FFT scroll behavior to prevent page scroll when zooming
@cophus All done. @dasol-yoon I will upload v2 tmr or the day after. |
quantem.widget show4dstem ophus feedback self PR v1
|
v2 updated |
|
Hey @bobleesj -- nicely done, very impressive! Had a quick look on a large-ish Arina dataset (256,256,192,192) and here are my quick thoughts (video-real time): compressed_demo.mov
|
|
@gvarnavi Thanks George for testing! 🙏 Ah, I should have checked with unbinned Arina data. Will fix: george-v1 after ophus-v1
Regarding the reset button, for now, based on the following feedback (we can discuss of course)
|
|
I think it's working mostly with full ~9 Gb dataset. Will discuss more today's dev call |
…ton unactivated, fft scale
|
@bobleesj this looks much better indeed! Will try and check on the gold dataset before the dev call |
…v1-ophus-v1 Merge `Show4DSTEM` george v1 ophus v1
|
@gvarnavi indeed, much better with feedback. - Testing on my macbook now - it can't handle 9 Gb... but for smaller datasets (48x48x192x192(, VI is real-time
|
|
I will report back - loading full arina dataset to macbook/laptop for overriding defaults - I will make it easy to toggle on and off sth like this: I think it's eaiser than subclassing a widget since i haven't done subclassing yet |
- Remove isPow2(), debug console.log, unused array_utils functions - Remove vite.config.js (using esbuild directly) - Remove Show4D alias from __init__.py - Batch pos_x/pos_y and roi_center updates into single save_changes() - Use Python's pre-computed viDataMin/viDataMax instead of JS array scan - Rename "Virtual Image" label to "Image" - Add tests/visual_check.py for Playwright screenshot testing
…v2-ophus-v1 `quantem.widget` `Show4DSTEM` george v2 ophus v1
|
@gvarnavi works on your dataset. I will test a bit more. Tested across ~4 data types. I will wait for @dasol-yoon's feedback on her dataset type.
|
|
@bobleesj I think that looks great! But I want to maybe poke at it a little bit to make sure this is the right approach
Screen.Recording.2026-03-04.at.11.27.50.AM.movThe main thing is that right now the barrier for making a new widget is probably too high and I don't think that it has to be. The _esm definition for anywidget is pretty easy and approachable (javascript on the other hand is a completely insane language). The good thing is that there are literally billions of examples of javascript out there so LLM's are fantastic at writing it, anything that takes out a compliation step should be considered. Anyways... I'm really not sure. That being said it would be nice to have consistent widgets, plotting across different packages, |
|
@CSSFrancis As we spoke on the phone for a bit. We can revisit the points you've mentioned. Before I only had two constraints in terms of widget infrastructure: 1) make it universally fast and so it solves sicentific problems (denoise, drfit correciton, etc.) 2) do not affect Now, you are addressing the third point of 3) How to make it scalable so other serious widget devs. I hope you make some powerful real-time widgets like |
|
(in other words, please feel free to try what works best for you in designing widgets that require lowest latency possible and human interactivity, as if we are using a smartphone) |









What this PR does
A combination of
react,anywidget,WebGPUto get real-time 4D-STEM explorer.For developers:
Install Method 1.
quantem.widgetusing condaInstall Method 2.
quantem.widgetusinguvwithnodealready installed locallyAPI design:
Notebooks:
test_show4dstem_arina.ipynb
test_show4dstem_legacy_h5.ipynb