Debian Codegraph @

matlab/+ismrmrd/+util/hdf5_datatypes.m

raw
1 classdef hdf5_datatypes
2 % This convenience class defines the HDF5 types used in the
3 % ISMRMRD HDF5 file
4
5 % The names, types, layout and offsets consistent with that generated
6 % by the C API. See the note at the bottom of the file for how to
7 % do this.
8
9 properties
10 T_float;
11 T_double;
12 T_char;
13 T_complexfloat;
14 T_complexdouble;
15 T_ushort;
16 T_EncodingCounters;
17 T_AcquisitionHeader;
18 T_Acquisition;
19 T_Waveform;
20 T_WaveformHeader;
21 end
22
23 methods
24
25 function obj = hdf5_datatypes()
26 obj.T_float = ismrmrd.util.hdf5_datatypes.getType_float();
27 obj.T_double = ismrmrd.util.hdf5_datatypes.getType_double();
28 obj.T_char = ismrmrd.util.hdf5_datatypes.getType_char();
29 obj.T_complexfloat = ismrmrd.util.hdf5_datatypes.getType_complexfloat();
30 obj.T_complexdouble = ismrmrd.util.hdf5_datatypes.getType_complexdouble();
31 obj.T_ushort = ismrmrd.util.hdf5_datatypes.getType_ushort();
32 obj.T_EncodingCounters = ismrmrd.util.hdf5_datatypes.getType_EncodingCounters();
33 obj.T_AcquisitionHeader = ismrmrd.util.hdf5_datatypes.getType_AcquisitionHeader();
34 obj.T_Acquisition = ismrmrd.util.hdf5_datatypes.getType_Acquisition();
35 obj.T_Waveform = ismrmrd.util.hdf5_datatypes.getType_Waveform();
36 obj.T_WaveformHeader = ismrmrd.util.hdf5_datatypes.getType_WaveformHeader();
37 end
38
39 end
40
41 methods (Static)
42
43 function b = getType_float()
44 b = H5T.copy('H5T_NATIVE_FLOAT');
45 end
46
47 function b = getType_double()
48 b = H5T.copy('H5T_NATIVE_DOUBLE');
49 end
50
51 function b = getType_char()
52 b = H5T.copy('H5T_NATIVE_CHAR');
53 end
54
55 function b = getType_complexfloat()
56 typesize = 2*H5T.get_size('H5T_NATIVE_FLOAT');
57 b = H5T.create ('H5T_COMPOUND', typesize);
58 H5T.insert (b, 'real', 0, 'H5T_NATIVE_FLOAT');
59 H5T.insert (b, 'imag', H5T.get_size('H5T_NATIVE_FLOAT'), 'H5T_NATIVE_FLOAT');
60 end
61
62 function b = getType_complexdouble()
63 b = H5T.create ('H5T_COMPOUND', ...
64 2*H5T.get_size('H5T_NATIVE_DOUBLE'));
65 H5T.insert (b, 'real', 0, 'H5T_NATIVE_DOUBLE');
66 H5T.insert (b, 'imag', H5T.get_size('H5T_NATIVE_DOUBLE'), 'H5T_NATIVE_DOUBLE');
67 end
68
69 function b = getType_ushort()
70 b = H5T.copy('H5T_NATIVE_USHORT');
71 end
72
73 function b = getType_EncodingCounters()
74
75 b = H5T.create ('H5T_COMPOUND', 34);
76 H5T.insert(b, 'kspace_encode_step_1', 0, 'H5T_NATIVE_UINT16');
77 H5T.insert(b, 'kspace_encode_step_2', 2, 'H5T_NATIVE_UINT16');
78 H5T.insert(b, 'average', 4, 'H5T_NATIVE_UINT16');
79 H5T.insert(b, 'slice', 6, 'H5T_NATIVE_UINT16');
80 H5T.insert(b, 'contrast', 8, 'H5T_NATIVE_UINT16');
81 H5T.insert(b, 'phase', 10, 'H5T_NATIVE_UINT16');
82 H5T.insert(b, 'repetition', 12, 'H5T_NATIVE_UINT16');
83 H5T.insert(b, 'set', 14, 'H5T_NATIVE_UINT16');
84 H5T.insert(b, 'segment', 16, 'H5T_NATIVE_UINT16');
85 H5T.insert(b, 'user', 18, H5T.array_create('H5T_NATIVE_UINT16',[8]));
86
87 end
88
89 function b = getType_AcquisitionHeader()
90 b = H5T.create ('H5T_COMPOUND', 340);
91 H5T.insert(b, 'version', 0, 'H5T_NATIVE_UINT16');
92 H5T.insert(b, 'flags', 2, 'H5T_NATIVE_UINT64');
93 H5T.insert(b, 'measurement_uid', 10, 'H5T_NATIVE_UINT32');
94 H5T.insert(b, 'scan_counter', 14, 'H5T_NATIVE_UINT32');
95 H5T.insert(b, 'acquisition_time_stamp', 18, 'H5T_NATIVE_UINT32');
96 H5T.insert(b, 'physiology_time_stamp', 22, H5T.array_create('H5T_NATIVE_UINT32',[3]));
97 H5T.insert(b, 'number_of_samples', 34, 'H5T_NATIVE_UINT16');
98 H5T.insert(b, 'available_channels', 36, 'H5T_NATIVE_UINT16');
99 H5T.insert(b, 'active_channels', 38, 'H5T_NATIVE_UINT16');
100 H5T.insert(b, 'channel_mask', 40, H5T.array_create('H5T_NATIVE_UINT64',[16]));
101 H5T.insert(b, 'discard_pre', 168, 'H5T_NATIVE_UINT16');
102 H5T.insert(b, 'discard_post', 170, 'H5T_NATIVE_UINT16');
103 H5T.insert(b, 'center_sample', 172, 'H5T_NATIVE_UINT16');
104 H5T.insert(b, 'encoding_space_ref', 174, 'H5T_NATIVE_UINT16');
105 H5T.insert(b, 'trajectory_dimensions', 176, 'H5T_NATIVE_UINT16');
106 H5T.insert(b, 'sample_time_us', 178, 'H5T_NATIVE_FLOAT');
107 H5T.insert(b, 'position', 182, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
108 H5T.insert(b, 'read_dir', 194, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
109 H5T.insert(b, 'phase_dir', 206, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
110 H5T.insert(b, 'slice_dir', 218, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
111 H5T.insert(b, 'patient_table_position', 230, H5T.array_create('H5T_NATIVE_FLOAT',[3]));
112 H5T.insert(b, 'idx', 242, ismrmrd.util.hdf5_datatypes.getType_EncodingCounters);
113 H5T.insert(b, 'user_int', 276, H5T.array_create('H5T_NATIVE_INT32',[8]));
114 H5T.insert(b, 'user_float', 308, H5T.array_create('H5T_NATIVE_FLOAT',[8]));
115 end
116
117 function b = getType_Acquisition()
118
119 head = H5T.copy(ismrmrd.util.hdf5_datatypes.getType_AcquisitionHeader());
120 traj = H5T.vlen_create(ismrmrd.util.hdf5_datatypes.getType_float());
121 data = H5T.vlen_create(ismrmrd.util.hdf5_datatypes.getType_float());
122
123 b = H5T.create ('H5T_COMPOUND', 376);
124 H5T.insert(b, 'head', 0, head);
125 H5T.insert(b, 'traj', 344, traj);
126 H5T.insert(b, 'data', 360, data);
127
128 end
129
130
131 function b = getType_WaveformHeader()
132 b = H5T.create('H5T_COMPOUND',38);
133 H5T.insert(b, 'version', 0, 'H5T_NATIVE_UINT16');
134 H5T.insert(b, 'flags', 8, 'H5T_NATIVE_UINT64');
135 H5T.insert(b, 'measurement_uid', 16, 'H5T_NATIVE_UINT32');
136 H5T.insert(b, 'scan_counter', 20, 'H5T_NATIVE_UINT32');
137 H5T.insert(b, 'time_stamp', 24, 'H5T_NATIVE_UINT32');
138 H5T.insert(b, 'number_of_samples', 28, 'H5T_NATIVE_UINT16');
139 H5T.insert(b, 'channels', 30, 'H5T_NATIVE_UINT16');
140 H5T.insert(b, 'sample_time_us', 32, 'H5T_NATIVE_FLOAT');
141 H5T.insert(b, 'waveform_id', 36, 'H5T_NATIVE_UINT16');
142 end
143
144 function b = getType_Waveform()
145
146 head = H5T.copy(ismrmrd.util.hdf5_datatypes.getType_WaveformHeader());
147 data = H5T.vlen_create(H5T.copy('H5T_NATIVE_UINT32'));
148
149 b = H5T.create ('H5T_COMPOUND', 58);
150 H5T.insert(b, 'head', 0, head);
151 H5T.insert(b, 'data', 42, data);
152
153 end
154
155
156
157 end % Methods (Static)
158
159 end
160
161 % Generate a dataset using the C utilities and run
162 % h5ls -a -v testdata/dataset/data
163 % This produces something the following output
164 % Chunks: {1} 376 bytes
165 % Storage: 96256 logical bytes, 96256 allocated bytes, 100.00% utilization
166 % Type: struct {
167 % "head" +0 struct {
168 % "version" +0 native unsigned short
169 % "flags" +2 native unsigned long
170 % "measurement_uid" +10 native unsigned int
171 % "scan_counter" +14 native unsigned int
172 % "acquisition_time_stamp" +18 native unsigned int
173 % "physiology_time_stamp" +22 [3] native unsigned int
174 % "number_of_samples" +34 native unsigned short
175 % "available_channels" +36 native unsigned short
176 % "active_channels" +38 native unsigned short
177 % "channel_mask" +40 [16] native unsigned long
178 % "discard_pre" +168 native unsigned short
179 % "discard_post" +170 native unsigned short
180 % "center_sample" +172 native unsigned short
181 % "encoding_space_ref" +174 native unsigned short
182 % "trajectory_dimensions" +176 native unsigned short
183 % "sample_time_us" +178 native float
184 % "position" +182 [3] native float
185 % "read_dir" +194 [3] native float
186 % "phase_dir" +206 [3] native float
187 % "slice_dir" +218 [3] native float
188 % "patient_table_position" +230 [3] native float
189 % "idx" +242 struct {
190 % "kspace_encode_step_1" +0 native unsigned short
191 % "kspace_encode_step_2" +2 native unsigned short
192 % "average" +4 native unsigned short
193 % "slice" +6 native unsigned short
194 % "contrast" +8 native unsigned short
195 % "phase" +10 native unsigned short
196 % "repetition" +12 native unsigned short
197 % "set" +14 native unsigned short
198 % "segment" +16 native unsigned short
199 % "user" +18 [8] native unsigned short
200 % } 34 bytes
201 % "user_int" +276 [8] native int
202 % "user_float" +308 [8] native float
203 % } 340 bytes
204 % "traj" +344 variable length of
205 % native float
206 % "data" +360 variable length of
207 % native float
208 % } 376 bytes