cornerstonejs / cornerstoneWADOImageLoader

[DEPRECATED] DICOM WADO Image Loader for the cornerstone library
MIT License
280 stars 267 forks source link

Unable to Change URL of xhrRequest in Each Loop Iteration, Resulting in Same Image Being Loaded #542

Open DarineZeyad opened 2 weeks ago

DarineZeyad commented 2 weeks ago

I am facing an issue with cornerstoneWADOImageLoader where I need to change the URL of the xhrRequest in each loop iteration. However, the loader keeps sending the URL from the first iteration, causing the same image to be loaded repeatedly. Here is the code snippet I am using:

cornerstoneWADOImageLoader.configure({
  useWebWorkers: true,
  decodeConfig: {
    convertFloatPixelDataToInt: false,
  },
  beforeSend: function (xhr) {
    xhr.open("GET", url, true);
    xhr.setRequestHeader("Authorization", `...TOKEN`);
    xhr.setRequestHeader("Accept", "image/jpeg");
  },
  onloadend: function (event, params) {
    // dispatching action
  },
});

cornerstoneWADOImageLoader.wadors.metaDataManager.add(
  imageId,
  instanceMetaData
);

Expected Behavior

The URL in the xhrRequest should change with each iteration, allowing different images to be loaded.

Actual Behavior

The URL remains the same for every iteration, leading to the same image being loaded repeatedly.

Alternative Approach

I have found an alternative way that successfully retrieves images, but I am unsure how cornerstone will handle the responded images:

cornerstoneWADOImageLoader.internal.xhrRequest(url, imageId, {
  Authorization: `Bearer ${sessionStorage.getItem(storageKeys.accessToken)}`,
});

HTTP Request Details

The whole point of trying to change the URL is to retrieve rendered images using the following HTTP request format: GET https://healthcare.googleapis.com/v1beta1/{parent=projects/*/locations/*/datasets/*/dicomStores/*}/dicomWeb/{dicomWebPath=studies/*/series/*/instances/*/rendered}

Could you please advise on how to correctly update the URL within the beforeSend function or guidance on how cornerstone processes the images retrieved using the alternative approach would be greatly appreciated.

Thank you for your assistance!