Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitkLesionManager.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 // semantic relations module
14 #include "mitkLesionManager.h"
15 #include "mitkRelationStorage.h"
18 #include "mitkUIDGeneratorBoost.h"
19 
20 mitk::SemanticTypes::Lesion mitk::GenerateNewLesion(const std::string& lesionClassType/* = ""*/)
21 {
22  SemanticTypes::Lesion lesion;
24  lesion.name = "New lesion";
25  lesion.lesionClass = GenerateNewLesionClass(lesionClassType);
26 
27  return lesion;
28 }
29 
30 mitk::SemanticTypes::LesionClass mitk::GenerateNewLesionClass(const std::string& lesionClassType/* = ""*/)
31 {
32  SemanticTypes::LesionClass lesionClass;
33  lesionClass.UID = UIDGeneratorBoost::GenerateUID();
34  lesionClass.classType = lesionClassType;
35 
36  return lesionClass;
37 }
38 
40 {
41  auto lambda = [&lesionUID](const SemanticTypes::Lesion& currentLesion)
42  {
43  return currentLesion.UID == lesionUID;
44  };
45 
47  const auto existingLesion = std::find_if(allLesions.begin(), allLesions.end(), lambda);
48 
49  SemanticTypes::Lesion lesion;
50  if (existingLesion != allLesions.end())
51  {
52  lesion = *existingLesion;
53  }
54 
55  return lesion;
56 }
57 
59 {
60  auto lambda = [&lesionClassType](const SemanticTypes::LesionClass& currentLesionClass)
61  {
62  return currentLesionClass.classType == lesionClassType;
63  };
64 
66  const auto existingLesionClass = std::find_if(allLesionClasses.begin(), allLesionClasses.end(), lambda);
67 
68  SemanticTypes::LesionClass lesionClass;
69  if (existingLesionClass != allLesionClasses.end())
70  {
71  lesionClass = *existingLesionClass;
72  }
73 
74  return lesionClass;
75 }
76 
78 {
79  std::vector<bool> lesionPresence;
80  auto lesion = lesionData.GetLesion();
81  bool presence = false;
82  auto controlPoints = RelationStorage::GetAllControlPointsOfCase(caseID);
83  // sort the vector of control points for the timeline
84  std::sort(controlPoints.begin(), controlPoints.end());
85  for (const auto& controlPoint : controlPoints)
86  {
87  try
88  {
89  presence = SemanticRelationsInference::IsLesionPresentAtControlPoint(caseID, lesion, controlPoint);
90  }
92  {
93  presence = false;
94  }
95 
96  lesionPresence.push_back(presence);
97  }
98 
99  lesionData.SetLesionPresence(lesionPresence);
100 }
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::LesionClass GenerateNewLesionClass(const std::string &lesionClassType="")
Generate a new lesion class with UID and the given string as lesion class type.
MITKSEMANTICRELATIONS_EXPORT void ComputeLesionPresence(LesionData &lesionData, const SemanticTypes::CaseID &caseID)
Compute and store lesion presence for all available control points and information types...
std::vector< LesionClass > LesionClassVector
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::LesionClassVector GetAllLesionClassesOfCase(const SemanticTypes::CaseID &caseID)
Return a vector of lesion classes that are currently available for the given case.
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...
void SetLesionPresence(const std::vector< bool > &lesionPresence)
SemanticTypes::Lesion GetLesion() const
std::vector< Lesion > LesionVector
This class holds the data of each lesion in the lesion tree view. The data is the lesion itself with ...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::LesionVector GetAllLesionsOfCase(const SemanticTypes::CaseID &caseID)
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.
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::LesionClass FindExistingLesionClass(const SemanticTypes::CaseID &caseID, const std::string &lesionClassType)
Find and return the whole lesion class including its UID given a specific lesion class type...
MITKSEMANTICRELATIONS_EXPORT std::string GenerateUID()
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::Lesion GetLesionByUID(const SemanticTypes::CaseID &caseID, const SemanticTypes::ID &lesionUID)
Find and return a whole lesion including its lesion class given a specific lesion UID...
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPointVector GetAllControlPointsOfCase(const SemanticTypes::CaseID &caseID)