-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Load DS9 regions into Subsets #1463
Conversation
4cdbf45
to
7122375
Compare
Codecov Report
@@ Coverage Diff @@
## main #1463 +/- ##
==========================================
+ Coverage 85.52% 85.62% +0.09%
==========================================
Files 94 94
Lines 9111 9209 +98
==========================================
+ Hits 7792 7885 +93
- Misses 1319 1324 +5
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
bffff54
to
c370b4c
Compare
124c6cc
to
3e0e591
Compare
This should be ready for review. With this patch, Ori can now load some common regions from DS9 file into Imviz for aperture photometry. |
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.
Just a few questions/suggestions from code-review. I still need to actually test and see how the static vs interactive subsets behave in the various subset/layer dropdowns before approving.
This looks like it deprecates but doesn't actually break existing API, is that right? So even though we don't officially have a semver policy (yet), there wouldn't be any need to bump the major version? Do we need to file a follow-up ticket/reminder to actually remove the deprecated methods?
WCS-to-pixel translation and mask creation, if needed, is relative | ||
to the image defined by ``refdata_label``. Meanwhile, the rest of | ||
the Subset operations are based on reference image as defined by Glue. |
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 worry that this distinction is too technical for a user. What other subset operations rely on the reference image instead of refdata_label
and what are the consquences?
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 it is okay to be a little technical in the API docstring.
I cannot tell you what are the implications because I tried to think of the scenarios and my head started to hurt. It is always murky here because Subsets are global but the linked coordinates transformation depends on what is the reference data in a particular viewer (which can be anything because Imviz is so flexible).
Ideas to make this implementation less confusing while maintaining flexibility is welcome. Otherwise, this is good enough until I get bug reports from Ori?
jdaviz/configs/imviz/helper.py
Outdated
self.app.session.edit_subset_mode._mode = NewMode | ||
self.default_viewer.apply_roi(state) | ||
self.default_viewer.session.edit_subset_mode.edit_subset = None # No overwrite next iteration # noqa |
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.
does this need to be reverted after the API call to whatever the user had set? Or is there a way to load these regions directly into the state without having to fake them as drawn regions?
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.
does this need to be reverted after the API call to whatever the user had set?
I don't think so? If user is using the API to load a bunch of Subset regions, and then user wants to interactively draw one, chances are user wants to draw a new one.
is there a way to load these regions directly into the state without having to fake them as drawn regions?
apply_roi
is the only way I know how to do this. Ideas welcome!
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.
My only idea would be if we could just add directly to app.data_collection.subset_groups
, but I'm not sure if that's writeable or not.
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.
Based on the implementation here, I cannot find a setter for the public property. In theory, you can write to almost anything in Python but since that would involve touching the private attribute, maybe we shouldn't go that route?
This is the opposite of what is offered by | ||
``glue_astronomy.translators.regions.AstropyRegionsHandler.to_object`` | ||
but does not cover all the same shapes exactly. |
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.
should this belong in AstropyRegionsHandler.to_data
then?
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.
Theoretically, yes, but if you look at https://github.com/glue-viz/glue-astronomy/blob/main/glue_astronomy/translators/regions.py at the time of posting:
(a) to_data
does not exist at all, so to implement one would include all the shapes that I do not care about as well, which is out of scope;
(b) getting anything into glue-astronomy takes too long and since this blocks Cubeviz feature, I want to avoid that overhead;
(c) I would also need to add more things to its to_object
because it does not support all the shapes I want here (especially sky regions).
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.
(d) If I could help it, I would say we get rid of glue-astronomy altogether but that is a fiery debate for another day.
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.
ok, then let's leave it here for now (I can now definitely appreciate point b). As for points a and c, I think something in glue-astronomy is better than nothing and we could always raise NotImplementedError
for things we don't need yet, but we can migrate this over if/when there is a need.
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.
Can always open a follow-up issue to port the code there. I'll add that as post-merge todo.
Only interactive subsets show in spatial subset dropdowns - is this always what we want? For the subset plugin, this probably makes sense since there isn't much of any information we can extract from the masked subsets (although maybe some day we'll want to be able to at least rename them there)... but is there anything preventing one of these masked subsets being used as the aperture in aperture photometry? This is likely the way that static regions behaved before, so I'd be ok with opening a new ticket and considering this out-of-scope, if you'd rather. Also, is this the expected numbering behavior for the following snippet? I would've expected "Subset 1", "MaskedSubset 2", "MaskedSubset 3" (in other words, are the numbering supposed to be independent or shared)?
|
Just got to your review now, Kyle. Thanks for your patience! I will comment in multiple parts as I work through the comments. And I will apply your suggestions in local commit (since I have rebased locally to resolve conflicts before I saw your suggestions) but I will credit you as co-author. Hope that is okay.
Yes. As you can see in the diff in test files, changes to the deprecated functionality are minimal. There is a bug fix to prevent bad mask from creating ghost Subsets but I don't see it worth mentioning in change log since the method is deprecated anyway and new API with the fix is still new API.
Yes. Over at |
Not sure what you mean. Your screenshot shows non-interactive MaskedSubset too. If you are talking about the Subset Tool plugin, I think there is a known bug that the non-interactive subsets do not show until after you interactively draw another one after you have loaded them. I thought there was a ticket but I cannot find it now. Maybe @rosteen remembers.
Yes.
I purposely made them independent. I don't see why they need to share numbering but I could be convinced otherwise. |
78720e5
to
1e39389
Compare
This comment was marked as resolved.
This comment was marked as resolved.
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.
Ok, I think all my questions were answered or addressed, thanks! Anything remaining can be iterated in the future based on user-feedback.
And just to clarify one thread:
Only interactive subsets show in spatial subset dropdowns - is this always what we want?
Not sure what you mean. Your screenshot shows non-interactive MaskedSubset too. If you are talking about the Subset Tool plugin, I think there is a known bug that the non-interactive subsets do not show until after you interactively draw another one after you have loaded them.
I meant for all plugin subset dropdowns (subset tool, model fitting, aperture photometry, etc). But your answer regarding aperture photometry suggests maybe this is desired behavior, at least for now.
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 tested this branch using the example FITS image and DS9 regions file from the ticket. Although all the regions are off the image, I didn't notice anything working differently than intended since Glue will still load those. I edited the regions file so a a few of their coordinates would land on frame and tried again, also with no issues. Both notebooks still work.
The tests added make sense, but should there be others for load_regions_from_file()
that cover scenarios where region_format != 'ds9'
? I guess those would really be a test that Regions.read()
works as we expect.
That is already tested in |
1bb1467
to
e362521
Compare
for some shapes. New API for Imviz regions and deprecate old ones. Update tests.
and post 2.8 release follow-up
Co-authored-by: ojustino <ojustino@users.noreply.github.com>
as ojustino requested
e362521
to
5453f94
Compare
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.
Thank you for the changes, @pllim. My last suggestions are just about wording, so I'll approve and leave their resolution to you.
Co-authored-by: ojustino <ojustino@users.noreply.github.com>
I opened follow-up issues. They are linked in the original post above. FYI. Thanks again for the thorough reviews! |
Description
This pull request is to allow loading DS9 regions into native Glue subset ROIs instead of the "static regions" that do not work with most plugins.
This is a breaking change for the following APIs:
jdaviz/jdaviz/configs/imviz/helper.py
Line 198 in cbcd65c
jdaviz/jdaviz/configs/imviz/helper.py
Line 236 in cbcd65c
jdaviz/jdaviz/configs/imviz/helper.py
Line 343 in cbcd65c
Pre-requisite for:
Close #1141
TODO
Post-merge
glue-astronomy
. See Move region/Subset translation code to glue-astronomy #1570Checklist 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.
trivial
label.CHANGES.rst
?