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

Imviz: Allow Subset recentering via centroiding #1823

Merged
merged 8 commits into from
Nov 14, 2022
Merged

Conversation

pllim
Copy link
Contributor

@pllim pllim commented Nov 4, 2022

Description

Implements centroiding of Subset in Imviz.

This pull request also shows a proof-of-concept notebook on how we might be able to edit Subset objects programmatically in a fun way.

If you know of a better way to do this, please let me know.

Click here to watch it in action. (YouTube video)

Address part of #1442

Example workflow

At the beginning, an imperfectly centered Subset was drawn. Clicking on Recenter button will take you to the second screenshot.

Screenshot 2022-11-09 180838

Subset is moved. Editable fields (desired) agree with static fields (actual).

Screenshot 2022-11-09 181027

After about 10 iterations of this (recenter, recenter, ...), it finally converged; i.e., clicking "Recenter" will not change anything. Note that for some sources (e.g., crowded or noisy fields), it may never converge.

Screenshot 2022-11-09 181121

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)? 🐱

@pllim pllim added the no-changelog-entry-needed changelog bot directive label Nov 4, 2022
@pllim pllim added this to the 3.2 milestone Nov 4, 2022
@github-actions github-actions bot added the documentation Explanation of code and concepts label Nov 4, 2022
@pllim pllim added the imviz label Nov 4, 2022
@codecov
Copy link

codecov bot commented Nov 4, 2022

Codecov Report

Base: 88.15% // Head: 88.23% // Increases project coverage by +0.08% 🎉

Coverage data is based on head (e7c15a4) compared to base (ab1b363).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1823      +/-   ##
==========================================
+ Coverage   88.15%   88.23%   +0.08%     
==========================================
  Files          95       95              
  Lines       10279    10343      +64     
==========================================
+ Hits         9061     9126      +65     
+ Misses       1218     1217       -1     
Impacted Files Coverage Δ
...igs/default/plugins/subset_plugin/subset_plugin.py 98.54% <100.00%> (+0.61%) ⬆️
...imviz/plugins/aper_phot_simple/aper_phot_simple.py 91.83% <100.00%> (+<0.01%) ⬆️
jdaviz/configs/imviz/plugins/viewers.py 87.64% <100.00%> (+0.14%) ⬆️
jdaviz/core/region_translators.py 98.98% <100.00%> (+0.13%) ⬆️
jdaviz/configs/mosviz/plugins/parsers.py 91.13% <0.00%> (+0.02%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pllim pllim marked this pull request as draft November 7, 2022 20:37
@pllim pllim removed the no-changelog-entry-needed changelog bot directive label Nov 7, 2022
@pllim pllim changed the title POC: Programmatically edit subsets POC: Programmatically recenter subsets Nov 7, 2022
@pllim pllim changed the title POC: Programmatically recenter subsets Imviz: Allow Subset recentering via centroiding Nov 9, 2022
@pllim pllim marked this pull request as ready for review November 9, 2022 23:17
@camipacifici
Copy link
Contributor

Love the functionality! I tried with multiple layers and everything worked as expected.
I find a bit inconvenient to have to click two things though. I do not see a use case where I would click recenter and not click update. Is there a better way to have the two actions happen with one click? If not, would you consider keeping the recenter tab open so at least the user does not have to click three times to do a second iteration?

@pllim
Copy link
Contributor Author

pllim commented Nov 10, 2022

I thought it would be too confusing to have "Recenter" do update and "Update" also do update. Only having one button that actually updates feel more consistent to me, but I'll defer to UI/UX experts.

would you consider keeping the recenter tab open

I would but I just don't know how to do that. Maybe Kyle knows? 😆

@kecnry
Copy link
Member

kecnry commented Nov 10, 2022

I would but I just don't know how to do that. Maybe Kyle knows? 😆

Pushed a commit that'll do this (feel free to rename anything)

I find a bit inconvenient to have to click two things though. I do not see a use case where I would click recenter and not click update. Is there a better way to have the two actions happen with one click?

I think I agree with this, but also see how it might be useful to have feedback of what will happen before making the edit (currently irreversibly). Another option might be to have non-editable text in the plugin for the "proposed" changes to the subset information that updates in real time as the data selection or subset position is moved... but then we'd have that information in 3 different places in the plugin which might cause some confusion.

I think it would also be useful to have the data dropdown default to the top layer... but that might be a more general improvement to the data dropdown component itself and out-of-scope here?

Comment on lines +47 to 48
in the app-level toolbar. It might not show some static regions loaded
via the API unless an interactive region is drawn after.
Copy link
Member

Choose a reason for hiding this comment

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

is there an issue filed for fixing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't remember, maybe @rosteen does. It only happens if you load things like Space Invader (which turns into masked subset), so 99% of users will never even encounter this.

Comment on lines +238 to +242
reg = _get_region_from_spatial_subset(self, self.subset_selected)
aperture = regions2aperture(reg)
Copy link
Member

Choose a reason for hiding this comment

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

would it be useful to move this into the component itself for re-use - so self.subset_select.aperture or self.subset_select.to_aperture()? Or would it have a place upstream in glue-astronomy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this will eventually move upstream. At least Larry or I added a few of these in that table.

@camipacifici
Copy link
Contributor

Having the tab open is very useful thank you!
I was thinking that another workflow could be to do one recenter and one update to see that the subset is actually moving in the right direction (no mistake in the layer or subset or anything), but then I could keep pressing recenter until the numbers do not change anymore before updating again. As far as I understand, this is currently not possible. I have to update before I can recenter again. Can "keep clicking recenter" be an option?

@@ -22,6 +22,29 @@
</v-col>
</v-row>

<!-- Sub-plugin for recentering of spatial subset (Imviz only) -->
<v-row v-if="config=='imviz' && is_editable">
<v-expansion-panels accordion v-model="subplugins_opened">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Magical. Thanks, Kyle!

@pllim
Copy link
Contributor Author

pllim commented Nov 10, 2022

I think it would also be useful to have the data dropdown default to the top layer

I wanted that a long time ago but never got it to work. See #743

@pllim
Copy link
Contributor Author

pllim commented Nov 10, 2022

Can "keep clicking recenter" be an option?

I don't see how that is useful without visual feedback. You see the numbers keep changing but the subset is not moving. How do you know it is moving in the right direction?

@pllim
Copy link
Contributor Author

pllim commented Nov 10, 2022

@kecnry and @camipacifici , have I sufficiently addressed/answered your comments/questions?

@camipacifici
Copy link
Contributor

Can "keep clicking recenter" be an option?

I don't see how that is useful without visual feedback. You see the numbers keep changing but the subset is not moving. How do you know it is moving in the right direction?

I would Guess that if the user sees it moving once in the right direction they will know it is going in the right direction when seeing the numbers change. And they could still update at any time.

@camipacifici
Copy link
Contributor

If I understood correctly, now I can keep pressing recenter, but nothing happens and there is no instructions that I have to update before I can recenter again (or maybe I missed it?). User might think that centroiding has converged, while it has not.

@kecnry
Copy link
Member

kecnry commented Nov 11, 2022

One option around this might be to have the recenter button immediately update the subset but to cache the old version and have a "revert/undo" button that can undo the latest step in case the user doesn't like the changes?

@camipacifici
Copy link
Contributor

I like the solution, if you think it will not be confusing for the user to have an "undo" button only here (and in the zoom tool right?), but not everywhere.

@pllim
Copy link
Contributor Author

pllim commented Nov 11, 2022

Then what do we do with the Update button? I am getting a little worried.

@kecnry
Copy link
Member

kecnry commented Nov 11, 2022

Then what do we do with the Update button?

No harm would be done if the user clicks "update" again, right? But maybe @Jenneh would have some ideas to make the different use-cases intuitive. Or maybe we're overthinking and recentering will almost never do anything "wrong" and so we can just immediately update the subset without having to worry about the user wanting to reject the proposed changes?

@pllim
Copy link
Contributor Author

pllim commented Nov 11, 2022

It's Friday and it appears I am outvoted 2-to-1, so I went ahead and changed the Recenter button to also Update.

@pllim pllim requested a review from Jenneh November 14, 2022 15:51
Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

Recentering itself seems to work as expected! But I guess subplugins_opened needs to be Any in order to accept None when closed 🤷 (sorry I missed that earlier).

There is some UI flashing when updating the subset, but that appears even with the manual entry so can probably be considered out of scope. Also out of scope - this is another case where making the layer/data dropdowns intelligent about the top layer (either by having a "top layer" option in the dropdown, having them default, or show a warning when selecting something that is not the top layer) would be quite useful!

Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>
@pllim
Copy link
Contributor Author

pllim commented Nov 14, 2022

Thanks! I applied your suggested fix.

@camipacifici
Copy link
Contributor

this is another case where making the layer/data dropdowns intelligent about the top layer (either by having a "top layer" option in the dropdown, having them default, or show a warning when selecting something that is not the top layer) would be quite useful!

I agree!

@camipacifici
Copy link
Contributor

Works well! Thank you!

@pllim
Copy link
Contributor Author

pllim commented Nov 14, 2022

having a "top layer" option in the dropdown

But top layer in which viewer? 😉 Pondering for another day.

I'll count Cami's comment as second approval and merge. Thanks, all!

@pllim pllim merged commit f0796f2 into spacetelescope:main Nov 14, 2022
@pllim pllim deleted the pong branch November 14, 2022 17:47
@rosteen
Copy link
Collaborator

rosteen commented Nov 14, 2022

I was too slow in testing this, but for what it's worth I also approve 😆. I like the immediate update on hitting the recenter button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Explanation of code and concepts imviz Ready for final review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants