feat(debug): Add timing information about time to first image/all images, and query time (#3681)
This commit is contained in:
1 parent
1b207f14d2
commit
108383b9ef
10 files changed
+125
-18
No files matched your search
@@ -28,6 +28,7 @@ import interleaveTopToBottom from './utils/interleaveTopToBottom';
|
||||
import initContextMenu from './initContextMenu';
|
||||
import initDoubleClick from './initDoubleClick';
|
||||
import { CornerstoneServices } from './types';
|
||||
import initViewTiming from './utils/initViewTiming';
|
||||
|
||||
// TODO: Cypress tests are currently grabbing this from the window?
|
||||
window.cornerstone = cornerstone;
|
||||
@@ -284,6 +285,8 @@ export default async function init({
|
||||
element.addEventListener(EVENTS.CAMERA_RESET, resetCrosshairs);
|
||||
|
||||
eventTarget.addEventListener(EVENTS.STACK_VIEWPORT_NEW_STACK, toolbarEventListener);
|
||||
|
||||
initViewTiming({ element, eventTarget });
|
||||
}
|
||||
|
||||
function elementDisabledHandler(evt) {
|
||||
@@ -305,8 +308,8 @@ export default async function init({
|
||||
viewportGridService.subscribe(
|
||||
viewportGridService.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED,
|
||||
activeViewportEventListener
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function CPUModal() {
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { log, Types } from '@ohif/core';
|
||||
import { EVENTS } from '@cornerstonejs/core';
|
||||
|
||||
const { TimingEnum } = Types;
|
||||
|
||||
const IMAGE_TIMING_KEYS = [
|
||||
TimingEnum.DISPLAY_SETS_TO_ALL_IMAGES,
|
||||
TimingEnum.DISPLAY_SETS_TO_FIRST_IMAGE,
|
||||
TimingEnum.STUDY_TO_FIRST_IMAGE,
|
||||
];
|
||||
|
||||
const imageTiming = {
|
||||
viewportsWaiting: 0,
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines the initial view timing reporting.
|
||||
* This allows knowing how many viewports are waiting for initial views and
|
||||
* when the IMAGE_RENDERED gets sent out.
|
||||
* The first image rendered will fire the FIRST_IMAGE timeEnd logs, while
|
||||
* the last of the enabled viewport will fire the ALL_IMAGES timeEnd logs.
|
||||
*
|
||||
*/
|
||||
|
||||
export default function initViewTiming({ element }) {
|
||||
if (!IMAGE_TIMING_KEYS.find(key => log.timingKeys[key])) {
|
||||
return;
|
||||
}
|
||||
imageTiming.viewportsWaiting += 1;
|
||||
element.addEventListener(EVENTS.IMAGE_RENDERED, imageRenderedListener);
|
||||
}
|
||||
|
||||
function imageRenderedListener(evt) {
|
||||
if (evt.detail.viewportStatus === 'preRender') {
|
||||
return;
|
||||
}
|
||||
log.timeEnd(TimingEnum.DISPLAY_SETS_TO_FIRST_IMAGE);
|
||||
log.timeEnd(TimingEnum.STUDY_TO_FIRST_IMAGE);
|
||||
log.timeEnd(TimingEnum.SCRIPT_TO_VIEW);
|
||||
imageTiming.viewportsWaiting -= 1;
|
||||
evt.detail.element.removeEventListener(EVENTS.IMAGE_RENDERED, imageRenderedListener);
|
||||
if (!imageTiming.viewportsWaiting) {
|
||||
log.timeEnd(TimingEnum.DISPLAY_SETS_TO_ALL_IMAGES);
|
||||
}
|
||||
}
|
||||
@@ -13,22 +13,23 @@ export default function getDisplaySetMessages(
|
||||
isReconstructable: boolean
|
||||
): DisplaySetMessageList {
|
||||
const messages = new DisplaySetMessageList();
|
||||
if (!instances.length) {
|
||||
const firstInstance = instances[0];
|
||||
if (!instances.length || firstInstance) {
|
||||
messages.addMessage(DisplaySetMessage.CODES.NO_VALID_INSTANCES);
|
||||
return;
|
||||
}
|
||||
|
||||
const firstInstance = instances[0];
|
||||
const { Modality, ImageType, NumberOfFrames } = firstInstance;
|
||||
// Due to current requirements, LOCALIZER series doesn't have any messages
|
||||
if (firstInstance?.ImageType?.includes('LOCALIZER')) {
|
||||
if (ImageType?.includes('LOCALIZER')) {
|
||||
return messages;
|
||||
}
|
||||
|
||||
const Modality = firstInstance.Modality;
|
||||
if (!constructableModalities.includes(Modality)) {
|
||||
return messages;
|
||||
}
|
||||
|
||||
const isMultiframe = firstInstance.NumberOfFrames > 1;
|
||||
const isMultiframe = 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);
|
||||
|
||||
Reference in new issue
Block a user