Importing Annotations Guide
You can import all annotation types that are supported in RedBrick AI, including segmentations, classifications, bounding boxes, and more. Imported annotations will appear automatically on your annotator’s interface.
Please note the following critical points about annotation imports:
- Best practices: It is best practice to import annotations and images together at the start. If you want to add annotations programmatically to images that have already been uploaded, please use the programmatic label & review.
- API key required: annotation import is only supported through the SDK and CLI. In other words, you cannot use the direct upload UI to import annotations, and you must use the items list with the SDK/CLI to provide the required metadata along with annotations.
- Consistency in dimensions: the image file and the annotation file must have the same dimensions.
- Annotation file type: all annotation files must be
uint8
oruint16
. - Valid entries: we do not recommend uploading empty entries (i.e. entries in the
segmentMap
that do not actually contain a segmentation mask). Using validation parameters such ascreate_datapoints(label_validate=True)
on upload is recommended if you believe there is a chance that yoursegmentMap
contains invalid entries.
To import images along with segmentations, you must provide us with:
-
Images in any supported format and NIftI segmentation files.
-
An items list that provides a mapping of:
-
Segmentation files to volumes so that segmentations are applied to correct images.
-
Values within segmentation file to taxonomy categories.
-
Once you’ve prepared the items list in the format defined below, you can import the images and annotations using the create_datapoints
SDK method or CLI upload
method.
Items list for importing segmentations
You can find the full format reference here. In this section, we will focus on importing segmentations. In the examples below, pay attention to the following fields:
-
segmentations
: The segmentation files to be applied to the task. -
segmentMap
: Map the values present in the segmentation files to their corresponding taxonomy categories.
I: One segmentation file per Task
segmentation.nii.gz
) is not necessarily a binary mask, i.e., it might contain multiple mask entries. Therefore, the mask associated with the “1” entry within segmentation.nii.gz
will map to “category-a”. The mapping between value and category should be consistent across files.II: Multiple segmentation files per task
Sometimes, segmentations for a single volume are stored in multiple segmentation files, but these segmentation files are not binary masks. In this case, follow the format below.
Common mistakes for I and II.
- The values 1 and 2 must be present in either
segmentation-1.nii.gz
orsegmentation-2.nii.gz.
- All values in
segmentation.nii.gz
that are not insegmentMap
will not be mapped to any taxonomy category in the editor.
III: Multiple binary segmentation files per task
A common pattern is to store each segmentation instance in a separate NIfTI file as a binary mask. In the example below, all non-zero values in segmentation-1.nii.gz
are meant to correspond to the taxonomy category category-a
.
Investigating segmentation files
The following code blocks are intended to be copy/paste solutions in Python for users wishing to verify a certain aspect of their segmentation files before upload.
We also recommend using the RedBrick Preview Tool to investigate files that are available on your local machine or in your bucket.
If you are still encountering issues, please reach out to us at support@redbrickai.com.
Verifying the number of entries in a segmentation file
Verifying the file type of a segmentation file
Was this page helpful?