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

Add schema for tiled pixelmap overlays #767

Merged
merged 6 commits into from
Feb 3, 2022
Merged

Conversation

naglepuff
Copy link
Collaborator

This PR includes the following changes:

  • Update the girder large image annotation schema to include tiledpixelmap elements
  • Calculate bounding box for tiledpixelmap elements using the same technique as imageoverlay elements
  • Update documentation to reflect schema changes.

@naglepuff naglepuff requested a review from manthey January 28, 2022 21:38
@jeffbaumes
Copy link
Member

One thought is on naming here. Could we simplify to “image” and “pixelmap”? If the tiled nature is important to call out, maybe “tiledimage” and “tiledpixelmap” for consistency?

categoryColorMap = {
'type': 'object',
'properties': {
'segments': {
Copy link
Member

Choose a reason for hiding this comment

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

I think this would be better as

'values': {
    'type': 'array',
    'items': {'type': 'integer'},
}

Using values for consistency with other annotations, and storing just indices into the category map rather than strings. Since we could have millions of pixels, using integers here will be more efficient.

The colormap might conceptually be better called categories where each entry has a color, a label string, and an optional description to give a more verbose description of the category.

For pixelmaps with boundaries, perhaps this value array should be half as long as the actual number of number of distinct indices and then the category would have a fillColor and a strokeColor (and for non-boundaries pixelmaps, this would just use the fillColor).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've implemented these changes in 47c74f4.

I've also removed having two representations of the values array. Let me know if there are any further refinements to be made.

Change `segments` to `values` to keep consistent with other annotation types.
Also store integers in the `values` array instead of strings to save space.
Those integers act as keys to indices in the `categories` array. Updated
docs in line with changes.
@naglepuff naglepuff requested a review from manthey February 2, 2022 20:33
@@ -679,6 +733,7 @@ def _migrateACL(self, annotation):
return annotation

def createAnnotation(self, item, creator, annotation, public=None):
print('\nCREATING ANNOTATION\n')
Copy link
Member

Choose a reason for hiding this comment

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

If you want to keep log messages, you should be able to use logger.debug (or another appropriate level). For development, I'll adjust the level to info and then set it to debug once I think it is stable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed in 24115d5

Also remove some extraneous print statements.
@naglepuff naglepuff requested a review from manthey February 2, 2022 22:34
},
'boundaries': {
'type': 'boolean',
'description': 'True if the boundaries of the pixelmap regions have '
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this description is right any more. Since we've added strokeColor into the category, this should probably read something on order of "True if the pixelmap doubles index values such that even values are the fill and odd values are the stroke of each superpixel. In this case, the values array will be half the length of the actual index values in the image".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated description in 95bab98

},
},
'required': ['values', 'categories', 'boundaries'],
'description': 'A tiled pixelmap to overlay onto a base resource.'
Copy link
Member

Choose a reason for hiding this comment

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

Please add 'additionalProperties': False to this and the pixelmapCategorySchema.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added in 95bab98

@@ -437,6 +437,59 @@ class AnnotationSchema:
'description': 'An image overlay on top of the base resource.',
})

pixelMapCategorySchema = {
Copy link
Member

Choose a reason for hiding this comment

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

For consistency, don't capitalize Map in pixelmap.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 95bab98

Also change some variable names for consistency and add additionalProperties
to pixelmapCategorySchema and pixelmapSchema.
@naglepuff naglepuff requested a review from manthey February 3, 2022 15:57
Copy link
Member

@manthey manthey left a comment

Choose a reason for hiding this comment

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

Thanks for putting up with the requested changes.

@naglepuff naglepuff merged commit 2503542 into master Feb 3, 2022
@naglepuff naglepuff deleted the pixelmap-overlay-schema branch February 3, 2022 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants