Skip to main content
Skip table of contents

DICOM Dump Service API

DICOM metadata from a session can be requested using the XNAT REST API. For example: 

CODE
% curl -u ${user} ${xnat_url}/data/services/dicomdump?src=/archive/projects/${project}/subjects/${subject}/experiments/${session}

dumps the parsed metadata from one arbitrarily selected file from the specified session, as JSON.

DICOM metadata can also be retrieved from sessions in the prearchive:

CODE
% curl -u ${user} ${xnat_url}/data/services/dicomdump?src=/prearchive/projects/${project}/${timestamp}/${session}


You can select a specific scan: 

CODE
% curl -u ${user} ${xnat_url}/data/services/dicomdump?src=/archive/projects/${project}/subjects/${subject}/experiments/${session}/scans/${scan}


You can also restrict the request to specified fields using the tag name: 

CODE
% curl -u ${user} "${xnat_url}/data/services/dicomdump?src=/archive/projects/${project}/subjects/${subject}/experiments/${session}&field=StudyDescription"

or the tag number: 

CODE
% curl -u ${user} "${xnat_url}/data/services/dicomdump?src=/archive/projects/${project}/subjects/${subject}/experiments/${session}&field=0020000d"


You can get more than one field per request by adding more field= arguments: 

CODE
% curl -u ${user} "${xnat_url}/data/services/dicomdump?src=/archive/projects/${project}/subjects/${subject}/experiments/${session}&field=PatientID&field=PatientName"


In addition to the standard DICOM header fields, you can request Siemens shadow header fields: 

CODE
% curl -u ${user} "${xnat_url}/data/services/dicomdump?src=/archive/projects/${project}/subjects/${subject}/experiments/${session}&field=00291020:RFEchoTrainLength"


Finally, you can request results in XML , HTTP, or CSV formats instead of JSON: 

CODE
% curl -u ${user} "${xnat_url}/data/services/dicomdump?src=/archive/projects/${project}/subjects/${subject}/experiments/${session}&field=00291020&format=xml"


Using sed and awk, the CSV output can be massaged to look sort of like the output of DCMTK dcmdump: 

CODE
% curl -u ${user} "${xnat_url}/data/services/dicomdump?src=/archive/projects/${project}/subjects/${subject}/experiments/${session}&format=csv" | sed -e 's/^"//' -e 's/"$//' | awk -F '(",")|(,")|(",)' '{printf("%s %s %-41s # %s %s\n",$1,$3,sprintf("[%s]",$4),$5,$2)}'


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.