diff --git a/code/core/rttbMaskAccessorGeneratorBase.h b/code/core/rttbMaskAccessorGeneratorBase.h index df7c5fc..14566f0 100644 --- a/code/core/rttbMaskAccessorGeneratorBase.h +++ b/code/core/rttbMaskAccessorGeneratorBase.h @@ -1,54 +1,53 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 707 $ (last changed revision) // @date $Date: 2014-09-04 16:37:24 +0200 (Do, 04 Sep 2014) $ (last change date) // @author $Author: floca $ (last changed by) */ #ifndef __MASK_ACCESSOR_GENERATOR_BASE_H #define __MASK_ACCESSOR_GENERATOR_BASE_H -#include #include "rttbMaskAccessorGeneratorInterface.h" namespace rttb{ namespace core { /*! @class MaskAccessorGeneratorBase @brief Abstract class for all DoseAccessor generating classes */ class MaskAccessorGeneratorBase: public MaskAccessorGeneratorInterface { public: typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; private: protected: /*! @brief Mask accessor which should be generated */ MaskAccessorPointer _maskAccessor; public: }; } } #endif diff --git a/code/core/rttbMaskAccessorGeneratorInterface.h b/code/core/rttbMaskAccessorGeneratorInterface.h index 2176856..76ff4af 100644 --- a/code/core/rttbMaskAccessorGeneratorInterface.h +++ b/code/core/rttbMaskAccessorGeneratorInterface.h @@ -1,60 +1,59 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 707 $ (last changed revision) // @date $Date: 2014-09-04 16:37:24 +0200 (Do, 04 Sep 2014) $ (last change date) // @author $Author: floca $ (last changed by) */ #ifndef __MASK_ACCESSOR_GENERATOR_INTERFACE_H #define __MASK_ACCESSOR_GENERATOR_INTERFACE_H -#include #include "rttbMaskAccessorInterface.h" namespace rttb{ namespace core { /*! @class MaskAccessorGeneratorInterface @brief Interface for all MaskAccessor generating classes */ class MaskAccessorGeneratorInterface { public: typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; private: MaskAccessorGeneratorInterface(const MaskAccessorGeneratorInterface&); //not implemented on purpose -> non-copyable MaskAccessorGeneratorInterface& operator=(const MaskAccessorGeneratorInterface&);//not implemented on purpose -> non-copyable protected: MaskAccessorGeneratorInterface() {}; virtual ~MaskAccessorGeneratorInterface() {}; public: /*! @brief Generate MaskAccessor @return Return shared pointer of MaskAccessor. */ virtual MaskAccessorPointer generateMaskAccessor() = 0; }; } } #endif diff --git a/code/io/itk/files.cmake b/code/io/itk/files.cmake index d68beb1..5ef2044 100644 --- a/code/io/itk/files.cmake +++ b/code/io/itk/files.cmake @@ -1,23 +1,26 @@ SET(CPP_FILES rttbITKImageDoseAccessor.cpp rttbITKImageFileDoseAccessorGenerator.cpp rttbITKImageDoseAccessorGenerator.cpp rttbGenericImageReader.cpp rttbFileDispatch.cpp rttbITKImageDoseAccessorConverter.cpp + rttbITKIOHelper.cpp ) SET(H_FILES rttbITKImageDoseAccessor.h rttbITKImageFileDoseAccessorGenerator.h - rttbITKImageFileDoseAccessorGenerator.tpp rttbITKImageDoseAccessorGenerator.h rttbGenericImageReader.h rttbImageReader.h rttbImageReader.tpp rttbFileDispatch.h rttbITKImageDoseAccessorConverter.h rttbDoseAccessorProcessorInterface.h rttbDoseAccessorProcessorBase.h rttbDoseAccessorConversionSettingInterface.h + rttbITKIOHelper.h + rttbITKIOHelper.tpp + ) diff --git a/code/io/itk/rttbITKImageFileDoseAccessorGenerator.cpp b/code/io/itk/rttbITKIOHelper.cpp similarity index 52% copy from code/io/itk/rttbITKImageFileDoseAccessorGenerator.cpp copy to code/io/itk/rttbITKIOHelper.cpp index 0207007..5ad1001 100644 --- a/code/io/itk/rttbITKImageFileDoseAccessorGenerator.cpp +++ b/code/io/itk/rttbITKIOHelper.cpp @@ -1,177 +1,168 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file -// @version $Revision$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @version $Revision: 793 $ (last changed revision) +// @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ -#include -#include -#include "rttbITKImageFileDoseAccessorGenerator.h" +#include "rttbITKIOHelper.h" #include "rttbException.h" #include "rttbInvalidDoseException.h" #include "rttbInvalidParameterException.h" namespace rttb { namespace io { namespace itk { - ITKImageFileDoseAccessorGenerator::~ITKImageFileDoseAccessorGenerator() - { - - } - ITKImageFileDoseAccessorGenerator::ITKImageFileDoseAccessorGenerator(const FileNameType& fileName) - { - _dicomDoseFileName = fileName; - } + ITKDoseImageType::Pointer readITKDoubleImage(FileNameType aITKImageFile){ + ITKDoseImageType::Pointer itkDoubleImage; - rttb::core::DoseAccessorGeneratorBase::DoseAccessorPointer - ITKImageFileDoseAccessorGenerator::generateDoseAccessor() - { GenericImageReader::Pointer spReader = GenericImageReader::New(); - spReader->setFileName(_dicomDoseFileName); + spReader->setFileName(aITKImageFile); GenericImageReader::GenericOutputImageType::Pointer itkGenericImage; ITKDoseImageType::ConstPointer itkDoubleImageConst; try { unsigned int loadedDimensions; GenericImageReader::LoadedPixelType loadedPixelType; GenericImageReader::LoadedComponentType loadedComponentType; itkGenericImage = spReader->GetOutput(loadedDimensions, loadedPixelType, loadedComponentType); if (loadedDimensions != 3) { throw core::InvalidParameterException("image dimensions != 3. Only dim = 3 supported."); } if (loadedPixelType != ::itk::ImageIOBase::SCALAR) { throw core::InvalidParameterException("image component type != SCALAR. Only SCALAR supported."); } if (loadedComponentType == ::itk::ImageIOBase::DOUBLE) { - _itkDoubleImage = dynamic_cast(itkGenericImage.GetPointer()); + itkDoubleImage = dynamic_cast(itkGenericImage.GetPointer()); } else { - handleGenericImage(itkGenericImage, loadedComponentType); + itkDoubleImage = handleGenericImage(itkGenericImage, loadedComponentType); } - if (_itkDoubleImage.IsNull()) + if (itkDoubleImage.IsNull()) { throw core::InvalidDoseException("Error!!! unable to load input image. File is not existing or has an unsupported format."); - return core::DoseAccessorGeneratorInterface::DoseAccessorPointer(); } } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; throw rttb::core::InvalidDoseException(e.GetDescription()); - return core::DoseAccessorGeneratorInterface::DoseAccessorPointer(); } - _doseAccessor = boost::make_shared(_itkDoubleImage.GetPointer()); - return _doseAccessor; + return itkDoubleImage; } - void ITKImageFileDoseAccessorGenerator::handleGenericImage( - GenericImageReader::GenericOutputImageType* itkGenericImage, - ::itk::ImageIOBase::IOComponentType& loadedComponentType) + ITKDoseImageType::Pointer handleGenericImage( + GenericImageReader::GenericOutputImageType* itkGenericImage, + ::itk::ImageIOBase::IOComponentType& loadedComponentType) { + ITKDoseImageType::Pointer itkDoubleImage; + switch (loadedComponentType) { - case ::itk::ImageIOBase::UCHAR: + case ::itk::ImageIOBase::UCHAR: { - doCasting(itkGenericImage); + itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::CHAR: + case ::itk::ImageIOBase::CHAR: { - doCasting(itkGenericImage); + itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::USHORT: + case ::itk::ImageIOBase::USHORT: { - doCasting(itkGenericImage); + itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::SHORT: + case ::itk::ImageIOBase::SHORT: { - doCasting(itkGenericImage); + itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::UINT: + case ::itk::ImageIOBase::UINT: { - doCasting(itkGenericImage); + itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::INT: + case ::itk::ImageIOBase::INT: { - doCasting(itkGenericImage); + itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::ULONG: + case ::itk::ImageIOBase::ULONG: { - doCasting(itkGenericImage); + itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::LONG: + case ::itk::ImageIOBase::LONG: { - doCasting(itkGenericImage); + itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::FLOAT: + case ::itk::ImageIOBase::FLOAT: { - doCasting(itkGenericImage); + itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::DOUBLE: + case ::itk::ImageIOBase::DOUBLE: { - doCasting(itkGenericImage); + itkDoubleImage = doCasting(itkGenericImage); break; } - default: + default: { throw core::InvalidParameterException("image type unknown"); } } + return itkDoubleImage; } + + }//end namespace itk }//end namespace io }//end namespace rttb diff --git a/code/io/itk/rttbITKIOHelper.h b/code/io/itk/rttbITKIOHelper.h new file mode 100644 index 0000000..7b4069b --- /dev/null +++ b/code/io/itk/rttbITKIOHelper.h @@ -0,0 +1,64 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ +/*! +// @file +// @version $Revision: 793 $ (last changed revision) +// @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) +// @author $Author: hentsch $ (last changed by) +*/ +#ifndef __ITK_IO_HELPER_H +#define __ITK_IO_HELPER_H + +#include "rttbDoseAccessorGeneratorBase.h" +#include "rttbBaseType.h" +#include "rttbITKImageDoseAccessor.h" +#include "rttbGenericImageReader.h" + +#include "itkImage.h" +#include "itkCastImageFilter.h" + + +namespace rttb +{ + namespace io + { + namespace itk + { + + /*! @brief Read a itk image file into itkImage + */ + ITKDoseImageType::Pointer readITKDoubleImage(FileNameType aITKImageFile); + + /*! @brief Converts a generic image to itkImage + @param itkGenericImage the image read by GenericImageReader + @param loadedComponentType the component type (used for casting later on) + @exception InvalidParameterException if component type is not supported + @sa GenericImageReader + */ + ITKDoseImageType::Pointer handleGenericImage(GenericImageReader::GenericOutputImageType* itkGenericImage, + ::itk::ImageIOBase::IOComponentType& loadedComponentType); + + /*! @brief Casts into itkImage + */ + template ITKDoseImageType::Pointer doCasting(GenericImageReader::GenericOutputImageType* genericImage); + + + }//end namespace itk + }//end namespace io +}//end namespace rttb + +#include "rttbITKIOHelper.tpp" + +#endif diff --git a/code/io/itk/rttbITKImageFileDoseAccessorGenerator.tpp b/code/io/itk/rttbITKIOHelper.tpp similarity index 77% rename from code/io/itk/rttbITKImageFileDoseAccessorGenerator.tpp rename to code/io/itk/rttbITKIOHelper.tpp index 768ee41..83f9171 100644 --- a/code/io/itk/rttbITKImageFileDoseAccessorGenerator.tpp +++ b/code/io/itk/rttbITKIOHelper.tpp @@ -1,64 +1,66 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file -// @version $Revision$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @version $Revision: 793 $ (last changed revision) +// @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) +// @author $Author: hentsch $ (last changed by) // Subversion HeadURL: $HeadURL: https://svn/sbr/Sources/SBR-Projects/MatchPoint/trunk/Code/IO/include/mapImageReader.tpp $ */ #ifndef __RTTB_ITK_IMAGE_FILE_DOSE_ACCESSOR_GENERATOR_TPP #define __RTTB_ITK_IMAGE_FILE_DOSE_ACCESSOR_GENERATOR_TPP #include "rttbITKImageFileDoseAccessorGenerator.h" #include "rttbInvalidParameterException.h" #include "rttbInvalidDoseException.h" #include "rttbITKImageDoseAccessor.h" namespace rttb { namespace io { namespace itk { - template void ITKImageFileDoseAccessorGenerator::doCasting( - GenericImageReader::GenericOutputImageType* genericImage) + template ITKDoseImageType::Pointer doCasting(GenericImageReader::GenericOutputImageType* genericImage) { + ITKDoseImageType::Pointer itkDoubleImage; typedef ::itk::Image InputImageType; typedef ITKDoseImageType OutputImageType; InputImageType::Pointer pCastedInput = dynamic_cast(genericImage); typedef ::itk::CastImageFilter CastFilterType; CastFilterType::Pointer castFilter = CastFilterType::New(); castFilter->SetInput(pCastedInput); try { //important to update the filter! castFilter->Update(); - _itkDoubleImage = castFilter->GetOutput(); + itkDoubleImage = castFilter->GetOutput(); } catch (::itk::ExceptionObject& e) { std::cerr << "ITK Error!!!" << std::endl; std::cerr << e << std::endl; } + + return itkDoubleImage; } } } } #endif diff --git a/code/io/itk/rttbITKImageFileDoseAccessorGenerator.cpp b/code/io/itk/rttbITKImageFileDoseAccessorGenerator.cpp index 0207007..dd9deee 100644 --- a/code/io/itk/rttbITKImageFileDoseAccessorGenerator.cpp +++ b/code/io/itk/rttbITKImageFileDoseAccessorGenerator.cpp @@ -1,177 +1,60 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #include #include #include "rttbITKImageFileDoseAccessorGenerator.h" #include "rttbException.h" #include "rttbInvalidDoseException.h" #include "rttbInvalidParameterException.h" +#include "rttbITKIOHelper.h" namespace rttb { namespace io { namespace itk { ITKImageFileDoseAccessorGenerator::~ITKImageFileDoseAccessorGenerator() { } ITKImageFileDoseAccessorGenerator::ITKImageFileDoseAccessorGenerator(const FileNameType& fileName) { _dicomDoseFileName = fileName; } rttb::core::DoseAccessorGeneratorBase::DoseAccessorPointer ITKImageFileDoseAccessorGenerator::generateDoseAccessor() { - GenericImageReader::Pointer spReader = GenericImageReader::New(); - - spReader->setFileName(_dicomDoseFileName); - - GenericImageReader::GenericOutputImageType::Pointer itkGenericImage; - - ITKDoseImageType::ConstPointer itkDoubleImageConst; - - try - { - unsigned int loadedDimensions; - GenericImageReader::LoadedPixelType loadedPixelType; - GenericImageReader::LoadedComponentType loadedComponentType; - itkGenericImage = spReader->GetOutput(loadedDimensions, loadedPixelType, loadedComponentType); - - if (loadedDimensions != 3) - { - throw core::InvalidParameterException("image dimensions != 3. Only dim = 3 supported."); - } - - if (loadedPixelType != ::itk::ImageIOBase::SCALAR) - { - throw core::InvalidParameterException("image component type != SCALAR. Only SCALAR supported."); - } - - if (loadedComponentType == ::itk::ImageIOBase::DOUBLE) - { - _itkDoubleImage = dynamic_cast(itkGenericImage.GetPointer()); - } - else - { - handleGenericImage(itkGenericImage, loadedComponentType); - } - - if (_itkDoubleImage.IsNull()) - { - throw core::InvalidDoseException("Error!!! unable to load input image. File is not existing or has an unsupported format."); - return core::DoseAccessorGeneratorInterface::DoseAccessorPointer(); - } - } - catch (::itk::ExceptionObject& e) - { - std::cerr << "Error!!!" << std::endl; - std::cerr << e << std::endl; - throw rttb::core::InvalidDoseException(e.GetDescription()); - return core::DoseAccessorGeneratorInterface::DoseAccessorPointer(); - } + _itkDoubleImage = readITKDoubleImage(_dicomDoseFileName); _doseAccessor = boost::make_shared(_itkDoubleImage.GetPointer()); return _doseAccessor; } - void ITKImageFileDoseAccessorGenerator::handleGenericImage( - GenericImageReader::GenericOutputImageType* itkGenericImage, - ::itk::ImageIOBase::IOComponentType& loadedComponentType) - { - switch (loadedComponentType) - { - case ::itk::ImageIOBase::UCHAR: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::CHAR: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::USHORT: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::SHORT: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::UINT: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::INT: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::ULONG: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::LONG: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::FLOAT: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::DOUBLE: - { - doCasting(itkGenericImage); - break; - } - - default: - { - throw core::InvalidParameterException("image type unknown"); - } - } - } }//end namespace itk }//end namespace io }//end namespace rttb diff --git a/code/io/itk/rttbITKImageFileDoseAccessorGenerator.h b/code/io/itk/rttbITKImageFileDoseAccessorGenerator.h index d199284..7edf237 100644 --- a/code/io/itk/rttbITKImageFileDoseAccessorGenerator.h +++ b/code/io/itk/rttbITKImageFileDoseAccessorGenerator.h @@ -1,98 +1,82 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #ifndef __ITK_IMAGE_DOSE_FILE_ACCESSOR_GENERATOR_H #define __ITK_IMAGE_DOSE_FILE_ACCESSOR_GENERATOR_H #include #include #include "rttbDoseAccessorGeneratorBase.h" #include "rttbBaseType.h" #include "rttbITKImageDoseAccessor.h" #include "rttbGenericImageReader.h" #include "itkImage.h" #include "itkCastImageFilter.h" namespace rttb { namespace io { namespace itk { /*! @class ITKImageFileDoseAccessorGenerator @brief Load dose data using the itk loading methods and wraps the resulting itk image in a ITKImageDoseAccessor. * this is normally used if dose distributions are stored in formats like meta image, nrrd... * @note it implies that the dose information is stored in absolute Gy values. */ class ITKImageFileDoseAccessorGenerator: public core::DoseAccessorGeneratorBase { public: typedef DoseAccessorGeneratorBase::DoseAccessorPointer DoseAccessorPointer; private: FileNameType _dicomDoseFileName; /** @brief The dose as itkImage */ ITKDoseImageType::Pointer _itkDoubleImage; ITKImageFileDoseAccessorGenerator(); - /*! @brief Casts into itkImage - @details result is stored into _itkDoubleImage - */ - template void doCasting(GenericImageReader::GenericOutputImageType* - genericImage); - - /*! @brief Converts a generic image to itkImage - @param itkGenericImage the image read by GenericImageReader - @param loadedComponentType the component type (used for casting later on) - @exception InvalidParameterException if component type is not supported - @sa GenericImageReader - */ - void handleGenericImage(GenericImageReader::GenericOutputImageType* itkGenericImage, - ::itk::ImageIOBase::IOComponentType& loadedComponentType); - - + public: ~ITKImageFileDoseAccessorGenerator(); ITKImageFileDoseAccessorGenerator(const FileNameType& fileName); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. @exception InvalidDoseException Thrown if file could not be read @exception InvalidParameterException Thrown if file has imageDimension !=3 or image component type != SCALAR @details is always converted into a itkImage by using a CastImageFilter @sa doCasting, handleGenericImage */ DoseAccessorPointer generateDoseAccessor(); }; }//end namespace itk }//end namespace io }//end namespace rttb -#include "rttbITKImageFileDoseAccessorGenerator.tpp" #endif diff --git a/code/io/mask/CMakeLists.txt b/code/io/mask/CMakeLists.txt index c200743..403a7de 100644 --- a/code/io/mask/CMakeLists.txt +++ b/code/io/mask/CMakeLists.txt @@ -1 +1 @@ -RTTB_CREATE_MODULE(RTTBMaskIO DEPENDS RTTBCore PACKAGE_DEPENDS Boost MatchPoint ITK) \ No newline at end of file +RTTB_CREATE_MODULE(RTTBMaskIO DEPENDS RTTBCore PACKAGE_DEPENDS Boost ITK) \ No newline at end of file diff --git a/code/io/mask/files.cmake b/code/io/mask/files.cmake index cc37d20..d31bb1a 100644 --- a/code/io/mask/files.cmake +++ b/code/io/mask/files.cmake @@ -1,18 +1,19 @@ SET(CPP_FILES rttbITKImageFileMaskAccessorGenerator.cpp rttbITKImageMaskAccessor.cpp rttbITKImageMaskAccessorGenerator.cpp rttbITKImageMaskAccessorConverter.cpp ) SET(H_FILES rttbITKImageFileMaskAccessorGenerator.h - rttbITKImageFileMaskAccessorGenerator.tpp rttbITKImageMaskAccessor.h rttbITKImageMaskAccessorGenerator.h rttbITKImageMaskAccessorConverter.h rttbMaskAccessorProcessorBase.h rttbMaskAccessorProcessorInterface.h ../itk/rttbImageReader.h ../itk/rttbImageReader.tpp + ../itk/rttbITKIOHelper.h + ../itk/rttbITKIOHelper.tpp ) diff --git a/code/io/mask/rttbITKImageFileMaskAccessorGenerator.cpp b/code/io/mask/rttbITKImageFileMaskAccessorGenerator.cpp index 5ac21e1..6d00481 100644 --- a/code/io/mask/rttbITKImageFileMaskAccessorGenerator.cpp +++ b/code/io/mask/rttbITKImageFileMaskAccessorGenerator.cpp @@ -1,177 +1,59 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include #include #include "rttbITKImageFileMaskAccessorGenerator.h" -#include "rttbException.h" #include "rttbInvalidDoseException.h" #include "rttbInvalidParameterException.h" +#include "../itk/rttbITKIOHelper.h" namespace rttb { namespace io { namespace mask { ITKImageFileMaskAccessorGenerator::~ITKImageFileMaskAccessorGenerator() { } ITKImageFileMaskAccessorGenerator::ITKImageFileMaskAccessorGenerator(const FileNameType& fileName) { _itkMaskFileName = fileName; } rttb::core::MaskAccessorGeneratorBase::MaskAccessorPointer ITKImageFileMaskAccessorGenerator::generateMaskAccessor() - { - io::itk::GenericImageReader::Pointer spReader = io::itk::GenericImageReader::New(); - - spReader->setFileName(_itkMaskFileName); - - io::itk::GenericImageReader::GenericOutputImageType::Pointer itkGenericImage; - - ITKImageMaskAccessor::ITKMaskImageType::ConstPointer itkDoubleImageConst; - - try - { - unsigned int loadedDimensions; - io::itk::GenericImageReader::LoadedPixelType loadedPixelType; - io::itk::GenericImageReader::LoadedComponentType loadedComponentType; - itkGenericImage = spReader->GetOutput(loadedDimensions, loadedPixelType, loadedComponentType); - - if (loadedDimensions != 3) - { - throw core::InvalidParameterException("image dimensions != 3. Only dim = 3 supported."); - } - - if (loadedPixelType != ::itk::ImageIOBase::SCALAR) - { - throw core::InvalidParameterException("image component type != SCALAR. Only SCALAR supported."); - } - - if (loadedComponentType == ::itk::ImageIOBase::DOUBLE) - { - _itkDoubleImage = dynamic_cast(itkGenericImage.GetPointer()); - } - else - { - handleGenericImage(itkGenericImage, loadedComponentType); - } - - if (_itkDoubleImage.IsNull()) - { - throw core::InvalidDoseException("Error!!! unable to load input image. File is not existing or has an unsupported format."); - return core::MaskAccessorGeneratorInterface::MaskAccessorPointer(); - } - } - catch (::itk::ExceptionObject& e) - { - std::cerr << "Error!!!" << std::endl; - std::cerr << e << std::endl; - throw rttb::core::InvalidDoseException(e.GetDescription()); - return core::MaskAccessorGeneratorInterface::MaskAccessorPointer(); - } - + { + _itkDoubleImage = rttb::io::itk::readITKDoubleImage(_itkMaskFileName); + _maskAccessor = boost::make_shared(_itkDoubleImage.GetPointer()); return _maskAccessor; } - void ITKImageFileMaskAccessorGenerator::handleGenericImage( - io::itk::GenericImageReader::GenericOutputImageType* itkGenericImage, - ::itk::ImageIOBase::IOComponentType& loadedComponentType) - { - switch (loadedComponentType) - { - case ::itk::ImageIOBase::UCHAR: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::CHAR: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::USHORT: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::SHORT: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::UINT: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::INT: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::ULONG: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::LONG: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::FLOAT: - { - doCasting(itkGenericImage); - break; - } - - case ::itk::ImageIOBase::DOUBLE: - { - doCasting(itkGenericImage); - break; - } - - default: - { - throw core::InvalidParameterException("image type unknown"); - } - } - } }//end namespace itk }//end namespace io }//end namespace rttb diff --git a/code/io/mask/rttbITKImageFileMaskAccessorGenerator.h b/code/io/mask/rttbITKImageFileMaskAccessorGenerator.h index f057897..9e12307 100644 --- a/code/io/mask/rttbITKImageFileMaskAccessorGenerator.h +++ b/code/io/mask/rttbITKImageFileMaskAccessorGenerator.h @@ -1,97 +1,77 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #ifndef __ITK_IMAGE_MASK_FILE_ACCESSOR_GENERATOR_H #define __ITK_IMAGE_MASK_FILE_ACCESSOR_GENERATOR_H -#include -#include - #include "rttbMaskAccessorGeneratorBase.h" #include "rttbBaseType.h" #include "rttbITKImageMaskAccessor.h" #include "../itk/rttbGenericImageReader.h" #include "itkImage.h" #include "itkCastImageFilter.h" namespace rttb { namespace io { namespace mask { /*! @class ITKImageFileMaskAccessorGenerator - @brief Load Mask data using the itk loading methods and wraps the resulting itk image in a ITKImageMaskAccessor. + @brief Load 3D Mask data using the itk loading methods and wraps the resulting itk image in a ITKImageMaskAccessor. * this is normally used if Mask distributions are stored in formats like meta image, nrrd... */ class ITKImageFileMaskAccessorGenerator: public core::MaskAccessorGeneratorBase { public: typedef MaskAccessorGeneratorBase::MaskAccessorPointer MaskAccessorPointer; private: FileNameType _itkMaskFileName; /** @brief The mask as itkImage */ ITKImageMaskAccessor::ITKMaskImageType::Pointer _itkDoubleImage; ITKImageFileMaskAccessorGenerator(); - /*! @brief Casts into itkImage - @details result is stored into _itkDoubleImage - */ - template void doCasting(rttb::io::itk::GenericImageReader::GenericOutputImageType* - genericImage); - - /*! @brief Converts a generic image to itkImage - @param itkGenericImage the image read by GenericImageReader - @param loadedComponentType the component type (used for casting later on) - @exception InvalidParameterException if component type is not supported - @sa GenericImageReader - */ - void handleGenericImage(rttb::io::itk::GenericImageReader::GenericOutputImageType* itkGenericImage, - ::itk::ImageIOBase::IOComponentType& loadedComponentType); - - public: ~ITKImageFileMaskAccessorGenerator(); ITKImageFileMaskAccessorGenerator(const FileNameType& fileName); /*! @brief Generate MaskAccessor @return Return shared pointer of MaskAccessor. @exception InvalidDoseException Thrown if file could not be read @exception InvalidParameterException Thrown if file has imageDimension !=3 or image component type != SCALAR @details is always converted into a itkImage by using a CastImageFilter @sa doCasting, handleGenericImage */ MaskAccessorPointer generateMaskAccessor(); }; }//end namespace itk }//end namespace io }//end namespace rttb -#include "rttbITKImageFileMaskAccessorGenerator.tpp" #endif diff --git a/code/io/mask/rttbITKImageFileMaskAccessorGenerator.tpp b/code/io/mask/rttbITKImageFileMaskAccessorGenerator.tpp deleted file mode 100644 index d511798..0000000 --- a/code/io/mask/rttbITKImageFileMaskAccessorGenerator.tpp +++ /dev/null @@ -1,64 +0,0 @@ -// ----------------------------------------------------------------------- -// MatchPoint - DKFZ translational registration framework -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See mapCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notices for more information. -// -//------------------------------------------------------------------------ -/*! -// @file -// @version $Revision: 793 $ (last changed revision) -// @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) -// @author $Author: hentsch $ (last changed by) -// Subversion HeadURL: $HeadURL: https://svn/sbr/Sources/SBR-Projects/MatchPoint/trunk/Code/IO/include/mapImageReader.tpp $ -*/ - -#ifndef __RTTB_ITK_IMAGE_FILE_MASK_ACCESSOR_GENERATOR_TPP -#define __RTTB_ITK_IMAGE_FILE_MASK_ACCESSOR_GENERATOR_TPP - -#include "rttbITKImageFileMaskAccessorGenerator.h" -#include "rttbInvalidParameterException.h" -#include "rttbInvalidDoseException.h" -#include "rttbITKImageMaskAccessor.h" - -namespace rttb -{ - namespace io - { - namespace mask - { - - template void ITKImageFileMaskAccessorGenerator::doCasting( - io::itk::GenericImageReader::GenericOutputImageType* genericImage) - { - typedef ::itk::Image InputImageType; - typedef ITKImageMaskAccessor::ITKMaskImageType OutputImageType; - InputImageType::Pointer pCastedInput = dynamic_cast(genericImage); - typedef ::itk::CastImageFilter CastFilterType; - CastFilterType::Pointer castFilter = CastFilterType::New(); - castFilter->SetInput(pCastedInput); - - try - { - //important to update the filter! - castFilter->Update(); - _itkDoubleImage = castFilter->GetOutput(); - } - catch (::itk::ExceptionObject& e) - { - std::cerr << "ITK Error!!!" << std::endl; - std::cerr << e << std::endl; - } - } - - } - } -} -#endif diff --git a/code/io/mask/rttbITKImageMaskAccessor.cpp b/code/io/mask/rttbITKImageMaskAccessor.cpp index cf56a61..3951272 100644 --- a/code/io/mask/rttbITKImageMaskAccessor.cpp +++ b/code/io/mask/rttbITKImageMaskAccessor.cpp @@ -1,175 +1,165 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ -#include #include #include #include "rttbITKImageMaskAccessor.h" -#include "rttbException.h" #include "rttbInvalidDoseException.h" namespace rttb { namespace io { namespace mask { ITKImageMaskAccessor::ITKImageMaskAccessor(ITKMaskImageType::ConstPointer aMaskImage) : _mask(aMaskImage) { if (_mask.IsNull()) { throw core::InvalidDoseException("Mask image = 0!") ; } assembleGeometricInfo(); } ITKImageMaskAccessor::~ITKImageMaskAccessor() { }; bool ITKImageMaskAccessor::assembleGeometricInfo() { _geoInfo = boost::make_shared(); _geoInfo->setSpacing(SpacingVectorType3D(_mask->GetSpacing()[0], _mask->GetSpacing()[1], _mask->GetSpacing()[2])); if (_geoInfo->getSpacing()[0] == 0 || _geoInfo->getSpacing()[1] == 0 || _geoInfo->getSpacing()[2] == 0) { throw core::InvalidDoseException("Pixel spacing = 0!"); } _geoInfo->setImagePositionPatient(WorldCoordinate3D(_mask->GetOrigin()[0], _mask->GetOrigin()[1], _mask->GetOrigin()[2])); OrientationMatrix OM(0); for (int col = 0; col < 3; ++col) { for (int row = 0; row < 3; ++row) { OM(col, row) = _mask->GetDirection()(col, row); } } _geoInfo->setOrientationMatrix(OM); _geoInfo->setNumColumns(_mask->GetLargestPossibleRegion().GetSize()[0]); _geoInfo->setNumRows(_mask->GetLargestPossibleRegion().GetSize()[1]); _geoInfo->setNumSlices(_mask->GetLargestPossibleRegion().GetSize()[2]); if (_geoInfo->getNumColumns() == 0 || _geoInfo->getNumRows() == 0 || _geoInfo->getNumSlices() == 0) { throw core::InvalidDoseException("Empty mask!") ; } return true; } void ITKImageMaskAccessor::updateMask() { return; } ITKImageMaskAccessor::MaskVoxelListPointer ITKImageMaskAccessor::getRelevantVoxelVector() { - // if not already generated start voxelization here updateMask(); - _spRelevantVoxelVector = boost::make_shared(); - - for(int gridIndex =0 ; gridIndex < _geoInfo->getNumColumns()*_geoInfo->getNumRows()*_geoInfo->getNumSlices(); gridIndex++){ - core::MaskVoxel currentVoxel = core::MaskVoxel(gridIndex); - if(getMaskAt(gridIndex, currentVoxel)){ - if(currentVoxel.getRelevantVolumeFraction() > 0){ - _spRelevantVoxelVector->push_back(currentVoxel); - } - } - } - return _spRelevantVoxelVector; + _relevantVoxelVector = getRelevantVoxelVector(0); + return _relevantVoxelVector; } ITKImageMaskAccessor::MaskVoxelListPointer ITKImageMaskAccessor::getRelevantVoxelVector(float lowerThreshold) { MaskVoxelListPointer filteredVoxelVectorPointer(new MaskVoxelList); updateMask(); - for(int gridIndex =0 ; gridIndex < _geoInfo->getNumColumns()*_geoInfo->getNumRows()*_geoInfo->getNumSlices(); gridIndex++){ + int size = _geoInfo->getNumColumns()*_geoInfo->getNumRows()*_geoInfo->getNumSlices(); + filteredVoxelVectorPointer->reserve(size); + for(int gridIndex =0 ; gridIndex < size; gridIndex++){ core::MaskVoxel currentVoxel = core::MaskVoxel(gridIndex); if(getMaskAt(gridIndex, currentVoxel)){ if(currentVoxel.getRelevantVolumeFraction() > lowerThreshold){ filteredVoxelVectorPointer->push_back(currentVoxel); } } } return filteredVoxelVectorPointer; } bool ITKImageMaskAccessor::getMaskAt(VoxelGridID aID, core::MaskVoxel& voxel) const { VoxelGridIndex3D aVoxelGridIndex; if (_geoInfo->convert(aID, aVoxelGridIndex)) { return getMaskAt(aVoxelGridIndex, voxel); } else { return false; } } bool ITKImageMaskAccessor::getMaskAt(const VoxelGridIndex3D& aIndex, core::MaskVoxel& voxel) const { voxel.setRelevantVolumeFraction(0); if (_geoInfo->validIndex(aIndex)) { const ITKMaskImageType::IndexType pixelIndex = {{aIndex[0], aIndex[1], aIndex[2]}}; double value = _mask->GetPixel(pixelIndex); VoxelGridID gridId; _geoInfo->convert(aIndex, gridId); if(value >= 0 && value <=1 ){ voxel.setRelevantVolumeFraction(value); } else{ std::cerr << "The pixel value of the mask should be >=0 and <=1!"< - -#include - #include "rttbMaskAccessorInterface.h" #include "rttbGeometricInfo.h" #include "rttbBaseType.h" #include "itkImage.h" namespace rttb { namespace io { namespace mask { /*! @class ITKImageMaskAccessor @brief This class gives access to mask information stored in an itk image */ class ITKImageMaskAccessor: public core::MaskAccessorInterface { public: typedef ::itk::Image ITKMaskImageType; typedef ::itk::ImageBase<3> ITKImageBaseType; typedef core::MaskAccessorInterface::MaskVoxelList MaskVoxelList; typedef core::MaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; - typedef boost::shared_ptr GeometricInfoPtr; + typedef boost::shared_ptr GeometricInfoPointer; private: /** @brief The mask as itkImage */ ITKMaskImageType::ConstPointer _mask; IDType _maskUID; - GeometricInfoPtr _geoInfo; + GeometricInfoPointer _geoInfo; /*! vector containing list of mask voxels*/ - MaskVoxelListPointer _spRelevantVoxelVector; + MaskVoxelListPointer _relevantVoxelVector; /*! @brief get all required data from the itk image contained in _Mask @exception InvalidDoseException if PixelSpacing is 0 or size in any dimension is 0. */ bool assembleGeometricInfo(); public: ~ITKImageMaskAccessor(); - // import of structure sets (loading from data) is done elsewhere. Structures are only voxelized here. - // here the original RTToolbox voxelization shall be implemented ITKImageMaskAccessor(ITKMaskImageType::ConstPointer aMaskImage); /*! @brief voxelization of the given structures according to the original RTToolbox algorithm*/ void updateMask(); /*! @brief get vector conatining al relevant voxels that are inside the given structure*/ MaskVoxelListPointer getRelevantVoxelVector(); /*! @brief get vector conatining al relevant voxels that have a relevant volume above the given threshold and are inside the given structure*/ MaskVoxelListPointer getRelevantVoxelVector(float lowerThreshold); /*!@brief determine how a given voxel on the dose grid is masked * @param aID ID of the voxel in grid. * @param voxel Reference to the voxel. * @post after a valid call voxel containes the information of the specified grid voxel. If aID is not valid, voxel values are undefined. * The relevant volume fraction will be set to zero. * @return Indicates of the voxel exists and therefore if parameter voxel containes valid values.*/ bool getMaskAt(const VoxelGridID aID, core::MaskVoxel& voxel) const; bool getMaskAt(const VoxelGridIndex3D& aIndex, core::MaskVoxel& voxel) const; /*! @brief give access to GeometricInfo*/ const core::GeometricInfo& getGeometricInfo() const; /* @ brief is true if Mask is on a homogeneous grid */ // Inhomogeneous grids are not supported at the moment, but if they will // be supported in the future the interface does not need to change. bool isGridHomogeneous() const { return true; }; IDType getMaskUID() const { return _maskUID; }; }; } } } #endif diff --git a/code/io/mask/rttbITKImageMaskAccessorConverter.cpp b/code/io/mask/rttbITKImageMaskAccessorConverter.cpp index 7795232..05d855c 100644 --- a/code/io/mask/rttbITKImageMaskAccessorConverter.cpp +++ b/code/io/mask/rttbITKImageMaskAccessorConverter.cpp @@ -1,138 +1,129 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 747 $ (last changed revision) // @date $Date: 2014-09-17 12:01:00 +0200 (Mi, 17 Sep 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ -#include #include #include "rttbITKImageMaskAccessorConverter.h" -#include "rttbException.h" #include "rttbInvalidDoseException.h" #include "rttbGeometricInfo.h" #include "itkImageRegionIterator.h" #include "rttbITKImageMaskAccessor.h" namespace rttb { namespace io { namespace mask { ITKImageMaskAccessorConverter::ITKImageMaskAccessorConverter(MaskAccessorPointer accessor) { setMaskAccessor(accessor); } bool ITKImageMaskAccessorConverter::process() { //Transfer GeometricInfo to ITK Properties core::GeometricInfo geoInfo = _maskAccessor->getGeometricInfo(); ITKImageMaskAccessor::ITKMaskImageType::RegionType region; - ITKImageMaskAccessor::ITKMaskImageType::IndexType start; + + ITKImageMaskAccessor::ITKMaskImageType::IndexType start = {{0, 0, 0}}; - for (unsigned int i = 0; i < 3; ++i) - { - start[i] = 0; - } - - ITKImageMaskAccessor::ITKMaskImageType::SizeType size; - size[0] = geoInfo.getNumColumns(); - size[1] = geoInfo.getNumRows(); - size[2] = geoInfo.getNumSlices(); + ITKImageMaskAccessor::ITKMaskImageType::SizeType size = {{geoInfo.getNumColumns(), geoInfo.getNumRows(), geoInfo.getNumSlices()}}; ITKImageMaskAccessor::ITKMaskImageType::SpacingType spacing; for (unsigned int i = 0; i < 3; ++i) { spacing[i] = geoInfo.getSpacing()[i]; } ITKImageMaskAccessor::ITKMaskImageType::PointType origin; for (unsigned int i = 0; i < 3; ++i) { origin[i] = geoInfo.getImagePositionPatient()[i]; } ITKImageMaskAccessor::ITKMaskImageType::DirectionType direction; OrientationMatrix OM = geoInfo.getOrientationMatrix(); for (int col = 0; col < 3; ++col) { for (int row = 0; row < 3; ++row) { direction(col, row) = OM(col, row); } } //Create image, assign properties region.SetSize(size); region.SetIndex(start); _itkImage = ITKImageMaskAccessor::ITKMaskImageType::New(); _itkImage->SetRegions(region); _itkImage->SetSpacing(spacing); _itkImage->SetDirection(direction); _itkImage->SetOrigin(origin); _itkImage->Allocate(); ::itk::ImageRegionIterator imageIterator(_itkImage, region); VoxelGridID id = 0; //Transfer Mask values to itk image //Large advantage: rttbVoxelGridId ordering is the same as itk ordering while (!imageIterator.IsAtEnd()) { VoxelGridIndex3D aIndex; if (_maskAccessor->getGeometricInfo().validID(id)) { rttb::core::MaskVoxel maskVoxel = core::MaskVoxel(id);; _maskAccessor->getMaskAt(id, maskVoxel); // Set the current pixel imageIterator.Set(maskVoxel.getRelevantVolumeFraction()); } else { if (failsOnInvalidIDs()) { throw core::InvalidDoseException("invalid Mask id!"); return false; } else { imageIterator.Set(_invalidDoseValue); } } ++imageIterator; ++id; } return true; } }//end namespace mask }//end namespace io }//end namespace rttb diff --git a/code/io/mask/rttbITKImageMaskAccessorConverter.h b/code/io/mask/rttbITKImageMaskAccessorConverter.h index 41374ab..31b7a81 100644 --- a/code/io/mask/rttbITKImageMaskAccessorConverter.h +++ b/code/io/mask/rttbITKImageMaskAccessorConverter.h @@ -1,70 +1,68 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #ifndef __ITK_IMAGE_MASK_ACCESSOR_CONVERTER_H #define __ITK_IMAGE_MASK_ACCESSOR_CONVERTER_H -#include - #include "rttbITKImageMaskAccessor.h" #include "rttbMaskAccessorProcessorBase.h" #include "../itk/rttbDoseAccessorConversionSettingInterface.h" namespace rttb { namespace io { namespace mask { /*! @class ITKImageMaskAccessorConverter @brief Class converts/dumps the processed accessor into an itk image @remark MaskAccessorConversionInterface defines how the converter should react on non valid Mask values. */ class ITKImageMaskAccessorConverter: public core::MaskAccessorProcessorBase, public rttb::core::DoseAccessorConversionSettingInterface { public: typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; bool process(); - ITKImageMaskAccessor::ITKMaskImageType::Pointer getITKImage() + const ITKImageMaskAccessor::ITKMaskImageType::Pointer getITKImage() { return _itkImage; } ITKImageMaskAccessorConverter(MaskAccessorPointer accessor); virtual ~ITKImageMaskAccessorConverter() {}; private: ITKImageMaskAccessorConverter(const ITKImageMaskAccessorConverter&); //not implemented on purpose -> non-copyable ITKImageMaskAccessorConverter& operator=(const ITKImageMaskAccessorConverter&);//not implemented on purpose -> non-copyable ITKImageMaskAccessor::ITKMaskImageType::Pointer _itkImage; }; } } } #endif diff --git a/code/io/mask/rttbITKImageMaskAccessorGenerator.cpp b/code/io/mask/rttbITKImageMaskAccessorGenerator.cpp index 75a5c61..0bf487d 100644 --- a/code/io/mask/rttbITKImageMaskAccessorGenerator.cpp +++ b/code/io/mask/rttbITKImageMaskAccessorGenerator.cpp @@ -1,52 +1,51 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ -#include #include #include #include "rttbITKImageMaskAccessorGenerator.h" #include "rttbException.h" #include "rttbInvalidDoseException.h" namespace rttb{ namespace io{ namespace mask{ ITKImageMaskAccessorGenerator::ITKImageMaskAccessorGenerator(const ITKImageMaskAccessor::ITKMaskImageType* aMaskImage){ if (aMaskImage == NULL){ throw core::InvalidDoseException("MaskImage is NULL"); } _maskPtr = aMaskImage; } core::MaskAccessorGeneratorBase::MaskAccessorPointer ITKImageMaskAccessorGenerator::generateMaskAccessor(){ _maskAccessor = boost::make_shared(_maskPtr); return _maskAccessor; } }//end namespace mask }//end namespace io }//end namespace rttb diff --git a/code/io/mask/rttbITKImageMaskAccessorGenerator.h b/code/io/mask/rttbITKImageMaskAccessorGenerator.h index f0d5082..21c959a 100644 --- a/code/io/mask/rttbITKImageMaskAccessorGenerator.h +++ b/code/io/mask/rttbITKImageMaskAccessorGenerator.h @@ -1,71 +1,67 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #ifndef __ITK_IMAGE_MASK_ACCESSOR_GENERATOR_H #define __ITK_IMAGE_MASK_ACCESSOR_GENERATOR_H -#include -#include - #include "rttbBaseType.h" #include "rttbITKImageMaskAccessor.h" #include "rttbMaskAccessorGeneratorBase.h" -#include "rttbITKImageMaskAccessor.h" #include "itkImage.h" namespace rttb { namespace io { namespace mask { class ITKImageMaskAccessorGenerator: public core::MaskAccessorGeneratorBase { public: typedef MaskAccessorGeneratorBase::MaskAccessorPointer MaskAccessorPointer; private: /** @brief The Mask as itkImage */ ITKImageMaskAccessor::ITKMaskImageType::ConstPointer _maskPtr; ITKImageMaskAccessorGenerator(); public: virtual ~ITKImageMaskAccessorGenerator() {}; /*! @pre aMaskImage must point to a valid instance. @exception InvalidDoseException Thrown if aMaskImage is invalid. */ ITKImageMaskAccessorGenerator(const ITKImageMaskAccessor::ITKMaskImageType* aMaskImage); /*! @brief Generate MaskAccessor @return Return shared pointer of MaskAccessor. */ MaskAccessorPointer generateMaskAccessor() ; }; } } } #endif diff --git a/code/io/mask/rttbMaskAccessorProcessorBase.h b/code/io/mask/rttbMaskAccessorProcessorBase.h index d225190..1d96910 100644 --- a/code/io/mask/rttbMaskAccessorProcessorBase.h +++ b/code/io/mask/rttbMaskAccessorProcessorBase.h @@ -1,61 +1,59 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #ifndef __MASK_ACCESSOR_PROCESSOR_BASE_H #define __MASK_ACCESSOR_PROCESSOR_BASE_H -#include - #include "rttbMaskAccessorProcessorInterface.h" namespace rttb { namespace core { /*! @class MaskAccessorProcessorBase @brief Abstract class for all MaskAccessor converter classes */ class MaskAccessorProcessorBase: public MaskAccessorProcessorInterface { public: typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; virtual void setMaskAccessor(MaskAccessorPointer accessor) { _maskAccessor = accessor; }; private: MaskAccessorProcessorBase(const MaskAccessorProcessorBase&); //not implemented on purpose -> non-copyable MaskAccessorProcessorBase& operator=(const MaskAccessorProcessorBase&);//not implemented on purpose -> non-copyable protected: MaskAccessorProcessorBase() {}; virtual ~MaskAccessorProcessorBase() {}; /*! @brief Mask accessor which should be generated */ MaskAccessorPointer _maskAccessor; }; } } #endif diff --git a/testing/io/mask/CMakeLists.txt b/testing/io/mask/CMakeLists.txt index beb72cc..9b2bda6 100644 --- a/testing/io/mask/CMakeLists.txt +++ b/testing/io/mask/CMakeLists.txt @@ -1,27 +1,24 @@ #----------------------------------------------------------------------------- # Setup the system information test. Write out some basic failsafe # information in case the test doesn't run. #----------------------------------------------------------------------------- SET(MaskIO_TEST ${EXECUTABLE_OUTPUT_PATH}/rttbMaskIOTests) SET(TEST_DATA_ROOT ${RTTBTesting_SOURCE_DIR}/data) SET(TEMP ${RTTBTesting_BINARY_DIR}/temporary) #----------------------------------------------------------------------------- ADD_TEST(MaskAccessorGeneratorTest ${MaskIO_TEST} MaskAccessorGeneratorTest "${TEST_DATA_ROOT}/MatchPointLogo.mhd") -ADD_TEST(MaskIOTest ${MaskIO_TEST} MaskIOTest -"${TEST_DATA_ROOT}/MatchPointLogo.mhd") - ADD_TEST(MaskAccessorConverterTest ${MaskIO_TEST} MaskAccessorConverterTest "${TEST_DATA_ROOT}/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm" "${TEST_DATA_ROOT}/DICOM/TestDose/ConstantTwo.dcm" "${TEST_DATA_ROOT}/MatchPointLogo.mhd") RTTB_CREATE_TEST_MODULE(rttbMaskIO DEPENDS RTTBMaskIO RTTBDicomIO RTTBITKIO RTTBMasks PACKAGE_DEPENDS Boost Litmus MatchPoint ITK DCMTK) diff --git a/testing/io/mask/MaskAccessorConverterTest.cpp b/testing/io/mask/MaskAccessorConverterTest.cpp index 9dac894..a5ed4c7 100644 --- a/testing/io/mask/MaskAccessorConverterTest.cpp +++ b/testing/io/mask/MaskAccessorConverterTest.cpp @@ -1,131 +1,159 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html [^] // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ // this file defines the rttbCoreTests for the test driver // and all it expects is that you have a function called RegisterTests #include #include #include "litCheckMacros.h" #include "litImageTester.h" #include "litTestImageIO.h" #include "itkImage.h" #include "itkImageFileReader.h" #include "rttbBaseType.h" #include "rttbDoseIteratorInterface.h" #include "rttbDicomFileDoseAccessorGenerator.h" #include "rttbDicomDoseAccessor.h" #include "rttbInvalidDoseException.h" #include "rttbDicomFileStructureSetGenerator.h" #include "rttbOTBMaskAccessor.h" #include "rttbITKImageMaskAccessorConverter.h" #include "rttbITKImageFileMaskAccessorGenerator.h" namespace rttb { namespace testing { /*!@brief MaskAccessorConverterTest - test the conversion rttb dose accessor ->itk 1) test with dicom file (DicomDoseAccessorGenerator) 2) test with mhd file (ITKImageFileDoseAccessorGenerator) */ int MaskAccessorConverterTest(int argc, char* argv[]) { typedef core::DoseIteratorInterface::DoseAccessorPointer DoseAccessorPointer; typedef core::StructureSetGeneratorInterface::StructureSetPointer StructureSetPointer; typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; typedef io::mask::ITKImageMaskAccessor::ITKMaskImageType::Pointer ITKImageTypePointer; PREPARE_DEFAULT_TEST_REPORTING; //ARGUMENTS: //ARGUMENTS: 1: structure file name // 2: dose1 file name std::string RTStr_FILENAME; std::string RTDose_FILENAME; std::string Mask_FILENAME; - if (argc > 1) + if (argc > 3) { RTStr_FILENAME = argv[1]; - } - - if (argc > 2) - { RTDose_FILENAME = argv[2]; - } - - if (argc > 3) - { Mask_FILENAME = argv[3]; } + //1) Read dicomFile and test getITKImage() io::dicom::DicomFileDoseAccessorGenerator doseAccessorGenerator1(RTDose_FILENAME.c_str()); DoseAccessorPointer doseAccessor1(doseAccessorGenerator1.generateDoseAccessor()); StructureSetPointer rtStructureSet = io::dicom::DicomFileStructureSetGenerator( RTStr_FILENAME.c_str()).generateStructureSet(); MaskAccessorPointer maskAccessorPtr = boost::make_shared(rtStructureSet->getStructure(0), doseAccessor1->getGeometricInfo()); io::mask::ITKImageMaskAccessorConverter maskAccessorConverter(maskAccessorPtr); CHECK_NO_THROW(maskAccessorConverter.process()); CHECK_NO_THROW(maskAccessorConverter.getITKImage()); //2) Read itk image, generate mask and convert it back to itk image, check equal MaskAccessorPointer maskAccessorPtr2 = io::mask::ITKImageFileMaskAccessorGenerator(Mask_FILENAME.c_str()).generateMaskAccessor(); io::mask::ITKImageMaskAccessorConverter maskAccessorConverter2(maskAccessorPtr2); maskAccessorConverter2.process(); typedef itk::Image< DoseTypeGy, 3 > MaskImageType; typedef itk::ImageFileReader ReaderType; ITKImageTypePointer convertedImagePtr = maskAccessorConverter2.getITKImage(); io::mask::ITKImageMaskAccessor::ITKMaskImageType::ConstPointer expectedImage = lit::TestImageIO::readImage( Mask_FILENAME); CHECK_EQUAL(convertedImagePtr->GetOrigin()[0], expectedImage->GetOrigin()[0]); CHECK_EQUAL(convertedImagePtr->GetOrigin()[1], expectedImage->GetOrigin()[1]); CHECK_EQUAL(convertedImagePtr->GetOrigin()[2], expectedImage->GetOrigin()[2]); CHECK_EQUAL(convertedImagePtr->GetSpacing()[0], expectedImage->GetSpacing()[0]); CHECK_EQUAL(convertedImagePtr->GetSpacing()[1], expectedImage->GetSpacing()[1]); CHECK_EQUAL(convertedImagePtr->GetSpacing()[2], expectedImage->GetSpacing()[2]); + int sizeX = convertedImagePtr->GetLargestPossibleRegion().GetSize()[0]; + int sizeY = convertedImagePtr->GetLargestPossibleRegion().GetSize()[1]; + int sizeZ = convertedImagePtr->GetLargestPossibleRegion().GetSize()[2]; + + io::mask::ITKImageMaskAccessor::ITKMaskImageType::IndexType index; + + for(unsigned int i=0; i<20 && iGetPixel(index) >= 0 && expectedImage->GetPixel(index)<=1){ + CHECK_EQUAL(convertedImagePtr->GetPixel(index), expectedImage->GetPixel(index)); + } + } + + for(unsigned int i=0; i<20; i++){ + index[0] = sizeX -1-i; + index[1] = sizeY -1-i; + index[2] = sizeZ -1-i; + + if(expectedImage->GetPixel(index) >= 0 && expectedImage->GetPixel(index)<=1){ + CHECK_EQUAL(convertedImagePtr->GetPixel(index), expectedImage->GetPixel(index)); + } + } + + for(unsigned int i=0; i<20 && (sizeX/2 -i) < sizeX && (sizeY/2 -i) < sizeY && (sizeZ/2 -i) < sizeZ; i++){ + index[0] = sizeX/2 -i; + index[1] = sizeY/2 -i; + index[2] = sizeZ/2 -i; + + if(expectedImage->GetPixel(index) >= 0 && expectedImage->GetPixel(index)<=1){ + CHECK_EQUAL(convertedImagePtr->GetPixel(index), expectedImage->GetPixel(index)); + } + } + RETURN_AND_REPORT_TEST_SUCCESS; } }//testing }//rttb diff --git a/testing/io/mask/MaskAccessorGeneratorTest.cpp b/testing/io/mask/MaskAccessorGeneratorTest.cpp index bd249a8..7c58759 100644 --- a/testing/io/mask/MaskAccessorGeneratorTest.cpp +++ b/testing/io/mask/MaskAccessorGeneratorTest.cpp @@ -1,97 +1,97 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html [^] // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ // this file defines the rttbCoreTests for the test driver // and all it expects is that you have a function called RegisterTests #include #include #include "litCheckMacros.h" #include "itkImage.h" #include "itkImageFileReader.h" #include "rttbBaseType.h" #include "rttbInvalidDoseException.h" #include "rttbITKImageFileMaskAccessorGenerator.h" #include "rttbITKImageMaskAccessorGenerator.h" namespace rttb { namespace testing { /*!@brief MaskAccessorGeneratorTest - test the generators for dicom data 1) test itk file generator generateDoseAccessor() 2) test itk generator generateDoseAccessor() */ int MaskAccessorGeneratorTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; //ARGUMENTS: // 1: mhd/raw file name std::string Mask_FILENAME; if (argc > 1) { Mask_FILENAME = argv[1]; } /* test ITKImageFileMaskAccessorGenerator generateDoseAccessor()*/ CHECK_THROW_EXPLICIT(io::mask::ITKImageFileMaskAccessorGenerator("test.test").generateMaskAccessor(), core::InvalidDoseException); CHECK_NO_THROW(io::mask::ITKImageFileMaskAccessorGenerator( Mask_FILENAME.c_str()).generateMaskAccessor()); /* test ITKImageMaskAccessorGenerator generateDoseAccessor()*/ typedef itk::Image< DoseTypeGy, 3 > MaskImageType; typedef itk::ImageFileReader ReaderType; MaskImageType::ConstPointer invalidDose = MaskImageType::New(); ReaderType::Pointer reader = ReaderType::New(); CHECK_THROW_EXPLICIT(io::mask::ITKImageMaskAccessorGenerator( invalidDose.GetPointer()).generateMaskAccessor(), core::InvalidDoseException); reader->SetFileName(Mask_FILENAME); //important to update the reader (won't work without) reader->Update(); CHECK_NO_THROW(io::mask::ITKImageMaskAccessorGenerator(reader->GetOutput()).generateMaskAccessor()); io::mask::ITKImageMaskAccessorGenerator::MaskAccessorPointer maskAcc = io::mask::ITKImageMaskAccessorGenerator(reader->GetOutput()).generateMaskAccessor(); - rttb::core::MaskAccessorInterface::MaskVoxelListPointer maskVoxelListPtr = maskAcc->getRelevantVoxelVector(); + CHECK_NO_THROW( maskAcc->getRelevantVoxelVector()); RETURN_AND_REPORT_TEST_SUCCESS; } }//testing }//rttb diff --git a/testing/io/mask/MaskIOTest.cpp b/testing/io/mask/MaskIOTest.cpp deleted file mode 100644 index c4166c4..0000000 --- a/testing/io/mask/MaskIOTest.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html [^] -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notices for more information. -// -//------------------------------------------------------------------------ -/*! -// @file -// @version $Revision: 793 $ (last changed revision) -// @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ - -// this file defines the rttbCoreTests for the test driver -// and all it expects is that you have a function called RegisterTests - -#include -#include - -#include "litCheckMacros.h" - -#include "rttbBaseType.h" -#include "rttbGeometricInfo.h" -#include "rttbDoseIteratorInterface.h" - - - -namespace rttb -{ - - namespace testing - { - - /*!@brief MaskIOTest - test the IO for mask data - - WARNING: The values for comparison need to be adjusted if the input files are changed! - */ - - int MaskIOTest(int argc, char* argv[]) - { - - PREPARE_DEFAULT_TEST_REPORTING; - //ARGUMENTS: - // 1: mhd file name - - std::string RTDOSE_FILENAME; - - if (argc > 1) - { - RTDOSE_FILENAME = argv[1]; - } - - - RETURN_AND_REPORT_TEST_SUCCESS; - } - - }//testing -}//rttb - diff --git a/testing/io/mask/files.cmake b/testing/io/mask/files.cmake index ea8fc70..3f345c4 100644 --- a/testing/io/mask/files.cmake +++ b/testing/io/mask/files.cmake @@ -1,9 +1,8 @@ SET(CPP_FILES MaskAccessorGeneratorTest.cpp MaskAccessorConverterTest.cpp - MaskIOTest.cpp rttbMaskIOTests.cpp ) SET(H_FILES ) diff --git a/testing/io/mask/rttbMaskIOTests.cpp b/testing/io/mask/rttbMaskIOTests.cpp index f146178..8a89504 100644 --- a/testing/io/mask/rttbMaskIOTests.cpp +++ b/testing/io/mask/rttbMaskIOTests.cpp @@ -1,60 +1,59 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ // this file defines the rttbCoreTests for the test driver // and all it expects is that you have a function called RegisterTests #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "litMultiTestsMain.h" namespace rttb{ namespace testing{ void registerTests() { LIT_REGISTER_TEST(MaskAccessorGeneratorTest); LIT_REGISTER_TEST(MaskAccessorConverterTest); - LIT_REGISTER_TEST(MaskIOTest); } } } int main(int argc, char* argv[]) { int result = 0; rttb::testing::registerTests(); try { result = lit::multiTestsMain(argc,argv); } catch(...) { result = -1; } return result; }