User guide contents:
pyxnat is a simple python library that relies on the REST API provided by the XNAT platform since its 1.4 version. XNAT is an extensible database for neuroimaging data. The main objective is to ease communications with an XNAT server to plug-in external tools or python scripts to process the data. It features:
- resources browsing capabilities
- read and write access to resources
- complex searches
- disk-caching of requested files and resources
[1] | XNAT home: http://www.xnat.org/ |
[2] | pyxnat documentation: http://packages.python.org/pyxnat/ |
[3] | pyxnat download: http://pypi.python.org/pypi/pyxnat#downloads |
[4] | pyxnat sources: http://github.com/schwarty/pyxnat |
A short overview
- Setup the connection
>>> from pyxnat import Interface >>> interface = Interface( server='http://central.xnat.org:8080', user='login', password='pass', cachedir=os.path.join(os.path.expanduser('~'), '.store') )- Browse the resources
>>> interface.select.projects().get() [u'CENTRAL_OASIS_CS', u'CENTRAL_OASIS_LONG', ...]- Create new resources
>>> interface.select.project('my_project').create() >>> interface.select.project('my_project').resource('images' ).file('image.nii').put('/tmp/image.nii')- Make complex searches
>>> table = interface.select('xnat:subjectData', ['xnat:subjectData/PROJECT', 'xnat:subjectData/SUBJECT_ID' ] ).where([('xnat:subjectData/SUBJECT_ID','LIKE','%'), ('xnat:subjectData/PROJECT', '=', 'my_project'), 'AND' ])
Interface | Main entry point to access a XNAT server. |
Select | Data selection interface. Callable object that indicates the data to be returned to the user. |
SearchManager | Search interface. Handles operations to save and get back searches on the server. |
CacheManager | Management interface for the cache. |
Users | Database user management interface. It is used to retrieve information on users registered on a server. |