itkDICOMSeriesFileNames.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkDICOMSeriesFileNames_h
00018 #define __itkDICOMSeriesFileNames_h
00019
00020 #ifdef _MSC_VER
00021 #pragma warning ( disable : 4786 )
00022 #endif
00023
00024 #include "itkObject.h"
00025 #include "itkObjectFactory.h"
00026 #include "itkExceptionObject.h"
00027 #include <vector>
00028
00029 #include "DICOMParser.h"
00030 #include "DICOMAppHelper.h"
00031
00032 namespace itk
00033 {
00034
00048 class ITK_EXPORT DICOMSeriesFileNames : public Object
00049 {
00050 public:
00052 typedef DICOMSeriesFileNames Self;
00053 typedef Object Superclass;
00054 typedef SmartPointer<Self> Pointer;
00055
00057 itkNewMacro(Self);
00058
00060 itkTypeMacro(DICOMSeriesFileNames, Object);
00061
00062
00063
00073 void SetDirectory(const std::string& dir)
00074 {
00075 if (m_Directory != dir)
00076 {
00077 m_Directory = dir;
00078 this->Modified();
00080
00081
00082 m_SeriesUIDs.clear();
00083 m_FileNames.clear();
00084 m_AppHelper.Clear();
00085 }
00086
00087
00088
00089
00090
00091
00092 m_DirectorySetTime.Modified();
00093 }
00094
00096 itkGetStringMacro(Directory);
00097
00100 itkSetMacro(Ascending, bool);
00101 itkGetConstMacro(Ascending, bool);
00102 itkBooleanMacro(Ascending);
00104
00106 typedef std::vector<std::string> FileNamesArrayType;
00107
00111 const FileNamesArrayType & GetSeriesUIDs(bool recursive = false);
00112
00115 const FileNamesArrayType & GetSeriesDescriptions(){return m_SeriesDescriptions;}
00116 const FileNamesArrayType & GetSeriesBodyParts(){return m_BodyParts;}
00117 const FileNamesArrayType & GetSeriesScanOptions(){return m_ScanOptions;}
00119
00123 const FileNamesArrayType & GetFileNames (bool recursive = false);
00124
00129 const FileNamesArrayType & GetFileNames (const std::string& seriesUID,
00130 bool recursive = false);
00131
00136 typedef enum {SortByImageNumber, SortBySliceLocation, SortByImagePositionPatient} FileNameSortingOrderType;
00137 itkSetEnumMacro(FileNameSortingOrder, FileNameSortingOrderType);
00138 itkGetEnumMacro(FileNameSortingOrder, FileNameSortingOrderType);
00139 void SetFileNameSortingOrderToSortByImageNumber()
00140 { this->SetFileNameSortingOrder(SortByImageNumber); }
00141 void SetFileNameSortingOrderToSortBySliceLocation()
00142 { this->SetFileNameSortingOrder(SortBySliceLocation); }
00143 void SetFileNameSortingOrderToSortByImagePositionPatient()
00144 { this->SetFileNameSortingOrder(SortByImagePositionPatient); }
00146
00150 std::string GetFileName(const std::string& instanceUID);
00151
00152
00153 protected:
00154 DICOMSeriesFileNames();
00155 ~DICOMSeriesFileNames() {};
00156 void PrintSelf(std::ostream& os, Indent indent) const;
00157
00158 private:
00159 DICOMSeriesFileNames(const Self&);
00160 void operator=(const Self&);
00161
00162 int CanReadFile(const char* fname);
00163 void RecurseDirectory( std::string directory, FileNamesArrayType &filenames);
00164
00165 itkdicomparser::DICOMParser m_Parser;
00166 itkdicomparser::DICOMAppHelper m_AppHelper;
00167
00168 bool m_Ascending;
00169 std::string m_Directory;
00170 FileNamesArrayType m_FileNames;
00171 FileNamesArrayType m_SeriesUIDs;
00172 FileNamesArrayType m_SeriesDescriptions;
00173 FileNamesArrayType m_BodyParts;
00174 FileNamesArrayType m_ScanOptions;
00175
00176 FileNameSortingOrderType m_FileNameSortingOrder;
00177
00178 TimeStamp m_DirectorySetTime;
00179 TimeStamp m_DirectoryScanTime;
00180 };
00181
00182 }
00183
00184 #endif // __itkDICOMSeriesFileNames_h
00185