17 #ifndef _itkGDCMSeriesFileNames_h
18 #define _itkGDCMSeriesFileNames_h
21 #include <itksys/SystemTools.hxx>
23 #include "gdcmSerieHelper.h"
52 itkExceptionMacro(<<
"SetInputDirectory() received a NULL string");
54 std::string fname = name;
62 itkWarningMacro( <<
"You need to specify a directory where "
63 "the DICOM files are located");
70 if( !itksys::SystemTools::FileIsDirectory(name.c_str()) )
72 itkWarningMacro( << name <<
" is not a directory" );
89 gdcm::FileList *flist =
m_SerieHelper->GetFirstSingleSerieUIDFileSet();
94 gdcm::File *file = (*flist)[0];
98 CreateUniqueSeriesIdentifier( file ).c_str();
106 itkWarningMacro(<<
"No Series were found");
115 gdcm::FileList *flist =
m_SerieHelper->GetFirstSingleSerieUIDFileSet();
119 <<
"No Series can be found, make sure your restrictions are not too strong");
125 while(flist && !found)
129 gdcm::File *file = (*flist)[0];
131 CreateUniqueSeriesIdentifier( file ).c_str();
143 itkWarningMacro(<<
"No Series were found");
149 gdcm::FileList::iterator it;
152 for(it = flist->begin();
153 it != flist->end(); ++it )
155 #if GDCM_MAJOR_VERSION < 2
156 gdcm::File * header = *it;
159 itkWarningMacro( <<
"GDCMSeriesFileNames got NULL header, "
160 "this is a serious bug" );
163 if( !header->IsReadable() )
165 itkWarningMacro( <<
"GDCMSeriesFileNames got a non DICOM file:"
166 << header->GetFileName() );
171 gdcm::FileWithName * header = *it;
178 itkDebugMacro(<<
"No files were found");
203 itkDebugMacro(<<
"No output directory was specified");
215 bool hasExtension =
false;
220 std::string::size_type dcmPos = (*it).rfind(
".dcm");
221 if ( (dcmPos != std::string::npos)
222 && (dcmPos == (*it).length() - 4) )
228 dcmPos = (*it).rfind(
".DCM");
229 if ( (dcmPos != std::string::npos)
230 && (dcmPos == (*it).length() - 4) )
237 std::string::size_type dicomPos = (*it).rfind(
".dicom");
238 if ( (dicomPos != std::string::npos)
239 && (dicomPos == (*it).length() - 6) )
245 dicomPos = (*it).rfind(
".DICOM");
246 if ( (dicomPos != std::string::npos)
247 && (dicomPos == (*it).length() - 6) )
254 std::string filename =
268 itkDebugMacro(<<
"No files were found.");
284 os << indent <<
"Recursive: True" << std::endl;
288 os << indent <<
"Recursive: False" << std::endl;
293 os << indent <<
"InputFilenames[" << i <<
"]: " <<
m_InputFileNames[i] << std::endl;
299 os << indent <<
"OutputFilenames[" << i <<
"]: " <<
m_OutputFileNames[i] << std::endl;