Skip to content

Xnat PreArchive Session Fix

dgutman edited this page Dec 28, 2013 · 5 revisions

sessfix.py

This script was written by Jacob Cobb and David A Gutman

When uploading large sets of images to the prearchive, I came across a scenario where all images sessions from the same patient were assigned the same session_ID; however XNAT requires this to be unique, which means doing a batch archive would not work. To get around this, we have written a script that will scan the prearchive looking for sessions with the same session_ID and will attempt to rename them by calling them PATIENT-ID_SCAN_DATE In most cases, this should deambiguate the sessions and allow them to be added to the prearchive in batch

##Pre-requisites

sudo apt-get install python-sqlalchemy
sudo apt-get install python-psycopg2
sudo apt-get install python-lxml

This script must be run from localhost as it accesses the postgres database to update variables

it's possible/likely this is not mandatory, but figuring out the firewall/password/credential issues is not something I've put high on my list of things to do

CONFIG FOR YOUR XNAT Server: engine = sa.create_engine('postgresql://xnat:xnat@localhost/xnat', echo=vv)
replace xnat:xnat with your userid/pass for your postgres database---
this could be modified to allow entry from nonlocalhost as well depending on your firewall settings