Skip to content
Merged
Show file tree
Hide file tree
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
3,512 changes: 1,808 additions & 1,704 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.321.1",
"@itk-wasm/dicom": "^3.2.1",
"@kitware/vtk.js": "^27.4.6",
"@netlify/edge-functions": "^2.0.0",
"@sentry/vue": "^7.54.0",
Expand All @@ -35,8 +36,8 @@
"dicomweb-client-typed": "^0.8.6",
"file-saver": "^2.0.5",
"gl-matrix": "3.4.3",
"itk-image-io": "1.0.0-b.66",
"itk-wasm": "1.0.0-b.66",
"itk-image-io": "1.0.0-b.130",
"itk-wasm": "1.0.0-b.130",
"jszip": "3.10.0",
"mitt": "^3.0.0",
"pinia": "^2.0.34",
Expand Down Expand Up @@ -90,7 +91,7 @@
"kw-doc": "3.1.2",
"lint-staged": "10.5.4",
"msedgedriver": "^91.0.0",
"patch-package": "^6.4.7",
"patch-package": "^8.0.0",
"prettier": "2.8.8",
"rollup-plugin-visualizer": "^5.9.2",
"sass": "^1.62.0",
Expand Down
21 changes: 0 additions & 21 deletions patches/itk-wasm+1.0.0-b.66.patch

This file was deleted.

50 changes: 25 additions & 25 deletions src/io/dicom.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { join } from '@/src/utils/path';
import { runPipeline, TextStream, InterfaceTypes, Image } from 'itk-wasm';

import {
runPipeline,
TextStream,
InterfaceTypes,
readDICOMTags,
readImageDICOMFileSeries,
Image,
} from 'itk-wasm';
readDicomTags,
readImageDicomFileSeries,
setPipelinesBaseUrl,
setPipelineWorkerUrl,
} from '@itk-wasm/dicom';

import itkConfig from '@/src/io/itk/itkConfig';

export interface TagSpec {
name: string;
Expand Down Expand Up @@ -58,15 +59,10 @@ export class DICOMIO {
inputs: any[],
outputs: any[]
) {
return runPipeline(
this.webWorker,
module,
args,
outputs,
inputs,
join(import.meta.env.BASE_URL, '/itk/pipelines'),
join(import.meta.env.BASE_URL, '/itk/pipeline.worker.js')
);
return runPipeline(this.webWorker, module, args, outputs, inputs, {
pipelineBaseUrl: itkConfig.pipelinesUrl,
pipelineWorkerUrl: itkConfig.pipelineWorkerUrl,
});
}

/**
Expand All @@ -77,6 +73,8 @@ export class DICOMIO {
*/
async initialize() {
if (!this.initializeCheck) {
setPipelinesBaseUrl(itkConfig.pipelinesUrl);
setPipelineWorkerUrl(itkConfig.pipelineWorkerUrl);
this.initializeCheck = new Promise<void>((resolve, reject) => {
this.runTask('dicom', [], [], [])
.then((result) => {
Expand All @@ -89,7 +87,7 @@ export class DICOMIO {
.then(async () => {
// preload read-dicom-tags pipeline
try {
await readDICOMTags(this.webWorker, new File([], ''), null);
await readDicomTags(this.webWorker, new File([], ''));
} catch {
// ignore
}
Expand Down Expand Up @@ -163,14 +161,14 @@ export class DICOMIO {
file: File,
tags: T
): Promise<Record<T[number]['name'], string>> {
const tagsArgs = tags.map((t) => t.tag);
const tagsArgs = { tagsToRead: { tags: tags.map(({ tag }) => tag) } };

const result = await readDICOMTags(
const result = await readDicomTags(
this.webWorker,
sanitizeFile(file),
tagsArgs
);
const tagValues = result.tags;
const tagValues = new Map(result.tags);

return tags.reduce((info, t) => {
const { tag, name } = t;
Expand Down Expand Up @@ -260,10 +258,12 @@ export class DICOMIO {
async buildImage(seriesFiles: File[]) {
await this.initialize();

const result = await readImageDICOMFileSeries(
seriesFiles.map((file) => sanitizeFile(file))
);
const inputImages = seriesFiles.map((file) => sanitizeFile(file));
const result = await readImageDicomFileSeries(null, {
inputImages,
singleSortedSeries: false,
});
Comment on lines +261 to +265
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jadh4v Using the @itk-wasm/dicom package here. This call results in an error. When I copy in a debug build of the .wasm, message is:
CLI::ArgumentMismatch: --input-images: 1 required INPUT_BINARY_FILE:FILE missing

Any suggestions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let me investigate it a little.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Addressing in a PR here: InsightSoftwareConsortium/ITK-Wasm#886


return result.image;
return result.outputImage;
}
}
6 changes: 3 additions & 3 deletions src/io/itk-dicom/emscripten-build/dicom.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/io/itk-dicom/emscripten-build/dicom.umd.js

Large diffs are not rendered by default.

Binary file modified src/io/itk-dicom/emscripten-build/dicom.umd.wasm
Binary file not shown.
Binary file modified src/io/itk-dicom/emscripten-build/dicom.wasm
Binary file not shown.
16 changes: 11 additions & 5 deletions src/io/itk/itkConfig.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
const base = import.meta.env.BASE_URL ?? '';
import { join } from '@src/utils/path';

const base = import.meta.env.BASE_URL;

const fullUrl = (relative) =>
new URL(join(base, relative), document.location.origin).href;

const itkConfig = {
pipelineWorkerUrl: `${base}/itk/pipeline.worker.js`,
imageIOUrl: `${base}/itk/image-io`,
meshIOUrl: `${base}/itk/mesh-io`,
pipelinesUrl: `${base}/itk/pipelines`,
pipelineWorkerUrl: fullUrl('/itk/pipeline.worker.js'),
imageIOUrl: fullUrl('/itk/image-io'),
meshIOUrl: fullUrl('/itk/mesh-io'),
pipelinesUrl: fullUrl('/itk/pipelines'),
};

export default itkConfig;
6 changes: 3 additions & 3 deletions src/io/resample/emscripten-build/resample.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/io/resample/emscripten-build/resample.umd.js

Large diffs are not rendered by default.

Binary file modified src/io/resample/emscripten-build/resample.umd.wasm
Binary file not shown.
Binary file modified src/io/resample/emscripten-build/resample.wasm
Binary file not shown.
11 changes: 8 additions & 3 deletions src/io/resample/itkWasmUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
WorkerPool,
stackImages,
} from 'itk-wasm';
import { join } from '@/src/utils/path';

import itkConfig from '@src/io/itk/itkConfig';

export async function runWasm(
pipeline,
Expand Down Expand Up @@ -44,8 +45,12 @@ export async function runWasm(
data: imageSharedBufferOrCopy(image),
}));

return [pipeline, taskArgs, outputs, inputs, join(import.meta.env.BASE_URL, '/itk/pipelines'),
join(import.meta.env.BASE_URL, '/itk/pipeline.worker.js')];
return [pipeline, taskArgs, outputs, inputs, {
pipelineBaseUrl: itkConfig.pipelinesUrl,
pipelineWorkerUrl: itkConfig.pipelineWorkerUrl,
}];


});

const workerPool = new WorkerPool(numberOfWorkers, runPipeline);
Expand Down
21 changes: 20 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function resolve(...args) {
const rootDir = resolve(__dirname);
const nodeModulesDir = resolve(rootDir, 'node_modules');
const distDir = resolve(rootDir, 'dist');
const itkConfig = resolve(rootDir, 'src', 'io', 'itk', 'itkConfig.js');

const { ANALYZE_BUNDLE, SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_PROJECT } =
process.env;
Expand Down Expand Up @@ -71,6 +72,17 @@ export default defineConfig({
find: '@src',
replacement: resolve(rootDir, 'src'),
},
// Patch itk-wasm library code with image-io .wasm file paths
// itkConfig alias only applies to itk-wasm library code after "npm run build"
// During "npm run serve", itk-wasm fetches image-io .wasm files from CDN
{
find: '../itkConfig.js',
replacement: itkConfig,
},
{
find: '../../itkConfig.js',
replacement: itkConfig,
},
],
},
plugins: [
Expand Down Expand Up @@ -121,9 +133,16 @@ export default defineConfig({
dest: 'itk',
},
{
src: resolve(nodeModulesDir, 'itk-image-io'),
src: resolve(nodeModulesDir, 'itk-image-io/*{.wasm,.js}'),
dest: 'itk/image-io',
},
{
src: resolve(
nodeModulesDir,
'@itk-wasm/dicom/dist/pipelines/*{.wasm,.js}'
),
dest: 'itk/pipelines',
},
{
src: 'src/io/itk-dicom/emscripten-build/**/dicom*',
dest: 'itk/pipelines',
Expand Down