Repository navigation
Consolidate loader interfaces #486
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
Changes from all commits
4faeebf
a42b313
fd3e935
3cc3ecb
8d4993e
e662fe7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ import Histogram from "./Histogram.js"; | |
| import { Lut, remapControlPoints } from "./Lut.js"; | ||
| import { type AxisName, type ColorizeFeature, type NumberType, type TripleViewPanes, ViewportCorner } from "./types.js"; | ||
| import { VolumeFileFormat, createVolumeLoader, PrefetchDirection } from "./loaders/index.js"; | ||
| import { LoadSpec } from "./loaders/IVolumeLoader.js"; | ||
| import { LoadSpec } from "./loaders/VolumeLoader.js"; | ||
| import { OMEZarrLoader } from "./loaders/OmeZarrLoader.js"; | ||
| import { JsonImageInfoLoader } from "./loaders/JsonImageInfoLoader.js"; | ||
| import { | ||
|
|
@@ -33,7 +33,8 @@ import type { VolumeDims } from "./VolumeDims.js"; | |
| export type { ImageInfo } from "./ImageInfo.js"; | ||
| export type { ControlPoint } from "./Lut.js"; | ||
| export type { CreateLoaderOptions } from "./loaders/index.js"; | ||
| export type { IVolumeLoader, PerChannelCallback, ThreadableVolumeLoader } from "./loaders/IVolumeLoader.js"; | ||
| // TODO export `IVolumeLoader`, `ThreadableVolumeLoader` as `VolumeLoader` aliases? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider exporting with a deprecated flag to explain the necessary migration? |
||
| export type { PerChannelCallback, VolumeLoader } from "./loaders/VolumeLoader.js"; | ||
| export type { ZarrLoaderFetchOptions } from "./loaders/OmeZarrLoader.js"; | ||
| export type { WorkerLoader } from "./workers/VolumeLoaderContext.js"; | ||
| export { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -103,46 +103,8 @@ export type RawChannelDataCallback = ( | |||||||||||||||||||||||||||||||
| * Loaders may keep state for reuse between volume creation and volume loading, and should be kept alive until volume | ||||||||||||||||||||||||||||||||
| * loading is complete. (See `createVolume`) | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| export interface IVolumeLoader { | ||||||||||||||||||||||||||||||||
| /** Use VolumeDims to further refine a `LoadSpec` for use in `createVolume` */ | ||||||||||||||||||||||||||||||||
| loadDims(loadSpec: LoadSpec): Promise<VolumeDims[]>; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * Create an empty `Volume` from a `LoadSpec`, which must be passed to `loadVolumeData` to begin loading. | ||||||||||||||||||||||||||||||||
| * Optionally pass a callback to respond whenever new channel data is loaded into the volume. | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| createVolume(loadSpec: LoadSpec, onChannelLoaded?: PerChannelCallback): Promise<Volume>; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * Begin loading a volume's data, as specified in its `LoadSpec`. | ||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||
| * Pass a callback to respond when this request loads a new channel. This callback will execute after the one | ||||||||||||||||||||||||||||||||
| * assigned in `createVolume`, if any. | ||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||
| * The returned `Promise` resolves once all channels load, or rejects with any error that occurs during loading. | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| // TODO make this return a promise that resolves when loading is done? | ||||||||||||||||||||||||||||||||
| // TODO this is not cancellable in the sense that any async requests initiated here are not stored | ||||||||||||||||||||||||||||||||
| // in a way that they can be interrupted. | ||||||||||||||||||||||||||||||||
| // TODO explicitly passing a `LoadSpec` is now rarely useful. Remove? | ||||||||||||||||||||||||||||||||
| loadVolumeData(volume: Volume, loadSpec?: LoadSpec, onChannelLoaded?: PerChannelCallback): Promise<void>; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** Change which directions to prioritize when prefetching. Currently only implemented on `OMEZarrLoader`. */ | ||||||||||||||||||||||||||||||||
| setPrefetchPriority(directions: PrefetchDirection[]): void; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * By default channel data can arrive out of order and at different times. | ||||||||||||||||||||||||||||||||
| * This can cause the rendering to update in a way that is not visually appealing. | ||||||||||||||||||||||||||||||||
| * In particular, during time series playback or Z slice playback, we would like | ||||||||||||||||||||||||||||||||
| * to see all channels update at the same time. | ||||||||||||||||||||||||||||||||
| * @param sync Set true to force all requested channels to load at the same time | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| syncMultichannelLoading(sync: boolean): void; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** Abstract class which allows loaders to accept and return types that are easier to transfer to/from a worker. */ | ||||||||||||||||||||||||||||||||
| export abstract class ThreadableVolumeLoader implements IVolumeLoader { | ||||||||||||||||||||||||||||||||
| /** Unchanged from `IVolumeLoader`. See that interface for details. */ | ||||||||||||||||||||||||||||||||
| export abstract class VolumeLoader { | ||||||||||||||||||||||||||||||||
| /** Use `VolumeDims` to further refine a `LoadSpec` for use in `createVolume` */ | ||||||||||||||||||||||||||||||||
| abstract loadDims(loadSpec: LoadSpec): Promise<VolumeDims[]>; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
|
|
@@ -173,10 +135,18 @@ export abstract class ThreadableVolumeLoader implements IVolumeLoader { | |||||||||||||||||||||||||||||||
| onData: RawChannelDataCallback | ||||||||||||||||||||||||||||||||
| ): Promise<void>; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** Change which directions to prioritize when prefetching. Currently only implemented on `OMEZarrLoader`. */ | ||||||||||||||||||||||||||||||||
| setPrefetchPriority(_directions: PrefetchDirection[]): void { | ||||||||||||||||||||||||||||||||
| // no-op by default | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * By default channel data can arrive out of order and at different times. | ||||||||||||||||||||||||||||||||
| * This can cause the rendering to update in a way that is not visually appealing. | ||||||||||||||||||||||||||||||||
| * In particular, during time series playback or Z slice playback, we would like | ||||||||||||||||||||||||||||||||
| * to see all channels update at the same time. | ||||||||||||||||||||||||||||||||
| * @param sync Set true to force all requested channels to load at the same time | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
|
Comment on lines
+143
to
+149
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Really minor nit, but I feel like the wording of the current method string explains the problem first and not what the method actually does? But maybe not important because the method name is descriptive.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the suggested change here removes the |
||||||||||||||||||||||||||||||||
| syncMultichannelLoading(_sync: boolean): void { | ||||||||||||||||||||||||||||||||
| // default behavior is async, to update channels as they arrive, depending on each | ||||||||||||||||||||||||||||||||
| // loader's implementation details. | ||||||||||||||||||||||||||||||||
|
|
@@ -194,6 +164,18 @@ export abstract class ThreadableVolumeLoader implements IVolumeLoader { | |||||||||||||||||||||||||||||||
| return vol; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * Begin loading a volume's data, as specified in its `LoadSpec`. | ||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||
| * Pass a callback to respond when this request loads a new channel. This callback will execute after the one | ||||||||||||||||||||||||||||||||
| * assigned in `createVolume`, if any. | ||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||
| * The returned `Promise` resolves once all channels load, or rejects with any error that occurs during loading. | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| // TODO make this return a promise that resolves when loading is done? | ||||||||||||||||||||||||||||||||
| // TODO this is not cancellable in the sense that any async requests initiated here are not stored | ||||||||||||||||||||||||||||||||
| // in a way that they can be interrupted. | ||||||||||||||||||||||||||||||||
| // TODO explicitly passing a `LoadSpec` is now rarely useful. Remove? | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these TODOs being addressed? shoudl they be elevated to issue tickets? |
||||||||||||||||||||||||||||||||
| async loadVolumeData( | ||||||||||||||||||||||||||||||||
| volume: Volume, | ||||||||||||||||||||||||||||||||
| loadSpecOverride?: LoadSpec, | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
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.
Is this exposed as an external API at all?