I have the following script to upload dicom images to an XNAT instance. I would like to know if this is the correct way of doing it since is quite slow.
My data is structured as [someDir]/[patientID]/[sessionID]/scans/[scanName]/*.dcm
imageDir=$1
PROJECT=<projectId>
JSESSIONID=<cookie>
for patientDir in $(ls -d $imageDir/*/);
do
SUBJECT=$(basename ${patientDir##$imageDir})
for session in $(ls -d $patientDir/*/)
do
SESSION=$(basename ${session##$patientDir})
find $session -name "*.dcm" -exec curl -H 'Content-Type: application/dicom' \
-X POST --cookie JSESSIONID=$JSESSIONID \
"https://<XNAT URL>/data/services/import?inbody=true&PROJECT_ID=$PROJECT&SUBJECT_ID=$SUBJECT&EXPT_LABEL=$SESSION" \
--data-binary @'{}' \;
done
done
This is a solution using zip files given by Chris Fahim. The data must be structured in the following manner: [patientID]/[sessionID]/scans/[scanName]/DICOM/*.dcm After the upload is done, the zip file will be uncompressed and mapped directly to the project, subject, session and scans.
I have a node app for xnat that can be used in the command line. xnat-rest