Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkDICOMSeriesFileNames.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkDICOMSeriesFileNames.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/04/09 21:46:59 $
00007   Version:   $Revision: 1.10 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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   /* -------- Define the API for DICOMSeriesFileNames ----------- */
00063 
00073   void SetDirectory(const std::string& dir)
00074     {
00075       if (m_Directory != dir)
00076         {
00077         m_Directory = dir;
00078         this->Modified();
00079 
00080         // Clear the SeriesUIDs and FileNames
00081         m_SeriesUIDs.clear();
00082         m_FileNames.clear();
00083         m_AppHelper.Clear();
00084         }
00085 
00086       // Keep track of when the directory name was set so we can
00087       // compare it when the directory was last scanned. We set this
00088       // modified time each time SetDirectory() is called. This allows
00089       // a call to SetDirectory() to force a directory to be rescanned
00090       // the next time GetFileNames() or GetSeriesUIDs() is called.
00091       m_DirectorySetTime.Modified();
00092     }
00093 
00095   itkGetStringMacro(Directory);
00096 
00099   itkSetMacro(Ascending, bool);
00100   itkGetMacro(Ascending, bool);
00101   itkBooleanMacro(Ascending);
00102 
00106   const std::vector<std::string> &GetSeriesUIDs(bool recursive = false);
00107   
00110   const std::vector<std::string> &GetSeriesDescriptions(){return m_SeriesDescriptions;}
00111   const std::vector<std::string> &GetSeriesBodyParts(){return m_BodyParts;}
00112   const std::vector<std::string> &GetSeriesScanOptions(){return m_ScanOptions;}
00113 
00117   const std::vector<std::string> &GetFileNames (bool recursive = false);
00118 
00123   const std::vector<std::string> &GetFileNames (const std::string& seriesUID,
00124                                                 bool recursive = false);
00125   
00130   typedef enum {SortByImageNumber, SortBySliceLocation, SortByImagePositionPatient} FileNameSortingOrderType;
00131   itkSetMacro(FileNameSortingOrder, FileNameSortingOrderType);
00132   itkGetMacro(FileNameSortingOrder, FileNameSortingOrderType);
00133   void SetFileNameSortingOrderToSortByImageNumber()
00134     { this->SetFileNameSortingOrder(SortByImageNumber); }
00135   void SetFileNameSortingOrderToSortBySliceLocation()
00136     { this->SetFileNameSortingOrder(SortBySliceLocation); }
00137   void SetFileNameSortingOrderToSortByImagePositionPatient()
00138     { this->SetFileNameSortingOrder(SortByImagePositionPatient); }
00139 
00143   std::string GetFileName(const std::string& instanceUID);
00144   
00145 
00146 protected:
00147   DICOMSeriesFileNames();
00148   ~DICOMSeriesFileNames() {};
00149   void PrintSelf(std::ostream& os, Indent indent) const;
00150   
00151 private:
00152   DICOMSeriesFileNames(const Self&); //purposely not implemented
00153   void operator=(const Self&); //purposely not implemented
00154   
00155   int CanReadFile(const char* fname);
00156   void RecurseDirectory( std::string directory, std::vector<std::string> &filenames);
00157 
00158   itkdicomparser::DICOMParser m_Parser;
00159   itkdicomparser::DICOMAppHelper m_AppHelper;
00160 
00161   bool m_Ascending;
00162   std::string m_Directory;
00163   std::vector<std::string>  m_FileNames;
00164   std::vector<std::string>  m_SeriesUIDs;
00165   std::vector<std::string>  m_SeriesDescriptions;
00166   std::vector<std::string>  m_BodyParts;
00167   std::vector<std::string>  m_ScanOptions;
00168 
00169   FileNameSortingOrderType m_FileNameSortingOrder;
00170 
00171   TimeStamp  m_DirectorySetTime;
00172   TimeStamp  m_DirectoryScanTime;
00173 };
00174 
00175 } //namespace ITK
00176 
00177 #endif // __itkDICOMSeriesFileNames_h

Generated at Wed May 24 23:03:13 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000