1 /*=========================================================================
4 Module: $RCSfile: gdcmSerieHelper.h,v $
6 Date: $Date: 2005/07/21 05:00:30 $
7 Version: $Revision: 1.14 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #ifndef GDCMSERIEHELPER_H
20 #define GDCMSERIEHELPER_H
22 #include "gdcmCommon.h"
23 #include "gdcmDebug.h" // for LEGACY
32 typedef std::vector<File* > FileList;
34 //-----------------------------------------------------------------------------
37 * - This class should be used for a stack of 2D dicom images.
38 * It allows to explore (recursively or not) a directory and
39 * makes a set of 'Coherent Files' list (coherent : same Serie UID)
40 * It allows to sort any of the Coherent File list on the image position
42 class GDCM_EXPORT SerieHelper
45 typedef std::map<std::string, FileList *> CoherentFileListmap;
46 typedef std::vector<File* > FileVector;
50 void Print(std::ostream &os = std::cout, std::string const &indent = "" );
52 /// \todo should return bool or throw error ?
53 void AddFileName(std::string const &filename);
54 void AddGdcmFile(File *header);
56 void SetDirectory(std::string const &dir, bool recursive=false);
57 void OrderFileList(FileList *coherentFileList);
59 /// \brief Gets the FIRST *coherent* File List.
60 /// Deprecated; kept not to break the API
61 /// \note Caller must call OrderFileList first
62 /// @return the (first) *coherent* File List
63 const FileList &GetFileList() { return *CoherentFileListHT.begin()->second; }
65 FileList *GetFirstCoherentFileList();
66 FileList *GetNextCoherentFileList();
67 FileList *GetCoherentFileList(std::string serieUID);
69 /// All the following allow user to restrict DICOM file to be part
70 /// of a particular serie
71 GDCM_LEGACY( void AddRestriction(TagKey const &key, std::string const &value) );
72 void AddRestriction(uint16_t group, uint16_t elem,
73 std::string const &value, int op);
76 * \brief Sets the LoadMode as a boolean string.
77 * NO_SEQ, NO_SHADOW, NO_SHADOWSEQ
78 ... (nothing more, right now)
79 * WARNING : before using NO_SHADOW, be sure *all* your files
80 * contain accurate values in the 0x0000 element (if any)
81 * of *each* Shadow Group. The parser will fail if the size is wrong !
82 * @param mode Load mode to be used
84 void SetLoadMode (int mode) { LoadMode = mode; }
87 bool ImagePositionPatientOrdering(FileList *coherentFileList);
88 bool ImageNumberOrdering(FileList *coherentFileList);
89 bool FileNameOrdering(FileList *coherentFileList);
91 static bool ImageNumberLessThan(File *file1, File *file2);
92 static bool FileNameLessThan(File *file1, File *file2);
95 CoherentFileListmap CoherentFileListHT;
96 CoherentFileListmap::iterator ItListHt;
98 typedef std::pair<TagKey, std::string> Rule;
99 typedef std::vector<Rule> SerieRestrictions;
100 SerieRestrictions Restrictions;
102 // New style for (extented) Rules (Moreover old one doesn't compile)
109 typedef std::vector<ExRule> SerieExRestrictions;
110 SerieExRestrictions ExRestrictions;
112 /// \brief Bit string integer (each one considered as a boolean)
113 /// Bit 0 : Skip Sequences, if possible
114 /// Bit 1 : Skip Shadow Groups if possible
115 /// Probabely, some more to add
119 } // end namespace gdcm
121 //-----------------------------------------------------------------------------