Overview of RedBrick AI CLI Export
The CLI will only fetch the newly created annotations in your project and update your cloned project folder.
For e.g. if you upload 10,000 images in your project, and annotate 8,000 images then export using the CLI, the CLI will export 8,000 tasks. A day later if you annotate another 5, the CLI will update the exported data with the 5 new tasks.
To export your data, you need to first go to your project directory
To export the latest state of all your tasks (even the ones queued in labeling and review stages) run the following command.
If you want to fetch only the tasks in the ground truth stage, you need to run the following command.
redbrick export groundtruth
To clear the local redbrick cache and force download all the annotations again, run the following command.
redbrick export --clear-cache
redbrick export --format nifti
Doing so will export labels in
niftidirectory inside the project directory.
Please view the format reference for a detailed description of the export format:
To export your annotations along with the raw data files, run the following command.
redbrick export --with-files
Doing so will export tasks in
dicomdirectory (based on project type) inside the project directory.
If you want to convert NIfTI segmentations performed on 2D data to 2D binary masks represented as numpy arrays, you can do the following:
import numpy as np
import matplotlib.pyplot as plt
# Load nifti file, and convert to numpy array
mask_nifti = nibabel.load("path/to/nifti.nii")
mask_arr = np.array(mask_nifti.dataobj)
# In NIfTI, ijk are columns, rows, slice.
# To change your mask array to rows, columns, slice perform transpose
mask_arr = np.transpose(mask_arr, (1,0,2))
# Display your mask