pyxnat: XNAT in Python

Overview

pyxnat is a Python library to communicate with XNAT which is an extensible database system for imaging and related data. pyxnat uses the RESTful Web Services provided by XNAT and aims to ease communications with an XNAT server to plug-in external tools or python scripts by exposing a simple and consistent API.

Installing pyxnat
Instructions on how to get the distribution.
Tutorial
Start here for a quick overview.
Documentation
Detailed documentation and examples.
External Resources
References to related projects and external resources.
About
Contributors and funding.
Latest changes
See changes from the latest version.

Short examples

Setup the connection

>>> from pyxnat import Interface
>>> interface = Interface(
              server='https://central.xnat.org',
              user='login',
              password='pass',
              cachedir='/tmp'
              )

Traverse the resource tree

>>> interface.select.projects().get()
[u'CENTRAL_OASIS_CS', u'CENTRAL_OASIS_LONG', ...]

Operate the database

>>> project = interface.select.project('my_project').insert()
>>> project.resource('images').file('image.nii').insert('/tmp/image.nii')

Use the search engine

>>> table = interface.select(
            'xnat:subjectData',
            ['xnat:subjectData/PROJECT', 'xnat:subjectData/SUBJECT_ID']
            ).where([('xnat:subjectData/SUBJECT_ID','LIKE','%'),
                     ('xnat:subjectData/PROJECT', '=', 'my_project'),
                     'AND'
                     ])

Module contents

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.

Table Of Contents

Next topic

pyxnat.Interface

This Page