Skip to content

Commit

Permalink
feat(transferSyntax): Add customizable Transfer syntax through dataso…
Browse files Browse the repository at this point in the history
…urce config (#3406)
  • Loading branch information
sedghi authored Jun 23, 2023
2 parents 3503e6e + ca3a0b5 commit 52f419d
Show file tree
Hide file tree
Showing 23 changed files with 132 additions and 58 deletions.
2 changes: 1 addition & 1 deletion extensions/cornerstone/src/init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default async function init({
prefetch: appConfig?.maxNumRequests?.prefetch || 10,
};

initWADOImageLoader(userAuthenticationService, appConfig);
initWADOImageLoader(userAuthenticationService, appConfig, extensionManager);

/* Measurement Service */
this.measurementServiceSource = connectToolsToMeasurementService(
Expand Down
23 changes: 12 additions & 11 deletions extensions/cornerstone/src/initWADOImageLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dicomImageLoader, {
webWorkerManager,
} from '@cornerstonejs/dicom-image-loader';
import dicomParser from 'dicom-parser';
import { errorHandler } from '@ohif/core';
import { errorHandler, utils } from '@ohif/core';

const { registerVolumeLoader } = volumeLoader;

Expand Down Expand Up @@ -35,7 +35,8 @@ function initWebWorkers(appConfig) {

export default function initWADOImageLoader(
userAuthenticationService,
appConfig
appConfig,
extensionManager
) {
dicomImageLoader.external.cornerstone = cornerstone;
dicomImageLoader.external.dicomParser = dicomParser;
Expand All @@ -55,18 +56,18 @@ export default function initWADOImageLoader(
convertFloatPixelDataToInt: false,
},
beforeSend: function(xhr) {
//TODO should be removed in the future and request emitted by DicomWebDataSource
const sourceConfig =
extensionManager.getActiveDataSource()?.[0].getConfig() ?? {};
const headers = userAuthenticationService.getAuthorizationHeader();
const acceptHeader = utils.generateAcceptHeader(
sourceConfig.acceptHeader,
sourceConfig.requestTransferSyntaxUID,
sourceConfig.omitQuotationForMultipartRequest
);

// Request:
// JPEG-LS Lossless (1.2.840.10008.1.2.4.80) if available, otherwise accept
// 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
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=*',
Accept: acceptHeader,
};

if (headers) {
Expand Down
65 changes: 36 additions & 29 deletions extensions/default/src/DicomWebDataSource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,50 @@ function createDicomWebApi(dicomWebConfig, userAuthenticationService) {
supportsReject,
staticWado,
singlepart,
omitQuotationForMultipartRequest,
acceptHeader,
requestTransferSyntaxUID,
} = dicomWebConfig;

const dicomWebConfigCopy = JSON.parse(JSON.stringify(dicomWebConfig));

const getAuthrorizationHeader = () => {
const xhrRequestHeaders = {};
const authHeaders = userAuthenticationService.getAuthorizationHeader();
if (authHeaders && authHeaders.Authorization) {
xhrRequestHeaders.Authorization = authHeaders.Authorization;
}
return xhrRequestHeaders;
};

const generateWadoHeader = () => {
let authorizationHeader = getAuthrorizationHeader();
//Generate accept header depending on config params
let formattedAcceptHeader = utils.generateAcceptHeader(
acceptHeader,
requestTransferSyntaxUID,
omitQuotationForMultipartRequest
);

return {
...authorizationHeader,
Accept: formattedAcceptHeader,
};
};

const qidoConfig = {
url: qidoRoot,
staticWado,
singlepart,
headers: userAuthenticationService.getAuthorizationHeader(),
headers: getAuthrorizationHeader(),
errorInterceptor: errorHandler.getHTTPErrorHandler(),
};

const wadoConfig = {
url: wadoRoot,
staticWado,
singlepart,
headers: userAuthenticationService.getAuthorizationHeader(),
headers: generateWadoHeader(),
errorInterceptor: errorHandler.getHTTPErrorHandler(),
};

Expand Down Expand Up @@ -110,11 +137,7 @@ function createDicomWebApi(dicomWebConfig, userAuthenticationService) {
studies: {
mapParams: mapParams.bind(),
search: async function(origParams) {
const headers = userAuthenticationService.getAuthorizationHeader();
if (headers) {
qidoDicomWebClient.headers = headers;
}

qidoDicomWebClient.headers = getAuthrorizationHeader();
const { studyInstanceUid, seriesInstanceUid, ...mappedParams } =
mapParams(origParams, {
supportsFuzzyMatching,
Expand All @@ -135,11 +158,7 @@ function createDicomWebApi(dicomWebConfig, userAuthenticationService) {
series: {
// mapParams: mapParams.bind(),
search: async function(studyInstanceUid) {
const headers = userAuthenticationService.getAuthorizationHeader();
if (headers) {
qidoDicomWebClient.headers = headers;
}

qidoDicomWebClient.headers = getAuthrorizationHeader();
const results = await seriesInStudy(
qidoDicomWebClient,
studyInstanceUid
Expand All @@ -151,11 +170,7 @@ function createDicomWebApi(dicomWebConfig, userAuthenticationService) {
},
instances: {
search: (studyInstanceUid, queryParameters) => {
const headers = userAuthenticationService.getAuthorizationHeader();
if (headers) {
qidoDicomWebClient.headers = headers;
}

qidoDicomWebClient.headers = getAuthrorizationHeader();
qidoSearch.call(
undefined,
qidoDicomWebClient,
Expand All @@ -182,6 +197,7 @@ function createDicomWebApi(dicomWebConfig, userAuthenticationService) {
return getDirectURL({ wadoRoot, singlepart }, params);
},
bulkDataURI: async ({ StudyInstanceUID, BulkDataURI }) => {
qidoDicomWebClient.headers = getAuthrorizationHeader();
const options = {
multipart: false,
BulkDataURI,
Expand All @@ -200,11 +216,6 @@ function createDicomWebApi(dicomWebConfig, userAuthenticationService) {
sortFunction,
madeInClient = false,
} = {}) => {
const headers = userAuthenticationService.getAuthorizationHeader();
if (headers) {
wadoDicomWebClient.headers = headers;
}

if (!StudyInstanceUID) {
throw new Error(
'Unable to query for SeriesMetadata without StudyInstanceUID'
Expand Down Expand Up @@ -234,17 +245,12 @@ function createDicomWebApi(dicomWebConfig, userAuthenticationService) {

store: {
dicom: async (dataset, request) => {
const headers = userAuthenticationService.getAuthorizationHeader();
if (headers) {
wadoDicomWebClient.headers = headers;
}

wadoDicomWebClient.headers = generateWadoHeader();
if (dataset instanceof ArrayBuffer) {
const options = {
datasets: [dataset],
request,
};

await wadoDicomWebClient.storeInstances(options);
} else {
const meta = {
Expand Down Expand Up @@ -282,7 +288,7 @@ function createDicomWebApi(dicomWebConfig, userAuthenticationService) {
madeInClient
) => {
const enableStudyLazyLoad = false;

wadoDicomWebClient.headers = generateWadoHeader();
// data is all SOPInstanceUIDs
const data = await retrieveStudyMetadata(
wadoDicomWebClient,
Expand Down Expand Up @@ -353,6 +359,7 @@ function createDicomWebApi(dicomWebConfig, userAuthenticationService) {
madeInClient = false
) => {
const enableStudyLazyLoad = true;
wadoDicomWebClient.headers = generateWadoHeader();
// Get Series
const {
preLoadData: seriesSummaryMetadata,
Expand Down
3 changes: 2 additions & 1 deletion platform/app/public/config/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ window.config = {
modes: [],
showStudyList: true,
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,

showWarningMessageForCrossOrigin: true,
showCPUFallbackMessage: true,
showLoadingIndicator: true,
Expand All @@ -30,6 +30,7 @@ window.config = {
supportsFuzzyMatching: false,
supportsWildcard: false,
staticWado: true,
omitQuotationForMultipartRequest: true,
},
},
{
Expand Down
3 changes: 1 addition & 2 deletions platform/app/public/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ window.config = {
// some windows systems have issues with more than 3 web workers
maxNumberOfWebWorkers: 3,
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,
showWarningMessageForCrossOrigin: true,
showCPUFallbackMessage: true,
showLoadingIndicator: true,
Expand Down Expand Up @@ -51,7 +50,6 @@ window.config = {
wadoUriRoot: 'https://d33do7qe4w26qo.cloudfront.net/dicomweb',
qidoRoot: 'https://d33do7qe4w26qo.cloudfront.net/dicomweb',
wadoRoot: 'https://d33do7qe4w26qo.cloudfront.net/dicomweb',

qidoSupportsIncludeField: false,
supportsReject: false,
imageRendering: 'wadors',
Expand All @@ -68,6 +66,7 @@ window.config = {
enabled: true,
relativeResolution: 'studies',
},
omitQuotationForMultipartRequest: true,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion platform/app/public/config/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ window.config = {
extensions: [],
showStudyList: true,
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,
showWarningMessageForCrossOrigin: true,
strictZSpacingForVolumeViewport: true,
showCPUFallbackMessage: true,
Expand All @@ -25,6 +24,7 @@ window.config = {
bulkDataURI: {
enabled: false,
},
omitQuotationForMultipartRequest: true,
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion platform/app/public/config/dicomweb-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ window.config = {
modes: [],
showStudyList: true,
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,
showWarningMessageForCrossOrigin: true,
showCPUFallbackMessage: true,
showLoadingIndicator: true,
Expand All @@ -28,6 +27,7 @@ window.config = {
enableStudyLazyLoad: true,
supportsFuzzyMatching: false,
supportsWildcard: false,
omitQuotationForMultipartRequest: true,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion platform/app/public/config/dicomweb_relative.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ window.config = {
showStudyList: true,
maxNumberOfWebWorkers: 3,
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,
showWarningMessageForCrossOrigin: true,
showCPUFallbackMessage: true,
showLoadingIndicator: true,
Expand All @@ -31,6 +30,7 @@ window.config = {
supportsWildcard: true,
staticWado: true,
singlepart: 'bulkdata,video,pdf',
omitQuotationForMultipartRequest: true,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion platform/app/public/config/docker_nginx-orthanc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ window.config = {
extensions: [],
modes: [],
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,
showWarningMessageForCrossOrigin: true,
showCPUFallbackMessage: true,
showLoadingIndicator: true,
Expand All @@ -23,6 +22,7 @@ window.config = {
qidoSupportsIncludeField: false,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
omitQuotationForMultipartRequest: true,
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ window.config = {
routerBasename: '/',
showStudyList: true,
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,
showWarningMessageForCrossOrigin: true,
showCPUFallbackMessage: true,
showLoadingIndicator: true,
Expand All @@ -18,6 +17,7 @@ window.config = {
qidoSupportsIncludeField: false,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
omitQuotationForMultipartRequest: true,
// REQUIRED TAG:
// TODO: Remove tag after https://github.com/OHIF/ohif-core/pull/19 is merged and we bump version
// requestOptions: {
Expand Down
3 changes: 2 additions & 1 deletion platform/app/public/config/docker_openresty-orthanc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ window.config = {
extensions: [],
modes: [],
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,

showWarningMessageForCrossOrigin: true,
showCPUFallbackMessage: true,
showLoadingIndicator: true,
Expand All @@ -23,6 +23,7 @@ window.config = {
qidoSupportsIncludeField: false,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
omitQuotationForMultipartRequest: true,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion platform/app/public/config/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ window.config = {
modes: ['@ohif/mode-test'],
showStudyList: true,
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,
maxNumberOfWebWorkers: 3,
showWarningMessageForCrossOrigin: false,
showCPUFallbackMessage: false,
Expand All @@ -31,6 +30,7 @@ window.config = {
supportsFuzzyMatching: false,
supportsWildcard: true,
singlepart: 'video,thumbnail,pdf',
omitQuotationForMultipartRequest: true,
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion platform/app/public/config/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ window.config = {
},
enableGoogleCloudAdapter: false,
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,
showWarningMessageForCrossOrigin: true,
showCPUFallbackMessage: true,
showLoadingIndicator: true,
Expand Down Expand Up @@ -55,6 +54,7 @@ window.config = {
supportsFuzzyMatching: true,
supportsWildcard: false,
dicomUploadEnabled: true,
omitQuotationForMultipartRequest: true,
},
},
{
Expand Down
1 change: 0 additions & 1 deletion platform/app/public/config/idc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ window.config = {
routerBasename: '/',
enableGoogleCloudAdapter: true,
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,
showWarningMessageForCrossOrigin: true,
showCPUFallbackMessage: true,
showLoadingIndicator: true,
Expand Down
2 changes: 1 addition & 1 deletion platform/app/public/config/local_dcm4chee.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ window.config = {
extensions: [],
modes: [],
// below flag is for performance reasons, but it might not work for all servers
omitQuotationForMultipartRequest: true,
showWarningMessageForCrossOrigin: true,
showCPUFallbackMessage: true,
showLoadingIndicator: true,
Expand Down Expand Up @@ -39,6 +38,7 @@ window.config = {
bulkDataURI: {
enabled: true,
},
omitQuotationForMultipartRequest: true,
},
},
{
Expand Down
Loading

0 comments on commit 52f419d

Please sign in to comment.