Skip to main content

Basic library for interacting with the REST interface of XNAT.

Project description

# The Boring XNAT Library (BXL)

[![PyPI version](https://badge.fury.io/py/bxl.svg)](https://badge.fury.io/py/bxl)
[![pipeline status](https://gitlab.com/bbrc/xnat/bxl/badges/master/pipeline.svg)](https://gitlab.com/bbrc/xnat/bxl/commits/master)
[![coverage report](https://gitlab.com/bbrc/xnat/bxl/badges/master/coverage.svg)](https://gitlab.com/bbrc/xnat/bxl/commits/master)


BXL is a library for interacting with the REST interface of XNAT ([Extensible Neuroimaging Archive Toolkit](https://www.xnat.org/)),
an open-source imaging informatics software platform.

## Usage

### Installation

BXL is available at [PyPI](https://pypi.org/project/bxl/), the Python Package Index.

With [pip](https://pypi.org/project/pip/) package management system:
```commandline
pip install bxl
```

Without pip:
```commandline
git clone https://gitlab.com/bbrc/xnat/bxl.git .
cd ./bxl
python setup.py install

```

### Credentials handling

The `xnat.Connection()` class constructor expects a `credentials` argument to be passed when instantiated,
* If is a `tuple`, it will proceed to a basic authentication procedure against the `host` XNAT instance.
* If is a `basestring`, it will reuse it as a cookie for authentication against the `host` XNAT instance.
* Otherwise (or if authentication procedure failed in the aforementioned cases), it will remain offline.

### Examples

Connect to XNAT instance using an existing JSESSIONID token and get a list of user-visible XNAT projects
```python
import bxl.xnat as xlib

c = xlib.Connection(hostname='http://myxnat.org',credentials='1A12346385E876546C99B4179E20986A')

data = c.get_json_data(URL=c.host + '/data/projects')
projects = { item['ID'] : item['URI'] for item in data }
print projects

c.close_jsession()

```

Connect via ['with' statement](https://docs.python.org/2.5/whatsnew/pep-343.html) to create a new Female subject 'dummy' in the 'test' project
```python
from bxl import xnat

with xnat.Connection(hostname='http://myxnat.org',credentials=(usr,pwd)) as c :
response = c.put_data(URL=c.host + '/data/projects/test/subjects/dummy', data="",options= {'gender' : 'female'} )
subject_uid = response.content
print 'New subject %s created!' %subject_uid

```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bxl-0.2.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

bxl-0.2.1-py2-none-any.whl (9.4 kB view details)

Uploaded Python 2

File details

Details for the file bxl-0.2.1.tar.gz.

File metadata

  • Download URL: bxl-0.2.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.13

File hashes

Hashes for bxl-0.2.1.tar.gz
Algorithm Hash digest
SHA256 cf2724b6abb617187dfed0af9709e5cf9021b63a3803f42f3842ebeff16b0032
MD5 3af765ebdcdb5b29e7c6b2e8ce6119e9
BLAKE2b-256 4db4e7a55bc627633e758315073f97b69b8ea948e4d701b10781d90a985fe9d6

See more details on using hashes here.

File details

Details for the file bxl-0.2.1-py2-none-any.whl.

File metadata

  • Download URL: bxl-0.2.1-py2-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.13

File hashes

Hashes for bxl-0.2.1-py2-none-any.whl
Algorithm Hash digest
SHA256 6ddfde6c004a769556462273b22de1cba334becad521951e439d871441bf6950
MD5 e928de9222ebc5929a730756cd3df59b
BLAKE2b-256 ca5a11e6d0605a8cf0a673359231bb0b4db22c11c6a8c95e8d79695793dfe8b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page