Import annotations from NIfTI files
A CLI how-to guide. SDK power-users can refer to our full SDK docs generated from our source code here
Ensure your images and videos have been successfully uploaded and processed
Before you import annotations, make sure your target images and videos are marked as
New
, or have been previously annotated already.
Once you've added volumetric data to a dataset in V7, you can use CLI commands to import existing annotations from NIfTI files.
You'll need to create a .json
file which contains the paths to the image files (these need to match the filenames in the target dataset exactly), the paths to the label files (these are .nii or .nii.gz files with integer values representing classes), a class mapping (a dictionary mapping integer values to class names you want to appear on V7), a mode (this is a string with video
, instances
or mask
)
Here is an example of what such a upload.json
file should look like
{
"data": [
{
"image": "FLAIR.nii",
"label": "labels/BRATS_001.nii.gz",
"class_map": {
"0": "background",
"1": "oedema",
"2": "non-enhancing tumour",
"3": "enhancing tumour",
},
"mode": "video"
}
]
}
The image path needs to match the filename used in the Dataset exactly, and the label path is a relative path from where you are running the darwin dataset import
command.
Multiple NIfTI uploads at once
You can add NIfTI labels for multiple files in a dataset with a single call to
darwin dataset import
, just add more entries in thedata
list with more paths and class maps.
If you set mode to video
then each class will be a single video annotation. This makes sense for contiguous 3D objects like a whole organ or a single tumour. If however you are dealing with a single class that is spread in separate instances (e.g white matter lesions in the brain) then you might prefer to set mode: instances
to have a separate video annotation for each lesion. The last option mask
will write to the raster layer and create mask classes. For more information on masks please visit - https://docs.v7labs.com/docs/introducing-masks.
You can now run the only CLI command needed for upload
darwin dataset import your-team/your-dataset nifti upload.json
If the class names supplied do not match ones created in your team the CLI will ask you whether you would like to create those classes.
That's it! you should now be able to see your 3D annotations on the platform.
Updated 4 months ago