Repository navigation
feat(ui): wire OME annotator predictions, navigation, prefetching and tools - #8025
jpggvilaca wants to merge 4 commits into
Conversation
🐳 Docker image sizes
|
There was a problem hiding this comment.
🟡 Changes recommended
For OME planes whose normalized size_z and size_t default to 1, the selected media item can retain those values even when the parent stack has additional Z/T planes; as a result, next-plane navigation skips the remaining planes and moves directly to the next media item.
1 open issue
What changed in this PR
Adds OME-aware annotator navigation, prediction requests, prefetching, annotation cache updates, and smart-tool filtering.
Changes:
- Uses
plane_rangefor OME predictions. - Supports Z/T plane navigation and OME-specific prefetching.
- Disables unsupported client-pixel tools while retaining SAM support.
| File | Description |
|---|---|
| application/ui/src/modules/annotator/tools/annotator-tools/use-available-tools.ts | Filters unsupported smart tools for OME and oversized media. |
| application/ui/src/modules/annotator/tools/annotator-tools/use-available-tools.test.ts | Tests smart-tool availability for OME and oversized media. |
| application/ui/src/modules/annotator/shell/utils.ts | Adds navigation through OME Z/T planes. |
| application/ui/src/modules/annotator/shell/utils.test.ts | Tests OME plane navigation behavior. |
| application/ui/src/modules/annotator/hooks/use-prefetch-media-item.hook.ts | Prefetches OME metadata, channel views, and annotations. |
| application/ui/src/modules/annotator/hooks/use-prefetch-media-item.hook.test.tsx | Tests OME media prefetching behavior. |
| application/ui/src/modules/annotator/api/use-media-predictions.ts | Adds plane-range support to media prediction queries. |
| application/ui/src/modules/annotator/api/use-media-predictions.test.ts | Verifies OME prediction request payloads. |
| application/ui/src/features/dataset/media-preview/use-next-prediction-prefetch.hook.ts | Prefetches predictions for upcoming OME planes. |
| application/ui/src/features/dataset/media-preview/media-preview.component.tsx | Passes OME plane ranges when requesting predictions. |
| application/ui/src/features/dataset/media-preview/api/use-submit-annotations.ts | Refreshes OME plane and parent annotation caches after submission. |
| application/ui/src/features/dataset/media-preview/api/use-submit-annotations.test.tsx | Tests OME annotation submission cache updates. |
Review effort: Lite
📊 Test coverage report
|
| { params: { path: { project_id: projectId, media_id: mediaItem.id } } }, | ||
| ], | ||
| [ | ||
| 'get', |
There was a problem hiding this comment.
np. we need to call this only when isOme is true
There was a problem hiding this comment.
we have the same for frames, we also have it on images. I believe, if the cache value did not change, this costs 0
| // OME planes are rendered server-side without client ImageData, so pixel-based smart tools are unavailable | ||
| // while server-backed SAM remains enabled. | ||
| if (isOme(mediaItem)) { | ||
| return taskTools.filter((tool) => tool.type !== 'magnetic-lasso' && tool.type !== 'ssim'); |
There was a problem hiding this comment.
that is not good, SSIM was the one that customer really like, we need to discuss this.
cc @leoll2
There was a problem hiding this comment.
very good point. let me find a way to enable it.
There was a problem hiding this comment.
reenabled and tested manually. Thanks!
| const { imageData, existingAnnotations, autoMergeDuplicates, template } = props; | ||
| const ssimMatches = convertToolMatchesToGetiMatches(matches); | ||
| const { imageData, imageBounds, existingAnnotations, autoMergeDuplicates, template } = props; | ||
| const bounds = imageBounds ?? roiFromImage(imageData); |
There was a problem hiding this comment.
In case of ome media, roi (imageBounds) is not based on imageData but based on media. Should we move roiFromImage to the ssim-tool and do roi: isOme ? roiFromImage(imageData) : roi?
There was a problem hiding this comment.
Good point, refactored this and other parts to not polute SSIM stuff with OME
| const getAxisRoi = (start: number, length: number, limit: number): [offset: number, size: number] => { | ||
| if (limit <= 0 || length <= 0 || (length * SSIM_SCALE_PX) / limit >= MIN_SSIM_TEMPLATE_PX) { | ||
| return [0, limit]; | ||
| } | ||
|
|
||
| const minSize = Math.max(1, Math.ceil(start + length) - Math.floor(start)); | ||
| const targetSize = Math.floor((length * SSIM_SCALE_PX) / MIN_SSIM_TEMPLATE_PX); | ||
| const size = Math.min(limit, Math.max(minSize, targetSize)); | ||
| const minOffset = Math.max(0, Math.ceil(start + length) - size); | ||
| const maxOffset = Math.min(Math.floor(start), limit - size); | ||
| const offset = clamp(Math.round(start + length / 2 - size / 2), minOffset, maxOffset); | ||
|
|
||
| return [offset, size]; | ||
| }; |
There was a problem hiding this comment.
It's not clear to me what we do here, could u please add unit tests for this?
There was a problem hiding this comment.
Simplified and added tests! But basically if you draw a small box (e.g. an 8px cell on a 2048px image), downscaling shrinks the template to < 1px and OpenCV crashes. I was testing manually and this happened, so now we make sure the boundaries are ok before running SSIM
| const roiTemplate: Rect = { | ||
| ...scaledTemplate, | ||
| x: scaledTemplate.x - roi.x, | ||
| y: scaledTemplate.y - roi.y, |
There was a problem hiding this comment.
is this math correct?
I mean that the whole roi is already scaled (x, y, width, height) and additionally we subtract x and y.
There was a problem hiding this comment.
Had to get help on this one, but the explanation is that inside @geti-ui/smart-tools, buildImage crops imageData to roi first and runSSIM indexes template relative to that cropped region (without subtracting roi.x/roi.y), while getMatches adds roi.x/roi.y back to every returned match. So template has to be translated into searchRoi-local coordinates here, so nothing is being scaled twice

Summary
What was done so far (to not lose track):
This PR:
plane_range): AddsplaneRangetomediaPredictionsQueryOptions,useMediaPredictions, anduseIsFetchingMediaPredictions, sending{ media_id, plane_range }instead of{ media_id, range }for OME items inMediaPreviewanduseNextPredictionPrefetch.GET .../planeson submit and refreshes the cached parentome_imageentry (matchingvideo_framesoannotated_ome_planesstays up to date).getNextMediaItemto step throughz_indexthent_indexbefore advancing to the next dataset item.usePrefetchMediaItemto prefetch/ome,/channel-view, and(z=0, t=0)annotations forome_imagecontainers, and plane annotations forome_plane, without rasterizing clientImageData.magnetic-lasso) for OME media inuseAvailableToolswhile keeping server-backed SAM enabled (supported since OME-TIFF improvements: server-side caching, SAM, faster rendering #8021) and keeping all smart tools disabled for oversized media.How to test
Checklist