Medical Imaging Interaction Toolkit  2018.4.99-1640525a
Medical Imaging Interaction Toolkit
mitkSemanticRelationsIntegration.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 // semantic relations module
17 #include "mitkDICOMHelper.h"
18 #include "mitkNodePredicates.h"
19 #include "mitkRelationStorage.h"
22 #include "mitkUIDGeneratorBoost.h"
23 
24 // multi label module
25 #include <mitkLabelSetImage.h>
26 
27 // c++
28 #include <iterator>
29 #include <algorithm>
30 
31 std::vector<mitk::ISemanticRelationsObserver*> mitk::SemanticRelationsIntegration::m_ObserverVector;
32 
34 {
35  std::vector<ISemanticRelationsObserver*>::iterator existingObserver = std::find(m_ObserverVector.begin(), m_ObserverVector.end(), observer);
36  if (existingObserver != m_ObserverVector.end())
37  {
38  // no need to add the already existing observer
39  return;
40  }
41 
42  m_ObserverVector.push_back(observer);
43 }
44 
46 {
47  m_ObserverVector.erase(std::remove(m_ObserverVector.begin(), m_ObserverVector.end(), observer), m_ObserverVector.end());
48 }
49 
50 /************************************************************************/
51 /* functions to add / remove instances / attributes */
52 /************************************************************************/
53 
55 {
56  if (nullptr == imageNode)
57  {
58  mitkThrowException(SemanticRelationException) << "Not a valid image data node.";
59  }
60 
61  SemanticTypes::CaseID caseID;
62  SemanticTypes::ID imageID;
63  SemanticTypes::InformationType informationType;
64  SemanticTypes::ControlPoint controlPoint;
65  try // retrieve information
66  {
67  caseID = GetCaseIDFromDataNode(imageNode);
68  imageID = GetIDFromDataNode(imageNode);
69 
70  informationType = GetDICOMModalityFromDataNode(imageNode);
71  controlPoint = GenerateControlPoint(imageNode);
72  }
73  catch (SemanticRelationException& e)
74  {
75  mitkReThrow(e) << "Cannot add the given image data node.";
76  }
77 
78  try // add and set information
79  {
81  RelationStorage::AddImage(caseID, imageID);
82 
83  AddInformationTypeToImage(imageNode, informationType);
84  SetControlPointOfImage(imageNode, controlPoint);
85  }
86  catch (SemanticRelationException& e)
87  {
88  mitkReThrow(e) << "Cannot add the given image data node.";
89  }
90 }
91 
93 {
94  if (nullptr == imageNode)
95  {
96  mitkThrowException(SemanticRelationException) << "Not a valid image data node.";
97  }
98 
99  SemanticTypes::CaseID caseID;
100  SemanticTypes::ID imageID;
101  try // retrieve information
102  {
103  caseID = GetCaseIDFromDataNode(imageNode);
104  imageID = GetIDFromDataNode(imageNode);
105  }
106  catch (SemanticRelationException& e)
107  {
108  mitkReThrow(e) << "Cannot remove the given image data node.";
109  }
110 
111  try
112  {
114  UnlinkImageFromControlPoint(imageNode);
115  }
116  catch (SemanticRelationException& e)
117  {
118  mitkReThrow(e) << "Cannot remove the given image data node.";
119  }
120 
121  RelationStorage::RemoveImage(caseID, imageID);
122  NotifyObserver(caseID);
123 }
124 
126 {
127  if (SemanticRelationsInference::InstanceExists(caseID, lesion))
128  {
129  mitkThrowException(SemanticRelationException) << "The lesion " << lesion.UID << " to add already exists for the given case.";
130  }
131 
132  RelationStorage::AddLesion(caseID, lesion);
133  NotifyObserver(caseID);
134 }
135 
137 {
138  if (SemanticRelationsInference::InstanceExists(caseID, lesion))
139  {
140  RelationStorage::OverwriteLesion(caseID, lesion);
141  NotifyObserver(caseID);
142  }
143  else
144  {
145  mitkThrowException(SemanticRelationException) << "The lesion " << lesion.UID << " to overwrite does not exist for the given case.";
146  }
147 }
148 
150 {
151  if (nullptr == segmentationNode)
152  {
153  mitkThrowException(SemanticRelationException) << "Not a valid segmentation data node.";
154  }
155 
156  SemanticTypes::CaseID caseID;
157  try
158  {
159  caseID = GetCaseIDFromDataNode(segmentationNode);
160  AddLesion(caseID, lesion);
161  LinkSegmentationToLesion(segmentationNode, lesion);
162  }
163  catch (SemanticRelationException& e)
164  {
165  mitkReThrow(e) << "Cannot add given lesion and link the given segmentation data node.";
166  }
167 
168  NotifyObserver(caseID);
169 }
170 
172 {
173  if (SemanticRelationsInference::InstanceExists(caseID, lesion))
174  {
175  SemanticTypes::IDVector allSegmentationIDsOfLesion = RelationStorage::GetAllSegmentationIDsOfLesion(caseID, lesion);
176  if (allSegmentationIDsOfLesion.empty())
177  {
178  // no more segmentations are linked to the specific lesion
179  // the lesion can be removed from the storage
180  RelationStorage::RemoveLesion(caseID, lesion);
181  NotifyObserver(caseID);
182  }
183  else
184  {
185  mitkThrowException(SemanticRelationException) << "The lesion " << lesion.UID << " to remove is still referred to by a segmentation node. Lesion will not be removed.";
186  }
187  }
188  else
189  {
190  mitkThrowException(SemanticRelationException) << "The lesion " << lesion.UID << " to remove does not exist for the given case.";
191  }
192 }
193 
194 void mitk::SemanticRelationsIntegration::AddSegmentation(const DataNode* segmentationNode, const DataNode* parentNode)
195 {
196  if (nullptr == segmentationNode)
197  {
198  mitkThrowException(SemanticRelationException) << "Not a valid segmentation data node.";
199  }
200 
201  if (nullptr == parentNode)
202  {
203  mitkThrowException(SemanticRelationException) << "Not a valid parent data node.";
204  }
205 
206  SemanticTypes::CaseID caseID;
207  SemanticTypes::ID segmentationNodeID;
208  SemanticTypes::ID parentNodeID;
209  try
210  {
211  caseID = GetCaseIDFromDataNode(segmentationNode);
212  segmentationNodeID = GetIDFromDataNode(segmentationNode);
213  parentNodeID = GetIDFromDataNode(parentNode);
214  }
215  catch (SemanticRelationException& e)
216  {
217  mitkReThrow(e) << "Cannot add the given segmentation data node.";
218  }
219 
220  RelationStorage::AddSegmentation(caseID, segmentationNodeID, parentNodeID);
221  NotifyObserver(caseID);
222 }
223 
225 {
226  if (nullptr == segmentationNode)
227  {
228  mitkThrowException(SemanticRelationException) << "Not a valid segmentation data node.";
229  }
230 
231  SemanticTypes::CaseID caseID;
232  SemanticTypes::ID segmentationID;
233  try
234  {
235  caseID = GetCaseIDFromDataNode(segmentationNode);
236  segmentationID = GetIDFromDataNode(segmentationNode);
237  }
238  catch (SemanticRelationException& e)
239  {
240  mitkReThrow(e) << "Cannot link the given segmentation data node to the given lesion.";
241  }
242 
243  if (SemanticRelationsInference::InstanceExists(caseID, lesion))
244  {
245  RelationStorage::LinkSegmentationToLesion(caseID, segmentationID, lesion);
246  NotifyObserver(caseID);
247  }
248  else
249  {
250  mitkThrowException(SemanticRelationException) << "The lesion " << lesion.UID << " to link does not exist for the given case.";
251  }
252 }
253 
255 {
256  if (nullptr == segmentationNode)
257  {
258  mitkThrowException(SemanticRelationException) << "Not a valid segmentation data node.";
259  }
260 
261  SemanticTypes::CaseID caseID;
262  SemanticTypes::ID segmentationID;
263  try
264  {
265  caseID = GetCaseIDFromDataNode(segmentationNode);
266  segmentationID = GetIDFromDataNode(segmentationNode);
267  }
268  catch (SemanticRelationException& e)
269  {
270  mitkReThrow(e) << "Cannot unlink the given segmentation data node from its lesion.";
271  }
272 
273  RelationStorage::UnlinkSegmentationFromLesion(caseID, segmentationID);
274  NotifyObserver(caseID);
275 }
276 
278 {
279  if (nullptr == segmentationNode)
280  {
281  mitkThrowException(SemanticRelationException) << "Not a valid segmentation data node.";
282  }
283 
284  SemanticTypes::CaseID caseID;
285  SemanticTypes::ID segmentationNodeID;
286  try
287  {
288  caseID = GetCaseIDFromDataNode(segmentationNode);
289  segmentationNodeID = GetIDFromDataNode(segmentationNode);
290  }
291  catch (SemanticRelationException& e)
292  {
293  mitkReThrow(e) << "Cannot remove the given segmentation data node.";
294  }
295 
296  try
297  {
298  UnlinkSegmentationFromLesion(segmentationNode);
299  }
300  catch (SemanticRelationException& e)
301  {
302  mitkReThrow(e) << "Cannot remove the given segmentation data node.";
303  }
304 
305  RelationStorage::RemoveSegmentation(caseID, segmentationNodeID);
306  NotifyObserver(caseID);
307 }
308 
310 {
311  if (nullptr == imageNode)
312  {
313  mitkThrowException(SemanticRelationException) << "Not a valid image data node.";
314  }
315 
316  SemanticTypes::CaseID caseID;
317  try
318  {
319  caseID = GetCaseIDFromDataNode(imageNode);
320  }
321  catch (SemanticRelationException& e)
322  {
323  mitkReThrow(e) << "Cannot set the given control point for the given image data node.";
324  }
325 
327  // need to check if an already existing control point fits/contains the user control point
328  SemanticTypes::ControlPoint existingControlPoint = FindExistingControlPoint(caseID, controlPoint);
329  try
330  {
331  if (!existingControlPoint.UID.empty())
332  {
333  // found an already existing control point
334  LinkImageToControlPoint(imageNode, existingControlPoint, false);
335  }
336  else
337  {
338  // find closest control point to add the new control point to the correct examination period
339  SemanticTypes::ControlPoint closestControlPoint = FindClosestControlPoint(caseID, controlPoint);
340  SemanticTypes::ExaminationPeriod examinationPeriod = FindContainingExaminationPeriod(caseID, closestControlPoint);
341  if (examinationPeriod.UID.empty())
342  {
343  // no closest control point (exceed threshold) or no examination period found
344  // create a new examination period for this control point and add it to the storage
345  examinationPeriod.UID = UIDGeneratorBoost::GenerateUID();
346  examinationPeriod.name = "New examination period";
347  AddExaminationPeriod(caseID, examinationPeriod);
348  }
349 
350  // added a new control point
351  AddControlPointAndLinkImage(imageNode, controlPoint, false);
352  // add the control point to the (newly created or found / close) examination period
353  AddControlPointToExaminationPeriod(caseID, controlPoint, examinationPeriod);
354  }
355  }
356  catch (SemanticRelationException& e)
357  {
358  mitkReThrow(e) << "Cannot set the given control point for the given image data node.";
359  }
360 
361  ClearControlPoints(caseID);
362  NotifyObserver(caseID);
363 }
364 
365 void mitk::SemanticRelationsIntegration::AddControlPointAndLinkImage(const DataNode* imageNode, const SemanticTypes::ControlPoint& controlPoint, bool checkConsistence)
366 {
367  if (nullptr == imageNode)
368  {
369  mitkThrowException(SemanticRelationException) << "Not a valid image data node.";
370  }
371 
372  SemanticTypes::CaseID caseID;
373  try
374  {
375  caseID = GetCaseIDFromDataNode(imageNode);
376  }
377  catch (SemanticRelationException& e)
378  {
379  mitkReThrow(e) << "Cannot add the given control point and link the given image data node.";
380  }
381 
382  if (SemanticRelationsInference::InstanceExists(caseID, controlPoint))
383  {
384  mitkThrowException(SemanticRelationException) << "The control point " << controlPoint.UID << " to add already exists for the given case. \n Use 'LinkImageToControlPoint' instead.";
385  }
386 
387  RelationStorage::AddControlPoint(caseID, controlPoint);
388 
389  try
390  {
391  LinkImageToControlPoint(imageNode, controlPoint, checkConsistence);
392  }
393  catch (SemanticRelationException& e)
394  {
395  mitkReThrow(e) << "Cannot add the given control point and link the given image data node.";
396  }
397 }
398 
399 void mitk::SemanticRelationsIntegration::LinkImageToControlPoint(const DataNode* imageNode, const SemanticTypes::ControlPoint& controlPoint, bool /*checkConsistence*/)
400 {
401  if (nullptr == imageNode)
402  {
403  mitkThrowException(SemanticRelationException) << "Not a valid image data node.";
404  }
405 
406  SemanticTypes::CaseID caseID;
407  SemanticTypes::ID imageID;
408  try
409  {
410  caseID = GetCaseIDFromDataNode(imageNode);
411  imageID = GetIDFromDataNode(imageNode);
412  }
413  catch (SemanticRelationException& e)
414  {
415  mitkReThrow(e) << "Cannot link the image data node to the given control point.";
416  }
417 
418  if (SemanticRelationsInference::InstanceExists(caseID, controlPoint))
419  {
420  RelationStorage::LinkImageToControlPoint(caseID, imageID, controlPoint);
421  }
422  else
423  {
424  mitkThrowException(SemanticRelationException) << "The control point " << controlPoint.UID << " to link does not exist for the given case.";
425  }
426 }
427 
429 {
430  if (nullptr == imageNode)
431  {
432  mitkThrowException(SemanticRelationException) << "Not a valid image data node.";
433  }
434 
435  SemanticTypes::CaseID caseID = "";
436  SemanticTypes::ID imageID = "";
437  try
438  {
439  caseID = GetCaseIDFromDataNode(imageNode);
440  imageID = GetIDFromDataNode(imageNode);
441  }
442  catch (SemanticRelationException& e)
443  {
444  mitkReThrow(e) << "Cannot unlink the given image data node from its control point.";
445  }
446 
448  ClearControlPoints(caseID);
449 }
450 
452 {
453  if (SemanticRelationsInference::InstanceExists(caseID, examinationPeriod))
454  {
455  mitkThrowException(SemanticRelationException) << "The examination period " << examinationPeriod.UID << " to add already exists for the given case.";
456  }
457  else
458  {
459  RelationStorage::AddExaminationPeriod(caseID, examinationPeriod);
460  }
461 }
462 
464 {
465  if (SemanticRelationsInference::InstanceExists(caseID, examinationPeriod))
466  {
467  RelationStorage::RenameExaminationPeriod(caseID, examinationPeriod);
468  NotifyObserver(caseID);
469  }
470  else
471  {
472  mitkThrowException(SemanticRelationException) << "The examination period " << examinationPeriod.UID << " to overwrite does not exist for the given case.";
473  }
474 }
475 
477 {
478  if (!SemanticRelationsInference::InstanceExists(caseID, controlPoint))
479  {
480  mitkThrowException(SemanticRelationException) << "The control point " << controlPoint.UID << " to add does not exist for the given case.";
481  }
482 
483  if (!SemanticRelationsInference::InstanceExists(caseID, examinationPeriod))
484  {
485  mitkThrowException(SemanticRelationException) << "The examination period " << examinationPeriod.UID << " does not exist for the given case. \n Use 'AddExaminationPeriod' before.";
486  }
487 
488  RelationStorage::AddControlPointToExaminationPeriod(caseID, controlPoint, examinationPeriod);
489 }
490 
492 {
493  SemanticTypes::CaseID caseID;
494  try
495  {
496  caseID = GetCaseIDFromDataNode(imageNode);
497 
499  AddInformationTypeToImage(imageNode, informationType);
500  }
501  catch (SemanticRelationException& e)
502  {
503  mitkReThrow(e) << "Cannot set the given information type for the given image data node.";
504  }
505 
506  NotifyObserver(caseID);
507 }
508 
510 {
511  if (nullptr == imageNode)
512  {
513  mitkThrowException(SemanticRelationException) << "Not a valid image data node.";
514  }
515 
516  SemanticTypes::CaseID caseID = "";
517  SemanticTypes::ID imageID = "";
518  try
519  {
520  caseID = GetCaseIDFromDataNode(imageNode);
521  imageID = GetIDFromDataNode(imageNode);
522  }
523  catch (SemanticRelationException& e)
524  {
525  mitkReThrow(e) << "Cannot add the given information type to the given image data node.";
526  }
527 
528  RelationStorage::AddInformationTypeToImage(caseID, imageID, informationType);
529 }
530 
532 {
533  if (nullptr == imageNode)
534  {
535  mitkThrowException(SemanticRelationException) << "Not a valid image data node.";
536  }
537 
538  SemanticTypes::CaseID caseID = "";
539  SemanticTypes::ID imageID = "";
540  try
541  {
542  caseID = GetCaseIDFromDataNode(imageNode);
543  imageID = GetIDFromDataNode(imageNode);
544  }
545  catch (SemanticRelationException& e)
546  {
547  mitkReThrow(e) << "Cannot remove the information type from the given image data node.";
548  }
549 
550  SemanticTypes::InformationType originalInformationType = RelationStorage::GetInformationTypeOfImage(caseID, imageID);
552 
553  // check for further references to the removed information type
554  SemanticTypes::IDVector allImageIDsVectorValue = RelationStorage::GetAllImageIDsOfCase(caseID);
555  for (const auto& otherImageID : allImageIDsVectorValue)
556  {
557  SemanticTypes::InformationType otherInformationType = RelationStorage::GetInformationTypeOfImage(caseID, otherImageID);
558  if (otherInformationType == originalInformationType)
559  {
560  // found the information type in another image -> cannot remove the information type from the case
561  return;
562  }
563  }
564 
565  // given information type was not referred by any other image of the case -> the information type can be removed from the case
566  RelationStorage::RemoveInformationType(caseID, originalInformationType);
567 }
568 
569 /************************************************************************/
570 /* private functions */
571 /************************************************************************/
572 void mitk::SemanticRelationsIntegration::NotifyObserver(const SemanticTypes::CaseID& caseID) const
573 {
574  for (auto& observer : m_ObserverVector)
575  {
576  observer->Update(caseID);
577  }
578 }
579 
580 void mitk::SemanticRelationsIntegration::ClearControlPoints(const SemanticTypes::CaseID& caseID)
581 {
583 
584  SemanticTypes::IDVector allImageIDsVectorValue = RelationStorage::GetAllImageIDsOfCase(caseID);
585  SemanticTypes::ControlPointVector referencedControlPoints;
586  for (const auto& imageID : allImageIDsVectorValue)
587  {
588  SemanticTypes::ControlPoint controlPointOfImage = RelationStorage::GetControlPointOfImage(caseID, imageID);
589  referencedControlPoints.push_back(controlPointOfImage);
590  }
591 
592  std::sort(allControlPointsOfCase.begin(), allControlPointsOfCase.end());
593  std::sort(referencedControlPoints.begin(), referencedControlPoints.end());
594 
595  SemanticTypes::ControlPointVector nonReferencedControlPoints;
596  std::set_difference(allControlPointsOfCase.begin(), allControlPointsOfCase.end(),
597  referencedControlPoints.begin(), referencedControlPoints.end(),
598  std::inserter(nonReferencedControlPoints, nonReferencedControlPoints.begin()));
599 
600  for (const auto& controlPoint : nonReferencedControlPoints)
601  {
602  const SemanticTypes::ExaminationPeriod& examinationPeriod = FindContainingExaminationPeriod(caseID, controlPoint);
603  RelationStorage::RemoveControlPointFromExaminationPeriod(caseID, controlPoint, examinationPeriod);
604  RelationStorage::RemoveControlPoint(caseID, controlPoint);
605  }
606 }
void AddExaminationPeriod(const SemanticTypes::CaseID &caseID, const SemanticTypes::ExaminationPeriod &examinationPeriod)
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 AddInformationTypeToImage(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &imageID, const SemanticTypes::InformationType &informationType)
void RemoveSegmentation(const DataNode *segmentationNode)
Remove the given segmentation from the set of already existing segmentations.
void LinkSegmentationToLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &segmentationID, const SemanticTypes::Lesion &lesion)
SemanticTypes::InformationType GetInformationTypeOfImage(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &imageID)
void AddControlPointToExaminationPeriod(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint, const SemanticTypes::ExaminationPeriod &examinationPeriod)
std::vector< ID > IDVector
void RemoveControlPoint(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint)
void UnlinkSegmentationFromLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &segmentationID)
void OverwriteLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion)
Overwrite an already existing lesion instance (this may be useful to overwrite the lesion with a diff...
void AddExaminationPeriod(const SemanticTypes::CaseID &caseID, const SemanticTypes::ExaminationPeriod &examinationPeriod)
Add an examination period instance to the set of already existing examination periods - with no conne...
void UnlinkImageFromControlPoint(const DataNode *imageNode)
Unlink the given image from the linked control point. If an image is unlinked from a control point...
#define mitkReThrow(mitkexception)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPoint FindExistingControlPoint(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint)
Returns an already existing control point from the given vector of control points. This existing control point has the the same date (year, month, day) as the given single control point. If no existing control point can be found an empty control point is returned.
void SetInformationType(const DataNode *imageNode, const SemanticTypes::InformationType &informationType)
Set (and possibly overwrite) the information type of the given image. An already associated informati...
void AddControlPoint(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint)
SemanticTypes::ControlPoint GetControlPointOfImage(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &imageID)
void AddImage(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &imageID)
MITKSEMANTICRELATIONS_EXPORT void RenameExaminationPeriod(const SemanticTypes::CaseID &caseID, const SemanticTypes::ExaminationPeriod &examinationPeriod)
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.
std::vector< ControlPoint > ControlPointVector
void RemoveLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion)
Remove the given lesion from the set of already existing lesions.
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPoint FindClosestControlPoint(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint)
Returns an already existing close control point from the given vector of control points. This closest control point has a date that is within a certain distance-in-days to the given control point. If no closest control point can be found within the distance threshold an empty control point is returned.
void RemoveControlPointFromExaminationPeriod(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint, const SemanticTypes::ExaminationPeriod &examinationPeriod)
void LinkImageToControlPoint(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &imageID, const SemanticTypes::ControlPoint &controlPoint)
The concept of an examination period. An examination period holds a vector of control point UIDs...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::IDVector GetAllSegmentationIDsOfLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ID GetIDFromDataNode(const mitk::DataNode *dataNode)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPoint GenerateControlPoint(const mitk::DataNode *datanode)
Provides helper functions that are needed to work with control points.
void UnlinkImageFromControlPoint(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &imageID)
void UnlinkSegmentationFromLesion(const DataNode *segmentationNode)
Unlink the given segmentation instance from the linked lesion instance. The lesion may stay unlinked ...
void OverwriteLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion)
void AddImage(const DataNode *imageNode)
Add the given image to the set of already existing images. The date is extracted from the DICOM data ...
void RemoveInformationTypeFromImage(const DataNode *imageNode)
Remove the information type of the given image. If the information type is removed, the function needs to check whether the information type is referenced by any other image:
void RemoveLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion)
#define mitkThrowException(classname)
void RenameExaminationPeriod(const SemanticTypes::CaseID &caseID, const SemanticTypes::ExaminationPeriod &examinationPeriod)
Rename an already existing examination period instance.
void RemoveInformationTypeFromImage(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &imageID)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ExaminationPeriod FindContainingExaminationPeriod(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint)
Returns the examination period to which the given control point belongs. Each examination point holds...
std::string InformationType
void AddInformationTypeToImage(const DataNode *imageNode, const SemanticTypes::InformationType &informationType)
Set the information type of the given image.
void RemoveObserver(ISemanticRelationsObserver *observer) override
Removes the given concrete observer from the vector that holds all currently registered observer...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::InformationType GetDICOMModalityFromDataNode(const mitk::DataNode *dataNode)
Extracts a specific DICOM tag from the node&#39;s base data and returns the tag as a information type (a ...
void AddObserver(ISemanticRelationsObserver *observer) override
Adds the given concrete observer to the vector that holds all currently registered observer...
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...
void AddControlPointAndLinkImage(const DataNode *imageNode, const SemanticTypes::ControlPoint &controlPoint, bool checkConsistence=true)
Add a newly created control point to the set of already existing control points. A reference to the c...
void AddControlPointToExaminationPeriod(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint, const SemanticTypes::ExaminationPeriod &examinationPeriod)
Add a control point to the vector of control point UIDs of an existing examination period...
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.
void RemoveSegmentation(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &segmentationID)
void RemoveImage(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &imageID)
void AddLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion)
Add a newly created lesion to the set of already existing lesions - with no connection to a specific ...
void AddLesion(const SemanticTypes::CaseID &caseID, const SemanticTypes::Lesion &lesion)
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...
void AddSegmentation(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &segmentationID, const SemanticTypes::ID &parentID)
void LinkImageToControlPoint(const DataNode *imageNode, const SemanticTypes::ControlPoint &controlPoint, bool checkConsistence=true)
Link the given image to an already existing control point.
MITKSEMANTICRELATIONS_EXPORT std::string GenerateUID()
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
void RemoveInformationType(const SemanticTypes::CaseID &caseID, const SemanticTypes::InformationType &informationType)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPointVector GetAllControlPointsOfCase(const SemanticTypes::CaseID &caseID)
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 ...
void AddCase(const SemanticTypes::CaseID &caseID)