Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkDiffusionCoreIOActivator.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #include <usModuleActivator.h>
17 #include <usModuleContext.h>
18 
23 
28 
30 
31 #include <mitkCoreServices.h>
34 
36 
37 namespace mitk
38 {
42  class DiffusionCoreIOActivator : public us::ModuleActivator
43  {
44  public:
45 
46  void Load(us::ModuleContext* context) override
47  {
50 
52  for (std::vector<mitk::CustomMimeType*>::const_iterator mimeTypeIter = m_MimeTypes.begin(),
53  iterEnd = m_MimeTypes.end(); mimeTypeIter != iterEnd; ++mimeTypeIter)
54  {
55  context->RegisterService(*mimeTypeIter, props);
56  }
57 
58  m_DiffusionImageNrrdReaderService = new DiffusionImageNrrdReaderService();
59  m_DiffusionImageNiftiReaderService = new DiffusionImageNiftiReaderService();
60  m_NrrdTensorImageReader = new NrrdTensorImageReader();
61  m_NrrdQBallImageReader = new NrrdQBallImageReader();
62 
63  m_DiffusionImageNrrdWriterService = new DiffusionImageNrrdWriterService();
64  m_DiffusionImageNiftiWriterService = new DiffusionImageNiftiWriterService();
65  m_NrrdTensorImageWriter = new NrrdTensorImageWriter();
66  m_NrrdQBallImageWriter = new NrrdQBallImageWriter();
67 
68  //register relevant properties
69  //non-persistent properties
70  mitk::CoreServices::GetPropertyDescriptions()->AddDescription(mitk::DiffusionPropertyHelper::BVALUEMAPPROPERTYNAME, "This map stores which b values belong to which gradients.");
71  mitk::CoreServices::GetPropertyDescriptions()->AddDescription(mitk::DiffusionPropertyHelper::ORIGINALGRADIENTCONTAINERPROPERTYNAME, "The original gradients used during acquisition. This property may be empty.");
72  //persistent properties
76  mitk::CoreServices::GetPropertyDescriptions()->AddDescription(mitk::DiffusionPropertyHelper::MODALITY, "Defines the modality used for acquisition. DWMRI signifies diffusion weighted images.");
77 
79  PPI_referenceBValue->SetNameAndKey(mitk::DiffusionPropertyHelper::REFERENCEBVALUEPROPERTYNAME, "DWMRI_b-value");
81  PPI_measurementFrame->SetNameAndKey(mitk::DiffusionPropertyHelper::MEASUREMENTFRAMEPROPERTYNAME, "measurement frame");
83  PPI_gradientContainer->SetNameAndKey(mitk::DiffusionPropertyHelper::GRADIENTCONTAINERPROPERTYNAME, "DWMRI_gradient");
85  PPI_modality->SetNameAndKey(mitk::DiffusionPropertyHelper::MODALITY, "modality");
86 
87  mitk::CoreServices::GetPropertyPersistence()->AddInfo(PPI_referenceBValue.GetPointer() , true);
88  mitk::CoreServices::GetPropertyPersistence()->AddInfo(PPI_measurementFrame.GetPointer(), true);
89  mitk::CoreServices::GetPropertyPersistence()->AddInfo(PPI_gradientContainer.GetPointer(), true);
90  mitk::CoreServices::GetPropertyPersistence()->AddInfo(PPI_modality.GetPointer(), true);
91  }
92 
93  void Unload(us::ModuleContext*) override
94  {
95  for (unsigned int loop(0); loop < m_MimeTypes.size(); ++loop)
96  {
97  delete m_MimeTypes.at(loop);
98  }
99 
100  delete m_DiffusionImageNrrdReaderService;
101  delete m_DiffusionImageNiftiReaderService;
102  delete m_NrrdTensorImageReader;
103  delete m_NrrdQBallImageReader;
104 
105  delete m_DiffusionImageNrrdWriterService;
106  delete m_DiffusionImageNiftiWriterService;
107  delete m_NrrdTensorImageWriter;
108  delete m_NrrdQBallImageWriter;
109  }
110 
111  private:
112 
113  DiffusionImageNrrdReaderService * m_DiffusionImageNrrdReaderService;
114  DiffusionImageNiftiReaderService * m_DiffusionImageNiftiReaderService;
115  NrrdTensorImageReader * m_NrrdTensorImageReader;
116  NrrdQBallImageReader * m_NrrdQBallImageReader;
117 
118  DiffusionImageNrrdWriterService * m_DiffusionImageNrrdWriterService;
119  DiffusionImageNiftiWriterService * m_DiffusionImageNiftiWriterService;
120  NrrdTensorImageWriter * m_NrrdTensorImageWriter;
121  NrrdQBallImageWriter * m_NrrdQBallImageWriter;
122 
123  std::vector<mitk::CustomMimeType*> m_MimeTypes;
124 
125  };
126 }
127 
128 US_EXPORT_MODULE_ACTIVATOR(mitk::DiffusionCoreIOActivator)
static const std::string REFERENCEBVALUEPROPERTYNAME
virtual bool AddDescription(const std::string &propertyName, const std::string &description, const std::string &className="", bool overwrite=false)=0
Add a description for a specific property.
US_Core_EXPORT const std::string & SERVICE_RANKING()
DataCollection - Class to facilitate loading/accessing structured data.
virtual void Unload(ModuleContext *context)=0
static IPropertyDescriptions * GetPropertyDescriptions(us::ModuleContext *context=us::GetModuleContext())
Get an IPropertyDescriptions instance.
static const std::string MEASUREMENTFRAMEPROPERTYNAME
static IPropertyPersistence * GetPropertyPersistence(us::ModuleContext *context=us::GetModuleContext())
Get an IPropertyPersistence instance.
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
static std::vector< CustomMimeType * > Get()
virtual bool AddInfo(const PropertyPersistenceInfo *info, bool overwrite=false)=0
Add persistence info for a specific base data property. If there is already a property info instance ...
static const std::string GRADIENTCONTAINERPROPERTYNAME
static const std::string BVALUEMAPPROPERTYNAME
virtual void Load(ModuleContext *context)=0
US_EXPORT_MODULE_ACTIVATOR(mitk::SimulationActivator)
static const std::string ORIGINALGRADIENTCONTAINERPROPERTYNAME