dicom-microscopy-viewer
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "dicom-microscopy-viewer", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Web-based viewer for DICOM Visible Light Whole Slide Microscopy Images", | ||
@@ -39,4 +39,5 @@ "main": "build/dicom-microscopy-viewer.js", | ||
"dependencies": { | ||
"dicomweb-client": "^0.0.3", | ||
"ol": "^5.1.3" | ||
} | ||
} |
[![Build Status](https://travis-ci.com/dcmjs-org/dicom-microscopy-viewer.svg?branch=master)](https://travis-ci.com/dcmjs-org/dicom-microscopy-viewer) | ||
# DICOM Microscopy Viewer | ||
Web-based viewer for [DICOM Visible Light Whole Slide Microscopy Images](http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_A.32.8.html). | ||
Vanilla JS library for web-based visualization of [DICOM VL Whole Slide Microscopy Image](http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_A.32.8.html) datasets. | ||
The library relies on [Openlayers](http://openlayers.org/) for rendering pyramid images and retrieves pyramid tiles (image frames) using [DICOMweb WADO-RS](https://www.dicomstandard.org/dicomweb/retrieve-wado-rs-and-wado-uri/). | ||
## Install | ||
## Installation | ||
The [dicom-microscopy-viewer](https://www.npmjs.com/package/dicom-microscopy-viewer) package can be installed via `npm` package manager: | ||
Install the [dicom-microscopy-viewer](https://www.npmjs.com/package/dicom-microscopy-viewer) package using the `npm` package manager: | ||
@@ -15,5 +16,5 @@ ```None | ||
## Build | ||
## Building and testing | ||
The library can be build locally with [rollup](https://rollupjs.org/guide/en): | ||
Build and test code locally: | ||
@@ -25,17 +26,19 @@ ```None | ||
npm run build | ||
npm test | ||
``` | ||
## Test | ||
We use [rollup](https://rollupjs.org/guide/en) for bundling and [mochify](https://github.com/mantoni/mochify.js) for testing (based on [mocha](https://mochajs.org/) and [chai](http://www.chaijs.com/)). | ||
The library can be tested locally with [mochify](https://github.com/mantoni/mochify.js) (using [mocha](https://mochajs.org/) and [chai](http://www.chaijs.com/)): | ||
```None | ||
git clone https://github.com/dcmjs-org/dicom-microscopy-viewer ~/dicom-microscopy-viewer | ||
cd ~/dicom-microscopy-viewer | ||
npm install | ||
npm test | ||
``` | ||
## Usage | ||
The viewer can be embedded in any website. | ||
To this end | ||
* Create an instance of the `DICOMMicroscopy` viewer. The constructor requires an instance of `DICOMwebClient` for retrieving frames from the archive as well as the [Study Instance UID](http://dicom.nema.org/medical/dicom/2018b/output/chtml/part03/sect_C.7.2.html#para_a73c2743-6150-4a31-9da7-0d50edb8cd67) and [Series Instance UID](http://dicom.nema.org/medical/dicom/2018b/output/chtml/part03/sect_C.7.3.html#para_b0bcb555-c05c-4c1d-8b7e-8904168a3d38). | ||
* Call the `render()` method, passing it the HTML element or the name of the element, which shall contain the viewport. | ||
```js | ||
@@ -42,0 +45,0 @@ const url = 'http://localhost:8080/dicomweb'; |
@@ -17,2 +17,5 @@ import builtins from 'rollup-plugin-node-builtins'; | ||
plugins: [ | ||
builtins(), | ||
commonjs(), | ||
json(), | ||
resolve({ | ||
@@ -23,6 +26,3 @@ jsnext: true, | ||
}), | ||
commonjs(), | ||
builtins(), | ||
json() | ||
] | ||
}; |
import WebGLMap from 'ol/WebGLMap'; | ||
import Map from 'ol/Map'; | ||
import View from 'ol/View'; | ||
@@ -217,2 +218,16 @@ import TileLayer from 'ol/layer/Tile'; | ||
} | ||
function base64Encode(data){ | ||
const uint8Array = new Uint8Array(data); | ||
const chunkSize = 0x8000; | ||
const strArray = []; | ||
for (let i=0; i < uint8Array.length; i+=chunkSize) { | ||
let str = String.fromCharCode.apply( | ||
null, uint8Array.subarray(i, i + chunkSize) | ||
); | ||
strArray.push(str); | ||
} | ||
return btoa(strArray.join('')); | ||
} | ||
function tileLoadFunction(tile, src) { | ||
@@ -236,5 +251,4 @@ if (src !== null) { | ||
client.retrieveInstanceFrames(retrieveOptions).then((frames) => { | ||
let pixels = frames[0]; | ||
// Encode pixel data as base64 string | ||
const encodedPixels = btoa(String.fromCharCode(...new Uint8Array(pixels))); | ||
const encodedPixels = base64Encode(frames[0]); | ||
// Add pixel data to image | ||
@@ -403,3 +417,3 @@ tile.getImage().src = "data:image/" + imageSubtype + ";base64," + encodedPixels; | ||
}); | ||
this.map.getView().fit(extent); | ||
this.map.getView().fit(extent, this.map.getSize()); | ||
return(this.map); | ||
@@ -406,0 +420,0 @@ }); |
@@ -5,20 +5,27 @@ const chai = require('chai'); | ||
const dicomMicroscopyViewer = require('../build/dicom-microscopy-viewer.js'); | ||
const viewer = new dicomMicroscopyViewer.api.DICOMMicroscopyViewer({ | ||
client: 'foo', | ||
studyInstanceUID: '1.2.3.4', | ||
seriesInstanceUID: '1.2.3.5' | ||
}); | ||
describe('viewer', function() { | ||
describe('dicomMicroscopyViewer.api.DICOMMicroscopyViewer', function() { | ||
const viewer = new dicomMicroscopyViewer.api.DICOMMicroscopyViewer({ | ||
client: 'foo', | ||
studyInstanceUID: '1.2.3.4', | ||
seriesInstanceUID: '1.2.3.5' | ||
}); | ||
it('should have property "map"', function() { | ||
viewer.should.have.property('map').equal(null); | ||
}); | ||
it('should have property "client"', function() { | ||
viewer.should.have.property('client').equal('foo'); | ||
}); | ||
it('should have property "studyInstanceUID"', function() { | ||
viewer.should.have.property('studyInstanceUID').equal('1.2.3.4'); | ||
}); | ||
it('should have property "seriesInstanceUID"', function() { | ||
viewer.should.have.property('seriesInstanceUID').equal('1.2.3.5'); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44298
80
25058042
2
13
+ Addeddicomweb-client@^0.0.3
+ Addeddicomweb-client@0.0.3(transitive)