Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkTestDICOMLoading.h
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 #ifndef mitkTestDICOMLoading_h
13 #define mitkTestDICOMLoading_h
14 
15 #include <mitkDICOMFileReader.h>
16 #include <mitkPropertyKeyPath.h>
17 
18 #include <MitkDICOMTestingExports.h>
19 
20 namespace mitk
21 {
22 
31 class MITKDICOMTESTING_EXPORT TestDICOMLoading
32 {
33  public:
34 
35  typedef std::list<Image::Pointer> ImageList;
38 
47  ImageList
48  LoadFiles( const StringList & files );
49 
56  Image::Pointer
57  DecorateVerifyCachedImage( const StringList& files, mitk::Image::Pointer cachedImage );
58 
66  Image::Pointer
67  DecorateVerifyCachedImage( const StringList& files, DICOMTagCache *tagCache, mitk::Image::Pointer cachedImage );
68 
79  std::string
80  DumpImageInformation( const Image* image );
81 
93  bool
94  CompareImageInformationDumps( const std::string& reference,
95  const std::string& test );
96 
97  private:
98 
99  typedef std::map<std::string,std::string> KeyValueMap;
100 
101  DICOMFileReader::Pointer
102  BuildDICOMReader();
103 
104  void SetDefaultLocale();
105 
106  void ResetUserLocale();
107 
108  std::string ComponentTypeToString( itk::IOComponentEnum type );
109 
110  KeyValueMap ParseDump( const std::string& dump );
111 
112  bool CompareSpacedValueFields( const std::string& reference,
113  const std::string& test,
114  double eps = mitk::eps );
115 
116  bool CompareJSON( const std::string& reference,
117  const std::string& test );
118 
125  std::string reduce(const std::string& pString,
126  const std::string& pFill = " ",
127  const std::string& pWhitespace = " \t");
128 
134  std::string trim(const std::string& pString,
135  const std::string& pWhitespace = " \t");
136 
137  template<typename T>
138  bool StringToNumber(const std::string& s, T& value)
139  {
140  std::stringstream stream(s);
141  stream >> value;
142  return (!stream.fail()) && (std::abs(value) <= std::numeric_limits<T>::max());
143  }
144 
145  static void AddPropertyToDump(const mitk::PropertyKeyPath& key, const mitk::Image* image, std::stringstream& result);
146 
147  const char* m_PreviousCLocale;
148  std::locale m_PreviousCppLocale;
149 
150 };
151 
152 }
153 
154 #endif
Abstract base class for caching DICOM tag values scanned from files.
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
Class that can be used to specify nested or wild carded property keys. E.g. for the use in context of...
Utility class for testing DICOM file loading and comparing loaded image properties.
std::string DumpImageInformation(const Image *image)
Dump relevant image information to a string for later comparison.
bool CompareImageInformationDumps(const std::string &reference, const std::string &test)
Compare two image information dumps for equality.
Image::Pointer DecorateVerifyCachedImage(const StringList &files, DICOMTagCache *tagCache, mitk::Image::Pointer cachedImage)
Verify a cached image using a specific tag cache.
Image::Pointer DecorateVerifyCachedImage(const StringList &files, mitk::Image::Pointer cachedImage)
Verify a cached image by decorating it with DICOM properties.
ImageList LoadFiles(const StringList &files)
Load DICOM files and return the resulting images.
std::list< Image::Pointer > ImageList
List of loaded image pointers.
Find image slices visible on a given plane.
MITKCORE_EXPORT const ScalarType eps
Epsilon value for floating point comparison (vnl_math::eps * 100).
std::vector< std::string > StringList
A list of strings, used throughout the DICOM module to hold file paths and similar data.