Skip to content

Commit

Permalink
fix: bundling issue with vite
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi committed Feb 3, 2025
1 parent 313a569 commit 6b81893
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ export default {
};
previewVoxelManager.forEach(callback);
}
const inputImage = await getItkImage(
segmentationImageData,
'interpolation'
);

let itkModule;
try {
Expand All @@ -54,12 +50,23 @@ export default {
throw new Error('Module not found');
}
} catch (error) {
console.debug(
console.warn(
"Warning: '@itk-wasm/morphological-contour-interpolation' module not found. Please install it separately."
);
return operationData;
}

let inputImage;
try {
inputImage = await getItkImage(segmentationImageData, 'interpolation');
if (!inputImage) {
throw new Error('Failed to get ITK image');
}
} catch (error) {
console.warn('Warning: Failed to get ITK image for interpolation');
return operationData;
}

const outputPromise = itkModule.morphologicalContourInterpolation(
inputImage,
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { peerImport } from '@cornerstonejs/core';

/**
* Get the ITK Image from the image data
*
Expand All @@ -12,13 +14,13 @@ export default async function getItkImage(
let Image, ImageType, IntTypes, FloatTypes, PixelTypes;

try {
const itkModule = await import('itk-wasm');
const itkModule = await peerImport('itk-wasm');
if (!itkModule) {
throw new Error('Module not found');
}
({ Image, ImageType, IntTypes, FloatTypes, PixelTypes } = itkModule);
} catch (error) {
console.debug(
console.warn(
"Warning: 'itk-wasm' module not found. Please install it separately."
);
return null;
Expand Down

0 comments on commit 6b81893

Please sign in to comment.