Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: tutorial example was broken after api updates #239

Merged
merged 2 commits into from
Oct 6, 2022
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
Binary file modified packages/docs/docs/assets/tutorial-basic-stack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/docs/docs/assets/tutorial-basic-volume-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions packages/docs/docs/tutorials/basic-annotation-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ toolGroup.setToolActive(BidirectionalTool.toolName, {
});
```


Let's load the volume and set the viewports to render the volume.

```js
Expand Down Expand Up @@ -152,6 +151,16 @@ renderingEngine.renderViewports([viewportId1, viewportId2]);
## Final code

```js
// Get Cornerstone imageIds and fetch metadata into RAM
const imageIds = await createImageIdsAndCacheMetaData({
StudyInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
SeriesInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.226151125820845824875394858561',
wadoRsRoot: 'https://d3t6nz73ql33tx.cloudfront.net/dicomweb',
type: 'VOLUME',
});

const content = document.getElementById('content');

// element for axial view
Expand Down Expand Up @@ -245,7 +254,6 @@ renderingEngine.renderViewports([viewportId1, viewportId2]);

You should be able to annotate images with the tools you added.


![](../assets/tutorial-annotation.png)

## Read more
Expand Down
11 changes: 10 additions & 1 deletion packages/docs/docs/tutorials/basic-manipulation-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,19 @@ toolGroup.setToolActive(ZoomTool.toolName, {
});
```


## Final code

```js
// Get Cornerstone imageIds and fetch metadata into RAM
const imageIds = await createImageIdsAndCacheMetaData({
StudyInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
SeriesInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.226151125820845824875394858561',
wadoRsRoot: 'https://d3t6nz73ql33tx.cloudfront.net/dicomweb',
type: 'STACK',
});

const content = document.getElementById('content');

const element = document.createElement('div');
Expand Down
17 changes: 10 additions & 7 deletions packages/docs/docs/tutorials/basic-segmentation-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ renderingEngine.renderViewports([viewportId1, viewportId2, viewportId3]);
## Final code

```js
// Get Cornerstone imageIds and fetch metadata into RAM
const imageIds = await createImageIdsAndCacheMetaData({
StudyInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
SeriesInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.226151125820845824875394858561',
wadoRsRoot: 'https://d3t6nz73ql33tx.cloudfront.net/dicomweb',
type: 'VOLUME',
});

const content = document.getElementById('content');

const viewportGrid = document.createElement('div');
Expand Down Expand Up @@ -347,13 +357,6 @@ await setVolumesForViewports(
[
{
volumeId,
callback: ({ volumeActor }) => {
// set the windowLevel after the volumeActor is created
volumeActor
.getProperty()
.getRGBTransferFunction(0)
.setMappingRange(-180, 220);
},
},
],
[viewportId1, viewportId2, viewportId3]
Expand Down
16 changes: 13 additions & 3 deletions packages/docs/docs/tutorials/basic-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const viewport = renderingEngine.getViewport(viewportId);

viewport.setStack(imageIds, 60);

viewport.render()
viewport.render();
```

:::note Tip
Expand All @@ -69,6 +69,17 @@ the second argument of `setStack`.
## Final code

```js
// Get Cornerstone imageIds and fetch metadata into RAM
const imageIds = await createImageIdsAndCacheMetaData({
StudyInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
SeriesInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.226151125820845824875394858561',
wadoRsRoot: 'https://d3t6nz73ql33tx.cloudfront.net/dicomweb',
type: 'STACK',
});

// Final code
const content = document.getElementById('content');
const element = document.createElement('div');
element.style.width = '500px';
Expand All @@ -92,7 +103,7 @@ const viewport = renderingEngine.getViewport(viewportInput.viewportId);

viewport.setStack(imageIds, 60);

viewport.render()
viewport.render();
```

You should see the following:
Expand All @@ -107,7 +118,6 @@ Learn more about:
- [rendering engine](../concepts/cornerstone-core/renderingEngine.md)
- [viewport](../concepts/cornerstone-core/viewports.md)


For advanced usage of Stack Viewport, please visit <a href="/live-examples/stackAPI.html" target="_blank">StackViewport API</a> example page.

:::note Tip
Expand Down
42 changes: 13 additions & 29 deletions packages/docs/docs/tutorials/basic-volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ renderingEngine.renderViewports([viewportId1, viewportId2]);
## Final code

```js
// Get Cornerstone imageIds and fetch metadata into RAM
const imageIds = await createImageIdsAndCacheMetaData({
StudyInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
SeriesInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.226151125820845824875394858561',
wadoRsRoot: 'https://d3t6nz73ql33tx.cloudfront.net/dicomweb',
type: 'VOLUME',
});

const content = document.getElementById('content');

const viewportGrid = document.createElement('div');
Expand Down Expand Up @@ -144,7 +154,9 @@ const renderingEngine = new RenderingEngine(renderingEngineId);
const volumeId = 'cornerStreamingImageVolume: myVolume';

// Define a volume in memory
const volume = await volumeLoader.createAndCacheVolume(volumeId, { imageIds });
const volume = await volumeLoader.createAndCacheVolume(volumeId, {
imageIds,
});

const viewportId1 = 'CT_AXIAL';
const viewportId2 = 'CT_SAGITTAL';
Expand Down Expand Up @@ -191,34 +203,6 @@ You should be able to see:

</div>

We can apply a `window/level` callback on the viewports when they load via the `setVolumesForViewports` API.

```js
setVolumesForViewports(
renderingEngine,
[
{
volumeId,
callback: ({ volumeActor }) => {
// set the windowLevel after the volumeActor is created
volumeActor
.getProperty()
.getRGBTransferFunction(0)
.setMappingRange(-180, 220);
},
},
],
[viewportId1, viewportId2]
);
```

<div style={{width:"75%"}}>


![](../assets/tutorial-basic-volume-2.png)

</div>

## Read more

Learn more about:
Expand Down
17 changes: 7 additions & 10 deletions packages/tools/examples/tutorial/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* WARNING
* DO NOT REMOVE ANY OF THE BELOW IMPORT STATEMENTS
* SOME ARE USED FOR SOME OF THE TUTORIALS, AND WILL BREAK IF REMOVED
*/

import {
RenderingEngine,
Types,
Expand Down Expand Up @@ -34,23 +40,14 @@ setTitleAndDescription(
'The playground for you to copy paste the codes in the tutorials and run it'
);

const { ViewportType } = Enums;
/**
* Runs the demo
*/
async function run() {
// Init Cornerstone and related libraries
await initDemo();

// Get Cornerstone imageIds and fetch metadata into RAM
const imageIds = await createImageIdsAndCacheMetaData({
StudyInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
SeriesInstanceUID:
'1.3.6.1.4.1.14519.5.2.1.7009.2403.226151125820845824875394858561',
wadoRsRoot: 'https://d3t6nz73ql33tx.cloudfront.net/dicomweb',
type: 'VOLUME',
});

/**
*
*
Expand Down