Skip to content

Commit

Permalink
add xnat.js to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
birdeggb2777 committed Feb 27, 2023
1 parent 54b2965 commit 137ac44
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bluelight/data/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{"path":"../scripts/plugin/graphic_annotation.js", "name": "graphic_annotation", "disableCatch": "true"},
{"path":"../scripts/plugin/rtss.js", "name": "rtss", "disableCatch": "true"},
{"path":"../scripts/plugin/seg.js", "name": "seg", "disableCatch": "true"},
{"path":"../scripts/plugin/tag.js", "name": "tag", "disableCatch": "true"}
{"path":"../scripts/plugin/tag.js", "name": "tag", "disableCatch": "true"},
{"path":"../scripts/plugin/xnat.js", "name": "tag", "disableCatch": "true"}
]
}
43 changes: 43 additions & 0 deletions bluelight/scripts/plugin/xnat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function getQueryVariable_xnat(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return false;
}

function readXNATRequest() {
var experiments = (getQueryVariable_xnat('experiments'));
var scans = (getQueryVariable_xnat('scans'));
var format = (getQueryVariable_xnat('format'));
if (experiments != false && scans != false) {
if (format == false) format = "json";
var url = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + "/data/experiments/"
+ experiments + "/scans/" + scans + "/files/" + "?format=" + format;
readJson_xnat(url);
}
}

function readJson_xnat(url) {
var requestURL = url;
var request = new XMLHttpRequest();
request.open('GET', requestURL);
request.responseType = 'json';
request.send();
request.onload = function () {
var response = request.response;
for (var i = 0; i < response["ResultSet"]["Result"].length; i++) {
if (response["ResultSet"]["Result"][i]["collection"] == "DICOM" || response["ResultSet"]["Result"][i]["collection"] == "DCM") {
var uri = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + response["ResultSet"]["Result"][i]["URI"];
url = "wadouri:" + uri;
series = loadAndViewImage(url);
}
}
}
}

readXNATRequest();

0 comments on commit 137ac44

Please sign in to comment.