From 2f63a9db80b59aaa07d134ba83b19342a5d51eda Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 18 May 2023 19:06:26 +0200 Subject: [PATCH] init commit making TS customizable in OHIF settings --- .../cornerstone/src/initWADOImageLoader.js | 48 ++++++++++++++++--- platform/viewer/public/config/default.js | 1 + 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/extensions/cornerstone/src/initWADOImageLoader.js b/extensions/cornerstone/src/initWADOImageLoader.js index fbbf3b95d..3bee57eff 100644 --- a/extensions/cornerstone/src/initWADOImageLoader.js +++ b/extensions/cornerstone/src/initWADOImageLoader.js @@ -54,7 +54,7 @@ export default function initWADOImageLoader( // we should set this flag to false. convertFloatPixelDataToInt: false, }, - beforeSend: function(xhr) { + beforeSend: function (xhr) { const headers = userAuthenticationService.getAuthorizationHeader(); // Request: @@ -62,12 +62,31 @@ export default function initWADOImageLoader( // whatever transfer-syntax the origin server provides. // For now we use image/jls and image/x-jls because some servers still use the old type // http://dicom.nema.org/medical/dicom/current/output/html/part18.html + + //Initialize the accept header content + const acceptHeader = ['multipart/related'] + //Storing the requesting transfer syntax specified in OHIF config + const requestTransferSyntaxUID = appConfig.requestTransferSyntaxUID + + if (requestTransferSyntaxUID) { + //Check TS is valid + if (!Object.keys(typeForTS).includes(requestTransferSyntaxUID)) { + console.warn(requestTransferSyntaxUID + 'is unexpected') + } else { + //Fetch type header according to requesting TS + let type = typeForTS[requestTransferSyntaxUID] + if (type === 'application/octet-stream' && !appConfig.omitQuotationForMultipartRequest) { + type = '"application/octet-stream"' + } + acceptHeader.push('type=' + type) + acceptHeader.push('transfer-syntax=' + requestTransferSyntaxUID) + } + + } const xhrRequestHeaders = { - Accept: appConfig.omitQuotationForMultipartRequest - ? 'multipart/related; type=application/octet-stream' - : 'multipart/related; type="application/octet-stream"', - // 'multipart/related; type="image/x-jls", multipart/related; type="image/jls"; transfer-syntax="1.2.840.10008.1.2.4.80", multipart/related; type="image/x-jls", multipart/related; type="application/octet-stream"; transfer-syntax=*', - }; + //Serialize Accept header + Accept: acceptHeader.join('; ') + } if (headers && headers.Authorization) { xhrRequestHeaders.Authorization = headers.Authorization; @@ -82,6 +101,23 @@ export default function initWADOImageLoader( initWebWorkers(appConfig); } +const typeForTS = { + "*": "application/octet-stream", + "1.2.840.10008.1.2.1": "application/octet-stream", + "1.2.840.10008.1.2": "application/octet-stream", + "1.2.840.10008.1.2.2": "application/octet-stream", + "1.2.840.10008.1.2.4.70": "image/jpeg", + "1.2.840.10008.1.2.4.50": "image/jpeg", + "1.2.840.10008.1.2.4.51": "image/dicom+jpeg", + "1.2.840.10008.1.2.4.57": "image/jpeg", + "1.2.840.10008.1.2.5": "image/dicom-rle", + "1.2.840.10008.1.2.4.80": "image/jls", + "1.2.840.10008.1.2.4.81": "image/jls", + "1.2.840.10008.1.2.4.90": "image/jp2", + "1.2.840.10008.1.2.4.91": "image/jp2", + "1.2.840.10008.1.2.4.92": "image/jpx", + "1.2.840.10008.1.2.4.93": "image/jpx", +} export function destroy() { // Note: we don't want to call .terminate on the webWorkerManager since diff --git a/platform/viewer/public/config/default.js b/platform/viewer/public/config/default.js index ff93f31a1..8a9bf99d5 100644 --- a/platform/viewer/public/config/default.js +++ b/platform/viewer/public/config/default.js @@ -16,6 +16,7 @@ window.config = { showCPUFallbackMessage: true, showLoadingIndicator: true, strictZSpacingForVolumeViewport: true, + requestTransferSyntaxUID: '1.2.840.10008.1.2.4.80', maxNumRequests: { interaction: 100, thumbnail: 75,