Skip to content

Instantly share code, notes, and snippets.

@rherrick
Last active July 24, 2017 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rherrick/4fbd8b574bfe28c9b38603364b63e22e to your computer and use it in GitHub Desktop.
Save rherrick/4fbd8b574bfe28c9b38603364b63e22e to your computer and use it in GitHub Desktop.
Create XNAT image reconstruction then update to include manually added files
# Get a session
http --auth admin:minda --session=admin xnat164.xnat.org/data/projects
# Create the reconstruction and resource folder
http --session=admin PUT xnat164.xnat.org/data/archive/projects/prj001/subjects/prj001_001/experiments/prj001_001_MR2/reconstructions/prj001_001_MR2_recon_001 xnat:reconstructedImageData/type==RECON_A
http --session=admin PUT xnat164.xnat.org/data/archive/projects/prj001/subjects/prj001_001/experiments/prj001_001_MR2/reconstructions/prj001_001_MR2_recon_001/resources/NIFTI format==NIFTI
# Upload NIFTI and JSON to the reconstruction resource
for SERIES in t1_mpr_1mm_p2_pos50_20061214091206_4 t1_mpr_1mm_p2_pos50_20061214091206_5 t2_spc_1mm_p2_20061214091206_6; do
http --session=admin PUT xnat164.xnat.org/data/archive/projects/prj001/subjects/prj001_001/experiments/prj001_001_MR2/reconstructions/prj001_001_MR2_recon_001/resources/NIFTI/files/${SERIES}.nii.gz inbody==true < ${SERIES}.nii.gz
http --session=admin PUT xnat164.xnat.org/data/archive/projects/prj001/subjects/prj001_001/experiments/prj001_001_MR2/reconstructions/prj001_001_MR2_recon_001/resources/NIFTI/files/${SERIES}.json inbody==true < ${SERIES}.json
done
# Now copy the subfolder into the resource folder on the server side, e.g.:
#
# cp -R /tmp/logs /data/xnat/archive/prj001/arc001/prj001_001_MR2/PROCESSED/prj001_001_MR2_recon_001/NIFTI
#
# Then run the refresh script.
# Refresh the experiment
http --session=admin POST xnat164.xnat.org/data/services/refresh/catalog options==populateStats,append,delete,checksum resource==/archive/projects/prj001/subjects/prj001_001/experiments/prj001_001_MR2
# Get the resources for the reconstruction
http --session=admin xnat164.xnat.org/data/projects/prj001/subjects/prj001_001/experiments/prj001_001_MR2/reconstructions/prj001_001_MR2_recon_001/out/resources/NIFTI/files format==json
# Just get the absolute paths to the reconstruction resources
http --session=admin --pretty=format xnat164.xnat.org/data/projects/prj001/subjects/prj001_001/experiments/prj001_001_MR2/reconstructions/prj001_001_MR2_recon_001/out/resources/NIFTI/files format==json locator==absolutePath | fgrep absolutePath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment