Matlab API tool

You can download the BrainSTEM Matlab API tools repository from GitHub at github.com/brainstem-org/brainstem_matlab_api_tools and add it to your Matlab setpath.

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

FunctionDescription
get_tokenGet 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 storage.
load_projectLoad project(s). Convenience function for handling projects. Extra parameters: id,name,description,sessions,subjects,tags,is_public. Included relational data: sessions,subjects,collections.
load_subjectLoad subject(s). Convenience function for handling subjects. Extra parameters: id,name,description,projects,strain,sex,tags. Included relational data: procedures,subjectlogs.
load_sessionLoad session(s). Convenience function for handling sessions. Extra parameters: id,name,description,projects,datastorage,tags. Included relational data: dataacquisition,behaviors,manipulations,epochs.
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 session with the id:

output = load_session('filter', {'id', 'ee57e766-fc0c-42e1-9277-7d40d6e9353a'});

Change sorting

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

output = load_model('model', 'session', '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, data acquisition, behaviors and manipulations related to each session will be included.

output = load_model('model', 'session', 'include', {'projects', 'dataacquisition', 'behaviors', 'manipulations'});

Convenience functions

For the three primary data models (projects, subjects and sessions), you can use convenience functions to ease commonly performed tasks. The convenience functions have the fields of the models accessible as input parameters providing convenient filters and the calls include relational data as well:

load_session

output = load_session('name','mysession');

Performs the same API call as:

output = load_model('app', 'stem', 'model', 'session', 'filter', {'name', 'mysession'}, 'include', {'dataacquisition', 'behaviors', 'manipulations', 'epochs'});

load_project

output = load_project('name','myproject');

Performs the same API call as:

output = load_model('app', 'stem', 'model', 'project', 'filter', {'name', 'myproject'}, 'include', {'sessions', 'subjects', 'collections'});

load_subject

output = load_subject('name','mysubject');

Performs the same API call as:

output = load_model('app', 'stem', 'model', 'subject', 'filter', {'name','mysubject'}, 'include', {'procedures', 'subjectlogs'});