sunpy / sunpy

SunPy - Python for Solar Physics
http://www.sunpy.org
BSD 2-Clause "Simplified" License
919 stars 591 forks source link

Region of Interest Object #164

Open wafels opened 12 years ago

wafels commented 12 years ago

It would be good to have a region of interest (ROI) object.

A ROI object would contain at least the following:

Example use case:

User uses HEK module to get a list of events for some time range. BBox info/chain-code from HEK results are automatically converted to SunPy RegionOfInterest instances. Those instances can then be drawn as overlays on a Map instance, using something like "aiamap.show(overlays=hek_events)"

Here are some possible ways I could imagine creating a new RegionOfInterest:


 roi = RegionOfInterest(0, 0, 100, 100)                # x1, y1, x2, y2
 roi = RegionOfInterest(0, 0, 0, 100, 100, 100)   # x1, y1, z1, x2, y2, z2
 roi = RegionOfInterest([(79.500,-552.300),(80.100,-551.700),(94.500,-531.900), ...])  # chaincode (2d)
 roi = RegionOfInterest([(79.500,-552.300, 100.),(80.100,-551.700, 200.),(94.500,-531.900, 300.), ...])  # chaincode (3d)

# Shapes?
roi = RegionOfInterest(rect=[...])
roi = RegionOfInterest(circle=[...])
roi = RegionOfInterest(sphere=[...])
roi = RegionOfInterest(polygon=[...])

# Time support?
roi = RegionOfInterest(rect=[...], datetime = ...)
roi = RegionOfInterest(circle=[...], datetime = ...)
roi = RegionOfInterest(sphere=[...], datetime = ...)
roi = RegionOfInterest(polygon=[...], datetime = ...)
roi = RegionOfInterest(chaincode=[...], datetime = ...)

# Support for lots of them on plotting for Map
rois = [roi1, roi2, roi3,..., ]

aia.show(overlay = rois, useOverlayDateTime = True )
# only display ROIs that overlap with the map object datetime
useOverlayDateTime = True 
# ignore the ROIs map object datetimes and plot them all on the map
useOverlayDateTime = False 

See an older GSoC project: https://openastronomy.org/gsoc/gsoc2018/#/projects?project=region_of_interest

Extra

More generally it would be good to have an HEK event class that holds event information. That could be an ROI or EOI factory, that understand HEK or other type of outputs.

WIP about extra methods

Could contain a number of functions (methods), such as 'GROW' or 'SHRINK' or 'ROTATE'. There are many different ways to perform a "grow" and a "shrink" operation; scipy has a set of these operators under the "morphology" module

http://docs.scipy.org/doc/scipy/reference/ndimage.html#module-scipy.ndimage.morphology

I suppose you could pick one method and say "This is the default method", but you are not guaranteed to end up with something like you thought you were going to get. For example, the "shrink" operation may end up splitting one ROI in to two unconnected ROIs.

How will we handle that? Is this what the user wants? On saying that, there are probably ways to ensure that you only ever return a single region after a "shrink" operation, but such considerations veer quickly in to the domain of image manipulation and away from a simple ROI object. I'm not saying it shouldn't be done, I'm just saying it requires some experimentation first.

khughitt commented 12 years ago

Example use case:

1) User uses HEK module to get a list of events for some time range. 2) BBox info/chain-code from HEK results are automatically converted to SunPy RegionOfInterest instances. 3) Those instances can then be drawn as overlays on a Map instance, using something like "aiamap.show(overlays=hek_events)"

aringlis commented 12 years ago

So, a ROI object as I understand it would contain at least the following:

We discussed yesterday that the ROI could contain a number of functions (methods), such as 'GROW' or 'SHRINK' or 'ROTATE' - Not sure how useful those would be for a free-form ROI though. Anyone have thoughts on other useful primary functions?

khughitt commented 12 years ago

Hehe. now that you have a Git account....

khughitt commented 12 years ago

Here are some possible ways I could imagine creating a new RegionOfInterest:

 roi = RegionOfInterest(0, 0, 100, 100)                # x1, y1, x2, y2
 roi = RegionOfInterest(0, 0, 0, 100, 100, 100)   # x1, y1, z1, x2, y2, z2
 roi = RegionOfInterest([(79.500,-552.300),(80.100,-551.700),(94.500,-531.900), ...])  # chaincode (2d)
 roi = RegionOfInterest([(79.500,-552.300, 100.),(80.100,-551.700, 200.),(94.500,-531.900, 300.), ...])  # chaincode (3d)

Question: What about circles/spheres?

If only three values are specified, we could assume it is x0, y0, r, but if four values are specified it could either be a sphere, or a 2d rectangle. Perhaps we should use kwargs to make it more clear? E.g.:

 roi = RegionOfInterest(rect=[...])
 roi = RegionOfInterest(circle=[...])
 roi = RegionOfInterest(sphere=[...])
 roi = RegionOfInterest(polygon=[...])

What do you guys think?

wafels commented 12 years ago

Should the ROI require a specified datetime ?

roi = RegionOfInterest(rect=[...], datetime = ...) roi = RegionOfInterest(circle=[...], datetime = ...) roi = RegionOfInterest(sphere=[...], datetime = ...) roi = RegionOfInterest(polygon=[...], datetime = ...) roi = RegionOfInterest(chaincode=[...], datetime = ...)

is better. Note you have to specify co-ordinate systems and units as well.

Also,

rois = [roi1, roi2, roi3,..., ]

aia.show(overlay = rois, useOverlayDateTime = True )

useOverlayDateTime = True : only display ROIs that overlap with the map object datetime useOverlayDateTime = False : ignore the ROIs map object datetimes and plot them all on the map

On Wed, Jun 27, 2012 at 11:45 AM, Keith Hughitt < reply@reply.github.com

wrote:

Here are some possible ways I could imagine creating a new RegionOfInterest:

roi = RegionOfInterest(0, 0, 100, 100) # x1, y1, x2, y2 roi = RegionOfInterest(0, 0, 0, 100, 100, 100) # x1, y1, z1, x2, y2, z2 roi = RegionOfInterest([(79.500,-552.300),(80.100,-551.700),(94.500,-531.900), ...]) # chaincode (2d) roi = RegionOfInterest([(79.500,-552.300, 100.),(80.100,-551.700, 200.),(94.500,-531.900, 300.), ...]) # chaincode (3d)

Question: What about circles/spheres?

If only three values are specified, we could assume it is x0, y0, r, but if four values are specified it could either be a sphere, or a 2d rectangle. Perhaps we should use kwargs to make it more clear? E.g.:

roi = RegionOfInterest(rect=[...]) roi = RegionOfInterest(circle=[...]) roi = RegionOfInterest(sphere=[...]) roi = RegionOfInterest(polygon=[...])

What do you guys think?


Reply to this email directly or view it on GitHub: https://github.com/sunpy/sunpy/issues/164#issuecomment-6607035

khughitt commented 12 years ago

Default for datetime could be datetime.datetime.utcnow(). What is the difference between polygon and chaincode?

wafels commented 12 years ago

I suppose none in effect, but they might have different definitions.

ehsteve commented 12 years ago

don't forget the grow and shrink methods. an attribute should probably be "shape" such as "rectangle" "circle" "polygon".

wafels commented 12 years ago

There are many different ways to perform a "grow" and a "shrink" operation; scipy has a set of these operators under the "morphology" module

http://docs.scipy.org/doc/scipy/reference/ndimage.html#module-scipy.ndimage.morphology .

They are very handy.

I suppose you could pick one method and say "This is the default method", but you are not guaranteed to end up with something like you thought you were going to get. For example, the "shrink" operation may end up splitting one ROI in to two unconnected ROIs. How will we handle that? Is this what the user wants? On saying that, there are probably ways to ensure that you only ever return a single region after a "shrink" operation, but such considerations veer quickly in to the domain of image manipulation and away from a simple ROI object. I'm not saying it shouldn't be done, I'm just saying it requires some experimentation first.

$0.02

jack

On Wed, Jun 27, 2012 at 11:22 PM, Steven Christe < reply@reply.github.com

wrote:

don't forget the grow and shrink methods. an attribute should probably be "shape" such as "rectangle" "circle" "polygon".


Reply to this email directly or view it on GitHub: https://github.com/sunpy/sunpy/issues/164#issuecomment-6621067

Cadair commented 11 years ago

Hey @dpshelio are you likely to get this wrapped up for 0.3?

yudhik11 commented 6 years ago

I have gone through modules for HEK and HELIO and also checked the ROI and CHAINCODE module as you previously suggested. But I am confused about which area of implementation I should begin with, like making the different area regions like the square, circle, rectangle and then ensuring panning is still available or any specific thing.

nabobalis commented 6 years ago

Has there been any planning on this feature?

wafels commented 6 years ago

There has been little planning concerning this feature. It depends what you mean by "region". Region originally meant a closed area in 2 spatial dimensions. Maybe we could start with that concept and generalize as necessary. A generalization would be a closed volume in any physical space describable by WCS co-ordinates?

On Fri, Mar 16, 2018 at 6:12 AM, Nabil Freij notifications@github.com wrote:

Has there been any planning on this feature?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/sunpy/sunpy/issues/164#issuecomment-373666568, or mute the thread https://github.com/notifications/unsubscribe-auth/AA8CF0trsatN21m57DMsv4oxllhb4_Zcks5te4_1gaJpZM4AC9fF .

yudhik11 commented 6 years ago

What I mean from region is, we already have chaincode module so are we supposed to somehow modify it to give outputs for rectangle, square and circle etc or similar module are supposed to be made as what I figured out was that chaincode returns a plot with the nodes marked as specified and does not relate to ROI for now. So should similar modules for all special figures should be made and than use them to mark a ROI as our need.

dstansby commented 4 years ago

This seems to exist here: https://docs.sunpy.org/en/stable/api/sunpy.roi.roi.html#sunpy.roi.roi . If there are requests to extend the functionality of the existing class then should we split those out to new issues?

nabobalis commented 3 years ago

The current one is being deprecated in 3.0 and will be removed after.

nabobalis commented 1 year ago

Astropy have one now: https://astropy-regions.readthedocs.io/en/stable/index.html

We should investigate if this will work for us