1 /*=========================================================================
4 Module: $RCSfile: gdcmSerieHelper.cxx,v $
6 Date: $Date: 2005/12/16 13:48:46 $
7 Version: $Revision: 1.40 $
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 #include "gdcmSerieHelper.h"
20 #include "gdcmDirList.h"
22 #include "gdcmDictEntry.h" // for TranslateToKey
23 #include "gdcmDebug.h"
30 #include <stdio.h> //for sscanf
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
37 // Constructor / Destructor
39 * \brief Constructor from a given SerieHelper
41 SerieHelper::SerieHelper()
43 m_UseSeriesDetails = false;
45 UserLessThanFunction = 0;
50 * \brief Canonical destructor.
52 SerieHelper::~SerieHelper()
58 * \brief Preventively, clear everything at constructor time.
59 * ( use it at destructor time.)
61 void SerieHelper::ClearAll()
63 // For all the 'Single SerieUID' Filesets that may already exist
64 FileList *l = GetFirstSingleSerieUIDFileSet();
67 // For all the gdcm::File of a File set
68 for (gdcm::FileList::iterator it = l->begin();
72 (*it)->Delete(); // remove each entry
75 delete l; // remove the container
76 l = GetNextSingleSerieUIDFileSet();
80 //-----------------------------------------------------------------------------
82 //-----------------------------------------------------------------------------
86 * \brief add a gdcm::File to the Fileset corresponding to its Serie UID
87 * @param filename Name of the file to deal with
89 void SerieHelper::AddFileName(std::string const &filename)
91 // Create a DICOM file
92 File *header = File::New();
93 header->SetLoadMode(LoadMode);
94 header->SetFileName( filename );
97 if ( header->IsReadable() )
100 // First step : the user defined a set of rules for the DICOM file
101 // he is looking for.
102 // Make sure the file corresponds to his set of rules:
105 for(SerieExRestrictions::iterator it2 = ExRestrictions.begin();
106 it2 != ExRestrictions.end();
109 const ExRule &r = *it2;
110 s = header->GetEntryString( r.group, r.elem );
111 if ( !Util::CompareDicomString(s, r.value.c_str(), r.op) )
113 // Argh ! This rule is unmatched; let's just quit
120 if ( allrules ) // all rules are respected:
122 // Allright! we have a found a DICOM that matches the user expectation.
125 // 0020 000e UI REL Series Instance UID
126 const std::string &uid = header->GetEntryString(0x0020, 0x000e);
127 // if uid == GDCM_UNFOUND then consistently we should find GDCM_UNFOUND
128 // no need here to do anything special
131 if ( SingleSerieUIDFileSetHT.count(uid) == 0 )
133 gdcmDebugMacro(" New Serie UID :[" << uid << "]");
134 // create a std::list in 'uid' position
135 SingleSerieUIDFileSetHT[uid] = new FileList;
137 // Current Serie UID and DICOM header seems to match; add the file:
138 SingleSerieUIDFileSetHT[uid]->push_back( header );
142 // at least one rule was unmatched we need to deallocate the file:
148 gdcmWarningMacro("Could not read file: " << filename );
154 * \brief add a gdcm::File to the first (and supposed to be unique) file set
155 * of the gdcm::SerieHelper.
156 * \warning : this method should be used by aware users only!
157 * Passing a gdcm::File* has the same effect than passing a file name!
158 * \todo : decide which one is wrong (the method, or the commentary)!
159 * the following comment doesn't match the method :-(
160 * User is supposed to know the files he want to deal with
161 * and consider them they belong to the same Serie
162 * (even if their Serie UID is different)
163 * user will probabely OrderFileList() this list (actually, ordering
164 * user choosen gdm::File is the sole interest of this method)
165 * Moreover, using vtkGdcmReader::SetCoherentFileList() will avoid
166 * vtkGdcmReader parsing twice the same files.
167 * *no* coherence check is performed, but those specified
168 * by SerieHelper::AddRestriction()
169 * @param header gdcm::File* of the file to deal with
171 void SerieHelper::AddGdcmFile(File *header)
174 // First step the user has defined a set of rules for the DICOM
175 // he is looking for.
176 // make sure the file correspond to his set of rules:
177 for(SerieRestrictions::iterator it = Restrictions.begin();
178 it != Restrictions.end();
182 const std::string s;// = header->GetEntryString( r.first );
183 if ( !Util::DicomStringEqual(s, r.second.c_str()) )
185 // Argh ! This rule is unmatch let's just quit
190 if ( allrules ) // all rules are respected:
192 // Allright ! we have a found a DICOM that match the user expectation.
195 const std::string &uid = "0";
196 // Serie UID of the gdcm::File* may be different.
197 // User is supposed to know what he wants
199 if ( SingleSerieUIDFileSetHT.count(uid) == 0 )
201 gdcmDebugMacro(" New Serie UID :[" << uid << "]");
202 // create a std::list in 'uid' position
203 SingleSerieUIDFileSetHT[uid] = new FileList;
205 // Current Serie UID and DICOM header seems to match; add the file:
206 SingleSerieUIDFileSetHT[uid]->push_back( header );
208 // Even if a rule was unmatch we don't deallocate the gdcm::File:
212 * \brief add a rule for restricting a DICOM file to be in the serie we are
213 * trying to find. For example you can select only the DICOM files from a
214 * directory which would have a particular EchoTime==4.0.
215 * This method is a user level, value is not required to be formatted as a DICOM
217 * \todo find a trick to allow user if he wants the Rectrictions to be *ored*
218 * (and not only *anded*)
219 * @param key Target tag we want restrict on a given value
220 * @param value value to be checked to exclude File
221 * @param op operator we want to use to check
223 void SerieHelper::AddRestriction(TagKey const &key,
224 std::string const &value, int op)
231 ExRestrictions.push_back( r );
235 * \brief add a rule for restricting a DICOM file to be in the serie we are
236 * trying to find. For example you can select only the DICOM file from a
237 * directory which would have a particular EchoTime==4.0.
238 * This method is a user level, value is not required to be formatted as a DICOM
240 * \todo find a trick to allow user if he wants the Rectrictions to be *ored*
241 * (and not only *anded*)
242 * @param group tag group number we want restrict on a given value
243 * @param elem tag element number we want restrict on a given value
244 * @param value value to be checked to exclude File
245 * @param op operator we want to use to check
247 void SerieHelper::AddRestriction(uint16_t group, uint16_t elem,
248 std::string const &value, int op)
255 ExRestrictions.push_back( r );
259 * \brief add an extra 'SerieDetail' for building a 'Serie Identifier'
260 * that ensures (hope so) File constistency (Series Instance UID doesn't.
261 * @param group tag group number we want restrict on a given value
262 * @param elem tag element number we want restrict on a given value
264 void SerieHelper::AddSeriesDetail(uint16_t group, uint16_t elem)
266 m_UseSeriesDetails = true;
271 ExDetails.push_back( d );
274 * \brief Sets the root Directory
275 * @param dir Name of the directory to deal with
276 * @param recursive whether we want explore recursively the root Directory
278 void SerieHelper::SetDirectory(std::string const &dir, bool recursive)
280 DirList dirList(dir, recursive); // OS specific
282 DirListType filenames_list = dirList.GetFilenames();
283 for( DirListType::const_iterator it = filenames_list.begin();
284 it != filenames_list.end(); ++it)
291 * \brief Sorts the given Fileset
292 * \warning This could be implemented in a 'Strategy Pattern' approach
293 * But as I don't know how to do it, I leave it this way
294 * BTW, this is also a Strategy, I don't know this is
295 * the best approach :)
297 void SerieHelper::OrderFileList(FileList *fileSet)
300 if ( SerieHelper::UserLessThanFunction )
302 UserOrdering( fileSet );
305 else if ( ImagePositionPatientOrdering( fileSet ) )
309 else if ( ImageNumberOrdering(fileSet ) )
315 FileNameOrdering(fileSet );
320 * \brief Elementary coherence checking of the files with the same Serie UID
321 * Only sizes and pixel type are checked right now ...
323 bool SerieHelper::IsCoherent(FileList *fileSet)
325 if(fileSet->size() == 1)
328 FileList::const_iterator it = fileSet->begin();
330 int nX = (*it)->GetXSize();
331 int nY = (*it)->GetYSize();
332 int pixelSize = (*it)->GetPixelSize();
333 bool signedPixelData = (*it)->IsSignedPixelData();
336 it != fileSet->end();
339 if ( (*it)->GetXSize() != nX )
341 if ( (*it)->GetYSize() != nY )
343 if ( (*it)->GetPixelSize() != pixelSize )
345 if ( (*it)->IsSignedPixelData() != signedPixelData )
347 // probabely more is to be checked (?)
352 #ifndef GDCM_LEGACY_REMOVE
354 FileList *SerieHelper::GetFirstCoherentFileList()
356 ItFileSetHt = SingleSerieUIDFileSetHT.begin();
357 if ( ItFileSetHt != SingleSerieUIDFileSetHT.end() )
358 return ItFileSetHt->second;
363 FileList *SerieHelper::GetNextCoherentFileList()
365 gdcmAssertMacro (ItFileSetHt != SingleSerieUIDFileSetHT.end());
368 if ( ItFileSetHt != SingleSerieUIDFileSetHT.end() )
369 return ItFileSetHt->second;
374 FileList *SerieHelper::GetCoherentFileList(std::string SerieUID)
376 if ( SingleSerieUIDFileSetHT.count(SerieUID) == 0 )
378 return SingleSerieUIDFileSetHT[SerieUID];
384 * \brief Get the first Fileset while visiting the SingleSerieUIDFileSetmap
385 * @return The first FileList (SingleSerieUIDFileSet) if found, otherwhise 0
387 FileList *SerieHelper::GetFirstSingleSerieUIDFileSet()
389 ItFileSetHt = SingleSerieUIDFileSetHT.begin();
390 if ( ItFileSetHt != SingleSerieUIDFileSetHT.end() )
391 return ItFileSetHt->second;
396 * \brief Get the next Fileset while visiting the SingleSerieUIDFileSetmap
397 * \note : meaningfull only if GetNextSingleSerieUIDFileSet() already called
398 * @return The next FileList (SingleSerieUIDFileSet) if found, otherwhise 0
400 FileList *SerieHelper::GetNextSingleSerieUIDFileSet()
402 gdcmAssertMacro (ItFileSetHt != SingleSerieUIDFileSetHT.end());
405 if ( ItFileSetHt != SingleSerieUIDFileSetHT.end() )
406 return ItFileSetHt->second;
411 * \brief Get the SingleSerieUIDFileSet according to its Serie UID
412 * @param SerieUID SerieUID to retrieve
413 * \return pointer to the FileList (SingleSerieUIDFileSet) if found, otherwhise 0
415 FileList *SerieHelper::GetSingleSerieUIDFileSet(std::string SerieUID)
417 if ( SingleSerieUIDFileSetHT.count(SerieUID) == 0 )
419 return SingleSerieUIDFileSetHT[SerieUID];
423 * \brief Splits a Single SerieUID Fileset according to the Orientations
424 * @param fileSet File Set to be splitted
425 * \return std::map of 'Xcoherent' File sets
428 XCoherentFileSetmap SerieHelper::SplitOnOrientation(FileList *fileSet)
430 XCoherentFileSetmap CoherentFileSet;
432 int nb = fileSet->size();
434 return CoherentFileSet;
437 std::string strOrient;
438 std::ostringstream ossOrient;
439 FileList::const_iterator it = fileSet->begin();
442 it != fileSet->end();
445 // Information is in :
446 // 0020 0037 : Image Orientation (Patient) or
447 // 0020 0035 : Image Orientation (RET)
449 // Let's build again the 'cosines' string, to be sure of it's format
450 (*it)->GetImageOrientationPatient(iop);
453 for (int i = 1; i < 6; i++)
458 strOrient = ossOrient.str();
460 // FIXME : is it a 'cleaner' way to initialize an ostringstream?
462 if ( CoherentFileSet.count(strOrient) == 0 )
464 gdcmDebugMacro(" New Orientation :[" << strOrient << "]");
465 // create a File set in 'orientation' position
466 CoherentFileSet[strOrient] = new FileList;
468 // Current Orientation and DICOM header match; add the file:
469 CoherentFileSet[strOrient]->push_back( (*it) );
471 return CoherentFileSet;
475 * \brief Splits a 'Single SerieUID' Fileset according to the Positions
476 * @param fileSet File Set to be splitted
477 * \return std::map of 'Xcoherent' File sets
480 XCoherentFileSetmap SerieHelper::SplitOnPosition(FileList *fileSet)
482 XCoherentFileSetmap CoherentFileSet;
484 int nb = fileSet->size();
486 return CoherentFileSet;
488 std::string strImPos; // read on disc
489 std::ostringstream ossPosition;
490 std::string strPosition; // re computed
491 FileList::const_iterator it = fileSet->begin();
494 it != fileSet->end();
497 // Information is in :
498 // 0020,0032 : Image Position Patient
499 // 0020,0030 : Image Position (RET)
501 strImPos = (*it)->GetEntryString(0x0020,0x0032);
502 if ( strImPos == GDCM_UNFOUND)
504 gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
505 strImPos = (*it)->GetEntryString(0x0020,0x0030); // For ACR-NEMA images
506 if ( strImPos == GDCM_UNFOUND )
508 gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
509 // User wants to split on the 'Position'
510 // No 'Position' info found.
511 // We return an empty Htable !
512 return CoherentFileSet;
516 if ( sscanf( strImPos.c_str(), "%f \\%f \\%f ",
517 &pos[0], &pos[1], &pos[2]) != 3 )
519 gdcmWarningMacro( "Wrong number for Position : ["
520 << strImPos << "]" );
521 return CoherentFileSet;
524 // Let's build again the 'position' string, to be sure of it's format
526 ossPosition << pos[0];
527 for (int i = 1; i < 3; i++)
530 ossPosition << pos[i];
532 strPosition = ossPosition.str();
535 if ( CoherentFileSet.count(strPosition) == 0 )
537 gdcmDebugMacro(" New Position :[" << strPosition << "]");
538 // create a File set in 'position' position
539 CoherentFileSet[strPosition] = new FileList;
541 // Current Position and DICOM header match; add the file:
542 CoherentFileSet[strPosition]->push_back( (*it) );
544 return CoherentFileSet;
548 * \brief Splits a 'Single SerieUID' File set Coherent according to the
549 * value of a given Tag
550 * @param fileSet File Set to be splitted
551 * @param group group number of the target Element
552 * @param elem element number of the target Element
553 * \return std::map of 'Xcoherent' File sets
556 XCoherentFileSetmap SerieHelper::SplitOnTagValue(FileList *fileSet,
557 uint16_t group, uint16_t elem)
559 XCoherentFileSetmap CoherentFileSet;
561 int nb = fileSet->size();
563 return CoherentFileSet;
565 std::string strTagValue; // read on disc
567 FileList::const_iterator it = fileSet->begin();
570 it != fileSet->end();
573 // Information is in :
574 // 0020,0032 : Image Position Patient
575 // 0020,0030 : Image Position (RET)
577 strTagValue = (*it)->GetEntryString(group,elem);
579 if ( CoherentFileSet.count(strTagValue) == 0 )
581 gdcmDebugMacro(" New Tag Value :[" << strTagValue << "]");
582 // create a File set in 'position' position
583 CoherentFileSet[strTagValue] = new FileList;
585 // Current Tag value and DICOM header match; add the file:
586 CoherentFileSet[strTagValue]->push_back( (*it) );
588 return CoherentFileSet;
591 //-----------------------------------------------------------------------------
594 //-----------------------------------------------------------------------------
597 * \brief sorts the images, according to their Patient Position.
599 * We may order, considering :
600 * -# Image Position Patient
603 * -# More to come :-)
604 * \note : FileList = std::vector<File* >
605 * @param fileList Coherent File list (same Serie UID) to sort
606 * @return false only if the header is bugged !
608 bool SerieHelper::ImagePositionPatientOrdering( FileList *fileList )
609 //based on Jolinda Smith's algorithm
611 //iop is calculated based on the file file
616 double min = 0, max = 0;
619 std::multimap<double,File *> distmultimap;
620 // Use a multimap to sort the distances from 0,0,0
621 for ( FileList::const_iterator
622 it = fileList->begin();
623 it != fileList->end(); ++it )
627 (*it)->GetImageOrientationPatient( cosines );
629 // You only have to do this once for all slices in the volume. Next,
630 // for each slice, calculate the distance along the slice normal
631 // using the IPP ("Image Position Patient") tag.
632 // ("dist" is initialized to zero before reading the first slice) :
633 normal[0] = cosines[1]*cosines[5] - cosines[2]*cosines[4];
634 normal[1] = cosines[2]*cosines[3] - cosines[0]*cosines[5];
635 normal[2] = cosines[0]*cosines[4] - cosines[1]*cosines[3];
637 ipp[0] = (*it)->GetXOrigin();
638 ipp[1] = (*it)->GetYOrigin();
639 ipp[2] = (*it)->GetZOrigin();
642 for ( int i = 0; i < 3; ++i )
644 dist += normal[i]*ipp[i];
647 distmultimap.insert(std::pair<const double,File *>(dist, *it));
654 ipp[0] = (*it)->GetXOrigin();
655 ipp[1] = (*it)->GetYOrigin();
656 ipp[2] = (*it)->GetZOrigin();
659 for ( int i = 0; i < 3; ++i )
661 dist += normal[i]*ipp[i];
664 distmultimap.insert(std::pair<const double,File *>(dist, *it));
666 min = (min < dist) ? min : dist;
667 max = (max > dist) ? max : dist;
672 // Find out if min/max are coherent
675 gdcmWarningMacro("Looks like all images have the exact same image position"
676 << ". No PositionPatientOrdering sort performed" );
680 // Check to see if image shares a common position
682 for (std::multimap<double, File *>::iterator it2 = distmultimap.begin();
683 it2 != distmultimap.end();
686 if (distmultimap.count((*it2).first) != 1)
688 gdcmErrorMacro("File: "
689 << ((*it2).second->GetFileName())
692 << " position is not unique");
701 fileList->clear(); // doesn't delete list elements, only nodes
705 for (std::multimap<double, File *>::iterator it3 = distmultimap.begin();
706 it3 != distmultimap.end();
709 fileList->push_back( (*it3).second );
712 else // user asked for reverse order
714 std::multimap<double, File *>::const_iterator it4;
715 it4 = distmultimap.end();
719 fileList->push_back( (*it4).second );
720 } while (it4 != distmultimap.begin() );
723 distmultimap.clear();
728 bool SerieHelper::ImageNumberLessThan(File *file1, File *file2)
730 return file1->GetImageNumber() < file2->GetImageNumber();
733 bool SerieHelper::ImageNumberGreaterThan(File *file1, File *file2)
735 return file1->GetImageNumber() > file2->GetImageNumber();
739 * \brief sorts the images, according to their Image Number
740 * \note Works only on bona fide files (i.e image number is a character string
741 * corresponding to an integer)
742 * within a bona fide serie (i.e image numbers are consecutive)
743 * @param fileList File set (same Serie UID) to sort
744 * @return false if non bona fide stuff encountered
746 bool SerieHelper::ImageNumberOrdering(FileList *fileList)
749 int n = fileList->size();
751 FileList::const_iterator it = fileList->begin();
752 min = max = (*it)->GetImageNumber();
754 for (; it != fileList->end(); ++it, ++n)
756 pos = (*it)->GetImageNumber();
757 min = (min < pos) ? min : pos;
758 max = (max > pos) ? max : pos;
761 // Find out if image numbers are coherent (consecutive)
762 if ( min == max || max == 0 || max >= (n+min) )
764 gdcmWarningMacro( " 'Image numbers' not coherent. "
765 << " No ImageNumberOrdering sort performed.");
769 std::sort(fileList->begin(), fileList->end(),
770 SerieHelper::ImageNumberLessThan );
772 std::sort(fileList->begin(), fileList->end(),
773 SerieHelper::ImageNumberGreaterThan );
778 bool SerieHelper::FileNameLessThan(File *file1, File *file2)
780 return file1->GetFileName() < file2->GetFileName();
783 bool SerieHelper::FileNameGreaterThan(File *file1, File *file2)
785 return file1->GetFileName() > file2->GetFileName();
788 * \brief sorts the images, according to their File Name
789 * @param fileList Coherent File list (same Serie UID) to sort
790 * @return false only if the header is bugged !
792 bool SerieHelper::FileNameOrdering(FileList *fileList)
795 std::sort(fileList->begin(), fileList->end(),
796 SerieHelper::FileNameLessThan);
798 std::sort(fileList->begin(), fileList->end(),
799 SerieHelper::FileNameGreaterThan);
805 * \brief sorts the images, according to user supplied function
806 * @param fileList Coherent File list (same Serie UID) to sort
807 * @return false only if the header is bugged !
809 bool SerieHelper::UserOrdering(FileList *fileList)
811 std::sort(fileList->begin(), fileList->end(),
812 SerieHelper::UserLessThanFunction);
815 std::reverse(fileList->begin(), fileList->end());
821 * \brief Heuritics to *try* to build a Serie Identifier that would ensure
822 * all the images are coherent.
824 * We allow user to add his own critierions, using AddSerieDetail
825 * (he knows more than we do about his images!)
826 * ex : in tagging series, the only pertnent tag is
827 * 0018|1312 [In-plane Phase Encoding Direction] value : ROW/COLUMN
828 * @param inFile gdcm::File we want to build a Serie Identifier for.
829 * @return the SeriesIdentifier
831 std::string SerieHelper::CreateUniqueSeriesIdentifier( File *inFile )
833 if( inFile->IsReadable() )
835 // 0020 000e UI REL Series Instance UID
836 std::string uid = inFile->GetEntryString (0x0020, 0x000e);
837 std::string id = uid.c_str();
838 if(m_UseSeriesDetails)
840 // If the user requests, additional information can be appended
841 // to the SeriesUID to further differentiate volumes in the DICOM
842 // objects being processed.
844 // 0020 0011 Series Number
845 // A scout scan prior to a CT volume scan can share the same
846 // SeriesUID, but they will sometimes have a different Series Number
847 std::string sNum = inFile->GetEntryString(0x0020, 0x0011);
848 if( sNum == gdcm::GDCM_UNFOUND )
852 // 0018 0024 Sequence Name
853 // For T1-map and phase-contrast MRA, the different flip angles and
854 // directions are only distinguished by the Sequence Name
855 std::string sName = inFile->GetEntryString(0x0018, 0x0024);
856 if( sName == gdcm::GDCM_UNFOUND )
860 // 0018 0050 Slice Thickness
861 // On some CT systems, scout scans and subsequence volume scans will
862 // have the same SeriesUID and Series Number - YET the slice
863 // thickness will differ from the scout slice and the volume slices.
864 std::string sThick = inFile->GetEntryString (0x0018, 0x0050);
865 if( sThick == gdcm::GDCM_UNFOUND )
870 // If the 2D images in a sequence don't have the same number of rows,
871 // then it is difficult to reconstruct them into a 3D volume.
872 std::string sRows = inFile->GetEntryString (0x0028, 0x0010);
873 if( sRows == gdcm::GDCM_UNFOUND )
878 // If the 2D images in a sequence don't have the same number of columns,
879 // then it is difficult to reconstruct them into a 3D volume.
880 std::string sColumns = inFile->GetEntryString (0x0028, 0x0011);
881 if( sColumns == gdcm::GDCM_UNFOUND )
886 // Concat the new info
887 std::string num = sNum.c_str();
888 num += sName.c_str();
889 num += sThick.c_str();
890 num += sRows.c_str();
891 num += sColumns.c_str();
893 // Add a loop, here, to deal with any extra user supplied tag.
894 // We allow user to add his own critierions
895 // (he knows more than we do about his images!)
896 // ex : in tagging series, the only pertinent tag is
897 // 0018|1312 [In-plane Phase Encoding Direction] value : ROW/COLUMN
900 for(SeriesExDetails::iterator it2 = ExDetails.begin();
901 it2 != ExDetails.end();
904 const ExDetail &r = *it2;
905 s = inFile->GetEntryString( r.group, r.elem );
909 // Append the new info to the SeriesUID
914 // Eliminate non-alnum characters, including whitespace...
915 // that may have been introduced by concats.
916 for(unsigned int i=0; i<id.size(); i++)
919 && !( id[i] == '.' || id[i] == '-'
920 || (id[i] >= 'a' && id[i] <= 'z')
921 || (id[i] >= '0' && id[i] <= '9')
922 || (id[i] >= 'A' && id[i] <= 'Z')))
929 else // Could not open inFile
931 gdcmWarningMacro("Could not parse series info.");
932 std::string id = gdcm::GDCM_UNFOUND;
938 //-----------------------------------------------------------------------------
941 * \brief Canonical printer.
943 void SerieHelper::Print(std::ostream &os, std::string const &indent)
945 // For all the Coherent File lists of the gdcm::Serie
946 SingleSerieUIDFileSetmap::iterator itl = SingleSerieUIDFileSetHT.begin();
947 if ( itl == SingleSerieUIDFileSetHT.end() )
949 gdcmWarningMacro( "No SingleSerieUID File set found" );
952 while (itl != SingleSerieUIDFileSetHT.end())
954 os << "Serie UID :[" << itl->first << "]" << std::endl;
956 // For all the files of a SingleSerieUID File set
957 for (FileList::iterator it = (itl->second)->begin();
958 it != (itl->second)->end();
961 os << indent << " --- " << (*it)->GetFileName() << std::endl;
967 //-----------------------------------------------------------------------------
968 } // end namespace gdcm