1 /*=========================================================================
4 Module: $RCSfile: gdcmSerieHelper.h,v $
6 Date: $Date: 2005/07/19 09:04:58 $
7 Version: $Revision: 1.13 $
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"
31 typedef std::vector<File* > FileList;
33 //-----------------------------------------------------------------------------
36 * - This class should be used for a stack of 2D dicom images.
37 * It allows to explore (recursively or not) a directory and
38 * makes a set of 'Coherent Files' list (coherent : same Serie UID)
39 * It allows to sort any of the Coherent File list on the image position
41 class GDCM_EXPORT SerieHelper
44 typedef std::map<std::string, FileList *> CoherentFileListmap;
45 typedef std::vector<File* > FileVector;
49 void Print(std::ostream &os = std::cout, std::string const &indent = "" );
51 /// \todo should return bool or throw error ?
52 void AddFileName(std::string const &filename);
53 void AddGdcmFile(File *header);
55 void SetDirectory(std::string const &dir, bool recursive=false);
56 void OrderFileList(FileList *coherentFileList);
58 /// \brief Gets the FIRST *coherent* File List.
59 /// Deprecated; kept not to break the API
60 /// \note Caller must call OrderFileList first
61 /// @return the (first) *coherent* File List
62 const FileList &GetFileList() { return *CoherentFileListHT.begin()->second; }
64 FileList *GetFirstCoherentFileList();
65 FileList *GetNextCoherentFileList();
66 FileList *GetCoherentFileList(std::string serieUID);
68 /// All the following allow user to restrict DICOM file to be part
69 /// of a particular serie
70 void AddRestriction(TagKey const &key, std::string const &value);
73 * \brief Sets the LoadMode as a boolean string.
74 * NO_SEQ, NO_SHADOW, NO_SHADOWSEQ
75 ... (nothing more, right now)
76 * WARNING : before using NO_SHADOW, be sure *all* your files
77 * contain accurate values in the 0x0000 element (if any)
78 * of *each* Shadow Group. The parser will fail if the size is wrong !
79 * @param mode Load mode to be used
81 void SetLoadMode (int mode) { LoadMode = mode; }
84 bool ImagePositionPatientOrdering(FileList *coherentFileList);
85 bool ImageNumberOrdering(FileList *coherentFileList);
86 bool FileNameOrdering(FileList *coherentFileList);
88 static bool ImageNumberLessThan(File *file1, File *file2);
89 static bool FileNameLessThan(File *file1, File *file2);
92 CoherentFileListmap CoherentFileListHT;
93 CoherentFileListmap::iterator ItListHt;
95 typedef std::pair<TagKey, std::string> Rule;
96 typedef std::vector<Rule> SerieRestrictions;
97 SerieRestrictions Restrictions;
99 /// \brief Bit string integer (each one considered as a boolean)
100 /// Bit 0 : Skip Sequences, if possible
101 /// Bit 1 : Skip Shadow Groups if possible
102 /// Probabely, some more to add
106 } // end namespace gdcm
108 //-----------------------------------------------------------------------------