Begin adding DICOM Segmentation handling to Cornerstone plugin via dcmjs

This commit is contained in:
Erik Ziegler committed 2019-02-03 22:18:08 +01:00
1 parent b93a677ef3
commit bf8f737fec
15 files changed
+346 -83

No files matched your search

@@ -1,4 +1,4 @@
import React, { Component } from "react";
import React, { Component } from 'react';
import dicomParser from 'dicom-parser';
import TypedArrayProp from './TypedArrayProp';
@@ -14,11 +14,10 @@ class DicomPDFViewport extends Component {
};
static propTypes = {
byteArray: TypedArrayProp.uint8,
byteArray: TypedArrayProp.uint8
};
renderPDF = (dataSet) => {
debugger;
renderPDF = dataSet => {
const sopClassUid = dataSet.string('x00080016');
if (sopClassUid !== SOP_CLASS_UIDS.ENCAPSULATED_PDF) {
@@ -29,15 +28,15 @@ class DicomPDFViewport extends Component {
const offset = fileTag.dataOffset;
const remainder = offset + fileTag.length;
const pdfByteArray = dataSet.byteArray.slice(offset, remainder);
const PDF = new Blob([pdfByteArray], {type: 'application/pdf'});
const PDF = new Blob([pdfByteArray], { type: 'application/pdf' });
const fileURL = URL.createObjectURL(PDF);
this.setState({
fileURL
});
}
};
parseByteArray = (byteArray) => {
parseByteArray = byteArray => {
const options = {
untilTag: ''
};
@@ -46,14 +45,14 @@ class DicomPDFViewport extends Component {
try {
dataSet = dicomParser.parseDicom(byteArray, options);
} catch(error) {
} catch (error) {
this.setState({
error
});
}
return dataSet
}
return dataSet;
};
componentDidMount() {
const dataSet = this.parseByteArray(this.props.byteArray);
@@ -63,18 +62,22 @@ class DicomPDFViewport extends Component {
render() {
return (
<div className={'DicomPDFViewport'} style={{width: '100%', height: '100%'}}>
{this.state.fileURL &&
<object data={this.state.fileURL} type="application/pdf" width="100%" height="100%">
</object>
}
{this.state.error &&
<h2>{JSON.stringify(this.state.error)}</h2>
}
<div
className={'DicomPDFViewport'}
style={{ width: '100%', height: '100%' }}
>
{this.state.fileURL && (
<object
data={this.state.fileURL}
type="application/pdf"
width="100%"
height="100%"
/>
)}
{this.state.error && <h2>{JSON.stringify(this.state.error)}</h2>}
</div>
);
}
}
export default DicomPDFViewport;
@@ -1,5 +1,5 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import OHIF from 'ohif-core';
import OHIFComponentPlugin from './OHIFComponentPlugin.js';
import DicomPDFViewport from './DicomPDFViewport';
@@ -10,13 +10,13 @@ class OHIFDicomPDFViewport extends Component {
static propTypes = {
studies: PropTypes.object,
displaySet: PropTypes.object,
viewportIndex: PropTypes.number,
viewportIndex: PropTypes.number
};
state = {
byteArray: null,
error: null
}
};
static id = 'DicomPDFViewportPDF';
@@ -41,8 +41,9 @@ class OHIFDicomPDFViewport extends Component {
error
});
throw new Error(error);
});
throw new Error(error);
}
);
}
retrieveDicomData(studyInstanceUid, seriesInstanceUid, sopInstanceUid, wadoRoot, wadoUri, authorizationHeaders) {
@@ -63,10 +64,10 @@ class OHIFDicomPDFViewport extends Component {
return (
<OHIFComponentPlugin {...pluginProps}>
{this.state.byteArray && <DicomPDFViewport byteArray={this.state.byteArray}/>}
{this.state.error &&
<h2>{JSON.stringify(this.state.error)}</h2>
}
{this.state.byteArray && (
<DicomPDFViewport byteArray={this.state.byteArray} />
)}
{this.state.error && <h2>{JSON.stringify(this.state.error)}</h2>}
</OHIFComponentPlugin>
);
}