Importing Data & Annotations

The RedBrick AI SDK allows you to programmatically import data and/or annotations with a Python script.
For simple import operations, we recommend using the CLI.
You can import either locally or externally stored data via the SDK using the create_datapoints method.
Please see the full reference documentation for create_datapoints here.

Project Setup

Perform the standard RedBrick AI SDK set-up to create a Project object.
project = redbrick.get_project(org_id, project_id, api_key)

Import Locally Stored Data

To import locally stored data, create a list of points with relative file paths to your locally stored data, and use the redbrick.StorageMethod.REDBRICK storage ID.
# create a list of file paths to your locally stored data
points = [{"items": ["path/to/data.nii"], "name": "..."}]
# designate the correct Storage Method (in this case, local)
storage_id = redbrick.StorageMethod.REDBRICK
# perform the upload operation
project.upload.create_datapoints(storage_id=storage_id, points=points)
Please see the Items List documentation for a comprehensive overview of the points array.

Import Externally Stored Data

To import data stored in an external storage method such as AWS s3, be sure to use the Storage ID found on the Storage tab of your RedBrick AI account.
Click on the field to copy the Storage ID to your clipboard!

Import Annotations

If you want to upload annotations with your data, include segmentations and segmentMap annotation information in the points object.
points = [
"name": "...",
"series": [
"items": "path/to/data.nii",
# path to your annotation file
"segmentations": "path/to/segmentation.nii",
# segment mapping of the annotation file (often viewed with nibabel)
"segmentMap": {1: "category-1", 2: "category-2"},
project.upload.create_datapoints(storage_id="...", points=points)
Please see our annotation format reference for a more detailed overview.