Add Region Browser with interactive editing functionality (#220, #219)#226
Add Region Browser with interactive editing functionality (#220, #219)#226Safwannn89 wants to merge 11 commits intoOSOceanAcoustics:mainfrom
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #226 +/- ##
===========================================
- Coverage 72.88% 52.13% -20.75%
===========================================
Files 11 12 +1
Lines 649 938 +289
===========================================
+ Hits 473 489 +16
- Misses 176 449 +273 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @Safwannn89, I've seen your PR, I should get back to you Wednesday! thx! |
|
Thanks for getting back to me! I wanted to share something I noticed after making this PR. I realized that relying only on PolyDraw wasn't ideal because it struggles to delete specific vertices (it's best used for adding and dragging). To give the user complete editing control, I think I will integrate PolyEdit alongside it. Here is how they would work together: PolyDraw: Add and move vertices. PolyEdit: Delete vertices (double-click, then press ESC). Since they both share the same polygon data, the user experience will be much smoother now. Please give your feedback on this! Thanks |
LOCEANlloydizard
left a comment
There was a problem hiding this comment.
Hi @Safwannn89,
Alright for the poly_draw and poly_edit, if that's smoother, then good! I guess we can still adapt/tune it later if needed, once we deploy and see how it goes.
One main change needed here: we should move the logic into modular functions so it can be reused elsewhere (and long-term integrated into a main app that call the different components/panels).
For instance, the code should live under echoshader/echoshader/, similar to those scripts:
Then in the notebook (which would keep the same content, I believe), you’d just call your function like:
browser = echoshader.region_browser(
ds=MVBS_ds,
regions=regions_df,
other options...
)
browser
Talking to @leewujung, she also mentioned we could look into xarray accessors: Extending xarray using accessors. See echoshader/core.py for how it’s implemented in echoshader. So the region browser could also fit this patern, e.g.:
browser = MVBS_ds.eshader.region_browser(regions_df, ...)
browser
The main code would still live in something like echoshader/region_browser.py, wth just a thin accessor method added in core.py. (does that makes sense?)
One open question: do we want something like
echoshader/regions/browser.py
echoshader/regions/editor.py
or should the editor come directly with the browser? (sorry if we already discussed this point!) Happy to hear your thoughts/ideas on this. Cheers!
|
@Safwannn89 following up on the review: just to clarify that we really don't necessarily have to go down the accessor route (just something to keep in mind). After a bit more discussion with @leewujung, not using the accessor pattern might actually be simpler for users, especially for more advanced functions like the region browser.. (But we would still need the .py script!) |
|
Thanks for clarifying! I'll go with the simple function approach (no accessor pattern needed). My Plan: I'll create a Usage would be simple: import echoshader
browser = echoshader.region_browser(ds=MVBS_ds, regions_df=regions)
browser.show()The notebook becomes much cleaner just load data and call the function! About the Browser vs Editor Question: I think keeping them combined (which is option A) makes more sense for a few reasons: The way I built it, Browse and Edit are just two modes in the same tool users toggle between them with a button. They share all the same components: navigation, echogram display, region selection, etc. Let me know what you think about this approach, then i will move forward. Thanks! |
|
Hi @Safwannn89, yes I think its good like this! Thank you! |
b872c0a to
ef393e4
Compare
|
Hi @LOCEANlloydizard and @leewujung, I've refactored the Region Browser and moved all logic into import echoshader
browser = echoshader.region_browser(ds, regions_df)
browser.show()
The notebook is now much simpler, just 3 cells to launch the browser! Let me know if you'd like any changes to the structure and also, I'm ready to test with real EVR data when you have it available! Thank you! |
156a22d to
3770e4f
Compare
| @@ -0,0 +1,134 @@ | |||
| { | |||
There was a problem hiding this comment.
| @@ -0,0 +1,134 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #4. # Create sample hake school regions in Echoregions standard format
- Put this as Markdown?
- remove icons
Reply via ReviewNB
| @@ -0,0 +1,134 @@ | |||
| { | |||
There was a problem hiding this comment.
Line #9. print("✅ Browser ready!")
maybe this is not useful? if the "Launching server at.." anyways comes up?
Reply via ReviewNB
|
Hi @Safwannn89, thanks for the update! Nice to see the shorter notebook also! I have a small comment below. Also, after addressing the first comments, I think you can request another round of review so I can take another look :) Notebook points
Implementation
So if a user wants to save their work, they still need to export the result to CSV. I wonder if we should make that more explicit, because “Save” sounds like it saves the work to disk. Also, if a user edits several regions and then clicks "Reset" by mistake before exporting, they would lose those edits, right? So I was wondering whether the Reset button should be this accessible, or even whether this functionality is really needed, since it seems users can already double-click a polygon to remove it?
Cheers! |
|
Thanks for taking the time to provide such a thorough review. I am currently working on your feedback and implementing the necessary changes. I will reach out to you as soon as I'm done. Thanks! |
for more information, see https://pre-commit.ci
…9/echoshader into feature/region-browser
for more information, see https://pre-commit.ci
|
I've pushed updates addressing all your points, along with some PEP8/flake8 style fixes. Notebook & UI Updates: Renamed to region_browser.ipynb and removed emojis for a cleaner look. Added narrative Markdown context, RTD links, and now display the native ds_ooi output. Created sample_hake_regions.csv to demonstrate a realistic import workflow directly in the notebook. Outputs are committed for ReadTheDocs. Tool and Bug Fixes: Drawing Tools: Fixed! The tools now properly attach to the overlay and reliably appear in the toolbar when switching to Edit mode. Added explicit UI instructions for using them. Reset Button: I re-engineered this based on your feedback. Instead of a global reset, it now safely restores only the currently viewed polygon to its original loaded state. This acts as a safe "Undo" if a user accidentally ruins a shape, without forcing them to lose all other edits by reloading the CSV. Happy to remove it if you still prefer! Save vs Export: Renamed "Save" to "Apply Edit" and added a highlighted UI warning so users know they must click "Export to CSV" to write changes to disk. Error Handling: Added explicit, color coded UI alerts for validation and parsing errors. Regarding the Speed/Lag Issue: To fix this properly, we need to refactor this component to use hv.DynamicMap. This will freeze the echogram in the browser and only stream the tiny polygon coordinate changes via WebSockets. Since this is a major architectural rewrite, I didn't want to risk breaking the current working CSV logic in this PR. Would you prefer I open a separate Issue to track a DynamicMap refactor for a follow-up PR, or include it here? Happy to discuss the best approach! Ready for another look! Cheers, Safwan |
|
Hi @LOCEANlloydizard , Hope you're doing well! Just a gentle nudge on PR #226, I've addressed all the feedback from your previous review, and the PR is ready for another look whenever you have a chance. Thanks! |

Implemented interactive region browser with Browse/Edit mode toggle and polygon editing capabilities.
Closes #220
Related to #219
Features:
Browse Mode
Edit Mode
Data Management
Validation
Technical Details
Format: Migrated to Echoregions standard (region_id as int, time/depth as numpy arrays)
Files:
docs/source/version_0.1.0/develop_region_browser.ipynb(Organized into 4 main sections: Setup & S3 Connection, Sample Data, Parser, and Interactive Dashboard)
Testing
Test Results:
Screenshots
Browse Mode:

Browse mode with dropdown navigation
Edit Mode:

Edit mode showing Actions section
Validation:

Validation error message
Ready for: