-
Couldn't load subscription status.
- Fork 1
WIP (point annotations) #169
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
Open
froyo-np
wants to merge
22
commits into
main
Choose a base branch
from
noah/ng-annotations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e61c736
first pass at implementing a decoder for ng-precomputed annotation files
froyo-np d17a40f
a little fiddling to promote type safety when extracting these annota…
froyo-np 3c26561
fill out a renderer system for this data type (points only for now)
froyo-np 7c39e47
first draft of one way of doing this
froyo-np 7389252
Merge branch 'main' into noah/ng-annotations
froyo-np 3f0a46d
less copy pasta
froyo-np cd1a2f0
Merge branch 'noah/ng-annotations' of https://github.com/AllenInstitu…
froyo-np 26414bc
update omezarr render settings to be easier to use for "real" volumet…
froyo-np 22b75f1
fix up handling of volumetric slicing. correct disparity between exam…
froyo-np ecf6256
fmt
froyo-np 7a8cfdb
put the logger back
froyo-np 98535c1
Merge branch 'main' into noah/ng-annotations
froyo-np 89c233f
lint
froyo-np 4a6a8e0
Merge branch 'noah/ng-annotations' of https://github.com/AllenInstitu…
froyo-np 9b74b14
lockfile
froyo-np a830850
fmt again
froyo-np 4de0fd7
Merge branch 'main' into noah/ng-annotations
froyo-np ac3d62e
missed a spot in the refactor
froyo-np 65baf43
fmt
froyo-np 8ef0e44
cleanup, fix the schema to match real data, rather than the documenta…
froyo-np b101c8a
fmt
froyo-np 1d96b5e
timewasters
froyo-np File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| { | ||
| "name": "@alleninstitute/vis-precomputed", | ||
| "version": "0.0.1", | ||
| "contributors": [ | ||
| { | ||
| "name": "Lane Sawyer", | ||
| "email": "[email protected]" | ||
| }, | ||
| { | ||
| "name": "Noah Shepard", | ||
| "email": "[email protected]" | ||
| }, | ||
| { | ||
| "name": "Skyler Moosman", | ||
| "email": "[email protected]" | ||
| }, | ||
| { | ||
| "name": "Su Li", | ||
| "email": "[email protected]" | ||
| }, | ||
| { | ||
| "name": "Joel Arbuckle", | ||
| "email": "[email protected]" | ||
| } | ||
| ], | ||
| "license": "BSD-3-Clause", | ||
| "source": "src/index.ts", | ||
| "main": "dist/main.js", | ||
| "module": "dist/module.js", | ||
| "types": "dist/types.d.ts", | ||
| "files": ["dist"], | ||
| "scripts": { | ||
| "typecheck": "tsc --noEmit", | ||
| "build": "parcel build --no-cache", | ||
| "watch": "parcel watch", | ||
| "test": "vitest --watch", | ||
| "test:ci": "vitest run", | ||
| "coverage": "vitest run --coverage" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/AllenInstitute/vis.git" | ||
| }, | ||
| "publishConfig": { | ||
| "registry": "https://npm.pkg.github.com/AllenInstitute" | ||
| }, | ||
| "packageManager": "[email protected]", | ||
| "dependencies": { | ||
| "@alleninstitute/vis-geometry": "workspace:*", | ||
| "@alleninstitute/vis-core": "workspace:*", | ||
| "regl": "2.1.0", | ||
| "ts-pattern": "5.7.1", | ||
| "zod": "3.24.3" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| export { | ||
| type AnnotationInfo, | ||
| isPointAnnotation, | ||
| isBoxAnnotation, | ||
| isEllipsoidAnnotation, | ||
| isLineAnnotation, | ||
| parseInfoFromJson as ParseNGPrecomputedInfo, | ||
| getAnnotations, | ||
| } from './loader/annotations'; | ||
| export { | ||
| buildNGPointAnnotationRenderer, | ||
| buildAsyncNGPointRenderer, | ||
| type AnnotationChunk, | ||
| } from './render/annotationRenderer'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { | ||
| AnnoStream, | ||
| type AnnotationInfo, | ||
| computeStride, | ||
| extractPoint, | ||
| getAnnotationBuffer, | ||
| isPointAnnotation, | ||
| parseInfoFromJson, | ||
| } from './annotations'; | ||
|
|
||
| describe('quick check', () => { | ||
| it('can parse a real (although simple) file, at least a little bit', async () => { | ||
| const base = | ||
| 'https://aind-open-data.s3.amazonaws.com/SmartSPIM_787715_2025-04-08_18-33-36_stitched_2025-04-09_22-42-59/image_cell_segmentation/Ex_445_Em_469/visualization/detected_precomputed/'; | ||
| const expectedMetadata: AnnotationInfo<'point'> = { | ||
| annotation_type: 'point', // TODO: the real json files here use lowercase, wtf | ||
| type: 'neuroglancer_annotations_v1', | ||
| dimensions: [ | ||
| { name: 'z', scale: 2e-6, unit: 'm' }, | ||
| { name: 'y', scale: 1.8e-6, unit: 'm' }, | ||
| { name: 'x', scale: 1.8e-6, unit: 'm' }, | ||
| ], | ||
| lower_bound: [4.0, 94.0, 558.0], | ||
| upper_bound: [3542.0, 8784.0, 7166.0], | ||
| properties: [], | ||
| relationships: [], | ||
| by_id: { key: 'by_id' }, //what? | ||
| spatial: [ | ||
| { | ||
| key: 'spatial0', | ||
| grid_shape: [1, 1, 1], | ||
| chunk_size: [3538.0, 8690.0, 6608.0], | ||
| limit: 150378, | ||
| }, | ||
| ], | ||
| }; | ||
| const infoFileJSON = await (await fetch(`${base}info`)).json(); | ||
| // biome-ignore lint/style/noNonNullAssertion: this is a test | ||
| const sanitized = parseInfoFromJson(infoFileJSON)!; | ||
| const stride = computeStride(expectedMetadata); | ||
| expect(stride).toBe(12); | ||
| expect(sanitized).toEqual(expectedMetadata); | ||
| const raw = await getAnnotationBuffer(base, expectedMetadata, { level: 0, cell: [0, 0, 0] }); | ||
| expect(raw.numAnnotations).toBe(150378n); | ||
| // each annotation (its shape and its properties) are written sequentially in the buffer,followed by all the ids for the annotations, like this: | ||
| // [{num_annotations:uint64},{annotation_0_and_properties_and_optional_padding},...,{annotation_n_and_properties_and_optional_padding},{id_of_anno_0:uint64},...,{id_of_anno_n:uint64}}] | ||
| // thus: 8 + (length*stride) + (size_in_bytes(uint64)*length) | ||
| expect(raw.view.buffer.byteLength).toBe(150378 * stride + 8 + 150378 * 8); | ||
| if (isPointAnnotation(sanitized)) { | ||
| const annoStream = await AnnoStream(sanitized, extractPoint, raw.view, raw.numAnnotations); | ||
| let count = 0; | ||
| // the ids in here just count up... I think the spec says they should be added at random when doing spatial indexing, so this is sus.... | ||
| let lastId: bigint | undefined; | ||
| for (const point of annoStream) { | ||
| count += 1; | ||
| if (lastId === undefined) { | ||
| lastId = point.id; | ||
| } else { | ||
| expect(point.id).toBe(lastId + 1n); | ||
| lastId = point.id; | ||
| } | ||
| expect(point.properties).toEqual({}); | ||
| } | ||
| expect(count).toBe(150378); | ||
| } else { | ||
| expect(sanitized?.annotation_type).toBe('point'); | ||
| } | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
remove todo