fix(multiframe): metadata handling of NM studies and loading order (#4554)
This commit is contained in:
1 parent
6729534a1a
commit
7624ccb5e4
57 files changed
+482
-662
No files matched your search
@@ -46,8 +46,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@cornerstonejs/adapters": "^2.2.13",
|
||||
"@cornerstonejs/core": "^2.2.13",
|
||||
"@cornerstonejs/adapters": "^2.2.20",
|
||||
"@cornerstonejs/core": "^2.2.20",
|
||||
"@kitware/vtk.js": "32.1.1",
|
||||
"react-color": "^2.19.3"
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@cornerstonejs/adapters": "^2.2.13",
|
||||
"@cornerstonejs/core": "^2.2.13",
|
||||
"@cornerstonejs/adapters": "^2.2.20",
|
||||
"@cornerstonejs/core": "^2.2.20",
|
||||
"@kitware/vtk.js": "32.1.1",
|
||||
"react-color": "^2.19.3"
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@cornerstonejs/adapters": "^2.2.13",
|
||||
"@cornerstonejs/core": "^2.2.13",
|
||||
"@cornerstonejs/tools": "^2.2.13",
|
||||
"@cornerstonejs/adapters": "^2.2.20",
|
||||
"@cornerstonejs/core": "^2.2.20",
|
||||
"@cornerstonejs/tools": "^2.2.20",
|
||||
"classnames": "^2.3.2"
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@cornerstonejs/core": "^2.2.13",
|
||||
"@cornerstonejs/tools": "^2.2.13",
|
||||
"@cornerstonejs/core": "^2.2.20",
|
||||
"@cornerstonejs/tools": "^2.2.20",
|
||||
"classnames": "^2.3.2"
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@
|
||||
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
|
||||
"@cornerstonejs/codec-openjpeg": "^1.2.4",
|
||||
"@cornerstonejs/codec-openjph": "^2.4.5",
|
||||
"@cornerstonejs/dicom-image-loader": "^2.2.13",
|
||||
"@cornerstonejs/dicom-image-loader": "^2.2.20",
|
||||
"@icr/polyseg-wasm": "^0.4.0",
|
||||
"@ohif/core": "3.10.0-beta.10",
|
||||
"@ohif/ui": "3.10.0-beta.10",
|
||||
@@ -55,9 +55,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@cornerstonejs/adapters": "^2.2.13",
|
||||
"@cornerstonejs/core": "^2.2.13",
|
||||
"@cornerstonejs/tools": "^2.2.13",
|
||||
"@cornerstonejs/adapters": "^2.2.20",
|
||||
"@cornerstonejs/core": "^2.2.20",
|
||||
"@cornerstonejs/tools": "^2.2.20",
|
||||
"@icr/polyseg-wasm": "^0.4.0",
|
||||
"@kitware/vtk.js": "32.1.1",
|
||||
"html2canvas": "^1.4.1",
|
||||
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
useSegmentationPresentationStore,
|
||||
useSynchronizersStore,
|
||||
} from './stores';
|
||||
import { useToggleOneUpViewportGridStore } from '../../default/src/stores/useToggleOneUpViewportGridStore';
|
||||
import { useToggleOneUpViewportGridStore } from '@ohif/extension-default';
|
||||
import { useActiveViewportSegmentationRepresentations } from './hooks/useActiveViewportSegmentationRepresentations';
|
||||
import { useMeasurements } from './hooks/useMeasurements';
|
||||
import getPanelModule from './getPanelModule';
|
||||
|
||||
@@ -38,6 +38,7 @@ import { SegmentationRepresentations } from '@cornerstonejs/tools/enums';
|
||||
import { useLutPresentationStore } from './stores/useLutPresentationStore';
|
||||
import { usePositionPresentationStore } from './stores/usePositionPresentationStore';
|
||||
import { useSegmentationPresentationStore } from './stores/useSegmentationPresentationStore';
|
||||
import { imageRetrieveMetadataProvider } from '@cornerstonejs/core/utilities';
|
||||
|
||||
const { registerColormap } = csUtilities.colormap;
|
||||
|
||||
@@ -135,9 +136,21 @@ export default async function init({
|
||||
cornerstoneStreamingDynamicImageVolumeLoader
|
||||
);
|
||||
|
||||
hangingProtocolService.registerImageLoadStrategy('interleaveCenter', interleaveCenterLoader);
|
||||
hangingProtocolService.registerImageLoadStrategy('interleaveTopToBottom', interleaveTopToBottom);
|
||||
hangingProtocolService.registerImageLoadStrategy('nth', nthLoader);
|
||||
// Register strategies using the wrapper
|
||||
const imageLoadStrategies = {
|
||||
interleaveCenter: interleaveCenterLoader,
|
||||
interleaveTopToBottom: interleaveTopToBottom,
|
||||
nth: nthLoader,
|
||||
};
|
||||
|
||||
Object.entries(imageLoadStrategies).forEach(([name, strategyFn]) => {
|
||||
hangingProtocolService.registerImageLoadStrategy(
|
||||
name,
|
||||
createMetadataWrappedStrategy(strategyFn)
|
||||
);
|
||||
});
|
||||
|
||||
// ... existing code ...
|
||||
|
||||
// add metadata providers
|
||||
metaData.addProvider(
|
||||
@@ -296,6 +309,28 @@ function initializeWebWorkerProgressHandler(uiNotificationService) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a wrapped image load strategy with metadata handling
|
||||
* @param strategyFn - The image loading strategy function to wrap
|
||||
* @returns A wrapped strategy function that handles metadata configuration
|
||||
*/
|
||||
const createMetadataWrappedStrategy = (strategyFn: (args: any) => any) => {
|
||||
return (args: any) => {
|
||||
const clonedConfig = imageRetrieveMetadataProvider.clone();
|
||||
imageRetrieveMetadataProvider.clear();
|
||||
|
||||
try {
|
||||
const result = strategyFn(args);
|
||||
return result;
|
||||
} finally {
|
||||
// Ensure metadata is always restored, even if there's an error
|
||||
setTimeout(() => {
|
||||
imageRetrieveMetadataProvider.restore(clonedConfig);
|
||||
}, 10);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function CPUModal() {
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -59,10 +59,10 @@ const initMeasurementService = (
|
||||
'Crosshairs',
|
||||
Length.matchingCriteria,
|
||||
() => {
|
||||
console.warn('Crosshairs mapping not implemented.');
|
||||
return null;
|
||||
},
|
||||
() => {
|
||||
console.warn('Crosshairs mapping not implemented.');
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1058,6 +1058,11 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
// Store the current position presentations for each viewport.
|
||||
viewports.forEach(({ id: viewportId }) => {
|
||||
const presentation = this._getPositionPresentation(viewportId);
|
||||
|
||||
// During a resize, the slice index should remain unchanged. This is a temporary fix for
|
||||
// a larger issue regarding the definition of slice index with slab thickness.
|
||||
// We need to revisit this to make it more robust and understandable.
|
||||
delete presentation.viewReference.sliceIndex;
|
||||
this.beforeResizePositionPresentations.set(viewportId, presentation);
|
||||
});
|
||||
|
||||
@@ -1066,10 +1071,12 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
|
||||
renderingEngine.resize(isImmediate);
|
||||
renderingEngine.render();
|
||||
|
||||
// Reset the camera for viewports that should reset their camera on resize,
|
||||
// Reset the camera for all viewports using position presentation to maintain relative size/position
|
||||
// which means only those viewports that have a zoom level of 1.
|
||||
this.beforeResizePositionPresentations.forEach((positionPresentation, viewportId) => {
|
||||
this.setPresentations(viewportId, { positionPresentation });
|
||||
this.setPresentations(viewportId, {
|
||||
positionPresentation,
|
||||
});
|
||||
});
|
||||
|
||||
// Resize and render the rendering engine again.
|
||||
|
||||
@@ -108,7 +108,7 @@ export default function interleaveTopToBottom({
|
||||
volumes.forEach(volume => {
|
||||
const requests = volume.getImageLoadRequests();
|
||||
|
||||
if (!requests.length || !requests[0] || !requests[0].imageId) {
|
||||
if (!requests?.[0]?.imageId) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ function createDicomJSONApi(dicomJsonConfig) {
|
||||
|
||||
const { query } = qs.parseUrl(instance.url);
|
||||
|
||||
// Add imageId specific mapping to this data as the URL isn't necessarliy WADO-URI.
|
||||
// Add imageId specific mapping to this data as the URL isn't necessarily WADO-URI.
|
||||
metadataProvider.addImageIdToUIDs(imageId, {
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID,
|
||||
|
||||
@@ -142,9 +142,7 @@ function createDicomLocalApi(dicomLocalConfig) {
|
||||
study.series.forEach(aSeries => {
|
||||
const { SeriesInstanceUID } = aSeries;
|
||||
|
||||
const isMultiframe = aSeries.instances[0].NumberOfFrames > 1;
|
||||
|
||||
aSeries.instances.forEach((instance, index) => {
|
||||
aSeries.instances.forEach(instance => {
|
||||
const {
|
||||
url: imageId,
|
||||
StudyInstanceUID,
|
||||
@@ -153,14 +151,22 @@ function createDicomLocalApi(dicomLocalConfig) {
|
||||
} = instance;
|
||||
|
||||
instance.imageId = imageId;
|
||||
|
||||
// Add imageId specific mapping to this data as the URL isn't necessarily WADO-URI.
|
||||
metadataProvider.addImageIdToUIDs(imageId, {
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID,
|
||||
SOPInstanceUID,
|
||||
frameIndex: isMultiframe ? index : 1,
|
||||
});
|
||||
const numberOfFrames = instance.NumberOfFrames || 1;
|
||||
// Process all frames consistently, whether single or multiframe
|
||||
for (let i = 0; i < numberOfFrames; i++) {
|
||||
const frameNumber = i + 1;
|
||||
const frameImageId = implementation.getImageIdsForInstance({
|
||||
instance,
|
||||
frame: frameNumber,
|
||||
});
|
||||
// Add imageId specific mapping to this data as the URL isn't necessarily WADO-URI.
|
||||
metadataProvider.addImageIdToUIDs(frameImageId, {
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID,
|
||||
SOPInstanceUID,
|
||||
frameNumber: numberOfFrames > 1 ? frameNumber : undefined,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
DicomMetadataStore._broadcastEvent(EVENTS.INSTANCES_ADDED, {
|
||||
@@ -209,9 +215,11 @@ function createDicomLocalApi(dicomLocalConfig) {
|
||||
return imageIds;
|
||||
},
|
||||
getImageIdsForInstance({ instance, frame }) {
|
||||
if (instance.imageId) {
|
||||
return instance.imageId;
|
||||
}
|
||||
// Important: Never use instance.imageId because it might be multiframe,
|
||||
// which would make it an invalid imageId.
|
||||
// if (instance.imageId) {
|
||||
// return instance.imageId;
|
||||
// }
|
||||
|
||||
const { StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID } = instance;
|
||||
const storedInstance = DicomMetadataStore.getInstance(
|
||||
|
||||
@@ -434,23 +434,32 @@ function createDicomWebApi(dicomWebConfig, servicesManager) {
|
||||
instance.wadoRoot = dicomWebConfig.wadoRoot;
|
||||
instance.wadoUri = dicomWebConfig.wadoUri;
|
||||
|
||||
const imageId = implementation.getImageIdsForInstance({
|
||||
instance,
|
||||
});
|
||||
const { StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID } = instance;
|
||||
|
||||
const numberOfFrames = instance.NumberOfFrames || 1;
|
||||
// Process all frames consistently, whether single or multiframe
|
||||
for (let i = 0; i < numberOfFrames; i++) {
|
||||
const frameNumber = i + 1;
|
||||
const frameImageId = implementation.getImageIdsForInstance({
|
||||
instance,
|
||||
frame: frameNumber,
|
||||
});
|
||||
// Add imageId specific mapping to this data as the URL isn't necessarily WADO-URI.
|
||||
metadataProvider.addImageIdToUIDs(frameImageId, {
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID,
|
||||
SOPInstanceUID,
|
||||
frameNumber: numberOfFrames > 1 ? frameNumber : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
// Adding imageId to each instance
|
||||
// Todo: This is not the best way I can think of to let external
|
||||
// metadata handlers know about the imageId that is stored in the store
|
||||
instance.imageId = imageId;
|
||||
|
||||
// Adding UIDs to metadataProvider
|
||||
// Note: storing imageURI in metadataProvider since stack viewports
|
||||
// will use the same imageURI
|
||||
metadataProvider.addImageIdToUIDs(imageId, {
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID: instance.SeriesInstanceUID,
|
||||
SOPInstanceUID: instance.SOPInstanceUID,
|
||||
const imageId = implementation.getImageIdsForInstance({
|
||||
instance,
|
||||
});
|
||||
instance.imageId = imageId;
|
||||
});
|
||||
|
||||
DicomMetadataStore.addInstances(naturalizedInstances, madeInClient);
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
"start": "yarn run dev"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@cornerstonejs/core": "^2.2.13",
|
||||
"@cornerstonejs/tools": "^2.2.13",
|
||||
"@cornerstonejs/core": "^2.2.20",
|
||||
"@cornerstonejs/tools": "^2.2.20",
|
||||
"@ohif/core": "3.10.0-beta.10",
|
||||
"@ohif/extension-cornerstone-dicom-sr": "3.10.0-beta.10",
|
||||
"@ohif/extension-default": "3.10.0-beta.10",
|
||||
|
||||
+12
-4
@@ -9,6 +9,7 @@ import { StudyBrowser } from '@ohif/ui-next';
|
||||
import { useTrackedMeasurements } from '../../getContextModule';
|
||||
import { Separator } from '@ohif/ui-next';
|
||||
import { PanelStudyBrowserHeader } from '@ohif/extension-default';
|
||||
import { useAppConfig } from '@state';
|
||||
import { defaultActionIcons, defaultViewPresets } from './constants';
|
||||
|
||||
const { formatDate, createStudyBrowserTabs } = utils;
|
||||
@@ -27,7 +28,7 @@ const thumbnailNoImageModalities = [
|
||||
*
|
||||
* @param {*} param0
|
||||
*/
|
||||
function PanelStudyBrowserTracking({
|
||||
export default function PanelStudyBrowserTracking({
|
||||
servicesManager,
|
||||
getImageSrc,
|
||||
getStudiesForPatientByMRN,
|
||||
@@ -45,6 +46,10 @@ function PanelStudyBrowserTracking({
|
||||
customizationService,
|
||||
} = servicesManager.services;
|
||||
const navigate = useNavigate();
|
||||
const { mode: studyMode } = customizationService.getCustomization('PanelStudyBrowser.studyMode', {
|
||||
id: 'default',
|
||||
mode: 'all',
|
||||
});
|
||||
|
||||
const { t } = useTranslation('Common');
|
||||
|
||||
@@ -55,7 +60,8 @@ function PanelStudyBrowserTracking({
|
||||
const [{ activeViewportId, viewports, isHangingProtocolLayout }, viewportGridService] =
|
||||
useViewportGrid();
|
||||
const [trackedMeasurements, sendTrackedMeasurementsEvent] = useTrackedMeasurements();
|
||||
const [activeTabName, setActiveTabName] = useState('all');
|
||||
|
||||
const [activeTabName, setActiveTabName] = useState(studyMode);
|
||||
const [expandedStudyInstanceUIDs, setExpandedStudyInstanceUIDs] = useState([
|
||||
...StudyInstanceUIDs,
|
||||
]);
|
||||
@@ -117,6 +123,10 @@ function PanelStudyBrowserTracking({
|
||||
|
||||
const { trackedSeries } = trackedMeasurements.context;
|
||||
|
||||
useEffect(() => {
|
||||
setActiveTabName(studyMode);
|
||||
}, [studyMode]);
|
||||
|
||||
// ~~ studyDisplayList
|
||||
useEffect(() => {
|
||||
// Fetch all studies for the patient in each primary study
|
||||
@@ -528,8 +538,6 @@ PanelStudyBrowserTracking.propTypes = {
|
||||
requestDisplaySetCreationForStudy: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default PanelStudyBrowserTracking;
|
||||
|
||||
function getImageIdForThumbnail(displaySet: any, imageIds: any) {
|
||||
let imageId;
|
||||
if (displaySet.isDynamicVolume) {
|
||||
|
||||
Reference in new issue
Block a user