11using System . Collections . Generic ;
22using UnityEngine ;
3+ using UnityEngine . Rendering ;
34
45namespace UnityVolumeRendering
56{
67 public class SegmentationBuilder
78 {
9+ public enum SegmentationClassType
10+ {
11+ TotalSegmentator ,
12+ TotalSegmentatorMR
13+ }
14+
815 private static Dictionary < string , Color > segmentationColours = new Dictionary < string , Color >
916 {
1017 { "liver" , new Color ( 0.42f , 0.18f , 0.12f ) } ,
@@ -30,12 +37,21 @@ public class SegmentationBuilder
3037 "rib_right_12" , "sternum" , "costal_cartilages"
3138 } ;
3239
33- public static List < SegmentationLabel > BuildSegmentations ( VolumeDataset dataset )
40+ private static List < string > totalSegmentatorMRLabels = new List < string >
41+ { "spleen" , "kidney_right" , "kidney_left" , "gallbladder" , "liver" , "stomach" , "pancreas" , "adrenal_gland_right" , "adrenal_gland_left" , "lung_left" , "lung_right" , "esophagus" ,
42+ "small_bowel" , "duodenum" , "colon" , "urinary_bladder" , "prostate" , "sacrum" , "vertebrae" , "intervertebral_discs" , "spinal_cord" , "heart" , "aorta" , "inferior_vena_cava" ,
43+ "portal_vein_and_splenic_vein" , "iliac_artery_left" , "iliac_artery_right" , "iliac_vena_left" , "iliac_vena_right" , "humerus_left" , "humerus_right" , "scapula_left" ,
44+ "scapula_right" , "clavicula_left" , "clavicula_right" , "femur_left" , "femur_right" , "hip_left" , "hip_right" , "gluteus_maximus_left" , "gluteus_maximus_right" , "gluteus_medius_left" ,
45+ "gluteus_medius_right" , "gluteus_minimus_left" , "gluteus_minimus_right" , "autochthon_left" , "autochthon_right" , "iliopsoas_left" , "iliopsoas_right" , "brain"
46+ } ;
47+
48+ public static List < SegmentationLabel > BuildSegmentations ( VolumeDataset dataset , SegmentationClassType classType = SegmentationClassType . TotalSegmentator )
3449 {
3550 List < SegmentationLabel > result = new List < SegmentationLabel > ( ) ;
3651 int minSegmentationId = int . MaxValue ;
3752 int maxSegmentationId = int . MinValue ;
3853 HashSet < int > usedSegmentationIds = new HashSet < int > ( ) ;
54+ List < string > labelList = classType == SegmentationClassType . TotalSegmentatorMR ? totalSegmentatorMRLabels : totalSegmentatorLabels ;
3955
4056 for ( int i = 0 ; i < dataset . data . Length ; i ++ )
4157 {
@@ -58,9 +74,9 @@ public static List<SegmentationLabel> BuildSegmentations(VolumeDataset dataset)
5874 segmentationLabel . id = segmentationId ;
5975 segmentationLabel . name = dataset . datasetName ;
6076 segmentationLabel . colour = Random . ColorHSV ( ) ;
61- if ( multiLabel && segmentationId < totalSegmentatorLabels . Count + 1 )
77+ if ( multiLabel && segmentationId < labelList . Count + 1 )
6278 {
63- string labelName = totalSegmentatorLabels [ segmentationId - 1 ] ;
79+ string labelName = labelList [ segmentationId - 1 ] ;
6480 if ( segmentationColours . ContainsKey ( labelName ) )
6581 {
6682 segmentationLabel . colour = segmentationColours [ labelName ] ;
0 commit comments