Skip to content

Commit

Permalink
fix local creation
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi committed May 21, 2024
1 parent d625a47 commit a18ec5a
Show file tree
Hide file tree
Showing 2 changed files with 1,680 additions and 2,456 deletions.
54 changes: 13 additions & 41 deletions packages/core/examples/volumeLarge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ addToggleButtonToToolbar({
title: 'Load 16 Int',
defaultToggle: false,
onClick: (toggle) => {
cache.purgeCache();
if (toggle) {
loadImage16Float();
} else {
Expand Down Expand Up @@ -129,6 +130,7 @@ async function loadImage16Float() {
}));

// Set the volume to load
// @ts-ignore
volume.load();

// Set the volume on the viewport
Expand All @@ -150,17 +152,16 @@ async function run() {

// Get Cornerstone imageIds and fetch metadata into RAM
// TODO - move the study into a shared context.
// const imageIds = await createImageIdsAndCacheMetaData({
// StudyInstanceUID: '1.2.250.1.90.4.3706890026.20240517115154.2024.1',
// SeriesInstanceUID: '1.2.250.1.90.3.3384839960.20240517203917.8108.53271',
// wadoRsRoot: 'http://localhost:5000/dicomweb',
// });
imageIds = await createImageIdsAndCacheMetaData({
StudyInstanceUID: '1.2.250.1.90.4.3706890026.20240517115154.2024.1',
SeriesInstanceUID: '1.2.250.1.90.3.3384839960.20240517203917.8108.53271',
wadoRsRoot: 'http://localhost/dicom-web',
});

// Instantiate a rendering engine
renderingEngine = new RenderingEngine(renderingEngineId);

// Create a stack viewport
const viewportId = 'CT_SAGITTAL';
// Create a volume viewport
const viewportInput = {
viewportId,
type: ViewportType.ORTHOGRAPHIC,
Expand All @@ -174,44 +175,15 @@ async function run() {
renderingEngine.enableElement(viewportInput);

// Get the stack viewport that was created
const viewport = <Types.IVolumeViewport>(
renderingEngine.getViewport(viewportId)
);

// Define a unique id for the volume
const volumeId = 'CT_VOLUME_ID'; // Id of the volume less loader prefix
// const volumeLoaderScheme = 'cornerstoneStreamingImageVolume'; // Loader id which defines which volume loader to use
// const volumeId = `${volumeLoaderScheme}:${volumeName}`; // VolumeId with loader id + volume id
viewport = <Types.IVolumeViewport>renderingEngine.getViewport(viewportId);

// Define a volume in memory

// 5 GB
cache.setMaxCacheSize(5294967296);

const dimensions = [750, 750, 1024] as Types.Point3;

await volumeLoader.createLocalVolume(
{
dimensions,
direction: [1, 0, 0, 0, 1, 0, 0, 0, 1],
spacing: [1, 1, 1],
origin: [0, 0, 0],
// @ts-ignore
metadata: {
Columns: dimensions[0],
Rows: dimensions[1],
Modality: 'CT',
},
targetBuffer: {
type: 'Float32Array',
sharedArrayBuffer: true,
},
},
volumeId
);
const volume = await volumeLoader.createAndCacheVolume(volumeId, {
imageIds,
});

// Set the volume to load
// volume.load();
volume.load();

// Set the volume on the viewport
viewport.setVolumes([
Expand Down
Loading

0 comments on commit a18ec5a

Please sign in to comment.