Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkDICOMSegmentationPropertyHelper.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
16 #include <mitkPropertyNameHelper.h>
18 #include <mitkPropertyList.h>
19 
21 
22 #include <vtkSmartPointer.h>
23 
24 #include <vtkSmartPointer.h>
25 
26 namespace mitk
27 {
29  {
30  PropertyList::Pointer propertyList = dicomSegImage->GetPropertyList();
31 
32  // Add DICOM Tag (0008, 0060) Modality "SEG"
33  propertyList->SetProperty(GeneratePropertyNameForDICOMTag(0x0008, 0x0060).c_str(),
35  // Add DICOM Tag (0008,103E) Series Description
36  propertyList->SetProperty(GeneratePropertyNameForDICOMTag(0x0008, 0x103E).c_str(),
37  TemporoSpatialStringProperty::New("MITK Segmentation"));
38  // Add DICOM Tag (0070,0084) Content Creator Name
39  propertyList->SetProperty(GeneratePropertyNameForDICOMTag(0x0070, 0x0084).c_str(),
41  // Add DICOM Tag (0012, 0071) Clinical Trial Series ID
42  propertyList->SetProperty(GeneratePropertyNameForDICOMTag(0x0012, 0x0071).c_str(),
44  // Add DICOM Tag (0012,0050) Clinical Trial Time Point ID
45  propertyList->SetProperty(GeneratePropertyNameForDICOMTag(0x0012, 0x0050).c_str(),
47  // Add DICOM Tag (0012, 0060) Clinical Trial Coordinating Center Name
48  propertyList->SetProperty(GeneratePropertyNameForDICOMTag(0x0012, 0x0060).c_str(),
50 
51  // Set DICOM properties for each label
52  // Iterate over all layers
53  for (unsigned int layer = 0; layer < dicomSegImage->GetNumberOfLayers(); ++layer)
54  {
55  // Iterate over all labels
56  const LabelSet *labelSet = dicomSegImage->GetLabelSet(layer);
57  auto labelIter = labelSet->IteratorConstBegin();
58  // Ignore background label
59  ++labelIter;
60 
61  for (; labelIter != labelSet->IteratorConstEnd(); ++labelIter)
62  {
63  Label::Pointer label = labelIter->second;
65  }
66  }
67  }
68 
70  {
72 
75  auto presets = vtkSmartPointer<AnatomicalStructureColorPresets>::New();
76  presets->LoadPreset();
77 
78  for (const auto &preset : presets->GetCategoryPresets())
79  {
80  auto presetOrganName = preset.first;
81  if (label->GetName().compare(presetOrganName) == 0)
82  {
83  category = preset.second;
84  break;
85  }
86  }
87 
88  for (const auto &preset : presets->GetTypePresets())
89  {
90  auto presetOrganName = preset.first;
91  if (label->GetName().compare(presetOrganName) == 0)
92  {
93  type = preset.second;
94  break;
95  }
96  }
97 
98  //------------------------------------------------------------
99  // Add Segment Sequence tags (0062, 0002)
100  // Segment Number:Identification number of the segment.The value of Segment Number(0062, 0004) shall be unique
101  // within the Segmentation instance in which it is created
103  TemporoSpatialStringProperty::New(std::to_string(label->GetValue())));
104 
105  // Segment Label: User-defined label identifying this segment.
108 
109  // Segment Algorithm Type: Type of algorithm used to generate the segment. AUTOMATIC SEMIAUTOMATIC MANUAL
111  TemporoSpatialStringProperty::New("SEMIAUTOMATIC"));
112  //------------------------------------------------------------
113  // Add Segmented Property Category Code Sequence tags (0062, 0003): Sequence defining the general category of this
114  // segment.
115  // (0008,0100) Code Value
116  if (!category.codeValue.empty())
117  label->SetProperty(
120 
121  // (0008,0102) Coding Scheme Designator
122  if (!category.codeScheme.empty())
123  label->SetProperty(
126 
127  // (0008,0104) Code Meaning
128  if (!category.codeName.empty())
129  label->SetProperty(
132  //------------------------------------------------------------
133  // Add Segmented Property Type Code Sequence (0062, 000F): Sequence defining the specific property type of this
134  // segment.
135  // (0008,0100) Code Value
136  if (!type.codeValue.empty())
137  label->SetProperty(
140 
141  // (0008,0102) Coding Scheme Designator
142  if (!type.codeScheme.empty())
143  label->SetProperty(
146 
147  // (0008,0104) Code Meaning
148  if (!type.codeName.empty())
149  label->SetProperty(
152  //------------------------------------------------------------
153  // Add Segmented Property Type Modifier Code Sequence (0062,0011): Sequence defining the modifier of the property
154  // type of this segment.
155  // (0008,0100) Code Value
156  if (!type.modifier.codeValue.empty())
157  label->SetProperty(
160 
161  // (0008,0102) Coding Scheme Designator
162  if (!type.modifier.codeScheme.empty())
163  label->SetProperty(
166 
167  // (0008,0104) Code Meaning
168  if (!type.modifier.codeName.empty())
169  label->SetProperty(
172  }
173 }
LabelContainerConstIteratorType IteratorConstBegin() const
Returns a const iterator poiting to the begining of the container.
static Pointer New()
void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Add new or change existent property.
Definition: mitkLabel.cpp:83
LabelContainerConstIteratorType IteratorConstEnd() const
Returns a const iterator pointing to the end of the container.
std::string MITKCORE_EXPORT GeneratePropertyNameForDICOMTag(unsigned int group, unsigned int element)
DataCollection - Class to facilitate loading/accessing structured data.
A data structure describing a label.
Definition: mitkLabel.h:31
MITKDICOMREADER_EXPORT std::string DICOMTagPathToPropertyName(const DICOMTagPath &tagPath)
unsigned int GetNumberOfLayers() const
PixelType GetValue() const
Definition: mitkLabel.cpp:169
mitk::PropertyList::Pointer GetPropertyList() const
Get the data&#39;s property list.
LabelSetImage class for handling labels and layers in a segmentation session.
static void DeriveDICOMSegmentationProperties(LabelSetImage *dicomSegImage)
mitk::LabelSet * GetLabelSet(unsigned int layer=0)
Gets the mitk::LabelSet for the given layer.
std::string GetName() const
Definition: mitkLabel.cpp:151