Slicer 5.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkSlicerTerminologiesModuleLogic.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
6 Queen's University, Kingston, ON, Canada. All Rights Reserved.
7
8 See COPYRIGHT.txt
9 or http://www.slicer.org/copyright/copyright.txt for details.
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 This file was originally developed by Csaba Pinter, PerkLab, Queen's University
18 and was supported through the Applied Cancer Research Unit program of Cancer Care
19 Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
20
21==============================================================================*/
22
23#ifndef __vtkSlicerTerminologiesModuleLogic_h
24#define __vtkSlicerTerminologiesModuleLogic_h
25
26// Slicer includes
28
29#include "vtkSlicerTerminologiesModuleLogicExport.h"
30
31#include <vtkVector.h>
32
33class vtkCodedEntry;
34class vtkSegment;
35class vtkStringArray;
39
40class VTK_SLICER_TERMINOLOGIES_LOGIC_EXPORT vtkSlicerTerminologiesModuleLogic :
42{
43public:
46 void PrintSelf(ostream& os, vtkIndent indent) override;
47
50 {
51 public:
53 { };
54 CodeIdentifier(std::string codingSchemeDesignator, std::string codeValue, std::string codeMeaning=std::string())
55 : CodingSchemeDesignator(codingSchemeDesignator)
56 , CodeValue(codeValue)
57 , CodeMeaning(codeMeaning)
58 { };
59 bool IsValid() const
60 {
61 return !CodingSchemeDesignator.empty() && !CodeValue.empty();
62 };
64 std::string CodeValue;
65 std::string CodeMeaning; // Human readable name (not required for ID)
66 };
67
69 static const char* GetNameAutoGeneratedAttributeName() { return "Terminologies.AutoUpdateNodeName"; };
71 static const char* GetColorAutoGeneratedAttributeName() { return "Terminologies.AutoUpdateNodeColor"; };
72
78 bool LoadContextFromFile(std::string filePath);
82 std::string LoadTerminologyFromFile(std::string filePath);
86 std::string LoadAnatomicContextFromFile(std::string filePath);
91 bool LoadTerminologyFromSegmentDescriptorFile(std::string contextName, std::string filePath);
94 bool LoadAnatomicContextFromSegmentDescriptorFile(std::string contextName, std::string filePath);
95
97 void GetLoadedTerminologyNames(std::vector<std::string> &terminologyNames);
99 void GetLoadedTerminologyNames(vtkStringArray* terminologyNames);
101 void GetLoadedAnatomicContextNames(std::vector<std::string> &anatomicContextNames);
103 void GetLoadedAnatomicContextNames(vtkStringArray* anatomicContextNames);
104
109 bool GetCategoriesInTerminology(std::string terminologyName, std::vector<CodeIdentifier>& categories);
114 bool FindCategoriesInTerminology(std::string terminologyName, std::vector<CodeIdentifier>& categories, std::string search);
115
118 std::vector<std::string> FindTerminologyNames(
119 std::string categoryCodingSchemeDesignator, std::string categoryCodeValue,
120 std::string typeCodingSchemeDesignator, std::string typeCodeValue,
121 std::string typeModifierCodingSchemeDesignator, std::string typeModifierCodeValue,
122 std::vector<std::string> preferredTerminologyNames,
123 vtkCollection* foundEntries=nullptr);
124
127 std::vector<std::string> FindAnatomicContextNames(
128 std::string anatomicRegionCodingSchemeDesignator, std::string anatomicRegionCodeValue,
129 std::string anatomicRegionModifierCodingSchemeDesignator, std::string anatomicRegionModifierCodeValue,
130 std::vector<std::string> preferredAnatomicContextNames,
131 vtkCollection* foundEntries=nullptr);
132
136 bool GetCategoryInTerminology(std::string terminologyName, CodeIdentifier categoryId, vtkSlicerTerminologyCategory* categoryObject);
138 int GetNumberOfCategoriesInTerminology(std::string terminologyName);
143 bool GetNthCategoryInTerminology(std::string terminologyName, int categoryIndex, vtkSlicerTerminologyCategory* category);
144
149 bool GetTypesInTerminologyCategory(std::string terminologyName, CodeIdentifier categoryId, std::vector<CodeIdentifier>& types);
156 bool FindTypesInTerminologyCategory(std::string terminologyName, CodeIdentifier categoryId, std::vector<CodeIdentifier>& types, std::string search,
157 std::vector<vtkSmartPointer<vtkSlicerTerminologyType>>* typeObjects=nullptr);
161 bool GetTypeInTerminologyCategory(std::string terminologyName, CodeIdentifier categoryId, CodeIdentifier typeId, vtkSlicerTerminologyType* typeObject);
163 int GetNumberOfTypesInTerminologyCategory(std::string terminologyName, vtkSlicerTerminologyCategory* category);
170 bool GetNthTypeInTerminologyCategory(std::string terminologyName, vtkSlicerTerminologyCategory* category, int typeIndex, vtkSlicerTerminologyType* type);
171
176 bool GetTypeModifiersInTerminologyType(std::string terminologyName, CodeIdentifier categoryId, CodeIdentifier typeId, std::vector<CodeIdentifier>& typeModifiers);
180 bool GetTypeModifierInTerminologyType(std::string terminologyName,
181 CodeIdentifier categoryId, CodeIdentifier typeId, CodeIdentifier modifierId, vtkSlicerTerminologyType* typeModifier);
191 bool GetNthTypeModifierInTerminologyType(std::string terminologyName, vtkSlicerTerminologyCategory* category, vtkSlicerTerminologyType* type, int typeModifierIndex, vtkSlicerTerminologyType* typeModifier);
192
197 bool GetRegionsInAnatomicContext(std::string anatomicContextName, std::vector<CodeIdentifier>& regions);
200 int GetNumberOfRegionsInAnatomicContext(std::string anatomicContextName);
207 bool GetNthRegionInAnatomicContext(std::string anatomicContextName, int regionIndex, vtkSlicerTerminologyType* regionObject);
208
211 bool FindRegionsInAnatomicContext(std::string anatomicContextName, std::vector<CodeIdentifier>& regions, std::string search);
215 bool GetRegionInAnatomicContext(std::string anatomicContextName, CodeIdentifier regionId, vtkSlicerTerminologyType* regionObject);
216
221 bool GetRegionModifiersInAnatomicRegion(std::string anatomicContextName, CodeIdentifier regionId, std::vector<CodeIdentifier>& regionModifiers);
225 bool GetRegionModifierInAnatomicRegion(std::string anatomicContextName,
226 CodeIdentifier regionId, CodeIdentifier modifierId, vtkSlicerTerminologyType* regionModifier);
229 int GetNumberOfRegionModifierInAnatomicRegion(std::string anatomicContextName, vtkSlicerTerminologyType* regionObject);
237 bool GetNthRegionModifierInAnatomicRegion(std::string anatomicContextName, vtkSlicerTerminologyType* regionObject,
238 int regionModifierIndex, vtkSlicerTerminologyType* regionModifier);
239
245 bool FindTypeInTerminologyBy3dSlicerLabel(std::string terminologyName, std::string slicerLabel, vtkSlicerTerminologyEntry* entry);
246
249
254
258 static std::string SerializeTerminologyEntry(
259 std::string terminologyContextName,
260 std::string categoryValue, std::string categorySchemeDesignator, std::string categoryMeaning,
261 std::string typeValue, std::string typeSchemeDesignator, std::string typeMeaning,
262 std::string modifierValue, std::string modifierSchemeDesignator, std::string modifierMeaning,
263 std::string anatomicContextName,
264 std::string regionValue, std::string regionSchemeDesignator, std::string regionMeaning,
265 std::string regionModifierValue, std::string regionModifierSchemeDesignator, std::string regionModifierMeaning );
266
271 bool DeserializeTerminologyEntry(std::string serializedEntry, vtkSlicerTerminologyEntry* entry);
272
277
280
284 // These functions are not static because in the future conversion may involve translation tables.
285 // (that allows comparing of terms between different coding schemes)
288 bool AreTerminologyEntriesEqual(std::string terminologyEntry1, std::string terminologyEntry2);
289 bool AreCodedEntriesEqual(vtkCodedEntry* codedEntry1, vtkCodedEntry* codedEntry2);
291
292public:
293 vtkGetStringMacro(UserContextsPath);
294 vtkSetStringMacro(UserContextsPath);
295
296protected:
299
300 void SetMRMLSceneInternal(vtkMRMLScene* newScene) override;
301
308
309protected:
311 char* UserContextsPath{nullptr};
312
313private:
315 void operator=(const vtkSlicerTerminologiesModuleLogic&) = delete;
316
317 class vtkInternal;
318 vtkInternal* Internal;
319 friend class vtkInternal;
320};
321
322#endif
Simple class for storing standard coded entries (coding scheme, value, meaning triplets)
A set of MRML Nodes that supports serialization and undo/redo.
This class encapsulates a segment that is part of a segmentation.
Definition vtkSegment.h:45
Information needed to uniquely identify a terminology code.
CodeIdentifier(std::string codingSchemeDesignator, std::string codeValue, std::string codeMeaning=std::string())
bool AreSegmentTerminologyEntriesEqual(vtkSegment *segment1, vtkSegment *segment2)
void GetLoadedAnatomicContextNames(std::vector< std::string > &anatomicContextNames)
Get context names of loaded anatomic contexts.
bool GetTypeModifiersInTerminologyType(std::string terminologyName, CodeIdentifier categoryId, CodeIdentifier typeId, std::vector< CodeIdentifier > &typeModifiers)
bool GetCategoryInTerminology(std::string terminologyName, CodeIdentifier categoryId, vtkSlicerTerminologyCategory *categoryObject)
void GetLoadedTerminologyNames(vtkStringArray *terminologyNames)
Python accessor variant of.
static std::string SerializeTerminologyEntry(vtkSlicerTerminologyEntry *entry)
bool LoadAnatomicContextFromSegmentDescriptorFile(std::string contextName, std::string filePath)
void PrintSelf(ostream &os, vtkIndent indent) override
bool GetRegionInAnatomicContext(std::string anatomicContextName, CodeIdentifier regionId, vtkSlicerTerminologyType *regionObject)
static vtkSlicerTerminologiesModuleLogic * New()
bool AreTerminologyEntriesEqual(std::string terminologyEntry1, std::string terminologyEntry2)
int GetNumberOfTypeModifiersInTerminologyType(std::string terminologyName, vtkSlicerTerminologyCategory *category, vtkSlicerTerminologyType *type)
Get number of type modifiers for the chosen category and type in a terminology.
bool FindRegionsInAnatomicContext(std::string anatomicContextName, std::vector< CodeIdentifier > &regions, std::string search)
bool GetNthTypeInTerminologyCategory(std::string terminologyName, vtkSlicerTerminologyCategory *category, int typeIndex, vtkSlicerTerminologyType *type)
static const char * GetColorAutoGeneratedAttributeName()
Node attribute name for color auto generated.
bool GetCategoriesInTerminology(std::string terminologyName, std::vector< CodeIdentifier > &categories)
bool GetNthRegionInAnatomicContext(std::string anatomicContextName, int regionIndex, vtkSlicerTerminologyType *regionObject)
bool GetRegionModifiersInAnatomicRegion(std::string anatomicContextName, CodeIdentifier regionId, std::vector< CodeIdentifier > &regionModifiers)
std::vector< std::string > FindAnatomicContextNames(std::string anatomicRegionCodingSchemeDesignator, std::string anatomicRegionCodeValue, std::string anatomicRegionModifierCodingSchemeDesignator, std::string anatomicRegionModifierCodeValue, std::vector< std::string > preferredAnatomicContextNames, vtkCollection *foundEntries=nullptr)
bool FindTypesInTerminologyCategory(std::string terminologyName, CodeIdentifier categoryId, std::vector< CodeIdentifier > &types, std::string search, std::vector< vtkSmartPointer< vtkSlicerTerminologyType > > *typeObjects=nullptr)
int GetNumberOfCategoriesInTerminology(std::string terminologyName)
Get number of categories in a terminology.
bool GetTypesInTerminologyCategory(std::string terminologyName, CodeIdentifier categoryId, std::vector< CodeIdentifier > &types)
int GetNumberOfTypesInTerminologyCategory(std::string terminologyName, vtkSlicerTerminologyCategory *category)
Get number of types in the chosen category in a terminology.
bool FindCategoriesInTerminology(std::string terminologyName, std::vector< CodeIdentifier > &categories, std::string search)
bool AreTerminologyEntriesEqual(vtkSlicerTerminologyEntry *entry1, vtkSlicerTerminologyEntry *entry2)
void LoadUserContexts()
Load terminologies and anatomic contexts from the user settings directory.
std::string LoadTerminologyFromFile(std::string filePath)
void LoadDefaultAnatomicContexts()
Load default anatomic context dictionaries from JSON into.
bool FindTypeInTerminologyBy3dSlicerLabel(std::string terminologyName, std::string slicerLabel, vtkSlicerTerminologyEntry *entry)
void GetLoadedAnatomicContextNames(vtkStringArray *anatomicContextNames)
Python accessor variant of.
bool DeserializeTerminologyEntry(std::string serializedEntry, vtkSlicerTerminologyEntry *entry)
void GetLoadedTerminologyNames(std::vector< std::string > &terminologyNames)
Get context names of loaded terminologies.
bool GetNthCategoryInTerminology(std::string terminologyName, int categoryIndex, vtkSlicerTerminologyCategory *category)
static CodeIdentifier GetCodeIdentifierFromCodedEntry(vtkCodedEntry *entry)
Convert terminology category, type, etc. object to code identifier.
static std::string GetInfoStringFromTerminologyEntry(vtkSlicerTerminologyEntry *entry)
Assemble human readable info string from a terminology entry, for example for tooltips.
bool GetTypeModifierInTerminologyType(std::string terminologyName, CodeIdentifier categoryId, CodeIdentifier typeId, CodeIdentifier modifierId, vtkSlicerTerminologyType *typeModifier)
int GetNumberOfRegionsInAnatomicContext(std::string anatomicContextName)
bool GetNthTypeModifierInTerminologyType(std::string terminologyName, vtkSlicerTerminologyCategory *category, vtkSlicerTerminologyType *type, int typeModifierIndex, vtkSlicerTerminologyType *typeModifier)
void SetMRMLSceneInternal(vtkMRMLScene *newScene) override
static const char * GetNameAutoGeneratedAttributeName()
Node attribute name for name auto generated.
std::string LoadAnatomicContextFromFile(std::string filePath)
bool GetTypeInTerminologyCategory(std::string terminologyName, CodeIdentifier categoryId, CodeIdentifier typeId, vtkSlicerTerminologyType *typeObject)
bool LoadContextFromFile(std::string filePath)
std::vector< std::string > FindTerminologyNames(std::string categoryCodingSchemeDesignator, std::string categoryCodeValue, std::string typeCodingSchemeDesignator, std::string typeCodeValue, std::string typeModifierCodingSchemeDesignator, std::string typeModifierCodeValue, std::vector< std::string > preferredTerminologyNames, vtkCollection *foundEntries=nullptr)
static std::string SerializeTerminologyEntry(std::string terminologyContextName, std::string categoryValue, std::string categorySchemeDesignator, std::string categoryMeaning, std::string typeValue, std::string typeSchemeDesignator, std::string typeMeaning, std::string modifierValue, std::string modifierSchemeDesignator, std::string modifierMeaning, std::string anatomicContextName, std::string regionValue, std::string regionSchemeDesignator, std::string regionMeaning, std::string regionModifierValue, std::string regionModifierSchemeDesignator, std::string regionModifierMeaning)
bool UpdateEntryFromLoadedTerminologies(vtkSlicerTerminologyEntry *entry)
int GetNumberOfRegionModifierInAnatomicRegion(std::string anatomicContextName, vtkSlicerTerminologyType *regionObject)
bool AreCodedEntriesEqual(vtkCodedEntry *codedEntry1, vtkCodedEntry *codedEntry2)
bool GetRegionsInAnatomicContext(std::string anatomicContextName, std::vector< CodeIdentifier > &regions)
bool LoadTerminologyFromSegmentDescriptorFile(std::string contextName, std::string filePath)
bool GetRegionModifierInAnatomicRegion(std::string anatomicContextName, CodeIdentifier regionId, CodeIdentifier modifierId, vtkSlicerTerminologyType *regionModifier)
bool GetNthRegionModifierInAnatomicRegion(std::string anatomicContextName, vtkSlicerTerminologyType *regionObject, int regionModifierIndex, vtkSlicerTerminologyType *regionModifier)
void LoadDefaultTerminologies()
Load default terminology dictionaries from JSON into.
Terminology property category object.
Terminology property type object.