Skip to content

Commit e7f295c

Browse files
committed
Update example in README
1 parent ea4b4ed commit e7f295c

File tree

1 file changed

+31
-36
lines changed

1 file changed

+31
-36
lines changed

README.md

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,57 +25,52 @@ Documentation of the JavaScript Application Programming Interface (API) is avail
2525
## Getting started
2626

2727
Note that the *dicom-microscopy-viewer* package is **not** a viewer application, it is a library to build viewer applications.
28+
2829
Below is an example for the most basic usage: a web page that displays a collection of DICOM VL Whole Slide Microscopy Image instances of a digital slide.
2930
For more advanced usage, take a look at the [Slim](https://github.com/herrmannlab/slim) viewer.
3031

3132
### Basic usage
3233

33-
```html
34-
<script type="text/javascript" src="https://unpkg.com/dicom-microscopy-viewer"></script>
35-
```
36-
3734
The viewer can be embedded in any website, one only needs to
3835

39-
* Create an instance of the `viewer.VolumeViewer`. The constructor requires an instance of `DICOMwebClient` for retrieving frames from the archive as well as the metadata for each DICOM image instance formatted according to the [
40-
DICOM JSON Model](http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.html).
36+
* Create an instance of `viewer.VolumeViewer`. The constructor requires an instance of `DICOMwebClient` for retrieving frames from the archive as well as the metadata for each DICOM image instance.
4137

4238
* Call the `render()` method, passing it the HTML element (or the name of the element), which shall contain the viewport.
4339

4440
```js
45-
const url = 'http://localhost:8080/dicomweb';
46-
const client = new DICOMwebClient.api.DICOMwebClient({url});
47-
const studyInstanceUID = '1.2.3.4';
48-
const seriesInstanceUID = '1.2.3.5';
49-
const searchInstanceOptions = {
50-
studyInstanceUID,
51-
seriesInstanceUID
41+
import * as DICOMMicroscopyViewer from 'dicom-microscopy-viewer';
42+
import * as DICOMwebClient from 'dicomweb-client';
43+
44+
// Construct client instance
45+
const client = new DICOMwebClient.api.DICOMwebClient({
46+
url: 'http://localhost:8080/dicomweb'
47+
});
48+
49+
// Retrieve metadata of a series of DICOM VL Whole Slide Microscopy Image instances
50+
const retrieveOptions = {
51+
studyInstanceUID: '1.2.3.4',
52+
seriesInstanceUID: '1.2.3.5'
5253
};
53-
client.searchForInstances(searchInstanceOptions).then((instances) => {
54-
const promises = []
55-
for (let i = 0; i < instances.length; i++) {
56-
const sopInstanceUID = instances[i]["00080018"]["Value"][0];
57-
const retrieveInstanceOptions = {
58-
studyInstanceUID,
59-
seriesInstanceUID,
60-
sopInstanceUID,
61-
};
62-
const promise = client.retrieveInstanceMetadata(retrieveInstanceOptions).then(metadata => {
63-
const image = new DICOMMicroscopyViewer.metadata.VLWholeSlideMicroscopyViewer({
64-
metadata
65-
})
66-
if (image.imageType[2] === "VOLUME") {
67-
return(image);
68-
}
69-
});
70-
promises.push(promise);
71-
}
72-
return(Promise.all(promises));
73-
}).then(metadata => {
74-
metadata = metadata.filter(m => m);
54+
client.retrieveSeriesMetadata(retrieveOptions).then((metadata) => {
55+
// Parse, format, and filter metadata
56+
const volumeImages = []
57+
metadata.forEach(m => {
58+
const image = new DICOMMicroscopyViewer.metadata.VLWholeSlideMicroscopyImage({
59+
metadata: m
60+
})
61+
const imageFlavor = image.ImageType[2]
62+
if (imageFlavor === 'VOLUME' || imageFlavor === 'THUMBNAIL') {
63+
volumeImages.push(image)
64+
}
65+
})
66+
67+
// Construct viewer instance
7568
const viewer = new DICOMMicroscopyViewer.viewer.VolumeViewer({
7669
client,
77-
metadata
70+
metadata: volumeImages
7871
});
72+
73+
// Render viewer instance in the "viewport" HTML element
7974
viewer.render({container: 'viewport'});
8075
});
8176
```

0 commit comments

Comments
 (0)