diff --git a/Modules/DiffusionImaging/Quantification/Algorithms/mitkTractAnalyzer.h b/Modules/DiffusionImaging/Quantification/Algorithms/mitkTractAnalyzer.h index d9c3296fcf..0f508ca5a6 100644 --- a/Modules/DiffusionImaging/Quantification/Algorithms/mitkTractAnalyzer.h +++ b/Modules/DiffusionImaging/Quantification/Algorithms/mitkTractAnalyzer.h @@ -1,152 +1,152 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkTractAnalyzer_h_ #define __mitkTractAnalyzer_h_ #include "QuantificationExports.h" #include #include "mitkImage.h" #include "mitkImageCast.h" #include #include namespace mitk{ /** * \brief Creates a region of interest for tract-specific analysis of existing TBSS data * * This class needs a 3D image (typically a mean FA skeleton as produced by the standard TBSS pipeline of FSL) * and a user-defined point set defining the points through which the region of interest should pass. */ class Quantification_EXPORT TractAnalyzer { public: TractAnalyzer(); ~TractAnalyzer() {} /** Image type definitions */ - typedef itk::Image CharImageType; + typedef itk::Image CharImageType; typedef itk::Image FloatImageType; /** \brief Main method for region of interest calculation * * A region of interest is calculated adding the segments between the points on the ROI * that was specified by the user. */ void MakeRoi(); /** \brief Sets the input image * * The region of interest is calculated on a 3D image. This is generally the mean FA skeleton as calculated * in the standard TBSS pipeline (see http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/TBSS). */ mitk::TbssRoiImage::Pointer GetRoiImage() { return m_TbssRoi; } /** \brief Sets the input image * * The region of interest is calculated on a 3D image. This is generally the mean FA skeleton as calculated * in the standard TBSS pipeline (see http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/TBSS). */ void SetInputImage(mitk::Image::Pointer inputImage) { m_InputImage = inputImage; } /** \brief Sets the user-defined point set * * Set the user-defined point sets. The region of interest must pass through these points. */ void SetPointSet(mitk::PointSet::Pointer pointSet) { m_PointSetNode = pointSet; } /** \brief Sets a lower bound for the threshold. * * Low fractional anisotropy values can indicate partial volume of non white matter tissue. * This thresholds limits the search for a region of interest to voxels with a minimum value. */ void SetThreshold(double threshold) { m_Threshold = threshold; } /** \brief Returns a string with the indices of points on the region of interest * * The region of interest calculated by the TractAnalyzer contains a list of ITK indices. * This method returns a string containing these indices for display in the GUI */ std::string GetPathDescription() { return m_PathDescription; } protected: /** \brief Calculates a segment of the region of interest * * The region of interest is calculated on a 3D image. This is generally the mean FA skeleton as calculated * in the standard TBSS pipeline (see http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/TBSS). */ std::vector< itk::Index<3> > CreateSegment(itk::Index<3> startPoint, itk::Index<3> endPoint); /** \brief Output TbssRoiImage */ mitk::TbssRoiImage::Pointer m_TbssRoi; /** \brief Inputimage */ mitk::Image::Pointer m_InputImage; /** \brief Threshold for ROI search */ double m_Threshold; /** \brief User defined point set */ mitk::PointSet::Pointer m_PointSetNode; /** \brief Path description in as string for display in GUI */ std::string m_PathDescription; private: }; } #endif //__itkTractAnalyzer_h_ diff --git a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageReader.h b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageReader.h index dbc59fdfdf..2ca8ff6687 100644 --- a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageReader.h +++ b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageReader.h @@ -1,79 +1,79 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkNrrdTbssRoiImageReader_h #define __mitkNrrdTbssRoiImageReader_h #include "mitkCommon.h" #include "mitkFileReader.h" #include "mitkTbssRoiImageSource.h" #include "itkImage.h" #include "mitkTbssRoiImage.h" namespace mitk { /** \brief */ class Quantification_EXPORT NrrdTbssRoiImageReader : public mitk::TbssRoiImageSource, public FileReader { public: typedef mitk::TbssRoiImage OutputType; - typedef itk::Image ImageType; + typedef itk::Image ImageType; typedef TbssRoiImageSource TbssVolSourceType; mitkClassMacro( NrrdTbssRoiImageReader, TbssVolSourceType ) itkNewMacro(Self) const char* GetFileName() const; void SetFileName(const char* aFileName); const char* GetFilePrefix() const; void SetFilePrefix(const char* aFilePrefix); const char* GetFilePattern() const; void SetFilePattern(const char* aFilePattern); static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); protected: /** Does the real work. */ virtual void GenerateData(); void ReadRoiInfo(itk::MetaDataDictionary dict); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; OutputType::Pointer m_OutputCache; itk::TimeStamp m_CacheTime; private: void operator=(const Self&); //purposely not implemented }; } //namespace MITK //#include "mitkNrrdTbssRoiImageReader.cpp" #endif // __mitkNrrdTbssImageReader_h diff --git a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageWriter.cpp b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageWriter.cpp index 0a7a5d08ef..0f0f480842 100644 --- a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageWriter.cpp +++ b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageWriter.cpp @@ -1,142 +1,142 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkNrrdTbssRoiImageWriter__cpp #define __mitkNrrdTbssRoiImageWriter__cpp #include "mitkNrrdTbssRoiImageWriter.h" #include "itkMetaDataDictionary.h" #include "itkMetaDataObject.h" #include "itkNrrdImageIO.h" //#include "itkNiftiImageIO.h" #include "itkImageFileWriter.h" #include "itksys/SystemTools.hxx" #include #include mitk::NrrdTbssRoiImageWriter::NrrdTbssRoiImageWriter() : m_FileName(""), m_FilePrefix(""), m_FilePattern(""), m_Success(false) { this->SetNumberOfRequiredInputs( 1 ); } mitk::NrrdTbssRoiImageWriter::~NrrdTbssRoiImageWriter() {} void mitk::NrrdTbssRoiImageWriter::GenerateData() { m_Success = false; InputType* input = this->GetInput(); if (input == NULL) { itkWarningMacro(<<"Sorry, input to NrrdTbssImageWriter is NULL!") return; } if ( m_FileName == "" ) { itkWarningMacro( << "Sorry, filename has not been set!" ) return ; } char keybuffer[512]; char valbuffer[512]; std::vector< itk::Index<3> > roi = input->GetRoi(); std::vector< itk::Index<3> >::iterator it = roi.begin(); int i=0; while(it != roi.end()) { itk::Index<3> ix = *it; sprintf( keybuffer, "ROI_index_%04d", i ); sprintf( valbuffer, "%1d %1d %1d", ix[0],ix[1],ix[2]); std::cout << valbuffer << std::endl; //input->GetImage()->GetMetaDataDictionary(); itk::EncapsulateMetaData< std::string >(input->GetImage()->GetMetaDataDictionary(), std::string(keybuffer), std::string(valbuffer)); it++; ++i; } std::string structure = input->GetStructure(); itk::EncapsulateMetaData< std::string >(input->GetImage()->GetMetaDataDictionary(), "structure", structure); - typedef itk::Image ImageType; + typedef itk::Image ImageType; ImageType::Pointer img = input->GetImage(); itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New(); io->SetFileType( itk::ImageIOBase::Binary ); io->UseCompressionOn(); typedef itk::ImageFileWriter WriterType; WriterType::Pointer nrrdWriter = WriterType::New(); nrrdWriter->UseInputMetaDataDictionaryOn(); nrrdWriter->SetInput( img ); nrrdWriter->SetImageIO(io); nrrdWriter->SetFileName(m_FileName); // nrrdWriter->UseCompressionOn(); nrrdWriter->SetImageIO(io); try { nrrdWriter->Update(); } catch (itk::ExceptionObject e) { std::cout << e << std::endl; } m_Success = true; } void mitk::NrrdTbssRoiImageWriter::SetInput( InputType* tbssVol ) { this->ProcessObject::SetNthInput( 0, tbssVol ); } mitk::TbssRoiImage* mitk::NrrdTbssRoiImageWriter::GetInput() { if ( this->GetNumberOfInputs() < 1 ) { return NULL; } else { return dynamic_cast ( this->ProcessObject::GetInput( 0 ) ); } } std::vector mitk::NrrdTbssRoiImageWriter::GetPossibleFileExtensions() { std::vector possibleFileExtensions; possibleFileExtensions.push_back(".roi"); return possibleFileExtensions; } #endif //__mitkNrrdTbssRoiImageWriter__cpp diff --git a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageWriter.h b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageWriter.h index 2136261626..7f461ae60b 100644 --- a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageWriter.h +++ b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkNrrdTbssRoiImageWriter.h @@ -1,138 +1,138 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _MITK_NRRDTBSSROIVOL_WRITER__H_ #define _MITK_NRRDTBSSROIVOL_WRITER__H_ #include #include #include #include #include "QuantificationExports.h" namespace mitk { /** * Writes diffusion volumes to a file * @ingroup Process */ class Quantification_EXPORT NrrdTbssRoiImageWriter : public mitk::FileWriterWithInformation { public: - typedef itk::Image ImageType; + typedef itk::Image ImageType; mitkClassMacro( NrrdTbssRoiImageWriter, mitk::FileWriterWithInformation ) mitkWriterMacro itkNewMacro( Self ) typedef mitk::TbssRoiImage InputType; /** * Sets the filename of the file to write. * @param FileName the nameInputType of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /**image * Sets the input object for the filter. * @param input the diffusion volumes to write to file. */ void SetInput( InputType* input ); /** * @returns the 0'th input object of the filter. */ InputType* GetInput(); /** * Returns false if an error happened during writing */ itkGetMacro( Success, bool ); /** * @return possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); // FileWriterWithInformation methods virtual const char * GetDefaultFilename() { return "TbssRoiImage.roi"; } virtual const char * GetFileDialogPattern() { return "Tbss Roi Images (*.roi)"; } virtual const char * GetDefaultExtension() { return ".roi"; } virtual bool CanWriteBaseDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); } virtual void DoWrite(BaseData::Pointer data) { if (CanWriteBaseDataType(data)) { this->SetInput(dynamic_cast(data.GetPointer())); this->Update(); } } protected: NrrdTbssRoiImageWriter(); virtual ~NrrdTbssRoiImageWriter(); virtual void GenerateData(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; bool m_Success; }; } // end of namespace mitk #endif diff --git a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssRoiImage.h b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssRoiImage.h index f31dd5a975..c29f2fb731 100644 --- a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssRoiImage.h +++ b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssRoiImage.h @@ -1,132 +1,132 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef __mitkTbssRoiImage__h #define __mitkTbssRoiImage__h #include "mitkImage.h" #include "itkImage.h" #include "mitkImageCast.h" #include "QuantificationExports.h" namespace mitk { /** * \brief this class encapsulates diffusion volumes (vectorimages not * yet supported by mitkImage) */ class Quantification_EXPORT TbssRoiImage : public Image { public: - typedef itk::Image ImageType; + typedef itk::Image ImageType; typedef itk::Index<3> IndexType; //typedef typename std::vector > RoiType; mitkClassMacro( TbssRoiImage, Image ) itkNewMacro(Self) //void SetRequestedRegionToLargestPossibleRegion(); //bool RequestedRegionIsOutsideOfTheBufferedRegion(); //virtual bool VerifyRequestedRegion(); //void SetRequestedRegion( const itk::DataObject *data); ImageType::Pointer GetImage() { return m_Image; } void SetImage(ImageType::Pointer image ) { this->m_Image = image; } itkGetMacro(PreprocessedFA, bool) itkSetMacro(PreprocessedFA, bool) itkGetMacro(PreprocessedFAFile, std::string) itkSetMacro(PreprocessedFAFile, std::string) itkGetMacro(Structure, std::string) itkSetMacro(Structure, std::string) void SetRoi(std::vector< itk::Index<3> > roi) { m_Roi = roi; } // depricated std::vector< itk::Index<3> > GetRoi() { return m_Roi; } void InitializeFromImage() { MITK_INFO << "make an mitk image that can be shown by mitk"; this->InitializeByItk(m_Image.GetPointer()); this->SetChannel(m_Image->GetBufferPointer()); } protected: TbssRoiImage(); virtual ~TbssRoiImage(){} ImageType::Pointer m_Image; std::vector< itk::Index<3> > m_Roi; bool m_PreprocessedFA; std::string m_PreprocessedFAFile; std::string m_Structure; }; // Does the same es the normal CastToMitkImage, but needed to reimplemented due to the templatet pixeltype /* template void CastToTbssImage(const ItkOutputImageType* itkimage, itk::SmartPointer< mitk::TbssRoiImage >& tbssoutputimage) { if(tbssoutputimage.IsNull()) { tbssoutputimage = mitk::TbssRoiImage::New(); } tbssoutputimage->InitializeByItk(itkimage); tbssoutputimage->SetChannel(itkimage->GetBufferPointer()); } */ } // namespace mitk //#include "mitkTbssRoiImage.cpp" #endif /* __mitkTbssRoiImage__h */