-
Notifications
You must be signed in to change notification settings - Fork 50
/
siemensraw.h
238 lines (204 loc) · 4.74 KB
/
siemensraw.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#ifndef SIEMENSRAW_H_
#define SIEMENSRAW_H_
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <map>
#include <string>
#define MDH_NUMBEROFEVALINFOMASK 2
#define MDH_NUMBEROFICEPROGRAMPARA_VB 4
#define MDH_NUMBEROFICEPROGRAMPARA_VD 24
#define MDH_FREEHDRPARA_VB 4
#define MDH_DMA_LENGTH_MASK (0x01FFFFFFL)
#define MDH_PACK_BIT_MASK (0x02000000L)
#define MDH_ENABLE_FLAGS_MASK (0xFC000000L)
#define MDH_SYNCDATA (0x00000020L)
enum class PMU_Type {
END = 0x01FF0000,
ECG1 = 0x01010000,
ECG2 = 0x01020000,
ECG3 = 0x01030000,
ECG4 = 0x01040000,
PULS = 0x01050000,
RESP = 0x01060000,
EXT1 = 0x01070000,
EXT2 = 0x01080000
};
enum class Trajectory {
TRAJECTORY_CARTESIAN = 0x01,
TRAJECTORY_RADIAL = 0x02,
TRAJECTORY_SPIRAL = 0x04,
TRAJECTORY_BLADE = 0x08
};
struct mdhLC {
uint16_t ushLine;
uint16_t ushAcquisition;
uint16_t ushSlice;
uint16_t ushPartition;
uint16_t ushEcho;
uint16_t ushPhase;
uint16_t ushRepetition;
uint16_t ushSet;
uint16_t ushSeg;
uint16_t ushIda;
uint16_t ushIdb;
uint16_t ushIdc;
uint16_t ushIdd;
uint16_t ushIde;
};
struct mdhCutOff {
uint16_t ushPre;
uint16_t ushPost;
};
struct mdhSlicePosVec {
float flSag;
float flCor;
float flTra;
};
/*
struct mdhSD {
mdhSlicePosVec sSlicePosVec;
};
*/
struct PMUdata {
uint16_t data;
uint16_t trigger;
};
struct mdhSliceData {
mdhSlicePosVec sSlicePosVec;
float aflQuaternion[4];
};
/* This is the VB line header */
struct sMDH
{
uint32_t ulFlagsAndDMALength;
int32_t lMeasUID;
uint32_t ulScanCounter;
uint32_t ulTimeStamp;
uint32_t ulPMUTimeStamp;
uint32_t aulEvalInfoMask[2];
uint16_t ushSamplesInScan;
uint16_t ushUsedChannels;
mdhLC sLC;
mdhCutOff sCutOff;
uint16_t ushKSpaceCentreColumn;
uint16_t ushCoilSelect;
float fReadOutOffcentre;
uint32_t ulTimeSinceLastRF;
uint16_t ushKSpaceCentreLineNo;
uint16_t ushKSpaceCentrePartitionNo;
uint16_t aushIceProgramPara[4];
uint16_t aushFreePara[4];
mdhSliceData sSliceData;
uint16_t ushChannelId;
uint16_t ushPTABPosNeg;
};
/* This is the VD line header */
struct sScanHeader
{
uint32_t ulFlagsAndDMALength;
int32_t lMeasUID;
uint32_t ulScanCounter;
uint32_t ulTimeStamp;
uint32_t ulPMUTimeStamp;
uint16_t ushSystemType;
uint16_t ulPTABPosDelay;
int32_t lPTABPosX;
int32_t lPTABPosY;
int32_t lPTABPosZ;
uint32_t ulReserved1;
uint32_t aulEvalInfoMask[2];
uint16_t ushSamplesInScan;
uint16_t ushUsedChannels;
mdhLC sLC;
mdhCutOff sCutOff;
uint16_t ushKSpaceCentreColumn;
uint16_t ushCoilSelect;
float fReadOutOffcentre;
uint32_t ulTimeSinceLastRF;
uint16_t ushKSpaceCentreLineNo;
uint16_t ushKSpaceCentrePartitionNo;
mdhSliceData sSliceData;
uint16_t aushIceProgramPara[24];
uint16_t aushReservedPara[4];
uint16_t ushApplicationCounter;
uint16_t ushApplicationMask;
uint32_t ulCRC;
};
typedef struct sChannelHeader
{
uint32_t ulTypeAndChannelLength;
int32_t lMeasUID;
uint32_t ulScanCounter;
uint32_t ulReserved1;
uint32_t ulSequenceTime;
uint32_t ulUnused2;
uint16_t ulChannelId;
uint16_t ulUnused3;
uint32_t ulCRC;
} sChannelHeader;
struct MrParcRaidFileEntry
{
uint32_t measId_;
uint32_t fileId_;
uint64_t off_;
uint64_t len_;
char patName_[64];
char protName_[64];
};
struct MrParcRaidFileHeader
{
uint32_t hdSize_;
uint32_t count_;
};
typedef struct
{
sMDH mdh;
void* previous;
void* next;
float* data;
} SiemensMdhNode;
typedef struct
{
uint32_t matrix_size[3];
uint32_t pat_matrix_size[3];
uint32_t base_resolution;
uint32_t phase_encoding_lines;
uint32_t partitions;
uint32_t dimensions;
float phase_resolution;
float slice_resolution;
float dwell_time_us;
uint32_t acceleration_factor_pe;
uint32_t acceleration_factor_3d;
} SiemensBaseParameters;
class SiemensRawData
{
public:
SiemensRawData();
~SiemensRawData();
int ReadRawFile(char* filename);
long GetNumberOfNodes();
SiemensMdhNode* GetFirstNode();
sMDH* GetMinValues();
sMDH* GetMaxValues();
SiemensBaseParameters GetBaseParameters() {return m_base_parameters;}
int GetMeasYapsParameter(std::string parameter_name, std::string& value);
const std::string& GetParameterBuffer(std::string name);
protected:
int ReadMdhNode(std::ifstream* f);
int DeleteNode(SiemensMdhNode* node);
int DeleteNodeList();
int UpdateMinMax();
int ParseMeasYaps();
SiemensMdhNode* m_first_node;
SiemensMdhNode* m_last_node;
long m_number_of_nodes;
sMDH m_mdh_min;
sMDH m_mdh_max;
bool m_min_max_is_valid;
std::map< std::string, std::string > m_parameter_buffers;
std::map< std::string, std::string > m_meas_yaps;
SiemensBaseParameters m_base_parameters;
};
#endif //SIEMENSRAW_H_