Open DavidT3 opened 2 years ago
The other issue is #80, says much the same thing as this one.
Going to write my general plan here. Work will probably be mostly focused in the Image class:
I think calls to edit regions will have to be done through a source/sample object for proper integration with XGA analyses. All the stuff I'm building into the Image class will remain there, but calling edit regions will return the new regions in various categories.
I did consider making every custom region an ellipse, but actually no I'll make buttons to allow circular or elliptical regions to be added as enabling things like rotation obviously makes no sense for circles, and circles can also have both their axes increased in size by all the buttons.
I'm testing out using a RangeSlider, something that seems to have come into matplotlib in v3.4 (I have 3.4.3 on the dev laptop) - If the rangeslider stays then I need to update the version in requirements.txt
There is the potential for a really big problem here due to the blocking behaviour of matplotlib combined with Jupyter Notebook. The editor is now working really well thankfully, but making it interact properly with XGA is going to be hard. This is because when a editor window is opened, none of the code waits for the user to be done interacting with the plot. So if you were running through 10 cluster's images for instance, you'd get 10 figures popping up, all interactive, and almost impossible to extract regions from.
Its okay if the windows pop out in a new window (as they do when the code is run in a non-Jupyter environment) because then (as long as plt.show(block=True) is added) then the code waits, but adding that line breaks the matplotlib implementation. I'm really not sure what to do about all this
So the Jupyter Notebook thing is causing some big issues here in terms of user experience, and I don't (yet) know how to solve them. The fact that the interactive window doesn't block the next steps in the code means that I can't make the code wait for the user to have edited regions.
The trouble is I need it to return an updated region list to a source object (for instance) so that source object can change its masks etc.
The interactive approach DOES work when windows are popped out (for instance when running the region editor from a script in terminal with a QT5Agg backend) but that is not the default behaviour in a notebook.
There are some immediate things I can do to mitigate these problems, though it's mostly putting artificial limits on the user and giving them some guidelines on how to use this in the documentation I'll write:
This issue is sort of connected to issue #777, where I want to introduce a method of checking what interloper regions a spectrum was generated with. Obviously if the interloper regions change I want XGA to know and to regenerate spectra etc.
The Image class needs to be altered so that it can have context as to what observation a region comes from. This will probably involve adding the ability to parse a dictionary of ObsID: [regions], as can now be output from a source object using get_interloper_regions().
This in turn will have to be accepted by the _InteractiveView class (which will require some modification), but then it will be able to keep straight which region belongs to which ObsID.
I am deleting the branch in which I performed the _InteractiveView work, as the reality is I'm not going to be coming back to it anytime soon, however this issue will remain open and on-hold.
This may be a duplicate issue but I can't find the other one (if I ever made it) so I'm doing this one!
I need to include the functionality that I wrote for FatController (ish) where regions can be moved around, new ones added, etc.
But I will need to research and figure out how to do interactive matplotlib in notebooks