feat(Thumbnail): Display set messages support & displaying of series inconsistencies in the thumbnail (#3499)
Co-authored-by: Igor Octaviano <igoroctaviano@gmail.com>
This commit is contained in:
1 parent
aedb9d1576
commit
5302e5b62b
31 files changed
+1126
-12
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import sortInstancesByPosition from '@ohif/core/src/utils/sortInstancesByPosition';
|
||||
import { constructableModalities } from '@ohif/core/src/utils/isDisplaySetReconstructable';
|
||||
import { DisplaySetMessage, DisplaySetMessageList } from '@ohif/core';
|
||||
import checkMultiFrame from './utils/validations/checkMultiframe';
|
||||
import checkSingleFrames from './utils/validations/checkSingleFrames';
|
||||
/**
|
||||
* Checks if a series is reconstructable to a 3D volume.
|
||||
*
|
||||
* @param {Object[]} instances An array of `OHIFInstanceMetadata` objects.
|
||||
*/
|
||||
export default function getDisplaySetMessages(
|
||||
instances: Array<any>,
|
||||
isReconstructable: boolean
|
||||
): DisplaySetMessageList {
|
||||
const messages = new DisplaySetMessageList();
|
||||
if (!instances.length) {
|
||||
messages.addMessage(DisplaySetMessage.CODES.NO_VALID_INSTANCES);
|
||||
}
|
||||
|
||||
const firstInstance = instances[0];
|
||||
// Due to current requirements, LOCALIZER series doesn't have any messages
|
||||
if (firstInstance.ImageType.includes('LOCALIZER')) {
|
||||
return messages;
|
||||
}
|
||||
|
||||
const Modality = firstInstance.Modality;
|
||||
if (!constructableModalities.includes(Modality)) {
|
||||
return messages;
|
||||
}
|
||||
|
||||
const isMultiframe = firstInstance.NumberOfFrames > 1;
|
||||
// Can't reconstruct if all instances don't have the ImagePositionPatient.
|
||||
if (
|
||||
!isMultiframe &&
|
||||
!instances.every(instance => instance.ImagePositionPatient)
|
||||
) {
|
||||
messages.addMessage(DisplaySetMessage.CODES.NO_POSITION_INFORMATION);
|
||||
}
|
||||
|
||||
const sortedInstances = sortInstancesByPosition(instances);
|
||||
|
||||
isMultiframe
|
||||
? checkMultiFrame(sortedInstances[0], messages)
|
||||
: checkSingleFrames(sortedInstances, messages);
|
||||
|
||||
if (!isReconstructable) {
|
||||
messages.addMessage(DisplaySetMessage.CODES.NOT_RECONSTRUCTABLE);
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
Reference in new issue
Block a user