UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-12-17)
usMetaHeaderParser.h
1 /****************************************************************************
2  *
3  * This file is part of the ustk software.
4  * Copyright (C) 2016 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ustk with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * This software was developed at:
17  * Inria Rennes - Bretagne Atlantique
18  * Campus Universitaire de Beaulieu
19  * 35042 Rennes Cedex
20  * France
21  *
22  * If you have questions regarding the use of this file, please contact
23  * Inria at ustk@inria.fr
24  *
25  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  * Authors:
29  * Marc Pouliquen
30  *
31  *****************************************************************************/
32 
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 #ifndef __usMetaHeaderParser_h_
40 #define __usMetaHeaderParser_h_
41 
42 #include <cstdlib>
43 #include <fstream>
44 #include <ios>
45 #include <iostream>
46 #include <map>
47 #include <sstream>
48 #include <stdint.h>
49 #include <string>
50 
51 #include <visp3/core/vpConfig.h>
52 #include <visp3/ustk_core/us.h>
53 #include <visp3/ustk_core/usImagePostScan2D.h>
54 #include <visp3/ustk_core/usImagePostScan3D.h>
55 #include <visp3/ustk_core/usImagePreScan2D.h>
56 #include <visp3/ustk_core/usImagePreScan3D.h>
57 #include <visp3/ustk_core/usImageRF2D.h>
58 #include <visp3/ustk_core/usImageRF3D.h>
59 
65 class VISP_EXPORT usMetaHeaderParser
66 {
67 
68 public:
69  typedef enum
70  {
71  MET_UNKNOWN = -1,
72  MET_UCHAR,
73  MET_SHORT,
74  MET_DOUBLE,
75  } ElementType;
76 
77 #ifndef DOXYGEN_SHOULD_SKIP_THIS
78  struct MHDHeader
79  {
80  std::string MHDFileName;
81  std::string rawFileName;
82  unsigned int numberOfDimensions;
83  int numberOfChannels;
84  ElementType elementType;
85  int dim[4];
86  double elementSpacing[4];
87  double position[4];
88  int headerSize;
89  bool msb;
90  us::ImageType imageType;
91  bool isTransducerConvex;
93  double transducerRadius;
94  double scanLinePitch;
95  double motorRadius;
96  double framePitch;
97  unsigned int scanLineNumber; // for post-scan
98  unsigned int frameNumber; // for post-scan
99  int transmitFrequency;
100  int samplingFrequency;
101  std::vector<uint64_t> timestamp;
102  };
103 #endif // DOXYGEN_SHOULD_SKIP_THIS
104 
105  // Constructor
106  usMetaHeaderParser();
107  usMetaHeaderParser(const std::string &MHDFilename);
108  // Desctructor
109  virtual ~usMetaHeaderParser();
110 
111  // Data accessors.
112  double getAxialResolution() const { return m_axialResolution; }
113  ElementType getElementType() const { return header.elementType; }
114  double getHeightResolution() const { return m_heightResolution; }
115  us::ImageType getImageType() const { return header.imageType; }
116  MHDHeader getMHDHeader() const { return header; }
117  usMotorSettings getMotorSettings() const { return m_motorSettings; }
118  std::string getRawFileName() const { return header.rawFileName; }
119  usTransducerSettings getTransducerSettings() const { return m_transducerSettings; }
120  double getWidthResolution() const { return m_widthResolution; }
121 
122  // comparison
123  bool operator==(usMetaHeaderParser const &other);
124 
125  void parse();
126 
127  void read(const std::string &filename);
128  void readMHDHeader(const std::string &fileName);
129 
130  // Setters
131  void setAxialResolution(const double axialresolution);
132  void setHeightResolution(const double heightResolution);
133  void setImageFileName(const std::string &imageFileName);
134  void setImageTimestamp(const std::vector<uint64_t> timestamp);
135  void setMHDHeader(MHDHeader header);
136  void setMotorSettings(const usMotorSettings &motorSettings);
137  void setRawFileName(const std::string &rawFileName);
138  void setTransducerSettings(const usTransducerSettings &transducerSettings);
139  void setWidthResolution(const double widthResolution);
140 
141 private:
142  usTransducerSettings m_transducerSettings;
143  usMotorSettings m_motorSettings;
144  double m_axialResolution;
145  double m_heightResolution;
146  double m_widthResolution;
147 
148  MHDHeader header;
149  std::map<std::string, int> imageTypeMap;
150  std::map<std::string, int> elementTypeMap;
151  std::map<int, std::string> imageTypeReverseMap;
152  std::map<int, std::string> elementTypeReverseMap;
153 };
154 #endif // __usMetaHeaderParser_h_
155 #endif // DOXYGEN_SHOULD_SKIP_THIS
Generic class for 3D ultrasound motor settings associated to the 3D probe used during acquisition.
Generic class for 2D ultrasound data common settings associated to the type of probe transducer used ...
ImageType
Definition: us.h:65