fix: mpr2d vtkjs viewport does not render if range is set to NaN values (#1157)
* chore: fix proptypes declaration * fix: seperate helper method to calculate our initial range * chore: remove unused import * chore: update studies propType from object to array
This commit is contained in:
parent
2381810ba9
commit
84a097212b
@ -65,8 +65,16 @@ class OHIFVTKViewport extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
studies: PropTypes.object,
|
viewportData: PropTypes.shape({
|
||||||
displaySet: PropTypes.object,
|
studies: PropTypes.array,
|
||||||
|
displaySet: PropTypes.shape({
|
||||||
|
studyInstanceUid: PropTypes.string,
|
||||||
|
displaySetInstanceUid: PropTypes.string,
|
||||||
|
sopClassUids: PropTypes.arrayOf(PropTypes.string),
|
||||||
|
sopInstanceUid: PropTypes.string,
|
||||||
|
frameIndex: PropTypes.number,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
viewportIndex: PropTypes.number,
|
viewportIndex: PropTypes.number,
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
};
|
};
|
||||||
@ -175,6 +183,19 @@ class OHIFVTKViewport extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {object} imageDataObject
|
||||||
|
* @param {object} imageDataObject.vtkImageData
|
||||||
|
* @param {object} imageDataObject.imageMetaData0
|
||||||
|
* @param {number} [imageDataObject.imageMetaData0.windowWidth] - The volume's initial windowWidth
|
||||||
|
* @param {number} [imageDataObject.imageMetaData0.windowCenter] - The volume's initial windowCenter
|
||||||
|
* @param {string} imageDataObject.imageMetaData0.modality - CT, MR, PT, etc
|
||||||
|
* @param {string} displaySetInstanceUid
|
||||||
|
* @returns vtkVolumeActor
|
||||||
|
* @memberof OHIFVTKViewport
|
||||||
|
*/
|
||||||
getOrCreateVolume(imageDataObject, displaySetInstanceUid) {
|
getOrCreateVolume(imageDataObject, displaySetInstanceUid) {
|
||||||
if (volumeCache[displaySetInstanceUid]) {
|
if (volumeCache[displaySetInstanceUid]) {
|
||||||
return volumeCache[displaySetInstanceUid];
|
return volumeCache[displaySetInstanceUid];
|
||||||
@ -183,18 +204,11 @@ class OHIFVTKViewport extends Component {
|
|||||||
const { vtkImageData, imageMetaData0 } = imageDataObject;
|
const { vtkImageData, imageMetaData0 } = imageDataObject;
|
||||||
const { windowWidth, windowCenter, modality } = imageMetaData0;
|
const { windowWidth, windowCenter, modality } = imageMetaData0;
|
||||||
|
|
||||||
let lower;
|
const { lower, upper } = _getRangeFromWindowLevels(
|
||||||
let upper;
|
windowWidth,
|
||||||
|
windowCenter,
|
||||||
if (modality === 'PT') {
|
modality
|
||||||
// For PET just set the range to 0-5 SUV
|
);
|
||||||
lower = 0;
|
|
||||||
upper = 5;
|
|
||||||
} else {
|
|
||||||
lower = windowCenter - windowWidth / 2.0;
|
|
||||||
upper = windowCenter + windowWidth / 2.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const volumeActor = vtkVolume.newInstance();
|
const volumeActor = vtkVolume.newInstance();
|
||||||
const volumeMapper = vtkVolumeMapper.newInstance();
|
const volumeMapper = vtkVolumeMapper.newInstance();
|
||||||
|
|
||||||
@ -379,4 +393,32 @@ class OHIFVTKViewport extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes window levels and converts them to a range (lower/upper)
|
||||||
|
* for use with VTK RGBTransferFunction
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} [width] - the width of our window
|
||||||
|
* @param {number} [center] - the center of our window
|
||||||
|
* @param {string} [modality] - 'PT', 'CT', etc.
|
||||||
|
* @returns { lower, upper } - range
|
||||||
|
*/
|
||||||
|
function _getRangeFromWindowLevels(width, center, modality = undefined) {
|
||||||
|
const levelsAreNotNumbers = isNaN(center) || isNaN(width);
|
||||||
|
|
||||||
|
if (levelsAreNotNumbers) {
|
||||||
|
return { lower: 0, upper: 512 };
|
||||||
|
}
|
||||||
|
|
||||||
|
// For PET just set the range to 0-5 SUV
|
||||||
|
if (modality === 'PT') {
|
||||||
|
return { lower: 0, upper: 5 };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
lower: center - width / 2.0,
|
||||||
|
upper: center + width / 2.0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default OHIFVTKViewport;
|
export default OHIFVTKViewport;
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
vtkInteractorStyleMPRCrosshairs,
|
vtkInteractorStyleMPRCrosshairs,
|
||||||
vtkInteractorStyleMPRWindowLevel,
|
vtkInteractorStyleMPRWindowLevel,
|
||||||
vtkInteractorStyleMPRSlice,
|
|
||||||
vtkInteractorStyleMPRRotate,
|
vtkInteractorStyleMPRRotate,
|
||||||
vtkSVGCrosshairsWidget,
|
vtkSVGCrosshairsWidget,
|
||||||
} from 'react-vtkjs-viewport';
|
} from 'react-vtkjs-viewport';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user