Skip to main content

Neuroscout API wrapper

Project description

pyNS 🌲

Build Status codecov

The Neuroscout API wrapper for Python

Overview

pyNS is a python package to easily interact with the Neuroscout API.

For more API documentation, check out the Swagger API Docs: http://alpha.neuroscout.org/swagger-ui/

Installation

pyNS is supported in Python 3.4+ Use pip to install it:

pip install pyns

Quickstart

We are assuming you already have valid Neuroscout API credentials (and if you dont, sign up at: alpha.neuroscout.org)

First, instantiate a Neuroscout API Client object:

from pyns import Neuroscout
neuroscout = Neuroscout(username='USERNAME', password='PASSWORD')

With the neuroscout instance, you can interact with the API. All of the major routes are linked to the main neuroscout object, and return requests Response objects.

For example we can retrieve our user profile:

>>> neuroscout.user.get()
{'email': 'user@example.com',
 'analyses': [ {'description': 'Does the brain care about language?',
  'hash_id': 'RZd',
  'modified_at': '2018-08-09T23:3',
  'name': 'My new analysis',
  'status': 'PASSED'}]]}

Or query various endpoints, such as datasets:

>>> neuroscout.datasets.get()
[{'description': {'Acknowledgements': '',
   'Authors': ['Tomoyasu Horikawa', 'Yukiyasu Kamitani'],
   'DatasetDOI': '',
   'Funding': '',
   'HowToAcknowledge': '',
   'License': '',
   'Name': 'Generic Object Decoding (fMRI on ImageNet)',
   'ReferencesAndLinks': ['Horikawa & Kamitani (2017) Generic decoding of seen and imagined objects using hierarchical visual features. Nature Communications volume 8:15037. doi:10.1038/ncomms15037']},
  'id': 1,
  'name': 'generic_object_decoding',
...
  'tasks': [{'id': 8, 'name': 'life'}]}]

For example, we could use this to get the first predictor associated with a dataset:

>>> first = neuroscout.predictors.get(dataset_id=5)[0]
{'description': 'Bounding polygon around face. y coordinate for vertex 1',
 'extracted_feature': {'created_at': '2018-04-12 00:44:14.868349',
  'description': 'Bounding polygon around face. y coordinate for vertex 1',
  'extractor_name': 'GoogleVisionAPIFaceExtractor',
  'id': 102,
  'modality': None},
 'id': 197,
 'name': 'boundingPoly_vertex1_y',
 'source': 'extracted'}

And get the predictor-events associated with that predictor:

>>> neuroscout.predictor_events.get(predictor_id=first['id'])[0:2]
[{'duration': 9.0,
  'id': '1050781',
  'onset': 114.0,
  'predictor_id': 197,
  'run_id': 2,
  'value': '13'},
 {'duration': 9.0,
  'id': '1050782',
  'onset': 114.0,
  'predictor_id': 197,
  'run_id': 26,
  'value': '13'}]

Testing

We use pytest for testing, and betamax to record HTTP requests used in test into cassettes.

To re-run tests locally set theUSER_TEST_EMAIL and USER_TEST_PWD environment variables with valid API credentials.

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

pyns-0.1.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

pyns-0.1.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file pyns-0.1.2.tar.gz.

File metadata

  • Download URL: pyns-0.1.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.2

File hashes

Hashes for pyns-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1846822bfbe186b19208a5d4959d885ed9409071ec783a5206f59b27f4ac4904
MD5 08cfd8895bc5004a2c9b9ef23a567a55
BLAKE2b-256 6c7255c3b3dbde608cf77dbde9d32e88a000bd54e9211da9621b993f428709f8

See more details on using hashes here.

Provenance

File details

Details for the file pyns-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyns-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.2

File hashes

Hashes for pyns-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a76909676727d1e31eccbce25162af2dec1948217409359403b4686c89a8bf50
MD5 98d605bc5933c6784337052fd1008264
BLAKE2b-256 21e6595ffb0ef94d41f454863bf3d1bd2ed8c468ef15786365cd41fdab7a3fdf

See more details on using hashes here.

Provenance

Supported by

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