Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkDICOMFilesHelper.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkDICOMFilesHelper.h"
14 
15 #include <itkGDCMImageIO.h>
16 #include <itksys/SystemTools.hxx>
17 #include <gdcmDirectory.h>
18 
20 {
21  DICOMFilePathList result;
22 
23  if (!filePath.empty())
24  {
25  std::string dir = itksys::SystemTools::GetFilenamePath(filePath);
26 
27  gdcm::Directory directoryLister;
28  directoryLister.Load(dir.c_str(), false); // non-recursive
29  result = FilterForDICOMFiles(directoryLister.GetFilenames());
30  }
31 
32  return result;
33 };
34 
36 {
38 
39  itk::GDCMImageIO::Pointer io = itk::GDCMImageIO::New();
40  for (auto aFile : fileList)
41  {
42  if (io->CanReadFile(aFile.c_str()))
43  {
44  result.push_back(aFile);
45  }
46  }
47 
48  return result;
49 };
DICOMFilePathList GetDICOMFilesInSameDirectory(const std::string &filePath)
DICOMFilePathList FilterForDICOMFiles(const DICOMFilePathList &fileList)
std::vector< std::string > DICOMFilePathList