Skip to content

Commit

Permalink
Add image loading console.time
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHax committed Aug 21, 2024
1 parent 5f17586 commit 6c00871
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 208 deletions.
225 changes: 30 additions & 195 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.435.0",
"@itk-wasm/dicom": "6.0.1",
"@itk-wasm/dicom": "7.1.0",
"@itk-wasm/htj2k": "^2.3.1",
"@itk-wasm/image-io": "1.1.1",
"@itk-wasm/image-io": "1.3.0",
"@kitware/vtk.js": "30.9.0",
"@netlify/edge-functions": "^2.0.0",
"@sentry/vue": "^7.54.0",
Expand All @@ -41,7 +41,7 @@
"fast-deep-equal": "^3.1.3",
"file-saver": "^2.0.5",
"gl-matrix": "3.4.3",
"itk-wasm": "1.0.0-b.171",
"itk-wasm": "1.0.0-b.178",
"jszip": "3.10.0",
"mitt": "^3.0.0",
"nanoid": "^4.0.1",
Expand Down
16 changes: 14 additions & 2 deletions src/core/streaming/ahiChunkImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { ComputedRef, Ref, computed, ref } from 'vue';
import mitt, { Emitter } from 'mitt';
import { decode } from '@itk-wasm/htj2k';
import { getWorker } from '@/src/io/itk/worker';
import { NameToMeta } from '../dicomTags';

const { fastComputeRange } = vtkDataArray;
Expand Down Expand Up @@ -96,7 +97,9 @@ function itkImageToURI(itkImage: Image) {
export async function dicomSliceToImageUri(blob: Blob) {
const array = await blob.arrayBuffer();
const uint8Array = new Uint8Array(array);
const result = await decode(uint8Array);
const result = await decode(uint8Array, {
webWorker: getWorker(),
});
return itkImageToURI(result.image);
}

Expand Down Expand Up @@ -266,7 +269,9 @@ export default class AhiChunkImage implements ChunkImage {

const array = await chunk.dataBlob.arrayBuffer();
const uint8Array = new Uint8Array(array);
const result = await decode(uint8Array);
const result = await decode(uint8Array, {
webWorker: getWorker(),
});
if (!result.image.data) throw new Error('No data read from chunk');

const meta = new Map(chunk.metadata);
Expand Down Expand Up @@ -315,6 +320,13 @@ export default class AhiChunkImage implements ChunkImage {
this.chunkStatus.value[chunkIndex] = ChunkStatus.Loaded;

this.imageData.modified();

const loaded = this.chunkStatus.value.every(
(status) => status === ChunkStatus.Loaded
);
if (loaded) {
console.timeEnd(`load time`);
}
}

private onChunkErrored(chunkIndex: number, err: unknown) {
Expand Down
7 changes: 7 additions & 0 deletions src/core/streaming/dicomChunkImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@ export default class DicomChunkImage implements ChunkImage {
this.chunkStatus.value[chunkIndex] = ChunkStatus.Loaded;

this.imageData.modified();

const loaded = this.chunkStatus.value.every(
(status) => status === ChunkStatus.Loaded
);
if (loaded) {
console.timeEnd(`load time`);
}
}

private onChunkErrored(chunkIndex: number, err: unknown) {
Expand Down
3 changes: 3 additions & 0 deletions src/io/import/importDataSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ async function importDicomChunkSources(sources: ChunkSource[]) {
export async function importDataSources(
dataSources: DataSource[]
): Promise<ImportDataSourcesResult[]> {
console.log('starting load timer');
console.time(`load time`);

const cleanupHandlers: Array<() => void> = [];
const onCleanup = (fn: () => void) => {
cleanupHandlers.push(fn);
Expand Down
7 changes: 3 additions & 4 deletions src/io/itk-dicom/emscripten-build/dicom.js

Large diffs are not rendered by default.

Binary file modified src/io/itk-dicom/emscripten-build/dicom.wasm
Binary file not shown.
Binary file modified src/io/itk-dicom/emscripten-build/dicom.wasm.zst
Binary file not shown.
7 changes: 3 additions & 4 deletions src/io/resample/emscripten-build/resample.js

Large diffs are not rendered by default.

Binary file modified src/io/resample/emscripten-build/resample.wasm
Binary file not shown.
Binary file modified src/io/resample/emscripten-build/resample.wasm.zst
Binary file not shown.

0 comments on commit 6c00871

Please sign in to comment.