icon-toolbox.png
XNAT Tools


Client Tools


XNAT Desktop


XNAT DICOM Gateway


Web Services


Web Services: XNAT Rest API


Web Services: Examples

[Edit Nav] ]

How to Upload Scan Data with REST

Before adding files to a scan, the scan must first be created. You can do this by doing a PUT to a URI like this:

/REST/projects/ID/subjects/ID/experiments/ID/scans/SCAN_ID?xsi:type=xnat:mrScanData

Because scans can be of multiple types, you will need to specify which type of scan you are creating using the xsi:type query string parameter.

MR
xnat:mrScanData
PET
xnat:petScanData
CT
xnat:ctScanData
EPS
xnat:epsScanData
HD
xnat:hdScanData
ECG
xnat:ecgScanData
US
xnat:usScanData
IO
xnat:ioScanData
MG
xnat:mgScanData
DX
xnat:dxScanData
CR
xnat:crScanData
GMV
xnat:gmvScanData
GM
xnat:gmScanData
ESV
xnat:esvScanData
ES
xnat:esScanData
NM
xnat:nmScanData
DX3DCraniofacial
xnat:dx3DCraniofacialScanData
XA3D
xnat:xa3DScanData
RF
xnat:rfScanData
XA
xnat:xaScanData
SM
xnat:smScanData
XC
xnat:xcScanData
XCV
xnat:xcvScanData
OP
xnat:opScanData
OPT
xnat:optScanData
RTImage
xnat:rtImageScanData
SC
xnat:scScanData
Seg
xnat:segScanData
MRS
xnat:mrsScanData
VoiceAudio
xnat:voiceAudioScanData
OtherDicom
xnat:otherDicomScanData

You can set the properties of the scan using the XML PATH shortcuts.

/REST/projects/ID/subjects/ID/experiments/ID/scans/SCAN_ID?xsi:type=xnat:mrScanData&type=T1

Uploading Files


Once you've created the scan, you can PUT files to it like follows:
/REST/projects/ID/subjects/ID/experiments/ID/scans/SCAN_ID/resources/RESOURCE ID/files/FILENAME

The RESOURCE ID should identify the type of file and can be used to group files together. For example, all DICOM files should
be added to a DICOM resource. The FILENAME should identify the name the file should have on the server (with file extension) and can contain sub-directories.

Here is an example command.

XNATRestClient $rest_params -m PUT -remote "/REST/projects/YOURTEST/subjects/subject1/experiments/session1/scans/SCAN1/resources/DICOM/files/1232132.dcm?format=DICOM&content=T1_RAW" -local /data/subject1/session1/RAW/SCAN1/1232132.dcm