Skip to content

supervisely-ecosystem/import-volumes-with-masks

Repository files navigation

Import Volumes with 3D Masks

OverviewWhat's NewHow to RunInput Data StructureDemo

GitHub release (latest SemVer) views runs

Overview

Import volumes in NRRD format with masks in NRRD format with semantic segmentation labels.

What's New

🏷️ Version 1.0.6

  • To maintain backwards compatibility with Export Volumes with 3D Annotations application, any Mask3D annotations that were in the project originally will be skipped during the import process. This enhancement is related to the new format for storing Mask3D objects geometry as .nrrd files in the mask directory. To learn more read this article.
  • If you want to import these originally created and exported using Export Volumes with 3D Annotations along with semantic segmentation, please delete the ann folder (if present) from the dataset folder of exported project.

🔥 Version 1.0.2

  • Object masks import as 3D shape figures, providing convenient editing options across all planes. With this feature, you can easily manipulate object masks in various dimensions, making the editing process more intuitive and efficient.
  • Seamless Compatibility with Export Volumes with 3D Annotations. This means that projects exported with Export App can now be directly loaded into this app without any modifications to the project folder structure. This streamlines your workflow, saving you valuable time and effort when transitioning between the two applications. But be careful with the class2idx.json, because this application uses its logic to work with classes, which is described in Input Data Structure

How to Run

The App can be launched from the Ecosystem, Team Files, or Agent.

Run from team files
  1. Run the application from the context menu of the folder (right mouse button) on the Team Files page

  2. Fill in the project name in the Result Project Name field or leave the default value.

  3. If you want to leave your folder in Team Files after successful import, uncheck the box Remove temporary files after successful import below.

  4. Also, you can set Advanced settings such as agent, app version, and others.

  5. Click the Run button to start the App.

Run from ecosystem
  1. Click the Run application button on the right side of the App page. A modal window will be opened.

    app
  2. If you want to upload a project folder from your computer, choose Drag & Drop option. You can upload the project folder to the drag-and-drop field or you can click on the drag-and-drop field and choose the project from your computer in the opened window.

  3. If you want to use a project from Team Files, choose the Team Files option and choose a folder to use in the app.

  4. Fill in the project name in the Result Project Name field or leave the default value.

  5. If you want to leave your folder in Team Files after successful import, uncheck the box Remove temporary files after successful import below.

  6. Also, you can set Advanced settings such as agent, app version, and others.

  7. Click the Run button to start the App.

Run from agent

The application supports import from a special directory on your local computer. It is made for Enterprise Edition customers who need to upload tens or even hundreds of gigabytes of data without using the drag-and-drop mechanism:

  1. Run an agent on your computer where data is stored. Watch the how-to video.
  2. Copy your data to the special folder on your computer that was created by the agent. Agent mounts this directory to your Supervisely instance, and it becomes accessible in Team Files. Learn more in the documentation. Watch the how-to video.
  3. Go to Team FilesSupervisely Agent and find your folder there.
  4. Right-click to open the context menu and start the App. Now the App will upload data directly from your computer to the platform.

Input Data Structure

The Project name will not be taken from the root folder name. You should specify the project name in the modal window when you run the App.

Project directory example:

📂my_volumes_project
├──📜class2idx.json (optional)
├──📂dataset_01
│   ├──📂volume
│   │   ├──📜volume_1.nrrd
│   │   ├──📜volume_2.nrrd
│   │   └──📜...
│   └──📂mask
│       ├──📂volume_1.nrrd
│       │   ├──📜mask_1.nrrd
│       │   ├──📜mask_2.nrrd
│       │   └──📜...
│       ├──📂volume_2.nrrd
│       │   ├──📜mask_1.nrrd
│       │   └──📜...
│       └── ...    
├──📂dataset_02
│   ├──📂volume
│   │   ├──📜volume_1.nrrd
│   │   └──📜...
│   └──📂mask
│       ├──📂volume_1.nrrd
│       │   ├──📜mask_1.nrrd
│       │   └──📜...
│       └──📂...    
└──📂...

class2idx.json is an optional JSON file containing dictionary { "class_name" (str) : index (int) } where indexes are values from .nrrd masks. Don't specify 0 as index in masks (reserved value for not labeled fields). If you don't provide class2idx.json, class names will be created automatically (class_1, class_2, ...).

💡 Important information

  • If the mask in .nrrd has more than one value greater than 0 - it will be identified as a semantic segmentation
  • If the mask in .nrrd has only one value greater than 0 - it will be identified as a single object mask

class2idx.json example:

{
    "brain": 1,
    "lung": 2
}
ℹ️ Click here to see class2idx.json structure in the app versions 1.0.2 - 1.0.5

class2idx.json is an optional JSON file containing dictionary { "class_name" (str): index (int) } where indexes start from 1 and increment accordingly the number of masks. If the number of classes is less than the number of masks, classes with the names like class_2 will be created automatically for every mask. If you don't provide this file, class names will be created automatically (class_1, class_2, ...).

💡Сlasses in JSON must be written in the same order as the masks are sorted by name inside the directory.

⚠️The class indexes are not tied to the order of the files, they are only used for numbering. You can skip any number. Do not use the same one twice.

class2idx.json example:

{

    "dataset_01_volume_1_mask_1": 1,
    "dataset_01_volume_1_mask_2": 2,
    "dataset_01_volume_2_mask_1": 3,
    "dataset_02_volume_1_mask_1": 4
}

Demo Project [72.9 MB] Download


Demo

Demo Project [72.4 MB] Download

The demo project contains 1 dataset dataset_01 with 2 volumes:

  • CTACardio volume has 2 masks .nrrd files where each contains 1 object - lung_1 and lung_2, respectively
  • MRHead volume has 1 mask .nrrd file with a brain object
  • Every volume has a semantic_segmentation file with all its masks
  • Every mask folder contains a human-readable-objects folder which is not included in the import process, this folder simply stores duplicates of single masks with human-readable names. This folder is created when you export the project through the Export Volumes with 3D Annotations

If you upload either only semantic_segmentation or only single masks, after uploading the project should look like this:

  1. Volume with lung_1 and lung_2 objects.

  2. Volume with brain object.