diff --git a/Modules/DICOMReader/Testing/mitkDICOMNullFileReader.cpp b/Modules/DICOMReader/Testing/mitkDICOMNullFileReader.cpp index d10f88eecb..949cd0f728 100644 --- a/Modules/DICOMReader/Testing/mitkDICOMNullFileReader.cpp +++ b/Modules/DICOMReader/Testing/mitkDICOMNullFileReader.cpp @@ -1,88 +1,88 @@ /*=================================================================== 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. ===================================================================*/ #include "mitkDICOMNullFileReader.h" mitk::DICOMNullFileReader ::DICOMNullFileReader() :DICOMFileReader() { } mitk::DICOMNullFileReader ::~DICOMNullFileReader() { } mitk::DICOMNullFileReader ::DICOMNullFileReader(const DICOMNullFileReader& other ) :DICOMFileReader(other) { } mitk::DICOMNullFileReader& mitk::DICOMNullFileReader ::operator=(const DICOMNullFileReader& other) { if (this != &other) { DICOMFileReader::operator=(other); } return *this; } void mitk::DICOMNullFileReader ::AnalyzeInputFiles() { this->ClearOutputs(); StringList inputFilenames = this->GetInputFiles(); this->SetNumberOfOutputs( inputFilenames.size() ); //generates one output for each input unsigned int o = 0; for (StringList::const_iterator inputIter = inputFilenames.begin(); inputIter != inputFilenames.end(); ++o, ++inputIter) { DICOMImageBlockDescriptor block; - StringList outputFiles; - outputFiles.push_back( *inputIter ); + DICOMImageFrameList outputFrames; + outputFrames.push_back( DICOMImageFrameInfo::New(*inputIter) ); - block.SetFilenames( outputFiles ); + block.SetImageFrameList( outputFrames ); this->SetOutput( o, block ); } } // void AllocateOutputImages(); bool mitk::DICOMNullFileReader ::LoadImages() { // does nothing return true; } bool mitk::DICOMNullFileReader ::CanHandleFile(const std::string& itkNotUsed(filename)) { return true; // can handle all } diff --git a/Modules/DICOMReader/files.cmake b/Modules/DICOMReader/files.cmake index 2c6496ff00..c04d918ae0 100644 --- a/Modules/DICOMReader/files.cmake +++ b/Modules/DICOMReader/files.cmake @@ -1,9 +1,11 @@ set(H_FILES mitkDICOMFileReader.h mitkDICOMImageBlockDescriptor.h + mitkDICOMITKSeriesGDCMReader.h ) set(CPP_FILES mitkDICOMFileReader.cpp mitkDICOMImageBlockDescriptor.cpp + mitkDICOMITKSeriesGDCMReader.cpp ) diff --git a/Modules/DICOMReader/mitkDICOMEnums.h b/Modules/DICOMReader/mitkDICOMEnums.h index 453fafd73a..618ad78dd4 100644 --- a/Modules/DICOMReader/mitkDICOMEnums.h +++ b/Modules/DICOMReader/mitkDICOMEnums.h @@ -1,34 +1,38 @@ /*=================================================================== 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 mitkDICOMEnums_h #define mitkDICOMEnums_h +#include "mitkDICOMImageFrameInfo.h" + namespace mitk { typedef std::vector StringList; typedef std::vector BoolList; + typedef std::vector DICOMImageFrameList; + typedef enum { SpacingInPatient, /// distances are mm within a patient SpacingAtDetector, /// distances are mm at detector surface SpacingUnknown /// NO spacing information is present, we use (1,1) as default } PixelSpacingInterpretation; } #endif diff --git a/Modules/DICOMReader/mitkDICOMITKSeriesGDCMReader.cpp b/Modules/DICOMReader/mitkDICOMITKSeriesGDCMReader.cpp new file mode 100644 index 0000000000..6ba11baea0 --- /dev/null +++ b/Modules/DICOMReader/mitkDICOMITKSeriesGDCMReader.cpp @@ -0,0 +1,140 @@ +/*=================================================================== + +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. + +===================================================================*/ + +#include "mitkDICOMITKSeriesGDCMReader.h" + +mitk::DICOMITKSeriesGDCMReader +::DICOMITKSeriesGDCMReader() +:DICOMFileReader() +,m_FixTiltByShearing(false) +,m_Group3DplusT(false) +{ +} + +mitk::DICOMITKSeriesGDCMReader +::DICOMITKSeriesGDCMReader(const DICOMITKSeriesGDCMReader& other ) +:DICOMFileReader(other) +,m_FixTiltByShearing(false) +,m_Group3DplusT(false) +{ +} + +mitk::DICOMITKSeriesGDCMReader +::~DICOMITKSeriesGDCMReader() +{ +} + +mitk::DICOMITKSeriesGDCMReader& +mitk::DICOMITKSeriesGDCMReader +::operator=(const DICOMITKSeriesGDCMReader& other) +{ + if (this != &other) + { + DICOMFileReader::operator=(other); + } + return *this; +} + + +void +mitk::DICOMITKSeriesGDCMReader +::AnalyzeInputFiles() +{ + this->ClearOutputs(); + + // prepare initial sorting (== list of input files) + + StringList inputFilenames = this->GetInputFiles(); + DICOMImageFrameList initialFramelist; + for (StringList::const_iterator inputIter = inputFilenames.begin(); + inputIter != inputFilenames.end(); + ++inputIter) + { + // TODO check DICOMness and non-multi-framedness + initialFramelist.push_back( DICOMImageFrameInfo::New(*inputIter, 0) ); + } + m_SortingResultInProgress.push_back( initialFramelist ); + + /* + PSEUDO CODE + + // scan files for sorting-relevant tags + + gdcm::Scanner gdcmScanner; + + foreach(DICOMDataSetSorter sorter, m_Sorter) + { + TagList tags = sorter->GetTagsOfInterest(); + foreach(Tag, tags) + { + gdcmScanner.AddTag( tag ); + } + } + + // sort and split blocks as configured + + DICOMImageFrameInfo nextStepSorting; // we should not modify our input list while processing it + foreach(DICOMDataSetSorter sorter, m_Sorter) + { + nextStepSorting.clear(); + + foreach(DICOMImageFrameList framelist, m_SortingResultInProgress) + { + sorter->SetInput(framelist); + sorter->Sort(); + unsigned int numberOfResultingBlocks = sorter->GetNumberOfOutputs(); + for (unsigned int b = 0; b < numberOfResultingBlocks; ++b) + { + DICOMImageFrameList blockResult = sorter->GetOutput(b); + nextStepSorting.push_back( blockResult ); + } + } + + m_SortingResultInProgress = nextStepSorting; + } + + */ + + // provide final result as output + + this->SetNumberOfOutputs( m_SortingResultInProgress.size() ); + unsigned int o = 0; + for (SortingBlockList::iterator blockIter = m_SortingResultInProgress.begin(); + blockIter != m_SortingResultInProgress.end(); + ++o, ++blockIter) + { + DICOMImageBlockDescriptor block; + block.SetImageFrameList( *blockIter ); + this->SetOutput( o, block ); + } +} + +// void AllocateOutputImages(); + +bool +mitk::DICOMITKSeriesGDCMReader +::LoadImages() +{ + // does nothing + return true; +} + +bool +mitk::DICOMITKSeriesGDCMReader +::CanHandleFile(const std::string& itkNotUsed(filename)) +{ + return true; // can handle all +} diff --git a/Modules/DICOMReader/mitkDICOMITKSeriesGDCMReader.h b/Modules/DICOMReader/mitkDICOMITKSeriesGDCMReader.h new file mode 100644 index 0000000000..6cd8e611b3 --- /dev/null +++ b/Modules/DICOMReader/mitkDICOMITKSeriesGDCMReader.h @@ -0,0 +1,59 @@ +/*=================================================================== + +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 mitkDICOMITKSeriesGDCMReader_h +#define mitkDICOMITKSeriesGDCMReader_h + +#include "mitkDICOMFileReader.h" + +namespace mitk +{ + +class DICOMITKSeriesGDCMReader : public DICOMFileReader +{ + public: + + mitkClassMacro( DICOMITKSeriesGDCMReader, DICOMFileReader ); + mitkCloneMacro( DICOMITKSeriesGDCMReader ); + itkNewMacro( DICOMITKSeriesGDCMReader ); + + virtual void AnalyzeInputFiles(); + + // void AllocateOutputImages(); + virtual bool LoadImages(); + + virtual bool CanHandleFile(const std::string& filename); + + protected: + + DICOMITKSeriesGDCMReader(); + virtual ~DICOMITKSeriesGDCMReader(); + + DICOMITKSeriesGDCMReader(const DICOMITKSeriesGDCMReader& other); + DICOMITKSeriesGDCMReader& operator=(const DICOMITKSeriesGDCMReader& other); + + private: + + bool m_FixTiltByShearing; + bool m_Group3DplusT; + + typedef std::list SortingBlockList; + SortingBlockList m_SortingResultInProgress; +}; + +} + +#endif diff --git a/Modules/DICOMReader/mitkDICOMImageBlockDescriptor.cpp b/Modules/DICOMReader/mitkDICOMImageBlockDescriptor.cpp index 9db8558bea..34ec3e1f97 100644 --- a/Modules/DICOMReader/mitkDICOMImageBlockDescriptor.cpp +++ b/Modules/DICOMReader/mitkDICOMImageBlockDescriptor.cpp @@ -1,179 +1,179 @@ /*=================================================================== 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. ===================================================================*/ #include "mitkDICOMImageBlockDescriptor.h" mitk::DICOMImageBlockDescriptor ::DICOMImageBlockDescriptor() :m_PixelsInterpolated(false) ,m_PixelSpacingInterpretation() { } mitk::DICOMImageBlockDescriptor ::~DICOMImageBlockDescriptor() { } mitk::DICOMImageBlockDescriptor ::DICOMImageBlockDescriptor(const DICOMImageBlockDescriptor& other) -:m_Filenames( other.m_Filenames ) +:m_ImageFrameList( other.m_ImageFrameList ) ,m_MitkImage( other.m_MitkImage ) ,m_SliceIsLoaded( other.m_SliceIsLoaded ) ,m_PixelsInterpolated( other.m_PixelsInterpolated ) ,m_PixelSpacingInterpretation( other.m_PixelSpacingInterpretation ) { if (m_MitkImage) { m_MitkImage = m_MitkImage->Clone(); } } mitk::DICOMImageBlockDescriptor& mitk::DICOMImageBlockDescriptor ::operator=(const DICOMImageBlockDescriptor& other) { if (this != &other) { - m_Filenames = other.m_Filenames; + m_ImageFrameList = other.m_ImageFrameList; m_MitkImage = other.m_MitkImage; m_SliceIsLoaded = other.m_SliceIsLoaded; m_PixelsInterpolated = other.m_PixelsInterpolated; m_PixelSpacingInterpretation = other.m_PixelSpacingInterpretation; if (m_MitkImage) { m_MitkImage = m_MitkImage->Clone(); } } return *this; } void mitk::DICOMImageBlockDescriptor -::SetFilenames(StringList filenames) +::SetImageFrameList(const DICOMImageFrameList& framelist) { - m_Filenames = filenames; - m_SliceIsLoaded.resize(filenames.size()); - m_SliceIsLoaded.assign(filenames.size(), false); + m_ImageFrameList = framelist; + m_SliceIsLoaded.resize(framelist.size()); + m_SliceIsLoaded.assign(framelist.size(), false); } -const mitk::StringList& +const mitk::DICOMImageFrameList& mitk::DICOMImageBlockDescriptor -::GetFilenames() const +::GetImageFrameList() const { - return m_Filenames; + return m_ImageFrameList; } void mitk::DICOMImageBlockDescriptor ::SetMitkImage(Image::Pointer image) { if (m_MitkImage != image) { m_MitkImage = image; } } mitk::Image::Pointer mitk::DICOMImageBlockDescriptor ::GetMitkImage() const { return m_MitkImage; } void mitk::DICOMImageBlockDescriptor ::SetSliceIsLoaded(unsigned int index, bool isLoaded) { if (index < m_SliceIsLoaded.size()) { m_SliceIsLoaded[index] = isLoaded; } else { std::stringstream ss; ss << "Index " << index << " out of range (" << m_SliceIsLoaded.size() << " indices reserved)"; throw std::invalid_argument( ss.str() ); } } bool mitk::DICOMImageBlockDescriptor ::IsSliceLoaded(unsigned int index) const { if (index < m_SliceIsLoaded.size()) { return m_SliceIsLoaded[index]; } else { std::stringstream ss; ss << "Index " << index << " out of range (" << m_SliceIsLoaded.size() << " indices reserved)"; throw std::invalid_argument( ss.str() ); } } bool mitk::DICOMImageBlockDescriptor ::AllSlicesAreLoaded() const { bool allLoaded = true; for (BoolList::const_iterator iter = m_SliceIsLoaded.begin(); iter != m_SliceIsLoaded.end(); ++iter) { allLoaded &= *iter; } return allLoaded; } void mitk::DICOMImageBlockDescriptor ::SetPixelsInterpolated(bool pixelsAreInterpolated) { if (m_PixelsInterpolated != pixelsAreInterpolated) { m_PixelsInterpolated = pixelsAreInterpolated; } } bool mitk::DICOMImageBlockDescriptor ::GetPixelsInterpolated() const { return m_PixelsInterpolated; } void mitk::DICOMImageBlockDescriptor ::SetPixelSpacingInterpretation( PixelSpacingInterpretation interpretation ) { if (m_PixelSpacingInterpretation != interpretation) { m_PixelSpacingInterpretation = interpretation; } } mitk::PixelSpacingInterpretation mitk::DICOMImageBlockDescriptor ::GetPixelSpacingInterpretation() const { return m_PixelSpacingInterpretation; } diff --git a/Modules/DICOMReader/mitkDICOMImageBlockDescriptor.h b/Modules/DICOMReader/mitkDICOMImageBlockDescriptor.h index 80c79793dd..2e01cd917b 100644 --- a/Modules/DICOMReader/mitkDICOMImageBlockDescriptor.h +++ b/Modules/DICOMReader/mitkDICOMImageBlockDescriptor.h @@ -1,66 +1,66 @@ /*=================================================================== 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 mitkDICOMImageBlockDescriptor_h #define mitkDICOMImageBlockDescriptor_h #include "mitkImage.h" #include "mitkDICOMEnums.h" #include "DICOMReaderExports.h" namespace mitk { class DICOMReader_EXPORT DICOMImageBlockDescriptor { public: DICOMImageBlockDescriptor(); ~DICOMImageBlockDescriptor(); DICOMImageBlockDescriptor(const DICOMImageBlockDescriptor& other); DICOMImageBlockDescriptor& operator=(const DICOMImageBlockDescriptor& other); - void SetFilenames(StringList filenames); - const StringList& GetFilenames() const; + void SetImageFrameList(const DICOMImageFrameList& framelist); + const DICOMImageFrameList& GetImageFrameList() const; void SetMitkImage(Image::Pointer image); Image::Pointer GetMitkImage() const; void SetSliceIsLoaded(unsigned int index, bool isLoaded); bool IsSliceLoaded(unsigned int index) const; bool AllSlicesAreLoaded() const; void SetPixelsInterpolated(bool pixelsAreInterpolated); bool GetPixelsInterpolated() const; void SetPixelSpacingInterpretation( PixelSpacingInterpretation interpretation ); PixelSpacingInterpretation GetPixelSpacingInterpretation() const; private: - StringList m_Filenames; + DICOMImageFrameList m_ImageFrameList; Image::Pointer m_MitkImage; BoolList m_SliceIsLoaded; bool m_PixelsInterpolated; PixelSpacingInterpretation m_PixelSpacingInterpretation; }; } #endif diff --git a/Modules/DICOMReader/mitkDICOMImageFrameInfo.h b/Modules/DICOMReader/mitkDICOMImageFrameInfo.h new file mode 100644 index 0000000000..6f58ece05d --- /dev/null +++ b/Modules/DICOMReader/mitkDICOMImageFrameInfo.h @@ -0,0 +1,50 @@ +/*=================================================================== + +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 mitkDICOMImageFrameInfo_h +#define mitkDICOMImageFrameInfo_h + +#include "itkObjectFactory.h" +#include "mitkCommon.h" + +#include "DICOMReaderExports.h" + +namespace mitk +{ + class DICOMReader_EXPORT DICOMImageFrameInfo : public itk::LightObject + { + public: + + std::string Filename; + unsigned int FrameNo; + + mitkClassMacro( DICOMImageFrameInfo, itk::LightObject ) + + itkNewMacro( DICOMImageFrameInfo ); + mitkNewMacro1Param( DICOMImageFrameInfo, const std::string&); + mitkNewMacro2Param( DICOMImageFrameInfo, const std::string&, unsigned int ); + + protected: + + DICOMImageFrameInfo(const std::string& filename = "", unsigned int frameNo = 0) + :Filename(filename) + ,FrameNo(frameNo) + { + } + }; +} + +#endif