xnat-rest
Use xnat-rest API with this package.
npm install xnat-rest
To test this package please download some DICOM files to your directory and modify the test.js script with the folder name. This package was tested with data available at archive.org
Run all tests with
npm test
Usage:
To write your own application and query XNAT Rest API
var xnat = ; xnatstart ;
The following operations are supported by this library
xnat xnat xnat; xnat;//Object to pass to the request library documentation is here https://github.com/request/request xnat;//url = http://localhost:8080/xnat for example xnat; xnat;//Object with {"user":"username","password":"yourpass"} given to the request lib documentation also in the 'auth' section https://github.com/request/request xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat; xnat;
To upload files using this library create a file (index.js) and add:
var xnat = ; xnat;
Help:
Usage: node index.js -d <directory> -p <project id>
Options:
-d <DICOM directory>, directory with DICOM files.
-p <project id>, project id in XNAT to upload the files.
--pid <patient id>, If patient id is specified, the patient id won't be extracted from the DICOM file.
--sessid <session id>, If session id is specified, the session id won't be extracted from the DICOM file.
--server <server url>, XNAT server url. When server is set, the user will be prompted for username and password
--prompt , If set, forces prompt for login information again. It will use the previous server URL saved in the configuration file
Documentation:
Usage simplified:
The function 'xnat.start()' will prompt for the xnat url, e.x., 'http://yourserver.com/xnat', then for username and password You can then query and do operations on your xnat instance after that.
const Promise = ; const _ = ; const xnat = ; var projectid = "YourProjectId"; var subjectid = "SomeSubjectId"; var sessionid = "SomeSessionId"; xnatstart ;
Get all images from a given session
const xnat = ; const _ = ; const Promise = ; var projectid = "YourProjectId"; var subjectid = "SomeSubjectId"; var sessionid = "SomeSessionId"; xnat
Upload a dicom directory to xnat
Create a script with the following code
const xnat = ; xnat;
Call your script
node yourscript.js -d /path/to/dicom/directory -p ProjectIdInXNAT
User login to xnat instance:
var user = user: "username" password: "password" xnat ;
Dump dicom file in JSON format
xnat ;
Get XNAT projects
Get projects from xnat in json format
xnat
Get XNAT subjects
Optional parameters are projectid and subjectid.
xnat ;
Required parameters when using function getSubject
xnat ;
Get XNAT experiments
Get XNAT experiments, projectid is optional
xnat ;
Create subject
xnat
Upload dicom image
xnat
Logout from xnat
xnat