Basic library for interacting with the REST interface of XNAT.
Project description
# The Boring XNAT Library (BXL)
[](https://badge.fury.io/py/bxl)
[](https://gitlab.com/bbrc/xnat/bxl/commits/master)
[](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
```
[](https://badge.fury.io/py/bxl)
[](https://gitlab.com/bbrc/xnat/bxl/commits/master)
[](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
Release history Release notifications | RSS feed
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.3.tar.gz
(8.2 kB
view details)
Built Distribution
bxl-0.2.3-py2-none-any.whl
(10.0 kB
view details)
File details
Details for the file bxl-0.2.3.tar.gz
.
File metadata
- Download URL: bxl-0.2.3.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6069206ab7e808ce34d73f296aa7110151fe16b30e07516a5e2900bcfc2bbe1b |
|
MD5 | 5e690e8ddda7c9e30b6b7e17917b0ee5 |
|
BLAKE2b-256 | 23d00cf380bebe953229abc08f3d44df374cc1606263b4f783caab6616849464 |
File details
Details for the file bxl-0.2.3-py2-none-any.whl
.
File metadata
- Download URL: bxl-0.2.3-py2-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 882e4b89cc28bc83b743b187a58fc50e049b897e45007ebd01eadb4b22536f46 |
|
MD5 | 08338311b18e7ba8163c9a7777c4e7a0 |
|
BLAKE2b-256 | 470308b619a2ab5030ef889eae590e3e6ec9769fc6d187d16aaf7567cd3e158c |