23 #include <itkComposeImageFilter.h>
46 m_DataVector.push_back(data.GetPointer());
47 m_NameVector.push_back(name);
48 m_FilePathVector.push_back(filePath);
49 size_t lastIndex = m_DataVector.size()-1;
50 m_DataNames[name] = lastIndex;
68 if (index >= m_FilePathVector.size())
69 mitkThrow() <<
"No element with the given index";
70 return m_FilePathVector[index];
80 index = m_DataNames.at(name);
84 mitkThrow() <<
"No element with the given name: " << name;
92 if (index >= m_NameVector.size())
94 MITK_ERROR <<
"DataCollection Index does not exist";
95 mitkThrow() <<
"No element with the given index";
97 return m_NameVector[index];
103 bool isInside = (m_DataNames.find(name) != m_DataNames.end());
110 if (index >= m_NameVector.size())
118 return m_DataVector.size();
124 if (!HasElement(index))
125 mitkThrow() <<
"Unkown index. No Element with the given index";
131 m_DataVector[index] = data;
137 SetData(data, NameToIndex(name));
143 if (!HasElement(index))
144 mitkThrow() <<
"Unkown index. No Element with the given index";
146 return m_DataVector[index];
152 return GetData(NameToIndex(name));
155 template <
typename TPixel>
159 if (mitkImage.IsNull())
162 if (itkImage.IsNotNull())
167 if (mitkImage.IsNull())
170 if (itkImage.IsNotNull())
182 itk::DataObject* itkData =
GetData(index).GetPointer();
186 mitkImage = ConvertItkObjectToMitkImage<double>(itkData, mitkImage);
187 mitkImage = ConvertItkObjectToMitkImage<float>(itkData, mitkImage);
188 mitkImage = ConvertItkObjectToMitkImage<unsigned char>(itkData, mitkImage);
189 mitkImage = ConvertItkObjectToMitkImage<signed char>(itkData, mitkImage);
190 mitkImage = ConvertItkObjectToMitkImage<unsigned short>(itkData, mitkImage);
191 mitkImage = ConvertItkObjectToMitkImage<signed short>(itkData, mitkImage);
192 mitkImage = ConvertItkObjectToMitkImage<unsigned int>(itkData, mitkImage);
193 mitkImage = ConvertItkObjectToMitkImage<signed int>(itkData, mitkImage);
194 mitkImage = ConvertItkObjectToMitkImage<unsigned long>(itkData, mitkImage);
195 mitkImage = ConvertItkObjectToMitkImage<signed long>(itkData, mitkImage);
203 return GetMitkImage(NameToIndex(name));
206 template <
class ImageType>
214 else if (NULL != dynamic_cast<ImageType*>(
GetData(index)))
218 template <
class ImageType>
226 else if (NULL != dynamic_cast<ImageType*> (
GetData(NameToIndex(name))))
233 return m_DataVector[index];
239 return operator[](NameToIndex(name));
244 m_XMLFile = absoluteXMlFile;
265 std::map<std::string, size_t>::iterator it = m_DataNames.find(m_NameVector[index]);
266 m_DataNames.erase(it);
267 m_DataNames[name] = index;
268 m_NameVector[index] = name;
274 if (!HasElement(index))
277 m_DataVector.erase(m_DataVector.begin() + index);
278 m_NameVector.erase(m_NameVector.begin() + index);
279 m_FilePathVector.erase(m_FilePathVector.begin() + index);
282 for (
size_t i = 0; i < m_NameVector.size(); ++i)
284 m_DataNames[m_NameVector[i]] = i;
292 if (!HasElement(name))
295 return RemoveIndex(NameToIndex(name));
300 for (std::vector<itk::DataObject::Pointer>::iterator it = m_DataVector.begin(); it != m_DataVector.end(); ++it)
346 node->SetName(IndexToName(index));
354 return GetDataNode(NameToIndex(name));
361 typedef itk::ComposeImageFilter<ImageType, VectorImageType> ComposeFilterType;
365 for (std::vector<std::string>::iterator it = probabilityNamesVector.begin(); it != probabilityNamesVector.end(); ++it)
367 ImageType* img =
dynamic_cast<ImageType*
>(this->
GetData((*it)).GetPointer());
370 composer->SetInput(i, img);
378 probImage->InitializeByItk(vecImage.GetPointer(), vecImage->GetNumberOfComponentsPerPixel());
379 probImage->SetVolume(vecImage->GetBufferPointer());
mitk::DataNode::Pointer GetDataNode(vcl_size_t index)
GetDataNode - returns data node containing data at index.
itk::SmartPointer< Self > Pointer
virtual void SetRequestedRegion(const itk::DataObject *)
Set the requested region from this data object to match the requested region of the data object passe...
void Init(std::string name)
Base of all data objects.
vcl_size_t Size() const
Size - number of data items in collection.
vcl_size_t AddData(DataObject::Pointer data, std::string name, std::string filePath="")
AddData Add a data item.
bool RemoveIndex(vcl_size_t index)
RemoveIndex - removes element at index.
std::string GetName() const
vcl_size_t NameToIndex(std::string name)
NameToIndex - Get index from data item name.
mitk::Image::Pointer GetMitkImage(vcl_size_t index)
GetMitkImage - casts data to mitk::Image and returns it.
mitk::DataCollection * GetParent()
GetParent - returns the parent collection if available else null is returned.
void SetXMLFile(std::string absoluteXMlFile)
SetXMLFile - sets xml file to which data collection is saved.
void SetData(itk::DataObject::Pointer data, vcl_size_t index)
SetData - set/update data item by index.
virtual ~DataCollection()
virtual bool VerifyRequestedRegion()
Verify that the RequestedRegion is within the LargestPossibleRegion.
T::Pointer GetData(const std::string &name)
mitk::Image::Pointer ConvertItkObjectToMitkImage(itk::DataObject *itkData, mitk::Image::Pointer mitkImage)
bool HasElement(std::string name)
HasElement - check if element with this name exists in collection.
map::core::discrete::Elements< 3 >::InternalImageType ImageType
virtual void SetRequestedRegionToLargestPossibleRegion()
Set the RequestedRegion to the LargestPossibleRegion.
virtual void UpdateOutputInformation()
std::string IndexToName(vcl_size_t index) const
IndexToName - Get name from index.
Image class for storing images.
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
Determine whether the RequestedRegion is outside of the BufferedRegion.
void SetNameForIndex(vcl_size_t index, std::string &name)
SetNameForIndex - sets name for given data item by index.
bool RemoveElement(std::string &name)
RemoveElement - removes element with name.
ImageType GetItkImage(vcl_size_t index, ImageType *itkImage)
GetMitkImage - casts data to privided itk::Image pointer.
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
void SetName(std::string name)
SetName - Sets name of DataCollection.
std::string GetXMLFile()
SetXMLFile - gets xml file to which data collection is supposed to be saved.
void Clear()
Clear - clears the data collection.
itk::DataObject::Pointer GetData(vcl_size_t index)
GetData Get original data by index.
std::string GetDataFilePath(vcl_size_t index) const
itk::DataObject::Pointer & operator[](vcl_size_t index)
mitk::Image::Pointer GetProbabilityMap(std::vector< std::string > probabilityNamesVector)
GetProbabilityMap - returns vectorimage generated out of images with names in the probabilityNamesVec...
void SetParent(mitk::DataCollection *parent)
SetParent - sets the parent collection.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.