-
Notifications
You must be signed in to change notification settings - Fork 101
NEW: Annotation Stores #135
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
Conversation
|
At the moment export to various formats is done via sub-classes with different |
|
Escalate to here for tracking. Basically, I want to do this but I haven't found a way to via the current API. Given the sample API in the OP. I guess you would like users to do this? But removal will require UUID to sync. Also, may need to write to the store based on UUID rather than simply appending any geometries. |
You can currently add a list of polygons. However, you cannot add a list of just indexes/UUIDs because the rtree data structure requires the geometry. You can do something equivalent like this: store = SQLite3RTreeStore('dumb.db')
list_of_ids = store.append(list_of_polygons)
store.remove(list_of_ids)I haven't exposed a way to let you specify the ID at the moment as this is generated as a hash of the geometry when appending to avoid duplicate geometries. This could be changed to be UUIDs instead or a manual ID could be allowed but would require some extra error handling etc. In your above sample, the geometry would not be serialised to disk. Therefore it would not be known when loaded again later and it would not be possible to spatially query the data. Additionally, storing the geometry using the class (rather than just using a bounding box) allows for optimised polygon intersection queries. |
Yes, the way it is currently implemented you could either make two stores (one for boxes and one for polygons), or you could store them as separate annotations in the same store. However, I am unsure why you are needing to store both. You can get the bounding box from the polygon via |
It sounds like you want something to act as an rtree index without storing the geometry and for you to handle the annotation in memory in a separate structure such as a list or dictionary. For this I would suggest simply using an RTree class (as in shapely or the rtree package). I could add a class to do this in memory with sqlite if you like (essentially the same as the current class but with no storage of geometry or properties to disk, just the rtree and an ID string). However, you would be losing the benefits of optimised storage go geometry on disk, and fast queries on large numbers of annotations (more than could fit in memory) etc. This PR is more aimed at creating a way to read and write a large number of annotation to and from disk efficiently (fast and in a with low memory usage so that you can work with more annotations that would fit in memory at once). Here the store class effectively is your dict of geometries and properties in this case. It handles the generation of IDs, spatial indexing and reading and writing from disk for you. You would only keep another list of dict in memory as a working set e.g. for performing operations on a subset of the annotations before updating the store class. |
shaneahmed
left a comment
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.
Thanks @John-P
Please make the requested changes. we can merge then.
…/tiatoolbox into feature-annotation-store
New line at the end of docstring.
shaneahmed
left a comment
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.
Thanks @john
### Major Updates and Feature Improvements - Adds nucleus instance segmentation base class - Adds [HoVerNet](https://www.sciencedirect.com/science/article/abs/pii/S1361841519301045) architecture - Adds multi-task segmentor [HoVerNet+](https://arxiv.org/abs/2108.13904) model - Adds <a href="https://www.thelancet.com/journals/landig/article/PIIS2589-7500(2100180-1/fulltext">IDaRS</a> pipeline - Adds [SlideGraph](https://arxiv.org/abs/2110.06042) pipeline - Adds PCam patch classification models - Adds support for stain augmentation feature - Adds classes and functions under `tiatoolbox.tools.graph` to enable construction of graphs in a format which can be used with PyG (PyTorch Geometric). - Add classes which act as a mutable mapping (dictionary like) structure and enables efficient management of annotations. (#135) - Adds example notebook for adding advanced models - Adds classes which can generate zoomify tiles from a WSIReader object. - Adds WSI viewer using Zoomify/WSIReader API (#212) - Adds README to example page for clarity - Adds support to override or specify mpp and power ### Changes to API - Replaces `models.controller` API with `models.engine` - Replaces `CNNPatchPredictor` with `PatchPredictor` ### Bug Fixes and Other Changes - Fixes Fix `filter_coordinates` read wrong resolutions for patch extraction - For `PatchPredictor` - `ioconfig` will supersede everything - if `ioconfig` is not provided - If `model` is pretrained (defined in `pretrained_model.yaml` ) - Use the yaml ioconfig - Any other input patch reading arguments will overwrite the yaml ioconfig (at the same keyword). - If `model` is not defined, all input patch reading arguments must be provided else exception will be thrown. - Improves performance of mask based patch extraction ### Development related changes - Improve tests performance for Travis runs - Adds feature detection mechanism to detect the platform and installed packages etc. - On demand imports for some libraries for performance - Improves performance of mask based patch extraction Co-authored-by: Shan Raza <[email protected]>
- Bump version: 0.8.0 → 1.0.0 ### Major Updates and Feature Improvements - Adds nucleus instance segmentation base class - Adds [HoVerNet](https://www.sciencedirect.com/science/article/abs/pii/S1361841519301045) architecture - Adds multi-task segmentor [HoVerNet+](https://arxiv.org/abs/2108.13904) model - Adds <a href="https://www.thelancet.com/journals/landig/article/PIIS2589-7500(2100180-1/fulltext">IDaRS</a> pipeline - Adds [SlideGraph](https://arxiv.org/abs/2110.06042) pipeline - Adds PCam patch classification models - Adds support for stain augmentation feature - Adds classes and functions under `tiatoolbox.tools.graph` to enable construction of graphs in a format which can be used with PyG (PyTorch Geometric). - Add classes which act as a mutable mapping (dictionary like) structure and enables efficient management of annotations. (#135) - Adds example notebook for adding advanced models - Adds classes which can generate zoomify tiles from a WSIReader object. - Adds WSI viewer using Zoomify/WSIReader API (#212) - Adds README to example page for clarity - Adds support to override or specify mpp and power ### Changes to API - Replaces `models.controller` API with `models.engine` - Replaces `CNNPatchPredictor` with `PatchPredictor` ### Bug Fixes and Other Changes - Fixes Fix `filter_coordinates` read wrong resolutions for patch extraction - For `PatchPredictor` - `ioconfig` will supersede everything - if `ioconfig` is not provided - If `model` is pretrained (defined in `pretrained_model.yaml` ) - Use the yaml ioconfig - Any other input patch reading arguments will overwrite the yaml ioconfig (at the same keyword). - If `model` is not defined, all input patch reading arguments must be provided else exception will be thrown. - Improves performance of mask based patch extraction ### Development related changes - Improve tests performance for Travis runs - Adds feature detection mechanism to detect the platform and installed packages etc. - On demand imports for some libraries for performance - Improves performance of mask based patch extraction Co-authored-by: @tialab
Add classes which act as a mutable mapping (dictionary like) structure and enables efficient management of annotations. An annotation here is defined as a geometry and some associated JSON data. Currently, supported features are:
Example (
SQLiteStore)To-Dos
MutableMappinginterface__getitem____setitem____delitem____iter____len____contains__keysitemsvaluesget__eq____ne__poppopitemclearupdatesetdefault