Skip to content

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

@DarineZeyad

Description

@DarineZeyad

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions