Attention: : Confluence is not suitable for the storage of highly confidential data. Please ensure that any data classified as Highly Protected is stored using a more secure platform.
If you have any questions, please refer to the University's data classification guide or contact ict.askcyber@sydney.edu.au

Skip to end of banner
Go to start of banner

RESTapi

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

For the full list of commands, see XNAT REST API Directory along with the Tutorials



List projects (will return only the projects the user has access to)

curl -u username "https://xnat.sydney.edu.au/data/archive/projects"

^data is returned in JSON format by default. Modify format using the format parameter with html, xml, json, csv.

^username is the XNAT logon username, password will be prompt.

List projects (in XML format and save to a file)

curl -u username "https://xnat.sydney.edu.au/data/archive/projects/?format=xml" -o projects.xml

List files for an experiment (in XML format and save to a file)

curl -u username "https://xnat.sydney.edu.au/data/projects/[insert project name here]/subjects/[insert subject name here]/experiments/[insert session name here]/scans/[insert scan ID here]/files?format=xml" -o filelist.xml

Download all DICOM files for a scan (in zip format)

curl -u username "https://xnat.sydney.edu.au/data/projects/[insert project name here]/subjects/[insert subject name here]/experiments/[insert session name here]/scans/[insert scan id here]/files?format=zip" -o dicomfiles.zip


For example, below command downloads to dicomfiles.zip that contains all files for existing scan "3980" of existing session "29", that is for existing subject "MH_Brain" of existing project "fang1".

curl -u xufang "https://dev.xnat.sydney.edu.au/data/projects/fang1/subjects/MH_Brain/experiments/29/scans/3980/files?format=zip" -o dicomfiles.zip


Upload all files into the scan

curl -u username -X PUT "https://xnat.sydney.edu.au/data/projects/[insert project name here]/subjects/[insert subject name here]/experiments/[insert session name here]/scans/[insert scan id here]/resources/[insert a custom folder name here]/files?extract=true" -F “file=@compresses-file.zip


For example, below command will decompress test.zip and save all DICOM files into "TEST" folder under existing scan "3980" of existing session "29", that is for existing subject "MH_Brain" of existing project "fang1". You can specify the name of folder, if not existed, it'll be created.

curl -u xufang -X PUT "https://dev.xnat.sydney.edu.au/data/projects/fang1/subjects/MH_Brain/experiments/29/scans/3980/resources/TEST/files?extract=true" -F "file=@test.zip"

Create folder

curl -u username -X PUT "https://xnat.sydney.edu.au/data/projects/[insert project name here]/subjects/[insert subject name here]/experiments/[insert session name here]/scans/[insert scan id here]/resources/[insert a custom folder name here]"


For example, below command creates a sub-folder "TEST3" under scan named "3980" of existing session "29", that is for existing subject "MH_Brain" of existing project "fang1". Note that no further sub-directories are allowed.

curl -u xufang -X PUT "https://xnat.sydney.edu.au/data/projects/fang1/subjects/MH_Brain/experiments/29/scans/3980/resources/TEST3"

  • No labels