Page tree
Skip to end of metadata
Go to start of metadata

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

% 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:

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

 

You can select a specific scan: 

% 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: 

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

or the tag number: 

% 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: 

% 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: 

% 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: 

% 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: 

% 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)}'
  • No labels