Wiki, snippets and issues associated with using the DPUK Node version of XNAT


A place for notes on using / managing a DPUK Imaging node.

Data management

Note that the XNAT data model has the following structure: Project > Subject > Experiment where a Project can have multiple Subjects and and a Subject can have multiple Experiments. Experiment is a general term that can be used to define an MRI Scan, a PET scan or a subject assessment via a questionnaire / clinical interview. An MRI Scan in XNAT is represented by a type of experiment called an "MR Session" which itself has "Scans" which correspond to sequences. When you create an experiment, it's label must be unique to the project, not to the subject, so it is often formed of a subject prefix plus an indication of the nature of the experiment, e.g. subj001_baseline_mr.

Project summaries

A high level summary of the amount of data in a project can be generated with a python script, see $2.

Oxford upload scripts

XNAT's primary use case is to receive DICOM direct from a scanner, anonymise it and file it for research purposes. It comes bundled with a dicom c-store which you can use to send data in and get data out. There are also zip uploaders and applets available for single scans (which xnat calls experiments - MR Sessions are a sub-type of experiments) but for batch uploads of dicom or nifti you're going to be best off utilising script fu and the xnat API.

Subjects / sessions

A single REST API call can be used to simultaneously create a Subject and MR Session more....


To upload a batch of dicom sessions which we can retrieve from deep storage in a particular file structure we use a combination of CSV with subject / scan IDs on it and dcmtk to upload via the dicom c-store more...


To upload a batch of nifti scan files we use a similar process where the script uses the xnat REST API more...


There are several python libraries for interacting with XNAT. The two principle ones are, somewhat confusingly named, pyxnat and xnatpy. Other libraries of interest include DAX and pynetdicom.


Some scripts use the XnatDataClient which is distributed with xnat and a java library with a curl-like interface to the xnat rest api. In oxford we've stopped using this tool as we've found

  • its cumbersome to redistribute a new xnatdataclient jar when we upgrade xnat
  • xnatdataclient doesnt give much value over curl, and in fact does the same thing in different ways which is confusing when you dont have the client handy but you can use curl