Medical Imaging Interaction Toolkit  2018.4.99-f51274ea
Medical Imaging Interaction Toolkit
mitkSemanticRelationsTestHelper.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 
14 
15 // mitk semantic relations
16 #include "mitkDICOMHelper.h"
17 #include "mitkRelationStorage.h"
18 #include "mitkUIDGeneratorBoost.h"
19 
20 // mitk core
21 #include <mitkImage.h>
24 
25 // mitk multilabel
26 #include <mitkLabelSetImage.h>
27 
29 {
30  // create new empty image
31  Image::Pointer image = Image::New();
32 
33  // set properties of image (base data)
34  image->SetProperty(GetCaseIDDICOMProperty().c_str(),
35  StringProperty::New("Patient1"));
36  image->SetProperty(GetNodeIDDICOMProperty().c_str(),
37  StringProperty::New(UIDGeneratorBoost::GenerateUID()));
38  image->SetProperty(GetDateDICOMProperty().c_str(),
39  StringProperty::New("20190101"));
40  image->SetProperty(GetModalityDICOMProperty().c_str(),
41  StringProperty::New("CT"));
42 
43  // create new data node and add image as base data
44  DataNode::Pointer dataNode = DataNode::New();
45  dataNode->SetData(image);
46 
47  return dataNode;
48 }
49 
51 {
52  // create new empty image
53  Image::Pointer image = Image::New();
54 
55  // set properties of image (base data)
56  image->SetProperty(GetCaseIDDICOMProperty().c_str(),
57  StringProperty::New("Patient1"));
58  image->SetProperty(GetNodeIDDICOMProperty().c_str(),
59  StringProperty::New(UIDGeneratorBoost::GenerateUID()));
60  image->SetProperty(GetDateDICOMProperty().c_str(),
61  StringProperty::New("20190101"));
62  image->SetProperty(GetModalityDICOMProperty().c_str(),
63  StringProperty::New("MR"));
64 
65  // create new data node and add image as base data
66  DataNode::Pointer dataNode = DataNode::New();
67  dataNode->SetData(image);
68 
69  return dataNode;
70 }
71 
73 {
74  // create new empty image
75  Image::Pointer image = Image::New();
76 
77  // set properties of image (base data)
78  image->SetProperty(GetCaseIDDICOMProperty().c_str(),
79  StringProperty::New("Patient1"));
80  image->SetProperty(GetNodeIDDICOMProperty().c_str(),
81  StringProperty::New(UIDGeneratorBoost::GenerateUID()));
82  image->SetProperty(GetDateDICOMProperty().c_str(),
83  StringProperty::New("20190131"));
84  image->SetProperty(GetModalityDICOMProperty().c_str(),
85  StringProperty::New("CT"));
86 
87  // create new data node and add image as base data
88  DataNode::Pointer dataNode = DataNode::New();
89  dataNode->SetData(image);
90 
91  return dataNode;
92 }
93 
95 {
96  // create new empty image
97  Image::Pointer image = Image::New();
98 
99  // set properties of image (base data)
100  image->SetProperty(GetCaseIDDICOMProperty().c_str(),
101  StringProperty::New("Patient2"));
102  image->SetProperty(GetNodeIDDICOMProperty().c_str(),
103  StringProperty::New(UIDGeneratorBoost::GenerateUID()));
104  image->SetProperty(GetDateDICOMProperty().c_str(),
105  StringProperty::New("20180101"));
106  image->SetProperty(GetModalityDICOMProperty().c_str(),
107  StringProperty::New("PT"));
108 
109  // create new data node and add image as base data
110  DataNode::Pointer dataNode = DataNode::New();
111  dataNode->SetData(image);
112 
113  return dataNode;
114 }
115 
117 {
118  // create new empty segmentation
119  LabelSetImage::Pointer segmentation = LabelSetImage::New();
120 
121  // set properties of segmentation (base data)
122  segmentation->SetProperty(GetCaseIDDICOMProperty().c_str(),
123  TemporoSpatialStringProperty::New("Patient2"));
124  segmentation->SetProperty(GetNodeIDDICOMProperty().c_str(),
125  TemporoSpatialStringProperty::New(UIDGeneratorBoost::GenerateUID()));
126  segmentation->SetProperty(GetDateDICOMProperty().c_str(),
127  TemporoSpatialStringProperty::New("20180101"));
128  // segmentation modality is 'SEG'
129 
130  // create new data node and add segmentation as base data
131  DataNode::Pointer dataNode = DataNode::New();
132  dataNode->SetData(segmentation);
133 
134  return dataNode;
135 }
136 
138 {
139  // create new empty image
140  Image::Pointer image = Image::New();
141 
142  // set properties of image (base data)
143  image->SetProperty(GetCaseIDDICOMProperty().c_str(),
144  StringProperty::New("Patient3"));
145  image->SetProperty(GetNodeIDDICOMProperty().c_str(),
146  StringProperty::New(UIDGeneratorBoost::GenerateUID()));
147  image->SetProperty(GetDateDICOMProperty().c_str(),
148  StringProperty::New("20190201"));
149  image->SetProperty(GetModalityDICOMProperty().c_str(),
150  StringProperty::New("CT"));
151 
152  // create new data node and add image as base data
153  DataNode::Pointer dataNode = DataNode::New();
154  dataNode->SetData(image);
155 
156  return dataNode;
157 }
158 
160 {
161  // create new empty segmentation
162  LabelSetImage::Pointer segmentation = LabelSetImage::New();
163 
164  // set properties of segmentation (base data)
165  segmentation->SetProperty(GetCaseIDDICOMProperty().c_str(),
166  TemporoSpatialStringProperty::New("Patient3"));
167  segmentation->SetProperty(GetNodeIDDICOMProperty().c_str(),
168  TemporoSpatialStringProperty::New(UIDGeneratorBoost::GenerateUID()));
169  segmentation->SetProperty(GetDateDICOMProperty().c_str(),
170  TemporoSpatialStringProperty::New("20190201"));
171  // segmentation modality is 'SEG'
172 
173  // create new data node and add segmentation as base data
174  DataNode::Pointer dataNode = DataNode::New();
175  dataNode->SetData(segmentation);
176 
177  return dataNode;
178 }
179 
181 {
182  // create new empty image
183  Image::Pointer image = Image::New();
184 
185  // set properties of image (base data)
186  image->SetProperty(GetCaseIDDICOMProperty().c_str(),
187  StringProperty::New("Patient3"));
188  image->SetProperty(GetNodeIDDICOMProperty().c_str(),
189  StringProperty::New(UIDGeneratorBoost::GenerateUID()));
190  image->SetProperty(GetDateDICOMProperty().c_str(),
191  StringProperty::New("20190215"));
192  image->SetProperty(GetModalityDICOMProperty().c_str(),
193  StringProperty::New("MR"));
194 
195  // create new data node and add image as base data
196  DataNode::Pointer dataNode = DataNode::New();
197  dataNode->SetData(image);
198 
199  return dataNode;
200 }
201 
203 {
204  // create new empty segmentation
205  LabelSetImage::Pointer segmentation = LabelSetImage::New();
206 
207  // set properties of segmentation (base data)
208  segmentation->SetProperty(GetCaseIDDICOMProperty().c_str(),
209  TemporoSpatialStringProperty::New("Patient3"));
210  segmentation->SetProperty(GetNodeIDDICOMProperty().c_str(),
211  TemporoSpatialStringProperty::New(UIDGeneratorBoost::GenerateUID()));
212  segmentation->SetProperty(GetDateDICOMProperty().c_str(),
213  TemporoSpatialStringProperty::New("20190215"));
214  // segmentation modality is 'SEG'
215 
216  // create new data node and add segmentation as base data
217  DataNode::Pointer dataNode = DataNode::New();
218  dataNode->SetData(segmentation);
219 
220  return dataNode;
221 }
222 
224 {
225  // create new empty image
226  Image::Pointer image = Image::New();
227 
228  // set properties of image (base data)
229  image->SetProperty(GetCaseIDDICOMProperty().c_str(),
230  StringProperty::New("Patient4"));
231  image->SetProperty(GetNodeIDDICOMProperty().c_str(),
232  StringProperty::New(UIDGeneratorBoost::GenerateUID()));
233 
234  // no DICOM information for Date
235 
236  image->SetProperty(GetModalityDICOMProperty().c_str(),
237  StringProperty::New("CT"));
238 
239  // create new data node and add image as base data
240  DataNode::Pointer dataNode = DataNode::New();
241  dataNode->SetData(image);
242 
243  return dataNode;
244 }
245 
247 {
248  // create new empty image
249  Image::Pointer image = Image::New();
250 
251  // set properties of image (base data)
252  image->SetProperty(GetCaseIDDICOMProperty().c_str(),
253  StringProperty::New("Patient5"));
254  image->SetProperty(GetNodeIDDICOMProperty().c_str(),
255  StringProperty::New(UIDGeneratorBoost::GenerateUID()));
256  image->SetProperty(GetDateDICOMProperty().c_str(),
257  StringProperty::New("20180101"));
258 
259  // no DICOM information for Modality
260 
261  // create new data node and add image as base data
262  DataNode::Pointer dataNode = DataNode::New();
263  dataNode->SetData(image);
264 
265  return dataNode;
266 }
267 
269 {
270  // create new empty image
271  Image::Pointer image = Image::New();
272 
273  // set properties of image (base data)
274  image->SetProperty(GetCaseIDDICOMProperty().c_str(),
275  StringProperty::New("Patient6"));
276 
277  // no DICOM information for NodeID
278 
279  image->SetProperty(GetDateDICOMProperty().c_str(),
280  StringProperty::New("20180101"));
281  image->SetProperty(GetModalityDICOMProperty().c_str(),
282  StringProperty::New("CT"));
283 
284  // create new data node and add image as base data
285  DataNode::Pointer dataNode = DataNode::New();
286  dataNode->SetData(image);
287 
288  return dataNode;
289 }
290 
292 {
293  // create new empty image
294  Image::Pointer image = Image::New();
295 
296  // set properties of image (base data)
297  // no DICOM information for CaseID
298 
299  image->SetProperty(GetNodeIDDICOMProperty().c_str(),
300  StringProperty::New(UIDGeneratorBoost::GenerateUID()));
301  image->SetProperty(GetDateDICOMProperty().c_str(),
302  StringProperty::New("20180101"));
303  image->SetProperty(GetModalityDICOMProperty().c_str(),
304  StringProperty::New("CT"));
305 
306  // create new data node and add image as base data
307  DataNode::Pointer dataNode = DataNode::New();
308  dataNode->SetData(image);
309 
310  return dataNode;
311 }
312 
314 {
315  // access the storage
317  if (nullptr == persistenceService)
318  {
319  MITK_DEBUG << "Persistence service could not be loaded";
320  return;
321  }
322 
323  auto allCaseIDs = mitk::RelationStorage::GetAllCaseIDs();
324  for (auto& caseID : allCaseIDs)
325  {
326  persistenceService->RemovePropertyList(caseID);
327  }
328 
329  std::string listIdentifier("caseIDs");
330  persistenceService->RemovePropertyList(listIdentifier);
331 }
DataNode::Pointer GetInvalidCaseID()
CaseID is 0x0010, 0x0010 (PatientName)
#define MITK_DEBUG
Definition: mitkLogMacros.h:22
DataNode::Pointer GetInvalidModality()
Modality is 0x0008, 0x0060(Modality)
MITKSEMANTICRELATIONS_EXPORT std::string GetCaseIDDICOMProperty()
Creates a property name for a DICOM tag. The tag is "0x0010, 0x0010" (PatientName) ...
DataNode::Pointer GetInvalidID()
ID is 0x0020, 0x000e (SeriesInstanceUID)
MITKSEMANTICRELATIONS_EXPORT std::string GetNodeIDDICOMProperty()
Creates a property name for a DICOM tag. The tag is "0x0020, 0x000e" (SeriesInstanceUID) ...
DataNode::Pointer GetInvalidDate()
Date is 0x0008, 0x0022 (AcquisitionDate)
mitk::Image::Pointer image
#define PERSISTENCE_GET_SERVICE_MACRO
MITKSEMANTICRELATIONS_EXPORT std::vector< SemanticTypes::CaseID > GetAllCaseIDs()
MITKSEMANTICRELATIONS_EXPORT std::string GetModalityDICOMProperty()
Creates a property name for a DICOM tag. The tag is "0x0008, 0x0060" (Modality)
MITKSEMANTICRELATIONS_EXPORT std::string GetDateDICOMProperty()
Creates a property name for a DICOM tag. The tag is "0x0008, 0x0022" (AcquisitionDate) ...
MITKSEMANTICRELATIONS_EXPORT std::string GenerateUID()