1
1
using System . Collections . Generic ;
2
2
using UnityEngine ;
3
+ using UnityEngine . Rendering ;
3
4
4
5
namespace UnityVolumeRendering
5
6
{
6
7
public class SegmentationBuilder
7
8
{
9
+ public enum SegmentationClassType
10
+ {
11
+ TotalSegmentator ,
12
+ TotalSegmentatorMR
13
+ }
14
+
8
15
private static Dictionary < string , Color > segmentationColours = new Dictionary < string , Color >
9
16
{
10
17
{ "liver" , new Color ( 0.42f , 0.18f , 0.12f ) } ,
@@ -30,12 +37,21 @@ public class SegmentationBuilder
30
37
"rib_right_12" , "sternum" , "costal_cartilages"
31
38
} ;
32
39
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 )
34
49
{
35
50
List < SegmentationLabel > result = new List < SegmentationLabel > ( ) ;
36
51
int minSegmentationId = int . MaxValue ;
37
52
int maxSegmentationId = int . MinValue ;
38
53
HashSet < int > usedSegmentationIds = new HashSet < int > ( ) ;
54
+ List < string > labelList = classType == SegmentationClassType . TotalSegmentatorMR ? totalSegmentatorMRLabels : totalSegmentatorLabels ;
39
55
40
56
for ( int i = 0 ; i < dataset . data . Length ; i ++ )
41
57
{
@@ -58,9 +74,9 @@ public static List<SegmentationLabel> BuildSegmentations(VolumeDataset dataset)
58
74
segmentationLabel . id = segmentationId ;
59
75
segmentationLabel . name = dataset . datasetName ;
60
76
segmentationLabel . colour = Random . ColorHSV ( ) ;
61
- if ( multiLabel && segmentationId < totalSegmentatorLabels . Count + 1 )
77
+ if ( multiLabel && segmentationId < labelList . Count + 1 )
62
78
{
63
- string labelName = totalSegmentatorLabels [ segmentationId - 1 ] ;
79
+ string labelName = labelList [ segmentationId - 1 ] ;
64
80
if ( segmentationColours . ContainsKey ( labelName ) )
65
81
{
66
82
segmentationLabel . colour = segmentationColours [ labelName ] ;
0 commit comments