Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/loaders/OmeZarrLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ class OMEZarrLoader extends ThreadableVolumeLoader {
let channelCount = 0;
for (const s of sources) {
s.channelOffset = channelCount;
channelCount += s.omeroMetadata?.channels.length ?? s.scaleLevels[0].shape[s.axesTCZYX[1]];
Copy link
Contributor

Choose a reason for hiding this comment

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

So just to check my understanding, this was failing before because s.axesTCZYX[1] evaluated to -1, which then caused the statement to effectively become:

channelCount += undefined ?? undefined

Is that right? and now in that failure case we instead increment by 1

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup! And adding undefined to channelCount is what eventually produced the NaNs in chunk request URLs.

(Vaguely interesting: the NaNs only appeared if the image missing the channel dimension came before the image with it. Configurations with the URLs the opposite way around fell victim to the completely separate bug I fixed further down this file.)

if (s.omeroMetadata !== undefined) {
channelCount += s.omeroMetadata.channels.length;
} else if (s.axesTCZYX[1] > -1) {
channelCount += s.scaleLevels[0].shape[s.axesTCZYX[1]];
} else {
channelCount += 1;
}
}
// Ensure the sizes of all sources' scale levels are matched up. See this function's docs for more.
matchSourceScaleLevels(sources);
Expand Down Expand Up @@ -452,10 +458,10 @@ class OMEZarrLoader extends ThreadableVolumeLoader {
});

// Get number of chunks per dimension in every source array
const chunkDimsTCZYX = this.sources.map((src) => {
const level = src.scaleLevels[scaleLevel];
const chunkDimsTCZYX = this.sources.map((source, sourceIndex) => {
const level = source.scaleLevels[scaleLevel];
const chunkDimsUnordered = level.shape.map((dim, idx) => Math.ceil(dim / level.chunks[idx]));
return this.orderByTCZYX(chunkDimsUnordered, 1);
return this.orderByTCZYX(chunkDimsUnordered, 1, sourceIndex);
});

// `ChunkPrefetchIterator` yields chunk coordinates in order of roughly how likely they are to be loaded next
Expand Down