Debian Codegraph @

doc/mrd_messages.md

raw
1 # Message Types
2 <style>
3 .mrdMsgTable2 {
4 border-collapse: collapse;
5 width: 100%;
6 text-align: center;
7 }
8 .mrdMsgTable2 tr th:nth-child(1) { text-align: center; background-color: #dbe5f0 !important;}
9 .mrdMsgTable2 tr td:nth-child(1) { text-align: center; background-color: #dbe5f0 !important;}
10 .mrdMsgTable2 tr th:nth-child(2) { text-align: center; background-color: #ebf0de !important;}
11 .mrdMsgTable2 tr td:nth-child(2) { text-align: center; background-color: #ebf0de !important;}
12
13
14 .mrdMsgTable3 {
15 border-collapse: collapse;
16 border-color: black !important;
17 width: 100%;
18 text-align: center;
19 }
20
21 .mrdMsgTable3 tr th:nth-child(1) { text-align: center; background-color: #dbe5f0 !important;}
22 .mrdMsgTable3 tr td:nth-child(1) { text-align: center; background-color: #dbe5f0 !important;}
23 .mrdMsgTable3 tr th:nth-child(2) { text-align: center; background-color: #f1dbdb !important;}
24 .mrdMsgTable3 tr td:nth-child(2) { text-align: center; background-color: #f1dbdb !important;}
25 .mrdMsgTable3 tr th:nth-child(3) { text-align: center; background-color: #ebf0de !important;}
26 .mrdMsgTable3 tr td:nth-child(3) { text-align: center; background-color: #ebf0de !important;}
27
28
29 .mrdMsgTable4 {
30 border-collapse: collapse;
31 width: 100%;
32 text-align: center;
33 }
34
35 .mrdMsgTable4 tr th:nth-child(1) { text-align: center; background-color: #dbe5f0 !important;}
36 .mrdMsgTable4 tr td:nth-child(1) { text-align: center; background-color: #dbe5f0 !important;}
37 .mrdMsgTable4 tr th:nth-child(2) { text-align: center; background-color: #f1dbdb !important;}
38 .mrdMsgTable4 tr td:nth-child(2) { text-align: center; background-color: #f1dbdb !important;}
39 .mrdMsgTable4 tr th:nth-child(3) { text-align: center; background-color: #ebf0de !important;}
40 .mrdMsgTable4 tr td:nth-child(3) { text-align: center; background-color: #ebf0de !important;}
41 .mrdMsgTable4 tr th:nth-child(4) { text-align: center; background-color: #e5e0eb !important;}
42 .mrdMsgTable4 tr td:nth-child(4) { text-align: center; background-color: #e5e0eb !important;}
43
44 .mrdMsgTable5 {
45 border-collapse: collapse;
46 width: 100%;
47 text-align: center;
48 }
49
50 .mrdMsgTable5 tr th:nth-child(1) { text-align: center; background-color: #dbe5f0 !important;}
51 .mrdMsgTable5 tr td:nth-child(1) { text-align: center; background-color: #dbe5f0 !important;}
52 .mrdMsgTable5 tr th:nth-child(2) { text-align: center; background-color: #f1dbdb !important;}
53 .mrdMsgTable5 tr td:nth-child(2) { text-align: center; background-color: #f1dbdb !important;}
54 .mrdMsgTable5 tr th:nth-child(3) { text-align: center; background-color: #ebf0de !important;}
55 .mrdMsgTable5 tr td:nth-child(3) { text-align: center; background-color: #ebf0de !important;}
56 .mrdMsgTable5 tr th:nth-child(4) { text-align: center; background-color: #c4d49f !important;}
57 .mrdMsgTable5 tr td:nth-child(4) { text-align: center; background-color: #c4d49f !important;}
58 .mrdMsgTable5 tr th:nth-child(5) { text-align: center; background-color: #e5e0eb !important;}
59 .mrdMsgTable5 tr td:nth-child(5) { text-align: center; background-color: #e5e0eb !important;}
60 </style>
61
62
63 (MRD_MESSAGE_CONFIG_FILE)=
64 ## ID 1: MRD_MESSAGE_CONFIG_FILE
65 <div class="mrdMsgTable2">
66
67 | ID | Config File Name |
68 | -- | -- |
69 | 2 bytes | 1024 bytes |
70 | unsigned short | char |
71 </div>
72
73 This message type is used to send the file name of a configuration file (local on the server file system) to be used during reconstruction. The file name must not exceed 1023 characters and is formatted as a null-terminated, UTF-8 encoded char string.
74
75 (MRD_MESSAGE_CONFIG_TEXT)=
76 ## ID 2: MRD_MESSAGE_CONFIG_TEXT
77 <div class="mrdMsgTable3">
78
79 | ID | Length | Config Text |
80 | -- | -- | -- |
81 | 2 bytes | 4 bytes | length * 1 byte |
82 | unsigned short | uint32_t | char |
83 </div>
84
85 Alternatively, the text contents of a configuration file can be sent directly via the data stream. The length is sent as an uint32_t. Configuration text is sent as a UTF-8 encoded char string.
86
87 In addition to specifying a configuration "preset" to be executed on the server, it is often desirable to modify specific parameters of the configuration, such as filter strength or the toggling of intermediate outputs for debugging purposes. While individual parameters are specific to a given pipeline and server, the format of this configuration is standardized to enable interoperable communications between various clients and servers.
88
89 (MRD_MESSAGE_HEADER)=
90 ## ID 3: MRD_MESSAGE_HEADER
91 <div class="mrdMsgTable3">
92
93 | ID | Length | XML Header Text |
94 | -- | -- | -- |
95 | 2 bytes | 4 bytes | length * 1 byte |
96 | unsigned short | uint32_t | char |
97 </div>
98
99 Metadata for MRD datasets are stored in a flexible XML formatted [MRD header](mrd_header.md). The header length is sent as an uint32_t and the text is sent as a UTF-8 encoded char string.
100
101 (MRD_MESSAGE_CLOSE)=
102 ## ID 4: MRD_MESSAGE_CLOSE
103 <div class="mrdMsgTable2">
104
105 | ID |
106 | -- |
107 | 2 bytes |
108 | unsigned short |
109 </div>
110
111 This message type consists only of an ID with no following data. It is used to indicate that all data related to an acquisition/reconstruction has been sent. The client will send this message after sending the last data (raw, image, or waveform) message. The server will also send this message after sending the last data (raw, image, or waveform) message back to the client.
112
113 (MRD_MESSAGE_TEXT)=
114 ## ID 5: MRD_MESSAGE_TEXT
115 <div class="mrdMsgTable3">
116
117 | ID | Length | Text |
118 | -- | -- | -- |
119 | 2 bytes | 4 bytes | length * 1 byte |
120 | unsigned short | uint32_t | char |
121 </div>
122
123 Informational (logging) text can be sent using this message type, typically from the reconstruction side to the acquisition/client side. The length of message text is sent as an uint32_t while the text is sent as a UTF-8 encoded char string. These messages are optional and their timing is not guaranteed.
124
125 (MRD_MESSAGE_ACQUISITION)=
126 ## ID 1008: MRD_MESSAGE_ACQUISITION
127 <div class="mrdMsgTable4">
128
129 | ID | Fixed Raw Data Header | Trajectory | Raw Data |
130 | -- | -- | -- | -- |
131 | 2 bytes | 340 bytes | number_of_samples * trajectory_dimensions * 4 bytes | number_of_channels * number_of_samples * 8 bytes |
132 | unsigned short | mixed | float | float |
133 </div>
134
135 This message type is used to send raw (k-space) acquisition data. A separate message is sent for each readout. A fixed [AcquisitionHeader](AcquisitionHeader) contains metadata such as [encoding loop counters](EncodingCounters). Three fields of the data header must be parsed in order to read the rest of the message:
136 - **trajectory_dimensions**: defines the number of dimensions in the k-space trajectory data component. For 2D acquisitions (k<sub>x</sub>, k<sub>y</sub>), this is set to 2, while for 3D acquisitions (k<sub>x</sub>, k<sub>y</sub>, k<sub>z</sub>), this is set to 3. If set to 0, the trajectory component is omitted.
137 - **number_of_samples**: number of readout samples.
138 - **active_channels**: number of channels for which raw data is acquired.
139
140 <style>
141 .smalltable td {
142 font-size: 80%;
143 border-collapse: collapse;
144 border-spacing: 0;
145 border-width: 0;
146 padding: 3px;
147 border: 1px solid lightgray
148 }
149 </style>
150
151 Trajectory data is organized by looping through the dimensions first then the samples:
152 - For 2D trajectory data:
153 <table class="smalltable">
154 <tr>
155 <td style="text-align: center" colspan="2">Sample 1</td>
156 <td style="text-align: center" colspan="2">Sample 2</td>
157 <td style="text-align: center" rowspan="2">...</td>
158 <td style="text-align: center" colspan="2">Sample n</td>
159 </tr>
160 <tr>
161 <td style="text-align: center">k<sub>x</sub></td>
162 <td style="text-align: center">k<sub>y</sub></td>
163 <td style="text-align: center">k<sub>x</sub></td>
164 <td style="text-align: center">k<sub>y</sub></td>
165 <td style="text-align: center">k<sub>x</sub></td>
166 <td style="text-align: center">k<sub>y</sub></td>
167 </tr>
168 </table>
169
170 - For 3D trajectory data:
171 <table class="smalltable">
172 <tr>
173 <td style="text-align: center" colspan="3">Sample 1</td>
174 <td style="text-align: center" colspan="3">Sample 2</td>
175 <td style="text-align: center" rowspan="2">...</td>
176 <td style="text-align: center" colspan="3">Sample n</td>
177 </tr>
178 <tr>
179 <td style="text-align: center">k<sub>x</sub></td>
180 <td style="text-align: center">k<sub>y</sub></td>
181 <td style="text-align: center">k<sub>z</sub></td>
182 <td style="text-align: center">k<sub>x</sub></td>
183 <td style="text-align: center">k<sub>y</sub></td>
184 <td style="text-align: center">k<sub>z</sub></td>
185 <td style="text-align: center">k<sub>x</sub></td>
186 <td style="text-align: center">k<sub>y</sub></td>
187 <td style="text-align: center">k<sub>z</sub></td>
188 </tr>
189 </table>
190
191 Raw data is organized by looping through real/imaginary data, samples, then channels:
192
193 <table class="smalltable">
194 <tr>
195 <td style="text-align: center" colspan="6">Channel 1</td>
196 <td style="text-align: center" colspan="6">Channel 2</td>
197 <td style="text-align: center" rowspan="3">...</td>
198 <td style="text-align: center" colspan="6">Channel n</td>
199 </tr>
200 <tr>
201 <td style="text-align: center" colspan="2">Sample 1</td>
202 <td style="text-align: center" colspan="2">...</td>
203 <td style="text-align: center" colspan="2">Sample n</td>
204 <td style="text-align: center" colspan="2">Sample 1</td>
205 <td style="text-align: center" colspan="2">...</td>
206 <td style="text-align: center" colspan="2">Sample n</td>
207 <td style="text-align: center" colspan="2">Sample 1</td>
208 <td style="text-align: center" colspan="2">...</td>
209 <td style="text-align: center" colspan="2">Sample n</td>
210 </tr>
211 <tr>
212 <td style="text-align: center">Re</td> <td style="text-align: center">Im</td>
213 <td style="text-align: center">Re</td> <td style="text-align: center">Im</td>
214 <td style="text-align: center">Re</td> <td style="text-align: center">Im</td>
215 <td style="text-align: center">Re</td> <td style="text-align: center">Im</td>
216 <td style="text-align: center">Re</td> <td style="text-align: center">Im</td>
217 <td style="text-align: center">Re</td> <td style="text-align: center">Im</td>
218 <td style="text-align: center">Re</td> <td style="text-align: center">Im</td>
219 <td style="text-align: center">Re</td> <td style="text-align: center">Im</td>
220 <td style="text-align: center">Re</td> <td style="text-align: center">Im</td>
221 </tr>
222 </table>
223
224 (MRD_MESSAGE_IMAGE)=
225 ## ID 1022: MRD_MESSAGE_IMAGE
226 <div class="mrdMsgTable5">
227
228 | ID | Fixed Image Header | Attribute Length | Attribute Data |Image Data |
229 | -- | -- | -- | -- | -- |
230 | 2 bytes | 198 bytes | 8 bytes | length * 1 byte | matrix_size[0] * matrix_size[1] * matrix_size[2] * channels * sizeof(data_type) |
231 | unsigned short | mixed | uint_64 | char | data_type |
232 </div>
233
234 Image data is sent using this message type. The fixed image header contains metadata including fields such as the [ImageType](ImageTypes) (magnitude, phase, etc.) and indices such as slice and repetition number. It is defined by the [ImageHeader](ImageHeader) struct. Within this header, there are 3 fields that must be interpreted to parse the rest of the message:
235 - **matrix_size**: This 3 element array indicates the size of each dimension of the image data.
236 - **channels**: This value indicates the number of (receive) channels for which image data is sent
237 - **data_type**: This value is an MRD_DataTypes enum that indicates the type of data sent. The following types are supported:
238 | Value | Name | Type | Size |
239 | -- | -- | -- | -- |
240 | 1 | MRD_USHORT | uint16_t | 2 bytes |
241 | 2 | MRD_SHORT | int16_t | 2 bytes |
242 | 3 | MRD_UINT | uint32_t | 4 bytes |
243 | 4 | MRD_INT | int32_t | 4 bytes |
244 | 5 | MRD_FLOAT | float | 4 bytes |
245 | 6 | MRD_DOUBLE | double | 8 bytes |
246 | 7 | MRD_CXFLOAT | complex float | 2 * 4 bytes |
247 | 8 | MRD_CXDOUBLE | complex double | 2 * 8 bytes |
248
249 Attributes are used to declare additional image metadata that is not present in the fixed image header. In general, this data is sent as a UTF-8 encoded char string (not null-terminated), with the length sent first as an uint_64 (not uint_32!). These are interpreted as an XML formatted set of image [MetaAttributes](MetaAttributes).
250
251 Image data is organized by looping through ``matrix_size[0]``, ``matrix_size[1]``, ``matrix_size[2]``, then ``channels``. For example, 2D image data would be formatted as:
252
253 <table class="smalltable">
254 <tr>
255 <td style="text-align: center" colspan="9">Channel 1</td>
256 <td style="text-align: center" rowspan="3">...</td>
257 <td style="text-align: center" colspan="9">Channel n</td>
258 </tr>
259 <tr>
260 <td style="text-align: center" colspan="3">y<sub>1</sub></td>
261 <td style="text-align: center" colspan="3">...</td>
262 <td style="text-align: center" colspan="3">y<sub>n</sub></td>
263 <td style="text-align: center" colspan="3">y<sub>1</sub></td>
264 <td style="text-align: center" colspan="3">...</td>
265 <td style="text-align: center" colspan="3">y<sub>n</sub></td>
266 </tr>
267 <tr>
268 <td style="text-align: center">x<sub>1</sub></td>
269 <td style="text-align: center">...</td>
270 <td style="text-align: center">x<sub>n</sub></td>
271 <td style="text-align: center">x<sub>1</sub></td>
272 <td style="text-align: center">...</td>
273 <td style="text-align: center">x<sub>n</sub></td>
274 <td style="text-align: center">x<sub>1</sub></td>
275 <td style="text-align: center">...</td>
276 <td style="text-align: center">x<sub>n</sub></td>
277 <td style="text-align: center">x<sub>1</sub></td>
278 <td style="text-align: center">...</td>
279 <td style="text-align: center">x<sub>n</sub></td>
280 <td style="text-align: center">x<sub>1</sub></td>
281 <td style="text-align: center">...</td>
282 <td style="text-align: center">x<sub>n</sub></td>
283 <td style="text-align: center">x<sub>1</sub></td>
284 <td style="text-align: center">...</td>
285 <td style="text-align: center">x<sub>n</sub></td>
286 </tr>
287 </table>
288
289 (MRD_MESSAGE_WAVEFORM)=
290 ## ID 1026: MRD_MESSAGE_WAVEFORM
291 <div class="mrdMsgTable3">
292
293 | ID | Fixed Waveform Header | Waveform Data |
294 | -- | -- | -- |
295 | 2 bytes | 40 bytes | channels * number of samples * bytes |
296 | unsigned short | mixed | uint32_t |
297 </div>
298
299 This message type is used to send arbitrary waveform data (e.g. physio signals, gradient waveforms, etc.). The fixed waveform data header contains metadata as defined by the [WaveformHeader](WaveformHeader).
300
301 The ``channels`` and ``number_of_samples`` members fields must be parsed in order to read the rest of the message. Waveform data is sent as an uint32_t array, ordered by looping through samples and then through channels:
302
303 <table class="smalltable">
304 <tr>
305 <td style="text-align: center" colspan="3">Channel 1</td>
306 <td style="text-align: center" colspan="3">Channel 2</td>
307 <td style="text-align: center" rowspan="2">...</td>
308 <td style="text-align: center" colspan="3">Channel n</td>
309 </tr>
310 <tr>
311 <td style="text-align: center">w<sub>1</sub></td>
312 <td style="text-align: center">...</td>
313 <td style="text-align: center">w<sub>n</sub></td>
314 <td style="text-align: center">w<sub>1</sub></td>
315 <td style="text-align: center">...</td>
316 <td style="text-align: center">w<sub>n</sub></td>
317 <td style="text-align: center">w<sub>1</sub></td>
318 <td style="text-align: center">...</td>
319 <td style="text-align: center">w<sub>n</sub></td>
320 </tr>
321 </table>