* Instance metadata plus metadata provider overhaul. Fix consumption of wado-uri urls fallbacks + datatype agnosticism. WIP DICOMify things. fix various issues with naturalized variable naming migration. Remove metadata provider. Fix consumption of multiframe images and addition of CWIL metadata. Fix strange build issues. Fix CWIL style windowWidth to array from naturalized DICOM. Fix PT, CT, CR and DX issues for cornerstone + DX issues for vtkjs. Move color palette fetching down to the natuaralized JSON level. Remove unused StudyMetadataSummary Remove redundant dicom metadata dictionary. Working local + json routes. Fix SR read. Finished first round of testing + cleaned up debugging etc. * data => metadata for instance naturalizedJSON * Update dcmjs version * Correct github isssues. * Fix erroneously replaced files. * Danny's recommended changes. * Instance metadata plus metadata provider overhaul. Fix consumption of wado-uri urls fallbacks + datatype agnosticism. WIP DICOMify things. fix various issues with naturalized variable naming migration. Remove metadata provider. Fix consumption of multiframe images and addition of CWIL metadata. Fix strange build issues. Fix CWIL style windowWidth to array from naturalized DICOM. Fix PT, CT, CR and DX issues for cornerstone + DX issues for vtkjs. Move color palette fetching down to the natuaralized JSON level. Remove unused StudyMetadataSummary Remove redundant dicom metadata dictionary. Working local + json routes. Fix SR read. Finished first round of testing + cleaned up debugging etc. * data => metadata for instance naturalizedJSON * Update dcmjs version * Correct github isssues. * Fix erroneously replaced files. * Danny's recommended changes. * Update JSON CI * Update casing of import. * Fix jump for SR. * Fix unit tests for measurements service * Fix json CI test. * fix: update yarn lock * Fix local non-encapsulated pdf view * CI updated to new sucess message. Co-authored-by: Danny <danny.ri.brown@gmail.com>
106 lines
2.8 KiB
JavaScript
106 lines
2.8 KiB
JavaScript
import React, { Component } from 'react';
|
|
import ReactResizeDetector from 'react-resize-detector';
|
|
import debounce from 'lodash.debounce';
|
|
|
|
class DicomMicroscopyViewport extends Component {
|
|
state = {
|
|
error: null,
|
|
};
|
|
|
|
viewer = null;
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.container = React.createRef();
|
|
|
|
this.debouncedResize = debounce(() => {
|
|
if (this.viewer) this.viewer.resize();
|
|
}, 100);
|
|
}
|
|
|
|
// install the microscopy renderer into the web page.
|
|
// you should only do this once.
|
|
installOpenLayersRenderer(container, displaySet) {
|
|
const dicomWebClient = displaySet.dicomWebClient;
|
|
|
|
const searchInstanceOptions = {
|
|
studyInstanceUID: displaySet.StudyInstanceUID,
|
|
seriesInstanceUID: displaySet.SeriesInstanceUID,
|
|
};
|
|
|
|
dicomWebClient
|
|
.searchForInstances(searchInstanceOptions)
|
|
.then(instances => {
|
|
const promises = [];
|
|
for (let i = 0; i < instances.length; i++) {
|
|
const sopInstanceUid = instances[i]['00080018']['Value'][0];
|
|
const retrieveInstanceOptions = {
|
|
studyInstanceUID: displaySet.StudyInstanceUID,
|
|
seriesInstanceUID: displaySet.SeriesInstanceUID,
|
|
sopInstanceUid,
|
|
};
|
|
|
|
const promise = dicomWebClient
|
|
.retrieveInstanceMetadata(retrieveInstanceOptions)
|
|
.then(metadata => {
|
|
const ImageType = metadata[0]['00080008']['Value'];
|
|
if (ImageType[2] === 'VOLUME') {
|
|
return metadata[0];
|
|
}
|
|
});
|
|
promises.push(promise);
|
|
}
|
|
return Promise.all(promises);
|
|
})
|
|
.then(async metadata => {
|
|
metadata = metadata.filter(m => m);
|
|
|
|
const { api } = await import(
|
|
/* webpackChunkName: "dicom-microscopy-viewer" */ 'dicom-microscopy-viewer'
|
|
);
|
|
const microscopyViewer = api.VLWholeSlideMicroscopyImageViewer;
|
|
|
|
this.viewer = new microscopyViewer({
|
|
client: dicomWebClient,
|
|
metadata,
|
|
retrieveRendered: false,
|
|
});
|
|
|
|
this.viewer.render({ container });
|
|
});
|
|
}
|
|
|
|
componentDidMount() {
|
|
const { displaySet } = this.props.viewportData;
|
|
|
|
this.installOpenLayersRenderer(this.container.current, displaySet);
|
|
}
|
|
|
|
render() {
|
|
const style = { width: '100%', height: '100%' };
|
|
return (
|
|
<div className={'DicomMicroscopyViewer'} style={style}>
|
|
{ReactResizeDetector && (
|
|
<ReactResizeDetector
|
|
handleWidth
|
|
handleHeight
|
|
onResize={this.onWindowResize}
|
|
/>
|
|
)}
|
|
{this.state.error ? (
|
|
<h2>{JSON.stringify(this.state.error)}</h2>
|
|
) : (
|
|
<div style={style} ref={this.container} />
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
onWindowResize = () => {
|
|
this.debouncedResize();
|
|
};
|
|
}
|
|
|
|
export default DicomMicroscopyViewport;
|