cylab-tw / bluelight

a browser-based DICOM viewer
MIT License
117 stars 45 forks source link

XNAT Connection #11

Closed Braisly closed 1 year ago

Braisly commented 1 year ago

Hi!

I would like to know how it is possible the connection with XNAT. I see the way to connect to Orthanc but no way to see the solution for XNAT. Could you help me on that?

Great work with bluelight!

cylien commented 1 year ago

We did not wrap this feature as an XNAT plugin. So we will release a document to describe how to integrate BlueLight into XANT. We replaced the DICOM web protocol with XNAT API so that users can open the DICOM file stored in an XNAT repository.

Braisly commented 1 year ago

Thank you @cylien look forward to see the updates.

cylien commented 1 year ago
  1. Step1: copy BlueLight to XNAT deployment folder
  2. Step 2: modified the function downloadSelectedScans in XNAT source code: "\scripts\xnat\app\scanTable\scanTable.js",
    // download all selected scans
    function downloadSelectedScans(){
        var selectedScans = [];
        scanTable.dataTable$.find('input.selectable-select-one:checked').each(function(){
            selectedScans.push(this.value);
        });    
        /* add those two lines to open a new windows with XNAT API  */ 
        var url = "/bluelight/html/start.html?experiments=" + exptId + "&scans=" + scanId + "&format=json";
        window.open(url);
        downloadIframe(url);
    }
  1. Step 3 : add codes to deal with XNAT API in BlueLight (code should be refined)
function readXNATRequest() {
  var experiments = (getQueryVariable('experiments'));
  var scans = (getQueryVariable('scans'));
  var format = (getQueryVariable('format'));
  if (experiments != false && scans != false && format != false) {
    var url = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + "/data/experiments/"
      + experiments + "/scans/" + scans + "/files/" + "?format=json";
    readJson2(url);
  }
}

function readJson2(url) {
  var requestURL = url;
  var request = new XMLHttpRequest();
  request.open('GET', requestURL);
  request.responseType = 'json';
  request.send();
  request.onload = function () {
    var superHeroes = request.response;
    for (var i = 0; i < superHeroes["ResultSet"]["Result"].length; i++) {
      if (superHeroes["ResultSet"]["Result"][i]["collection"] == "DICOM") {
        var uri = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + superHeroes["ResultSet"]["Result"][i]["URI"];
        url = "wadouri:" + uri;
        series = virtualLoadImage(url, 0);  // launch viewer, should be refined.
      }
    }
  }
}
cylien commented 1 year ago

add xnat.js as a plugin for this issue. 137ac44 Step1: copy BlueLight to XNAT deployment folder Step2: type URL: https://{XNAT's hostname}/bluelight/search/html/start.html?experiments={XNAT expID}&scans={scanID}&format=json

BlueLight will query the XNAT's API to get the XML and retrieve the DICOM stored in experiments and its scans.

http://{XNAT's hostname}/REST/projects/test/subjects/XNAT_S00001/experiments/XNAT_E00002/scans/1/files?format=json

the XML looks like 圖片

cylien commented 1 year ago

Here is a video for the integration of BlueLight with XNAT media

We add the following two lines in the function of displayScanDetails in ScanTable.js i.e., in "scripts/xnat/app/scanTable" of the XNAT.

// inline scan table functions
    scanTable.displayScanDetails = function(scanId){

        if (!scanId) return false;

        var BLurl = "/bluelight/bluelight/html/start.html?experiments=" + exptId + "&scans=" + scanId + "&format=json";
        window.open(BLurl);
...