Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkSemanticRelationsTest.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 
13 // mitk semantic relations
18 #include "mitkRelationStorage.h"
20 #include "mitkDICOMHelper.h"
21 #include "mitkLesionManager.h"
23 #include "mitkUIDGeneratorBoost.h"
24 
25 // mitk core
27 #include <mitkTestFixture.h>
28 #include <mitkTestingMacros.h>
29 #include <mitkPropertyNameHelper.h>
30 
31 // mitk persistence
32 #include <mitkPersistenceService.h>
33 
34 class mitkSemanticRelationsTestSuite : public mitk::TestFixture
35 {
36  CPPUNIT_TEST_SUITE(mitkSemanticRelationsTestSuite);
37  MITK_TEST(IntegrationTest);
38  MITK_TEST(InferenceTest);
39  MITK_TEST(DataStorageAccessTest);
40  MITK_TEST(RemoveAndUnlinkTest);
41  CPPUNIT_TEST_SUITE_END();
42 
43 private:
44 
46 
47 public:
48 
49  void setUp() override
50  {
52  m_DataStorage = mitk::StandaloneDataStorage::New();
53  }
54 
55  void tearDown() override
56  {
57  // clear semantic relations storage
59  }
60 
62  // SPECIFIC TEST GROUPS
64  void IntegrationTest()
65  {
66  MITK_INFO << "=== IntegrationTest start ===";
67  AddNewData();
68  ExaminationPeriod();
69  SegmentationAndLesion();
70  InvalidData();
71  MITK_INFO << "=== IntegrationTest end ===";
72  }
73 
74  void InferenceTest()
75  {
76  MITK_INFO << "=== InferenceTest start ===";
77  CombinedQueries();
78  InstanceExistences();
79  MITK_INFO << "=== InferenceTest end ===";
80  }
81 
82  void DataStorageAccessTest()
83  {
84  MITK_INFO << "=== DataStorageAccessTest start ===";
85  DataStorageAccess();
86  MITK_INFO << "=== DataStorageAccessTest end ===";
87  }
88 
89  void RemoveAndUnlinkTest()
90  {
91  MITK_INFO << "=== RemoveAndUnlinkTest start ===";
92  CPRemoveAndUnlink();
93  LesionRemoveAndUnlink();
94  RemoveImagesAndSegmentation();
95  MITK_INFO << "=== RemoveAndUnlinkTest end ===";
96  }
97 
99  // SPECIFIC TESTS
101  // IntegrationTest
102  void AddNewData()
103  {
104  MITK_INFO << "=== AddNewData";
105 
106  // load data
107  mitk::SemanticRelationsIntegration semanticRelationsIntegration;
108 
110  m_DataStorage->Add(image);
111  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", image.IsNotNull());
112  CPPUNIT_ASSERT_MESSAGE("Image data is empty", image->GetData() != nullptr);
113  semanticRelationsIntegration.AddImage(image);
114 
115  // start test
116  auto allCaseIDs = mitk::RelationStorage::GetAllCaseIDs();
117  CPPUNIT_ASSERT_MESSAGE("CaseID not correctly stored", allCaseIDs.front() == "Patient1");
118  auto caseID = allCaseIDs.front();
119 
120  // test control point
121  auto allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
122  CPPUNIT_ASSERT_MESSAGE("One control point should be stored", allControlPoints.size() == 1);
123 
125  mitk::SemanticTypes::ControlPoint controlPointToCompare;
126  controlPointToCompare.date = boost::gregorian::date(2019, 01, 01);
127  CPPUNIT_ASSERT_MESSAGE("Control point not correctly stored", controlPointOfImage.date == controlPointToCompare.date);
128 
129  // test information type
130  auto allInformationTypes = mitk::RelationStorage::GetAllInformationTypesOfCase(caseID);
131  CPPUNIT_ASSERT_MESSAGE("One information type should be stored", allInformationTypes.size() == 1);
132 
134  CPPUNIT_ASSERT_MESSAGE("Information type not correctly stored", informationType == "CT");
135 
136  semanticRelationsIntegration.SetInformationType(image, "MR");
138  CPPUNIT_ASSERT_MESSAGE("Information type not correctly stored", informationType == "MR");
139  }
140 
141  void ExaminationPeriod()
142  {
143  MITK_INFO << "=== ExaminationPeriod";
144 
145  // load data
146  mitk::SemanticRelationsIntegration semanticRelationsIntegration;
147 
149  m_DataStorage->Add(MRImage);
150  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", MRImage.IsNotNull());
151  CPPUNIT_ASSERT_MESSAGE("Image data is empty", MRImage->GetData() != nullptr);
152  semanticRelationsIntegration.AddImage(MRImage);
153 
154  // start test
155  auto allCaseIDs = mitk::RelationStorage::GetAllCaseIDs();
156  CPPUNIT_ASSERT_MESSAGE("One CaseID should be stored", allCaseIDs.size() == 1);
157  auto caseID = allCaseIDs.front();
158 
159  auto allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
160  CPPUNIT_ASSERT_MESSAGE("One control point should be stored", allControlPoints.size() == 1);
161 
162  auto controlPointOfImage = mitk::SemanticRelationsInference::GetControlPointOfImage(MRImage);
164  controlPoint.date = boost::gregorian::date(2019, 01, 01);
165  CPPUNIT_ASSERT_MESSAGE("Control point not correctly stored", controlPointOfImage.date == controlPoint.date);
166 
167  auto examinationPeriod = mitk::RelationStorage::GetAllExaminationPeriodsOfCase(caseID);
168  CPPUNIT_ASSERT_MESSAGE("One examination period should be stored", examinationPeriod.size() == 1);
169 
170  auto allImageIDs = mitk::RelationStorage::GetAllImageIDsOfControlPoint(caseID, controlPointOfImage);
171  CPPUNIT_ASSERT_MESSAGE("Two images should reference the same control point", allImageIDs.size() == 2);
172 
173  // add additional control point to the same examination period
174  // load data
176  m_DataStorage->Add(CTImage);
177  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", CTImage.IsNotNull());
178  CPPUNIT_ASSERT_MESSAGE("Image data is empty", CTImage->GetData() != nullptr);
179  semanticRelationsIntegration.AddImage(CTImage);
180 
181  // start test
182  allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
183  CPPUNIT_ASSERT_MESSAGE("Two control points should be stored", allControlPoints.size() == 2);
184 
185  examinationPeriod = mitk::RelationStorage::GetAllExaminationPeriodsOfCase(caseID);
186  CPPUNIT_ASSERT_MESSAGE("One examination period should be stored", examinationPeriod.size() == 1);
187 
188  // modify control point to create new examination period
189  // current control point is 2019, 01, 31
190  // new control point should exceed threshold (30 days) and create new examination period
191  // new control point is 2019, 02, 01
192  controlPoint.UID = mitk::UIDGeneratorBoost::GenerateUID();
193  controlPoint.date = boost::gregorian::date(2019, 02, 01);
194  semanticRelationsIntegration.UnlinkImageFromControlPoint(CTImage);
195  semanticRelationsIntegration.SetControlPointOfImage(CTImage, controlPoint);
196 
197  allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
198  CPPUNIT_ASSERT_MESSAGE("Two control points should be stored", allControlPoints.size() == 2);
199 
200  examinationPeriod = mitk::RelationStorage::GetAllExaminationPeriodsOfCase(caseID);
201  CPPUNIT_ASSERT_MESSAGE("Two examination periods should be stored", examinationPeriod.size() == 2);
202  }
203 
204  void SegmentationAndLesion()
205  {
206  MITK_INFO << "=== SegmentationAndLesion";
207 
208  // load data
209  mitk::SemanticRelationsIntegration semanticRelationsIntegration;
210 
211  // Patient2
213  m_DataStorage->Add(image);
214  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", image.IsNotNull());
215  CPPUNIT_ASSERT_MESSAGE("Image data is empty", image->GetData() != nullptr);
216  semanticRelationsIntegration.AddImage(image);
217 
219  m_DataStorage->Add(segmentation, image);
220  CPPUNIT_ASSERT_MESSAGE("Not a valid segmentation data node", segmentation.IsNotNull());
221  CPPUNIT_ASSERT_MESSAGE("Segmentation data is empty", segmentation->GetData() != nullptr);
222  semanticRelationsIntegration.AddSegmentation(segmentation, image);
223 
224  // start test
225  auto allCaseIDs = mitk::RelationStorage::GetAllCaseIDs();
226  CPPUNIT_ASSERT_MESSAGE("Two CaseIDs should be stored", allCaseIDs.size() == 2);
227 
228  // test lesion (add and link)
229  auto lesion = mitk::GenerateNewLesion();
230  semanticRelationsIntegration.AddLesionAndLinkSegmentation(segmentation, lesion);
231 
232  auto representedLesion = mitk::SemanticRelationsInference::GetLesionOfSegmentation(segmentation);
233  CPPUNIT_ASSERT_MESSAGE("Represented lesion should be the only stored lesion", lesion.UID == representedLesion.UID);
234  }
235 
236  void InvalidData()
237  {
238  MITK_INFO << "=== InvalidData";
239 
240  // TEST INVALID CASE ID
241  std::string caseID = "invalidID";
242  auto allLesions = mitk::RelationStorage::GetAllLesionsOfCase(caseID);
243  CPPUNIT_ASSERT_MESSAGE("No lesion should be stored, given a non-existing CaseID", allLesions.size() == 0);
244 
245  auto allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
246  CPPUNIT_ASSERT_MESSAGE("No control point should be stored, given a non-existing CaseID", allControlPoints.size() == 0);
247 
248  auto allExaminationPeriods = mitk::RelationStorage::GetAllExaminationPeriodsOfCase(caseID);
249  CPPUNIT_ASSERT_MESSAGE("No examination periods should be stored, given a non-existing CaseID", allExaminationPeriods.size() == 0);
250 
251  auto allInformationTypes = mitk::RelationStorage::GetAllInformationTypesOfCase(caseID);
252  CPPUNIT_ASSERT_MESSAGE("No information type should be stored, given a non-existing CaseID", allInformationTypes.size() == 0);
253 
254  auto allImageIDsOfCase = mitk::RelationStorage::GetAllImageIDsOfCase(caseID);
255  CPPUNIT_ASSERT_MESSAGE("No image ID should be stored, given a non-existing CaseID", allControlPoints.size() == 0);
256 
257  // TEST INVALID DATE
259  m_DataStorage->Add(invalidDateImage);
260 
261  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", invalidDateImage.IsNotNull());
262  CPPUNIT_ASSERT_MESSAGE("Image data is empty", invalidDateImage->GetData() != nullptr);
263 
264  mitk::SemanticRelationsIntegration semanticRelationsIntegration;
265  CPPUNIT_ASSERT_THROW_MESSAGE("Semantic relation exception not thrown: AddImage",
266  semanticRelationsIntegration.AddImage(invalidDateImage),
268 
269  auto controlPointOfImage = mitk::SemanticRelationsInference::GetControlPointOfImage(invalidDateImage);
270  CPPUNIT_ASSERT_MESSAGE("No control point should be stored for an invalid DICOM date", controlPointOfImage.UID.empty());
271 
272  // set invalid date format for current image
273  // 0x0008, 0x0022 (AcquisitionDate), should be 20180101
274  invalidDateImage->GetData()->SetProperty(mitk::GeneratePropertyNameForDICOMTag(0x0008, 0x0022).c_str(),
275  mitk::StringProperty::New("201811"));
276  CPPUNIT_ASSERT_THROW_MESSAGE("Semantic relation exception not thrown: GenerateControlPoint",
277  mitk::GenerateControlPoint(invalidDateImage),
279 
280  // set valid date format for current image and add image again (only control point should be updated)
281  // 0x0008, 0x0022 (AcquisitionDate), should be 20180101
282  invalidDateImage->GetData()->SetProperty(mitk::GeneratePropertyNameForDICOMTag(0x0008, 0x0022).c_str(),
283  mitk::StringProperty::New("20180101"));
284  semanticRelationsIntegration.AddImage(invalidDateImage);
285 
286  controlPointOfImage = mitk::SemanticRelationsInference::GetControlPointOfImage(invalidDateImage);
287  mitk::SemanticTypes::ControlPoint controlPointToCompare;
288  controlPointToCompare.date = boost::gregorian::date(2018, 01, 01);
289  CPPUNIT_ASSERT_MESSAGE("Control point not correctly stored", controlPointOfImage.date == controlPointToCompare.date);
290 
291  // TEST INVALID MODALITY
293  m_DataStorage->Add(invalidModalityImage);
294 
295  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", invalidModalityImage.IsNotNull());
296  CPPUNIT_ASSERT_MESSAGE("Image data is empty", invalidModalityImage->GetData() != nullptr);
297 
298  CPPUNIT_ASSERT_THROW_MESSAGE("Semantic relation exception not thrown: AddImage",
299  semanticRelationsIntegration.AddImage(invalidModalityImage),
301 
302  auto informationTypeOfImage = mitk::SemanticRelationsInference::GetInformationTypeOfImage(invalidModalityImage);
303  CPPUNIT_ASSERT_MESSAGE("No information type should be stored for an invalid DICOM date", informationTypeOfImage.empty());
304 
305  // set valid modality for current image and add image again
306  // 0x0008, 0x0060 (Modality), should be CT
307  invalidModalityImage->GetData()->SetProperty(mitk::GeneratePropertyNameForDICOMTag(0x0008, 0x0060).c_str(),
309  semanticRelationsIntegration.AddImage(invalidModalityImage);
310 
311  auto informationType = mitk::SemanticRelationsInference::GetInformationTypeOfImage(invalidModalityImage);
312  CPPUNIT_ASSERT_MESSAGE("Information type not correctly stored", informationType == "CT");
313 
314  // TEST INVALID ID
316  m_DataStorage->Add(invalidIDImage);
317 
318  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", invalidModalityImage.IsNotNull());
319  CPPUNIT_ASSERT_MESSAGE("Image data is empty", invalidModalityImage->GetData() != nullptr);
320 
321  CPPUNIT_ASSERT_THROW_MESSAGE("Semantic relation exception not thrown: AddImage",
322  semanticRelationsIntegration.AddImage(invalidIDImage),
324 
325  // set valid ID for current image and add image again
326  // 0x0020, 0x000e (SeriesInstanceUID)
327  auto generatedUID = mitk::UIDGeneratorBoost::GenerateUID();
328  invalidIDImage->GetData()->SetProperty(mitk::GeneratePropertyNameForDICOMTag(0x0020, 0x000e).c_str(),
329  mitk::StringProperty::New(generatedUID));
330  semanticRelationsIntegration.AddImage(invalidIDImage);
331 
332  auto IDFromNode = mitk::GetIDFromDataNode(invalidIDImage);
333  CPPUNIT_ASSERT_MESSAGE("ID not correctly stored", IDFromNode == generatedUID);
334 
335  // TEST INVALID CASE ID
337  m_DataStorage->Add(invalidCaseIDImage);
338 
339  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", invalidModalityImage.IsNotNull());
340  CPPUNIT_ASSERT_MESSAGE("Image data is empty", invalidModalityImage->GetData() != nullptr);
341 
342  CPPUNIT_ASSERT_THROW_MESSAGE("Semantic relation exception not thrown: AddImage",
343  semanticRelationsIntegration.AddImage(invalidCaseIDImage),
345 
346  // set valid case ID for current image and add image again
347  // 0x0010, 0x0010 (PatientName)
348  invalidCaseIDImage->GetData()->SetProperty(mitk::GeneratePropertyNameForDICOMTag(0x0010, 0x0010).c_str(),
349  mitk::StringProperty::New("Patient7"));
350  semanticRelationsIntegration.AddImage(invalidCaseIDImage);
351 
352  auto caseIDFromNode = mitk::GetCaseIDFromDataNode(invalidCaseIDImage);
353  CPPUNIT_ASSERT_MESSAGE("Case ID not correctly stored", caseIDFromNode == "Patient7");
354  }
355 
356  // InferenceTest
357  void CombinedQueries()
358  {
359  MITK_INFO << "=== CombinedQueries";
360 
361  // add image with segmentation and lesion
363  m_DataStorage->Add(image);
364 
365  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", image.IsNotNull());
366  CPPUNIT_ASSERT_MESSAGE("Image data is empty", image->GetData() != nullptr);
367 
369  m_DataStorage->Add(segmentation, image);
370 
371  CPPUNIT_ASSERT_MESSAGE("Not a valid segmentation data node", segmentation.IsNotNull());
372  CPPUNIT_ASSERT_MESSAGE("Segmentation data is empty", segmentation->GetData() != nullptr);
373 
374  mitk::SemanticRelationsIntegration semanticRelationsIntegration;
375  semanticRelationsIntegration.AddImage(image);
376  semanticRelationsIntegration.AddSegmentation(segmentation, image);
377 
378  auto caseID = mitk::GetCaseIDFromDataNode(image);
379 
380  auto lesion = mitk::GenerateNewLesion();
381  semanticRelationsIntegration.AddLesionAndLinkSegmentation(segmentation, lesion);
382 
384  CPPUNIT_ASSERT_MESSAGE("One lesion should be stored", allLesionsOfImage.size() == 1);
385 
387  auto allLesionsOfControlPoint = mitk::SemanticRelationsInference::GetAllLesionsOfControlPoint(caseID, controlPoint);
388  CPPUNIT_ASSERT_MESSAGE("Lesions should be the same", (allLesionsOfImage.size() == allLesionsOfControlPoint.size())
389  && (allLesionsOfImage.front().UID == allLesionsOfControlPoint.front().UID));
390 
391  auto allImageIDsOfLesion = mitk::SemanticRelationsInference::GetAllImageIDsOfLesion(caseID, allLesionsOfControlPoint.front());
392  CPPUNIT_ASSERT_MESSAGE("Image IDs should be the same", (allImageIDsOfLesion.size() == 1)
393  && (allImageIDsOfLesion.front() == mitk::GetIDFromDataNode(image)));
394 
395  auto allControlPointsOfLesion = mitk::SemanticRelationsInference::GetAllControlPointsOfLesion(caseID, allLesionsOfImage.front());
396  CPPUNIT_ASSERT_MESSAGE("Control points should be the same", (allControlPointsOfLesion.size() == 1)
397  && (allControlPointsOfLesion.front().date == controlPoint.date));
398 
400  auto allControlPointsOfInformationType = mitk::SemanticRelationsInference::GetAllControlPointsOfInformationType(caseID, informationType);
401  CPPUNIT_ASSERT_MESSAGE("Control points should be the same", (allControlPointsOfLesion.size() == 1)
402  && (allControlPointsOfLesion.front().date == controlPoint.date));
403 
404  auto allInformationTypesOfControlPoint = mitk::SemanticRelationsInference::GetAllInformationTypesOfControlPoint(caseID, controlPoint);
405  CPPUNIT_ASSERT_MESSAGE("Information types should be the same", (allInformationTypesOfControlPoint.size() == 1)
406  && (allInformationTypesOfControlPoint.front() == informationType));
407  }
408 
409  void InstanceExistences()
410  {
411  MITK_INFO << "=== InstanceExistences";
412 
413  mitk::SemanticRelationsDataStorageAccess semanticRelationsDataStorageAccess(m_DataStorage);
414  auto allSegmentationsOfCase = semanticRelationsDataStorageAccess.GetAllSegmentationsOfCase("Patient2");
415  CPPUNIT_ASSERT_MESSAGE("One segmentation should be stored", allSegmentationsOfCase.size() == 1);
416 
417  auto segmentation = allSegmentationsOfCase.front();
418  CPPUNIT_ASSERT_MESSAGE("Not a valid segmentation data node", segmentation.IsNotNull());
419  CPPUNIT_ASSERT_MESSAGE("Segmentation data is empty", segmentation->GetData() != nullptr);
420 
422  CPPUNIT_ASSERT_MESSAGE("Segmentation node should represent a lesion", valid);
423 
424  auto caseID = "Patient2";
426  CPPUNIT_ASSERT_MESSAGE("Segmentation (via ID) should represent a lesion", valid);
427 
428  auto allLesions = mitk::RelationStorage::GetAllLesionsOfCase(caseID);
429  CPPUNIT_ASSERT_MESSAGE("One lesion should be stored", allLesions.size() == 1);
430 
431  auto lesion = allLesions.front();
432  valid = mitk::SemanticRelationsInference::IsLesionPresent(lesion, segmentation);
433  CPPUNIT_ASSERT_MESSAGE("Lesion should be present on segmentation", valid);
434 
435  auto allImagesOfCase = semanticRelationsDataStorageAccess.GetAllImagesOfCase(caseID);
436  CPPUNIT_ASSERT_MESSAGE("One image should be stored", allImagesOfCase.size() == 1);
437 
438  auto image = allImagesOfCase.front();
439  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", image.IsNotNull());
440  CPPUNIT_ASSERT_MESSAGE("Image data is empty", image->GetData() != nullptr);
441 
443  CPPUNIT_ASSERT_MESSAGE("Lesion should be present on image", valid);
444 
446  CPPUNIT_ASSERT_MESSAGE("Lesion should be present on segmentation", valid);
447 
449  CPPUNIT_ASSERT_MESSAGE("Lesion should be present on image", valid);
450 
452  valid = mitk::SemanticRelationsInference::IsLesionPresentAtControlPoint(caseID, lesion, controlPoint);
453  CPPUNIT_ASSERT_MESSAGE("Lesion should be present at control point", valid);
454 
455  controlPoint.date = boost::gregorian::date(2019, 01, 01);
456  valid = mitk::SemanticRelationsInference::IsLesionPresentAtControlPoint(caseID, lesion, controlPoint);
457  CPPUNIT_ASSERT_MESSAGE("No lesion should be present at control point", !valid);
458 
460  CPPUNIT_ASSERT_MESSAGE("Image should exist", valid);
461 
463  CPPUNIT_ASSERT_MESSAGE("Segmentation should exist", valid);
464 
465  valid = mitk::SemanticRelationsInference::InstanceExists(caseID, lesion);
466  CPPUNIT_ASSERT_MESSAGE("Lesion should exist", valid);
467 
468  auto emptyLesion = mitk::GenerateNewLesion("ExampleLesionClass");
469  valid = mitk::SemanticRelationsInference::InstanceExists(caseID, emptyLesion);
470  CPPUNIT_ASSERT_MESSAGE("Lesion should not exist", !valid);
471 
472  auto newControlPoint = mitk::SemanticTypes::ControlPoint();
473  valid = mitk::SemanticRelationsInference::InstanceExists(caseID, newControlPoint);
474  CPPUNIT_ASSERT_MESSAGE("Control point should not exist for this case", !valid);
475 
476  valid = mitk::SemanticRelationsInference::InstanceExists(caseID, controlPoint);
477  CPPUNIT_ASSERT_MESSAGE("Control point should exist for this case", valid);
478 
479  auto allExaminationPeriod = mitk::RelationStorage::GetAllExaminationPeriodsOfCase(caseID);
480  CPPUNIT_ASSERT_MESSAGE("One examination period should be stored", allExaminationPeriod.size() == 1);
481  auto examinationPeriod = allExaminationPeriod.front();
482 
483  valid = mitk::SemanticRelationsInference::InstanceExists(caseID, examinationPeriod);
484  CPPUNIT_ASSERT_MESSAGE("Examination period should exist for this case", valid);
485 
487  valid = mitk::SemanticRelationsInference::InstanceExists(caseID, informationType);
488  CPPUNIT_ASSERT_MESSAGE("Control point should exist for this case", valid);
489 
491  CPPUNIT_ASSERT_MESSAGE("Control point should not exist for this case", !valid);
492 
493  valid = mitk::SemanticRelationsInference::SpecificImageExists(caseID, lesion, informationType);
494  CPPUNIT_ASSERT_MESSAGE("Specific image should exist for this case", valid);
495 
496  valid = mitk::SemanticRelationsInference::SpecificImageExists(caseID, lesion, controlPoint);
497  CPPUNIT_ASSERT_MESSAGE("Specific image should exist for this case", valid);
498 
499  valid = mitk::SemanticRelationsInference::SpecificImageExists(caseID, informationType, controlPoint);
500  CPPUNIT_ASSERT_MESSAGE("Specific image should exist for this case", valid);
501  }
502 
503  // DataStorageAccessTest
504  void DataStorageAccess()
505  {
506  MITK_INFO << "=== DataStorageAccess";
507 
508  // load data
509  mitk::SemanticRelationsIntegration semanticRelationsIntegration;
510 
511  // Patient1
513  m_DataStorage->Add(CTImage);
514  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", CTImage.IsNotNull());
515  CPPUNIT_ASSERT_MESSAGE("Image data is empty", CTImage->GetData() != nullptr);
516  semanticRelationsIntegration.AddImage(CTImage);
517 
519  m_DataStorage->Add(MRImage);
520  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", MRImage.IsNotNull());
521  CPPUNIT_ASSERT_MESSAGE("Image data is empty", MRImage->GetData() != nullptr);
522  semanticRelationsIntegration.AddImage(MRImage);
523 
525  m_DataStorage->Add(otherCTImage);
526  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", otherCTImage.IsNotNull());
527  CPPUNIT_ASSERT_MESSAGE("Image data is empty", otherCTImage->GetData() != nullptr);
528  semanticRelationsIntegration.AddImage(otherCTImage);
529 
530  // Patient2
532  m_DataStorage->Add(PETImage);
533  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", PETImage.IsNotNull());
534  CPPUNIT_ASSERT_MESSAGE("Image data is empty", PETImage->GetData() != nullptr);
535  semanticRelationsIntegration.AddImage(PETImage);
536 
538  m_DataStorage->Add(PETSegmentation, PETImage);
539  CPPUNIT_ASSERT_MESSAGE("Not a valid segmentation data node", PETSegmentation.IsNotNull());
540  CPPUNIT_ASSERT_MESSAGE("Segmentation data is empty", PETSegmentation->GetData() != nullptr);
541  semanticRelationsIntegration.AddSegmentation(PETSegmentation, PETImage);
542 
543  auto lesion = mitk::GenerateNewLesion();
544  semanticRelationsIntegration.AddLesionAndLinkSegmentation(PETSegmentation, lesion);
545 
546  // start test
547  mitk::SemanticRelationsDataStorageAccess semanticRelationsDataStorageAccess(m_DataStorage);
548 
549  auto caseID = "Patient1";
550  auto allSegmentationsOfCase = semanticRelationsDataStorageAccess.GetAllSegmentationsOfCase(caseID);
551  CPPUNIT_ASSERT_MESSAGE("No segmentation should be stored", allSegmentationsOfCase.size() == 0);
552 
553  auto allImagesOfCase = semanticRelationsDataStorageAccess.GetAllImagesOfCase(caseID);
554  CPPUNIT_ASSERT_MESSAGE("Three images should be stored", allImagesOfCase.size() == 3);
555 
556  auto allLesions = mitk::RelationStorage::GetAllLesionsOfCase(caseID);
557  CPPUNIT_ASSERT_MESSAGE("No lesion should be stored", allLesions.size() == 0);
558 
559  auto emptyLesion = mitk::GenerateNewLesion("ExampleLesionClass");
560  CPPUNIT_ASSERT_THROW_MESSAGE("Semantic relation exception not thrown: GetAllSegmentationsOfLesion",
561  semanticRelationsDataStorageAccess.GetAllSegmentationsOfLesion(caseID, emptyLesion),
563 
564  caseID = "Patient2";
565  allLesions = mitk::RelationStorage::GetAllLesionsOfCase(caseID);
566  CPPUNIT_ASSERT_MESSAGE("One lesion should be stored", allLesions.size() == 1);
567 
568  lesion = allLesions.front();
569  auto allSegmentationsOfLesion = semanticRelationsDataStorageAccess.GetAllSegmentationsOfLesion(caseID, lesion);
570  CPPUNIT_ASSERT_MESSAGE("One segmentation should be stored", allSegmentationsOfLesion.size() == 1);
571 
572  auto allImagesOfLesion = semanticRelationsDataStorageAccess.GetAllImagesOfLesion(caseID, lesion);
573  CPPUNIT_ASSERT_MESSAGE("One image should be stored", allImagesOfLesion.size() == 1);
574 
575  auto allControlPointsOfLesion = mitk::SemanticRelationsInference::GetAllControlPointsOfLesion(caseID, lesion);
576  CPPUNIT_ASSERT_MESSAGE("One control point should be stored", allControlPointsOfLesion.size() == 1);
577  auto controlPoint = allControlPointsOfLesion.front();
578 
579  auto allSpecificImages = semanticRelationsDataStorageAccess.GetAllSpecificImages(caseID, controlPoint, "PT");
580  CPPUNIT_ASSERT_MESSAGE("One image should be stored", allSpecificImages.size() == 1);
581 
582  CPPUNIT_ASSERT_THROW_MESSAGE("Semantic relation exception not thrown: GetAllSpecificImages",
583  semanticRelationsDataStorageAccess.GetAllSpecificImages(caseID, controlPoint, "CT"),
585 
586  auto allSpecificSegmentations = semanticRelationsDataStorageAccess.GetAllSpecificSegmentations(caseID, controlPoint, "PT");
587  CPPUNIT_ASSERT_MESSAGE("One segmentation should be stored", allSpecificSegmentations.size() == 1);
588 
589  CPPUNIT_ASSERT_THROW_MESSAGE("Semantic relation exception not thrown: GetAllSpecificSegmentations",
590  semanticRelationsDataStorageAccess.GetAllSpecificSegmentations(caseID, controlPoint, "MR"),
592  }
593 
594  // RemoveAndUnlinkTest
595  void CPRemoveAndUnlink()
596  {
597  MITK_INFO << "=== RemoveAndUnlink";
598 
599  // load data
600  mitk::SemanticRelationsIntegration semanticRelationsIntegration;
601 
603  m_DataStorage->Add(CTImage);
604  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", CTImage.IsNotNull());
605  CPPUNIT_ASSERT_MESSAGE("Image data is empty", CTImage->GetData() != nullptr);
606  semanticRelationsIntegration.AddImage(CTImage);
607 
609  m_DataStorage->Add(MRImage);
610  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", MRImage.IsNotNull());
611  CPPUNIT_ASSERT_MESSAGE("Image data is empty", MRImage->GetData() != nullptr);
612  semanticRelationsIntegration.AddImage(MRImage);
613 
614  // start test
615  auto allCaseIDs = mitk::RelationStorage::GetAllCaseIDs();
616  CPPUNIT_ASSERT_MESSAGE("One CaseID should be stored", allCaseIDs.size() == 1);
617 
618  auto caseID = allCaseIDs.front();
619  CPPUNIT_ASSERT_MESSAGE("CaseID should be Patient3", caseID == "Patient3");
620 
621  auto allExaminationPeriods = mitk::RelationStorage::GetAllExaminationPeriodsOfCase(caseID);
622  CPPUNIT_ASSERT_MESSAGE("One examination period should be sored", allExaminationPeriods.size() == 1);
623 
624  auto allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
625  CPPUNIT_ASSERT_MESSAGE("Two control points should be stored", allControlPoints.size() == 2);
626 
627  // control points
628  auto CTControlPoint = mitk::SemanticRelationsInference::GetControlPointOfImage(CTImage);
629  semanticRelationsIntegration.UnlinkImageFromControlPoint(CTImage);
630 
631  allExaminationPeriods = mitk::RelationStorage::GetAllExaminationPeriodsOfCase(caseID);
632  CPPUNIT_ASSERT_MESSAGE("One examination period should be stored", allExaminationPeriods.size() == 1);
633 
634  allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
635  CPPUNIT_ASSERT_MESSAGE("One control point should be stored since one has been removed", allControlPoints.size() == 1);
636 
638  CPPUNIT_ASSERT_MESSAGE("Control point should be removed", CTControlPoint.UID.empty());
639 
640  CTControlPoint = mitk::GenerateControlPoint(CTImage);
641  semanticRelationsIntegration.SetControlPointOfImage(CTImage, CTControlPoint);
642 
643  allExaminationPeriods = mitk::RelationStorage::GetAllExaminationPeriodsOfCase(caseID);
644  CPPUNIT_ASSERT_MESSAGE("One examination period should be sored", allExaminationPeriods.size() == 1);
645 
646  allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
647  CPPUNIT_ASSERT_MESSAGE("Two control points should be stored", allControlPoints.size() == 2);
648 
649  mitk::SemanticTypes::ControlPoint newCTControlPoint;
650  newCTControlPoint.UID = mitk::UIDGeneratorBoost::GenerateUID();
651  newCTControlPoint.date = boost::gregorian::date(2019, 03, 01);
652  semanticRelationsIntegration.SetControlPointOfImage(CTImage, newCTControlPoint);
653 
654  allExaminationPeriods = mitk::RelationStorage::GetAllExaminationPeriodsOfCase(caseID);
655  CPPUNIT_ASSERT_MESSAGE("One examination period should be sored", allExaminationPeriods.size() == 1);
656 
657  allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
658  CPPUNIT_ASSERT_MESSAGE("Two control points should be stored", allControlPoints.size() == 2);
659 
660  newCTControlPoint.UID = mitk::UIDGeneratorBoost::GenerateUID();
661  newCTControlPoint.date = boost::gregorian::date(2019, 01, 01);
662  semanticRelationsIntegration.SetControlPointOfImage(CTImage, newCTControlPoint);
663 
664  allExaminationPeriods = mitk::RelationStorage::GetAllExaminationPeriodsOfCase(caseID);
665  CPPUNIT_ASSERT_MESSAGE("Two examination periods should be stored", allExaminationPeriods.size() == 2);
666 
667  allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
668  CPPUNIT_ASSERT_MESSAGE("Two control points should be stored", allControlPoints.size() == 2);
669  }
670 
671  void LesionRemoveAndUnlink()
672  {
673  MITK_INFO << "=== LesionRemoveAndUnlink";
674 
675  // load data
676  mitk::SemanticRelationsIntegration semanticRelationsIntegration;
677  mitk::SemanticRelationsDataStorageAccess semanticRelationsDataStorageAccess(m_DataStorage);
678 
679  auto allCaseIDs = mitk::RelationStorage::GetAllCaseIDs();
680  CPPUNIT_ASSERT_MESSAGE("One CaseID should be stored", allCaseIDs.size() == 1);
681  auto caseID = allCaseIDs.front();
682 
683  auto allImages = semanticRelationsDataStorageAccess.GetAllImagesOfCase(caseID);
684  CPPUNIT_ASSERT_MESSAGE("Two images should be stored", allImages.size() == 2);
685 
686  auto allCTImageIDs = mitk::RelationStorage::GetAllImageIDsOfInformationType(caseID, "CT");
687  CPPUNIT_ASSERT_MESSAGE("One image should be stored", allCTImageIDs.size() == 1);
688 
689  auto allMRImageIDs = mitk::RelationStorage::GetAllImageIDsOfInformationType(caseID, "MR");
690  CPPUNIT_ASSERT_MESSAGE("One image should be stored", allMRImageIDs.size() == 1);
691 
692  mitk::DataNode::Pointer CTImage;
693  mitk::DataNode::Pointer MRImage;
694  for (const auto& image : allImages)
695  {
696  auto imageID = mitk::GetIDFromDataNode(image);
697  if (imageID == allCTImageIDs.front())
698  {
699  CTImage = image;
700  }
701  else if (imageID == allMRImageIDs.front())
702  {
703  MRImage = image;
704  }
705  }
706 
707  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", CTImage.IsNotNull());
708  CPPUNIT_ASSERT_MESSAGE("Image data is empty", CTImage->GetData() != nullptr);
709 
710  CPPUNIT_ASSERT_MESSAGE("Not a valid image data node", MRImage.IsNotNull());
711  CPPUNIT_ASSERT_MESSAGE("Image data is empty", MRImage->GetData() != nullptr);
712 
714  m_DataStorage->Add(CTSegmentation, CTImage);
715  CPPUNIT_ASSERT_MESSAGE("Not a valid segmentation data node", CTSegmentation.IsNotNull());
716  CPPUNIT_ASSERT_MESSAGE("Segmentation data is empty", CTSegmentation->GetData() != nullptr);
717  semanticRelationsIntegration.AddSegmentation(CTSegmentation, CTImage);
718 
720  m_DataStorage->Add(MRSegmentation, MRImage);
721  CPPUNIT_ASSERT_MESSAGE("Not a valid segmentation data node", MRSegmentation.IsNotNull());
722  CPPUNIT_ASSERT_MESSAGE("Segmentation data is empty", MRSegmentation->GetData() != nullptr);
723  semanticRelationsIntegration.AddSegmentation(MRSegmentation, MRImage);
724 
725  auto newLesion = mitk::GenerateNewLesion();
726  semanticRelationsIntegration.AddLesionAndLinkSegmentation(CTSegmentation, newLesion);
727  newLesion = mitk::GenerateNewLesion();
728  semanticRelationsIntegration.AddLesionAndLinkSegmentation(MRSegmentation, newLesion);
729 
730  // start test
731  auto allLesions = mitk::RelationStorage::GetAllLesionsOfCase(caseID);
732  CPPUNIT_ASSERT_MESSAGE("Two lesions should be stored", allLesions.size() == 2);
733 
734  auto MRLesion = mitk::SemanticRelationsInference::GetLesionOfSegmentation(MRSegmentation);
735  semanticRelationsIntegration.UnlinkSegmentationFromLesion(MRSegmentation);
736 
737  allLesions = mitk::RelationStorage::GetAllLesionsOfCase(caseID);
738  CPPUNIT_ASSERT_MESSAGE("Two lesions should be stored", allLesions.size() == 2);
739 
740  auto emptyLesion = mitk::SemanticRelationsInference::GetLesionOfSegmentation(MRSegmentation);
741  CPPUNIT_ASSERT_MESSAGE("Lesion should be removed", emptyLesion.UID.empty());
742 
743  semanticRelationsIntegration.LinkSegmentationToLesion(MRSegmentation, MRLesion);
744  allLesions = mitk::RelationStorage::GetAllLesionsOfCase(caseID);
745  CPPUNIT_ASSERT_MESSAGE("Two lesions should be stored", allLesions.size() == 2);
746 
747  auto CTLesion = mitk::SemanticRelationsInference::GetLesionOfSegmentation(CTSegmentation);
748  CPPUNIT_ASSERT_THROW_MESSAGE("Semantic relation exception not thrown: RemoveLesion",
749  semanticRelationsIntegration.RemoveLesion(caseID, CTLesion),
751 
752  semanticRelationsIntegration.UnlinkSegmentationFromLesion(CTSegmentation);
753  semanticRelationsIntegration.RemoveLesion(caseID, CTLesion);
754 
755  allLesions = mitk::RelationStorage::GetAllLesionsOfCase(caseID);
756  CPPUNIT_ASSERT_MESSAGE("One lesions should be stored since one has been removed", allLesions.size() == 1);
757 
759  CPPUNIT_ASSERT_MESSAGE("Lesion should be removed", CTLesion.UID.empty());
760  }
761 
762  void RemoveImagesAndSegmentation()
763  {
764  MITK_INFO << "=== RemoveImagesAndSegmentation";
765 
766  // load data
767  mitk::SemanticRelationsIntegration semanticRelationsIntegration;
768  mitk::SemanticRelationsDataStorageAccess semanticRelationsDataStorageAccess(m_DataStorage);
769 
770  auto allCaseIDs = mitk::RelationStorage::GetAllCaseIDs();
771  CPPUNIT_ASSERT_MESSAGE("One CaseID should be stored", allCaseIDs.size() == 1);
772  auto caseID = allCaseIDs.front();
773 
774  auto allImages = semanticRelationsDataStorageAccess.GetAllImagesOfCase(caseID);
775  CPPUNIT_ASSERT_MESSAGE("Two images should be stored", allImages.size() == 2);
776 
777  auto allSegmentations = semanticRelationsDataStorageAccess.GetAllSegmentationsOfCase(caseID);
778  CPPUNIT_ASSERT_MESSAGE("Two segmentations should be stored", allSegmentations.size() == 2);
779 
780  for (const auto& image : allImages)
781  {
782  semanticRelationsIntegration.RemoveImage(image);
783  }
784 
785  for (const auto& segmentation : allSegmentations)
786  {
787  semanticRelationsIntegration.RemoveSegmentation(segmentation);
788  }
789 
790  allImages = semanticRelationsDataStorageAccess.GetAllImagesOfCase(caseID);
791  CPPUNIT_ASSERT_MESSAGE("No images should be stored", allImages.size() == 0);
792 
793  allSegmentations = semanticRelationsDataStorageAccess.GetAllSegmentationsOfCase(caseID);
794  CPPUNIT_ASSERT_MESSAGE("No segmentations should be stored", allSegmentations.size() == 0);
795 
796  auto allControlPoints = mitk::RelationStorage::GetAllControlPointsOfCase(caseID);
797  CPPUNIT_ASSERT_MESSAGE("No control point should be stored", allControlPoints.size() == 0);
798 
799  auto allInformationTypes = mitk::RelationStorage::GetAllInformationTypesOfCase(caseID);
800  CPPUNIT_ASSERT_MESSAGE("No information type should be stored", allInformationTypes.size() == 0);
801 
802  auto allLesions = mitk::RelationStorage::GetAllLesionsOfCase(caseID);
803  CPPUNIT_ASSERT_MESSAGE("One lesions should be stored", allLesions.size() == 1);
804  }
805 
806 };
807 
808 MITK_TEST_SUITE_REGISTRATION(mitkSemanticRelations)
void AddSegmentation(const DataNode *segmentationNode, const DataNode *parentNode)
Add a segmentation instance to the set of already existing segmentations - with no connection to a sp...
void RemoveSegmentation(const DataNode *segmentationNode)
Remove the given segmentation from the set of already existing segmentations.
MITKSEMANTICRELATIONS_EXPORT bool IsLesionPresent(const SemanticTypes::Lesion &lesion, const DataNode *dataNode)
Check if the given lesion is present on the given data node. The function receives the case- and the ...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::InformationType GetInformationTypeOfImage(const DataNode *imageNode)
Return the information type of the given image. If the image does not contain any information type...
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_INFO
Definition: mitkLogMacros.h:18
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::Lesion GenerateNewLesion(const std::string &lesionClassType="")
Generate a new lesion and lesion class with UIDs and the given string as lesion class type...
DataNode::Pointer GetInvalidCaseID()
CaseID is 0x0010, 0x0010 (PatientName)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::LesionVector GetAllLesionsOfControlPoint(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint)
Returns a vector of all lesions that are valid for the given case, given a specific control point...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPointVector GetAllControlPointsOfLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion)
Return a vector of all control points that are valid for the given case, given a specific lesion...
std::string MITKCORE_EXPORT GeneratePropertyNameForDICOMTag(unsigned int group, unsigned int element)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
DataNode::Pointer GetInvalidModality()
Modality is 0x0008, 0x0060(Modality)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPointVector GetAllControlPointsOfInformationType(const SemanticTypes::CaseID &caseID, const SemanticTypes::InformationType &informationType)
Return a vector of all control points that are valid for the given case, given a specific information...
void UnlinkImageFromControlPoint(const DataNode *imageNode)
Unlink the given image from the linked control point. If an image is unlinked from a control point...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::LesionVector GetAllLesionsOfImage(const DataNode *imageNode)
Returns a vector of all lesions that are currently available for the current case and are connected t...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::InformationTypeVector GetAllInformationTypesOfCase(const SemanticTypes::CaseID &caseID)
MITKSEMANTICRELATIONS_EXPORT bool IsRepresentingALesion(const DataNode *segmentationNode)
Check if the given segmentation refers to an existing lesion instance. This function can be used befo...
DataNode::Pointer GetInvalidID()
ID is 0x0020, 0x000e (SeriesInstanceUID)
void SetInformationType(const DataNode *imageNode, const SemanticTypes::InformationType &informationType)
Set (and possibly overwrite) the information type of the given image. An already associated informati...
The API provides functions to manipulate image relations and instances that are helpful during follow...
MITKSEMANTICRELATIONS_EXPORT bool SpecificImageExists(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion, const SemanticTypes::InformationType &informationType)
Determine if the given information type contains images, which are connected to segmentations that re...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPoint GetControlPointOfImage(const DataNode *dataNode)
Return the control point of a data node. If the data node is not linked to a control point or the dat...
MITKSEMANTICRELATIONS_EXPORT bool IsLesionPresentOnImage(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion, const SemanticTypes::ID &imageID)
Check if the given lesion is related to the image identified by the given image ID. Each lesion is represented by a segmentation which is connected to its parent image.
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::CaseID GetCaseIDFromDataNode(const mitk::DataNode *dataNode)
void RemoveImage(const DataNode *imageNode)
Remove the given image from the set of already existing images.
void RemoveLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion)
Remove the given lesion from the set of already existing lesions.
mitk::DataStorage::Pointer m_DataStorage
DataNode::Pointer GetInvalidDate()
Date is 0x0008, 0x0022 (AcquisitionDate)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::IDVector GetAllImageIDsOfInformationType(const SemanticTypes::CaseID &caseID, const SemanticTypes::InformationType &informationType)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ID GetIDFromDataNode(const mitk::DataNode *dataNode)
Test fixture for parameterized tests.
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPoint GenerateControlPoint(const mitk::DataNode *datanode)
Provides helper functions that are needed to work with control points.
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::LesionVector GetAllLesionsOfCase(const SemanticTypes::CaseID &caseID)
mitk::Image::Pointer image
void UnlinkSegmentationFromLesion(const DataNode *segmentationNode)
Unlink the given segmentation instance from the linked lesion instance. The lesion may stay unlinked ...
void AddImage(const DataNode *imageNode)
Add the given image to the set of already existing images. The date is extracted from the DICOM data ...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::IDVector GetAllImageIDsOfControlPoint(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint)
MITKSEMANTICRELATIONS_EXPORT bool IsLesionPresentOnSegmentation(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion, const SemanticTypes::ID &segmentationID)
Check if the given lesion is present on the segmentation identified by the given segmentation ID...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ExaminationPeriodVector GetAllExaminationPeriodsOfCase(const SemanticTypes::CaseID &caseID)
MITKSEMANTICRELATIONS_EXPORT std::vector< SemanticTypes::CaseID > GetAllCaseIDs()
void AddLesionAndLinkSegmentation(const DataNode *segmentationNode, const SemanticTypes::Lesion &lesion)
Add a newly created lesion to the set of already existing lesions. The lesion is added and a referenc...
The API provides functions to query and manipulate image relations and instances, that are helpful du...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::IDVector GetAllImageIDsOfCase(const SemanticTypes::CaseID &caseID)
void SetControlPointOfImage(const DataNode *imageNode, const SemanticTypes::ControlPoint &controlPoint)
Set the control point for the given image.
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::InformationTypeVector GetAllInformationTypesOfControlPoint(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint)
Return a vector of all information types that are valid for the given case, given a specific control ...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::Lesion GetLesionOfSegmentation(const DataNode *segmentationNode)
Return the lesion that is defined by the given segmentation.
MITKSEMANTICRELATIONS_EXPORT bool IsLesionPresentAtControlPoint(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion, const SemanticTypes::ControlPoint &controlPoint)
Check if the given lesion is present at the given control point.
void LinkSegmentationToLesion(const DataNode *segmentationNode, const SemanticTypes::Lesion &lesion)
Link the given segmentation instance to an an already existing lesion instance. If the segmentation i...
static Pointer New()
MITKSEMANTICRELATIONS_EXPORT std::string GenerateUID()
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPointVector GetAllControlPointsOfCase(const SemanticTypes::CaseID &caseID)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::IDVector GetAllImageIDsOfLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion)
Return a vector of all image IDs that identify images that are related to the given lesion...
MITKSEMANTICRELATIONS_EXPORT bool InstanceExists(const DataNode *dataNode)
Check if the given data node exists in the relation storage. The function receives the case- and the ...