-
Notifications
You must be signed in to change notification settings - Fork 0
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
Noah/fix omezarr tile math mistake #45
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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 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 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 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,195 @@ | ||
import type { ZarrDataset } from '../zarr-data'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { Box2D, box2D } from '@alleninstitute/vis-geometry'; | ||
import { getVisibleTiles } from './loader'; | ||
const exampleOmeZarr: ZarrDataset = { | ||
url: 'https://allen-genetic-tools.s3.us-west-2.amazonaws.com/tissuecyte/1263343692/ome-zarr/', | ||
multiscales: [ | ||
{ | ||
axes: [ | ||
{ | ||
name: 'c', | ||
type: 'channel', | ||
unit: 'millimeter', | ||
}, | ||
{ | ||
name: 'z', | ||
type: 'space', | ||
unit: 'millimeter', | ||
}, | ||
{ | ||
name: 'y', | ||
type: 'space', | ||
unit: 'millimeter', | ||
}, | ||
{ | ||
name: 'x', | ||
type: 'space', | ||
unit: 'millimeter', | ||
}, | ||
], | ||
datasets: [ | ||
{ | ||
coordinateTransformations: [ | ||
{ | ||
scale: [1, 0.1, 0.00035, 0.00035], | ||
type: 'scale', | ||
}, | ||
{ | ||
translation: [0, 0, 0, 0], | ||
type: 'translation', | ||
}, | ||
], | ||
path: '0', | ||
shape: [3, 142, 29998, 39998], | ||
}, | ||
{ | ||
coordinateTransformations: [ | ||
{ | ||
scale: [1, 0.1, 0.0007, 0.0007], | ||
type: 'scale', | ||
}, | ||
{ | ||
translation: [0, 0, 0.00035, 0.00035], | ||
type: 'translation', | ||
}, | ||
], | ||
path: '1', | ||
shape: [3, 142, 14999, 19999], | ||
}, | ||
{ | ||
coordinateTransformations: [ | ||
{ | ||
scale: [1, 0.1, 0.0014, 0.0014], | ||
type: 'scale', | ||
}, | ||
{ | ||
translation: [0, 0, 0.00105, 0.00105], | ||
type: 'translation', | ||
}, | ||
], | ||
path: '2', | ||
shape: [3, 142, 7499, 9999], | ||
}, | ||
{ | ||
coordinateTransformations: [ | ||
{ | ||
scale: [1, 0.1, 0.0028, 0.0028], | ||
type: 'scale', | ||
}, | ||
{ | ||
translation: [0, 0, 0.00245, 0.00245], | ||
type: 'translation', | ||
}, | ||
], | ||
path: '3', | ||
shape: [3, 142, 3749, 4999], | ||
}, | ||
{ | ||
coordinateTransformations: [ | ||
{ | ||
scale: [1, 0.1, 0.0056, 0.0056], | ||
type: 'scale', | ||
}, | ||
{ | ||
translation: [0, 0, 0.00525, 0.00525], | ||
type: 'translation', | ||
}, | ||
], | ||
path: '4', | ||
shape: [3, 142, 1874, 2499], | ||
}, | ||
{ | ||
coordinateTransformations: [ | ||
{ | ||
scale: [1, 0.1, 0.0112, 0.0112], | ||
type: 'scale', | ||
}, | ||
{ | ||
translation: [0, 0, 0.01085, 0.01085], | ||
type: 'translation', | ||
}, | ||
], | ||
path: '5', | ||
shape: [3, 142, 937, 1249], | ||
}, | ||
{ | ||
coordinateTransformations: [ | ||
{ | ||
scale: [1, 0.1, 0.0224, 0.0224], | ||
type: 'scale', | ||
}, | ||
{ | ||
translation: [0, 0, 0.02205, 0.02205], | ||
type: 'translation', | ||
}, | ||
], | ||
path: '6', | ||
shape: [3, 142, 468, 624], | ||
}, | ||
{ | ||
coordinateTransformations: [ | ||
{ | ||
scale: [1, 0.1, 0.0448, 0.0448], | ||
type: 'scale', | ||
}, | ||
{ | ||
translation: [0, 0, 0.044449999999999996, 0.044449999999999996], | ||
type: 'translation', | ||
}, | ||
], | ||
path: '7', | ||
shape: [3, 142, 234, 312], | ||
}, | ||
{ | ||
coordinateTransformations: [ | ||
{ | ||
scale: [1, 0.1, 0.0896, 0.0896], | ||
type: 'scale', | ||
}, | ||
{ | ||
translation: [0, 0, 0.08925, 0.08925], | ||
type: 'translation', | ||
}, | ||
], | ||
path: '8', | ||
shape: [3, 142, 117, 156], | ||
}, | ||
{ | ||
coordinateTransformations: [ | ||
{ | ||
scale: [1, 0.1, 0.1792, 0.1792], | ||
type: 'scale', | ||
}, | ||
{ | ||
translation: [0, 0, 0.17885, 0.17885], | ||
type: 'translation', | ||
}, | ||
], | ||
path: '9', | ||
shape: [3, 142, 58, 78], | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
describe('omezarr basic tiled loading', () => { | ||
describe('getVisibleTiles', () => { | ||
it('visible tiles cannot extend beyond the bounds of their layer', () => { | ||
const view: box2D = { | ||
minCorner: [-7, -11], | ||
maxCorner: [28, 35], | ||
}; | ||
const camera = { view, screenSize: [210, 210] as const }; | ||
const visible = getVisibleTiles(camera, 'xy', 2, exampleOmeZarr, 256); | ||
// this is a basic regression test: we had a bug which would result in | ||
// tiles from the image being larger than the image itself (they would be the given tile size) | ||
expect(visible.length).toBe(1); | ||
const expectedLayer = exampleOmeZarr.multiscales[0].datasets[9]; | ||
// we expect to be seeing the lowest resolution layer with our very zoomed out, low res camera | ||
const [_c, _z, y, x] = expectedLayer.shape; | ||
expect(visible[0].bounds).toEqual(Box2D.create([0, 0], [x, y])); | ||
}); | ||
}); | ||
}); |
This file contains 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
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.
this is the fix - it limits the visited tiles by the total size of the image. The bug here caused a bunch of math later in the process to be incorrect, because the tiles extended past what was actually possible.