Experimental interface API endpoint

The point where hardware meets the animal or tissue, such as an implanted probe, a cranial window or a fiber.

Table of contents

  1. Endpoints
  2. Fields
  3. List
  4. Add
  5. Detail
  6. Change
  7. Delete
  8. Custom actions
  9. Data model

Endpoints

  • Private portal: https://www.brainstem.org/api/private/modules/experimentalinterface/ (needs a token; one record: append <id>/)
  • Public portal: https://www.brainstem.org/api/public/modules/experimentalinterface/ (read-only, public projects, no token)
  • Response keys: experimentalinterface (detail, create, update), experimentalinterfaces (list)
  • Permissions: inherited through subject.projects or specimen_set.projects (from project)
  • Schema payload: type selects a ExperimentalInterface type; send its fields in details. type_schema_version is set by the server; do not send it.
  • Schema payload: coordinates selects a Coordinates type; send its fields in coordinates_json. coordinates_schema_version is set by the server; do not send it.
  • Deleting: also deletes the linked materialusage records

Form-only inputs (sent on create or update, not returned in responses):

  • target_type [required]. Choices: subject, specimen_set. Choose whether this interface targets an in-vivo subject or an ex-vivo specimen set.

Fields

[required] fields must be sent on create; [read-only] fields are returned but cannot be set. A nestable relation can be traversed in filters (filter{field.other}) and sideloaded with include[]=field.*; other relations can only be compared with ids (filter{field}=<id>). See the query syntax.

FieldDescription
idUUID string [read-only]
namestring [required]; max 255 characters
notesstring; max 500 characters; nullable
typeone of the ExperimentalInterface types [required]
persistenceone of chronic, session, transient [required]
subjectsubject id; nullable; nestable
specimen_setspecimenset id; nullable; nestable
target_specimenslist of specimen ids. Specific specimens within the specimen set targeted by this interface. Leave empty when the interface applies to the whole specimen set.
material_usageslist of materialusage ids [read-only]
materialscomputed [read-only]
equipmentlist of equipment ids
target_regionslist of anatomicalregion ids; nestable
coordinatesone of the Coordinates types [required]; nullable
coordinates_jsonJSON object; nullable
coordinates_schema_versionstring [set by the server]; max 20 characters
detailsJSON object
type_schema_versionstring [set by the server]
installed_atdatetime; nullable
removed_atdatetime; nullable

List

  • Allowed portals: private, public
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/modules/experimentalinterface/
  • Responses: 200 OK; 401 Not authenticated; 403 Not allowed

Use example (Python API tool)

resp = client.load('experimentalinterface', load_all=True)
records = resp['experimentalinterfaces']

Use example (MATLAB API tool)

resp = client.load('experimentalinterface', 'load_all', true);
records = resp.experimentalinterfaces;

Response example

{
    "experimentalinterfaces": [
        {
            "id": "<id>",
            "name": "Experimental interface 1",
            "notes": "",
            "type": "SiliconProbe",
            "persistence": "chronic",
            "subject": "<subject-id>",
            "specimen_set": "<specimenset-id>",
            "target_specimens": [
                "<specimen-id>"
            ],
            "material_usages": [
                "<materialusage-id>"
            ],
            "materials": null,
            "equipment": [
                "<equipment-id>"
            ],
            "target_regions": [
                "<anatomicalregion-id>"
            ],
            "coordinates": "External_XYZ_Euler",
            "coordinates_json": {
                "...": "see the schema of the selected type"
            },
            "coordinates_schema_version": "set by the server",
            "details": {
                "...": "see the schema of the selected type"
            },
            "type_schema_version": "set by the server",
            "installed_at": "2024-03-22T10:30:00Z",
            "removed_at": "2024-03-22T10:30:00Z"
        }
    ],
    "meta": {
        "page": 1,
        "per_page": 100,
        "total_results": 1,
        "total_pages": 1
    }
}

Add

  • Allowed portals: private
  • Request method: POST
  • URL: https://www.brainstem.org/api/private/modules/experimentalinterface/
  • Data: JSON object with at least the required fields
  • Responses: 201 Created; 400 Bad request (validation errors per field); 403 Not allowed

Use example (Python API tool)

resp = client.save('experimentalinterface', data={"name": "Experimental interface 1", "type": "AuditoryStimulator", "persistence": "chronic", "coordinates": "Stereotaxic_BregmaBrainSurface", "details": {"...": "see the schema of the selected type"}, "coordinates_json": {"...": "the fields of the selected Coordinates type"}, "target_type": "subject", "subject": "<subject-id>"})
record = resp.json()['experimentalinterface']

Use example (MATLAB API tool)

created = client.save(struct('name', 'Experimental interface 1', 'type', 'AuditoryStimulator', 'persistence', 'chronic', 'coordinates', 'Stereotaxic_BregmaBrainSurface', 'details', struct(), 'coordinates_json', struct(), 'target_type', 'subject', 'subject', '<subject-id>'), 'experimentalinterface');  % struct() stands for the fields of the selected type
record = created.experimentalinterface;

Detail

  • Allowed portals: private, public
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/modules/experimentalinterface/<id>/
  • Responses: 200 OK; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.load('experimentalinterface', id='<id>')
record = resp.json()['experimentalinterface']

Use example (MATLAB API tool)

out = client.load('experimentalinterface', 'id', '<id>');
record = out.experimentalinterface;

Response example

{
    "experimentalinterface": {
        "id": "<id>",
        "name": "Experimental interface 1",
        "notes": "",
        "type": "SiliconProbe",
        "persistence": "chronic",
        "subject": "<subject-id>",
        "specimen_set": "<specimenset-id>",
        "target_specimens": [
            "<specimen-id>"
        ],
        "material_usages": [
            "<materialusage-id>"
        ],
        "materials": null,
        "equipment": [
            "<equipment-id>"
        ],
        "target_regions": [
            "<anatomicalregion-id>"
        ],
        "coordinates": "External_XYZ_Euler",
        "coordinates_json": {
            "...": "see the schema of the selected type"
        },
        "coordinates_schema_version": "set by the server",
        "details": {
            "...": "see the schema of the selected type"
        },
        "type_schema_version": "set by the server",
        "installed_at": "2024-03-22T10:30:00Z",
        "removed_at": "2024-03-22T10:30:00Z"
    }
}

Change

  • Allowed portals: private
  • Request method: PATCH
  • URL: https://www.brainstem.org/api/private/modules/experimentalinterface/<id>/
  • Data: JSON object with the fields to change. Lists (projects, tags, …) and JSON payloads (details, coordinates) are replaced as a whole: read the record first and send the full list or object.
  • Responses: 200 OK; 400 Bad request; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.save('experimentalinterface', id='<id>', data={"name": "Experimental interface 1 (renamed)"})

Use example (MATLAB API tool)

client.save(struct('id', '<id>', 'name', 'Experimental interface 1 (renamed)'), 'experimentalinterface', 'method', 'patch');

Delete

  • Allowed portals: private
  • Request method: DELETE
  • URL: https://www.brainstem.org/api/private/modules/experimentalinterface/<id>/
  • Responses: 204 Deleted; 400 Still referenced by other records; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.delete('experimentalinterface', id='<id>')

Use example (MATLAB API tool)

client.delete('<id>', 'experimentalinterface');

Custom actions

ActionRequest
apply_material_templatePOST /api/private/modules/experimentalinterface/<id>/apply-material-template/
material_optionsGET /api/private/modules/experimentalinterface/material-options/
materialsGET, PUT /api/private/modules/experimentalinterface/<id>/materials/

materials returns the ordered material usage rows that describe what the interface is made of; PUT replaces them as a whole. apply-material-template copies the rows of a material usage template. material-options lists the material roles and allowed sources of an interface type (?type=<Type>).

Data model

The fields are described for the web forms on the Experimental interface data model page.