Import annotations from NIfTI files

🚧

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 containing:

  • The paths to the local NifTI volume annotations
  • The paths to the remote dataset files to import the annotations to
  • A class mapping that maps integer values to Darwin class names
  • A mode to import annotations as either:
    • video - Each class will result in a single continuous polygon annotation. This makes sense for contiguous 3D objects like a whole organ or a single tumor
    • instances - Each class instance will result in a single polygon annotation. This makes sense for scenarios where the same class may appear many times
    • mask - Each class will result in a mask annotation written to the raster layer. For more information on masks please see our article on masks

Here is an example of what such a .json file should look like:

{
    "data": [
        {
            "image": "/remote/path/to/dataset/item/volume.nii",
            "label": "/local/path/to/nifti/annotations/annotations.nii.gz",
            "slot_names": "name_of_target_slot",
            "class_map": {
                "0": "background",
                "1": "oedema",
                "2": "non-enhancing tumor",
                "3": "enhancing tumor",
            },
            "mode": "video"
        }
    ]
}

It's important to note:

  • The image path needs to match the remote filepath used in the Darwin dataset exactly
  • The label path is a local relative path from where you are running the darwin dataset import command
  • slot_names determines the slot that the NifTI annotation will be imported to. If not provided, the annotations will be uploaded to the first medical slot in the dataset item
  • The background class is not imported as annotations

📘

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 the data list with more paths and class maps.

You can now run the only CLI command needed to upload

darwin dataset import your-team/your-dataset nifti upload.json

If the class names provided do not match those created in your team, the CLI will prompt you to create the missing classes.

That’s it! You should now be able to view your 3D annotations on the platform.