Link Search Menu Expand Document

Python API tool

Python toolset for interacting with the BrainSTEM API. You can get it from GitHub at github.com/brainstem-org/brainstem_python_api_tools.

Please see the dedicated tutorial with examples on usage. The main functions are described below.

FunctionDescription
authenticationGet and save authentication token
load_modelLoad data from any model
save_modelSave data to any model
load_settingsLocal settings: API token, url to the server, and local repositories.
brainstem_api_tutorialTutorial script.

Filters

You can use filters, using fields and relationships by providing cell array with paired filters. Below example will just load the dataset with the id:

output = load_model(settings, 'dataset', filters={'id': 'ee57e766-fc0c-42e1-9277-7d40d6e9353a'})

Change sorting

Loaded models can be sorted by different criteria applying to their fields. In below example, datasets will be sorted in descending order according to their name.

output = load_model(settings, 'dataset', sort=["-name"])

In some cases models contain relations with other models, and they can be also loaded with the models if requested.

In below example, all the projects, experiment data, behaviors and manipulations related to each dataset will be included.

output = load_model(settings, 'dataset', include=['projects','experimentdata','behaviors','manipulations'])