File: gdcmCSAHeader.cxx

package info (click to toggle)
gdcm 2.4.4-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 32,868 kB
  • sloc: cpp: 188,481; ansic: 124,526; xml: 41,799; sh: 7,162; python: 3,667; cs: 2,128; java: 1,344; lex: 1,290; tcl: 677; php: 128; makefile: 116
file content (1257 lines) | stat: -rw-r--r-- 50,091 bytes parent folder | download | duplicates (2)
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
/*=========================================================================

  Program: GDCM (Grassroots DICOM). A DICOM library

  Copyright (c) 2006-2011 Mathieu Malaterre
  All rights reserved.
  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "gdcmCSAHeader.h"
#include "gdcmPrivateTag.h"
#include "gdcmDataElement.h"
#include "gdcmCSAElement.h"
#include "gdcmDataSet.h"
#include "gdcmExplicitDataElement.h"
#include "gdcmSwapper.h"

namespace gdcm
{
CSAElement CSAHeader::CSAEEnd = CSAElement((unsigned int)-1);

  const CSAElement& CSAHeader::GetCSAEEnd() const
  {
    return CSAEEnd;
  }


/*
 *  (0029,1110) OB 53\54\45\50\3b\0a... # 5342,1 MedCom OOG Info
 *  -> MEDCOM Object Oriented Graphics (OOG) data.
 *  I think this is the STEP-File, aka ISO standard (10303)
 *  http://sourceforge.net/projects/stepmod
 *
 *  $ ./bin/gdcmraw -i MR-SIEMENS-DICOM-WithOverlays.dcm -t 0029,1110 -o 0029_1110.raw
 *  $ gvim 0029_1110.raw
STEP;
HEADER;
    FILE_IDENTIFICATION(
  '',
  'Wed Nov 30 15:11:24 2005',
  ('meduser'),
  (''),
  '1.0',
  '1.0',
  'Exchangeboard');
    FILE_DESCRIPTION('STEP format');
    IMP_LEVEL('1.0');
ENDSEC;
DATA;
@329 = CsaGraDoubleVec3DArray(0, ());
@331 = CsaGraDoubleVec3DArray(0, (69.0, 246.0, 0.0, 67.0, 245.0, 0.0, 66.0, 244.0, 0.0, 64.0, 244.0, 0.0, 62.0, 243.0, 0.0, 61.0, 243.0, 0.0, 59.0, 243.0, 0.0, 57.0, 243.0, 0.0, 56.0, 243.0, 0.0, 55.0, 243.0, 0.0, 53.0, 243.0, 0.0, 52.0, 243.0, 0.0, 51.0, 243.0, 0.0, 50.0, 243.0, 0.0, 49.0, 243.0, 0.0, 48.0, 243.0, 0.0, 48.0, 244.0, 0.0, 47.0, 244.0, 0.0, 46.0, 245.0, 0.0, 46.0, 247.0, 0.0, 46.0, 248.0, 0.0, 46.0, 249.0, 0.0, 46.0, 250.0, 0.0, 46.0, 251.0, 0.0, 46.0, 252.0, 0.0, 46.0, 253.0, 0.0, 46.0, 255.0, 0.0, 46.0, 257.0, 0.0, 47.0, 258.0, 0.0, 47.0, 259.0, 0.0, 48.0, 261.0, 0.0, 49.0, 261.0, 0.0, 50.0, 263.0, 0.0, 50.0, 264.0, 0.0, 51.0, 266.0, 0.0, 53.0, 267.0, 0.0, 54.0, 268.0, 0.0, 55.0, 270.0, 0.0, 56.0, 270.0, 0.0, 56.0, 271.0, 0.0, 57.0, 271.0, 0.0, 58.0, 271.0, 0.0, 59.0, 272.0, 0.0, 61.0, 272.0, 0.0, 62.0, 272.0, 0.0, 62.0, 273.0, 0.0, 63.0, 273.0, 0.0, 64.0, 273.0, 0.0, 65.0, 273.0, 0.0, 66.0, 273.0, 0.0, 67.0, 273.0, 0.0, 69.0, 273.0, 0.0, 69.0, 272.0, 0.0, 71.0, 271.0, 0.0, 72.0, 270.0, 0.0, 73.0, 269.0, 0.0, 73.0, 268.0, 0.0, 73.0, 267.0, 0.0, 74.0, 267.0, 0.0, 75.0, 266.0, 0.0, 75.0, 265.0, 0.0, 76.0, 265.0, 0.0, 77.0, 263.0, 0.0, 77.0, 261.0, 0.0, 78.0, 261.0, 0.0, 78.0, 259.0, 0.0, 78.0, 258.0, 0.0, 79.0, 257.0, 0.0, 79.0, 256.0, 0.0, 80.0, 256.0, 0.0, 80.0, 255.0, 0.0, 80.0, 254.0, 0.0, 80.0, 253.0, 0.0, 80.0, 252.0, 0.0, 80.0, 251.0, 0.0, 80.0, 250.0, 0.0, 79.0, 248.0, 0.0, 77.0, 247.0, 0.0, 77.0, 246.0, 0.0, 77.0, 245.0, 0.0, 77.0, 244.0, 0.0, 75.0, 244.0, 0.0, 75.0, 243.0, 0.0, 74.0, 242.0, 0.0, 73.0, 242.0, 0.0, 72.0, 241.0, 0.0, 71.0, 240.0, 0.0, 71.0, 239.0, 0.0, 70.0, 239.0, 0.0, 69.0, 239.0, 0.0, 68.0, 239.0, 0.0, 66.0, 239.0, 0.0, 64.0, 239.0, 0.0, 63.0, 239.0, 0.0, 64.0, 242.0, 0.0));
@333 = CsaImageOverlay(0, (), (), '', 0, 0, 0, $, (), (), (), (), (), (#332), 0, 0, (), '', '', (), '', (), 0, 0, $, 0, 0.0, 0.0, (), '', 0, 0, 'CAP_3D_MEANING', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, );
@332 = CsaGraphicPrimGroup(0, 0, 0, 0, 0.0, 0, #329, 1, 1, 0, 0, $, #333, $, $, $, (#330));
@335 = CsaUVString(0, (67, 111, 110, 116, 111, 117, 114, 77, 97, 110, 105, 112, 49, 54, 56, 49, 55, 100, 101, 48, 45, 97, 50, 48, 102, 45, 52, 50, 102, 99, 45, 97, 102, 102, 49, 45, 48, 55, 99, 49, 99, 51, 54, 48, 57, 102, 56, 102, 0));
@336 = CsaGraphicFrameApplContainer(0, (), 0);
@334 = CsaGraVVIDictionary(0, (#335), (#336), (-1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), (-1));
@330 = CsaGraphicPolygon(0, 0, 0, 0, 0.0, 0, #331, 0, 1, 0, 0, #332, $, #334, $, $, 0, 63.0, 256.0, 0.0, 0, 0, 0, 0, 0, 65535, 1.0, 0.0, 1.0, 0.0, 0, 0.29899999999999999, 0.58699999999999997, 0.114, 0, 65535, 0.0, 0.0, 0.0, 0.0, 0, 0.29899999999999999, 0.58699999999999997, 0.114, 1, 0, '', 1, 0, 0, 0, 65535, 1.0, 1.0, 1.0, 0.0, 0, 0.29899999999999999, 0.58699999999999997, 0.114, 0, 65535, 0.0, 0.0, 0.0, 0.0, 0, 0.29899999999999999, 0.58699999999999997, 0.114, 2, $, $, 1);
@337 = CsaGraDoubleVec3DArray(0, ());
@339 = CsaGraDoubleVec3DArray(0, (0.84375, 0.84375, 0.0));
@341 = CsaImageOverlay(0, (), (), '', 0, 0, 0, $, (), (), (), (), (), (#340), 0, 0, (), '', '', (), '', (), 0, 0, $, 0, 0.0, 0.0, (), '', 0, 0, 'CAP_3D_MEANING', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, );
@343 = CsaGraDoubleVec3DArray(0, (0.90234375, 0.29296875, 0.0));
@345 = CsaUVString(0, (68, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 77, 97, 110, 105, 112, 35, 51, 95, 48, 98, 51, 57, 97, 54, 98, 53, 51, 45, 56, 53, 97, 50, 45, 52, 54, 102, 48, 45, 56, 99, 49, 52, 45, 97, 55, 102, 48, 51, 99, 100, 48, 53, 51, 56, 99, 0));
@346 = CsaGraphicFrameApplContainer(0, (), 0);
@344 = CsaGraVVIDictionary(0, (#345), (#346), (-1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), (-1));
@342 = CsaGraphicText(0, 0, 0, 0, 0.0, 0, #343, 4, 1, 1, 1, #340, $, #344, $, $, 0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 65535, 1.0, 1.0, 1.0, 0.0, 0, 0.29899999999999999, 0.58699999999999997, 0.114, 0, 65535, 0.0, 0.0, 0.0, 0.0, 0, 0.29899999999999999, 0.58699999999999997, 0.114, (84, 114, 97, 0), 1, -1, 0, 100, -16, 0, 0, 0, 400, 0, 0, 0, 0, 3, 2, 1, 34, 77, 77, 105, 110, 99, 104, 111, 32, 102, 111, 114, 32, 83, 105, 101, 109, 101, 110, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2);
@340 = CsaGraphicPrimGroup(0, 0, 0, 0, 0.0, 0, #337, 1, 1, 0, 0, $, #341, $, $, $, (#338, #342));
@348 = CsaUVString(0, (79, 114, 105, 101, 110, 116, 73, 110, 100, 105, 35, 51, 95, 48, 56, 54, 97, 100, 54, 52, 102, 50, 45, 50, 56, 49, 55, 45, 52, 102, 102, 50, 45, 57, 56, 52, 100, 45, 55, 49, 49, 101, 54, 55, 99, 52, 48, 53, 56, 57, 0));
@349 = CsaGraphicFrameApplContainer(0, (), 0);
@347 = CsaGraVVIDictionary(0, (#348), (#349), (-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1), (-1));
@338 = CsaGraphicCube(0, 0, 0, 0, 0.0, 0, #339, 4, 1, 0, 0, #340, $, #347, $, $, 0, 0.84375, 0.84375, 0.0, 0, 0, 0, 0, 0, 65535, 1.0, 1.0, 0.0, 0.0, 0, 0.29899999999999999, 0.58699999999999997, 0.114, 0, 65535, 0.0, 0.0, 0.0, 0.0, 0, 0.29899999999999999, 0.58699999999999997, 0.114, 1, 0, '', 1, 0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.05859375);
ENDSEC;
ENDSTEP;
9
 */

/*
 * http://www.enac.northwestern.edu/~tew/archives/2003/02/25/incomplete-dicom-headers/
 * http://www.nmr.mgh.harvard.edu/~rudolph/software/vox2ras/download/vox2ras_rsolve.m
 * http://www.mail-archive.com/freesurfer@nmr.mgh.harvard.edu/msg03409.html
 *
 * Pretty good link:
 * http://www.mmrrcc.upenn.edu/CAMRIS/cfn/dicomhdr.html
 */

/*
 * SIEMENS-JPEG-CorruptFragClean.dcm (0029,xx10):
 * (0000,0005) FD (??) 337.625                              # 8,? (1)
 * (0000,0006) FD (??) 4.665                                # 8,? (1)
 * (0000,0007) SL (??) 955                                  # 4,? (1)
 * (0000,0008) SL (??) 200                                  # 4,? (1)
 * (0000,000c) FD (??) 4                                    # 8,? (1)
 * (0000,000d) SL (??) 2                                    # 4,? (1)
 * (0000,0013) SL (??) 337                                  # 4,? (1)
 * (0000,0014) SL (??) 0                                    # 4,? (1)
 * (0000,0016) SL (??) 50                                   # 4,? (1)
 * (0000,0018) SL (??) 672                                  # 4,? (1)
 * (0000,001d) LT (??) [N.E.C.K]                            # 8,? (1)
 * (0000,001e) FD (??) 160                                  # 8,? (1)
 * (0000,001f) FD (??) 0                                    # 8,? (1)
 * (0000,0020) FD (??) 3                                    # 8,? (1)
 * (0000,0021) SL (??) 1                                    # 4,? (1)
 * (0000,0022) SL (??) 11                                   # 4,? (1)
 * (0000,0025) SL (??) 8                                    # 4,? (1)
 * (0000,0027) FD (??) 60                                   # 8,? (1)
 * (0000,0028) SL (??) 292                                  # 4,? (1)
 * (0000,0029) SL (??) 0                                    # 4,? (1)
 * (0000,002c) SL (??) 200                                  # 4,? (1)
 * (0000,002d) SL (??) 0                                    # 4,? (1)
 * (0000,002e) SL (??) 0                                    # 4,? (1)
 * (0000,002f) FD (??) 1                                    # 8,? (1)
 * (ffff,ffff) CS (??) [END!      ]                         # 10,? (1)
 */

/*

Example of (29,10,SIEMENS CSA NON-IMAGE) / 0000,0a01

MlScanProtocol_Begin:   112

MlScanProtocolAttributes_Begin: 112

ActiveEntry:    0
AEC_SlopeObese: 0.33
AEC_SlopeSmall: 0.50
AutoReferenceLinesMode: MlAutoReferenceLinesModeOff
BodySizeOld:    MlAdult
BreathHold:     99.000
BreathingDefault:       15.000
Cardiac:        1
CustomProtocol: 1
Ident:  21003100
Partial:        1
PatientID:      "4.0.201300074"
PatientName:    "DQ"
PatientPosition:        MlPositionUndefined
PreCond4Displ:  65535
ProtocolName:   "PETCT_DailyQC"
Region: MlPET
Service:        0
StudyDescription:       "PET^PETCT_DailyQC (Adult)"
StudyID:        "4.0.311400557"
TotalmAs:       139
TotalNoOfScans: 1

CursorPos: 0


MlScanProtocolAttributes_End:   112

PROTOCOL_ENTRY_NO:      1

MlModeEntry_Begin:      112

MlModeEntryAttributes_Begin:    112

AutoRange:      MlAutoRangeNone
EntrySelected:  1
PatientPositionFoR:     MlFaceUpHeadFirst
Visible:        1
BodySize:       MlAdult
ModeEntryUID:   3


MlModeEntryAttributes_End:      112

MlModeScanNotNULL:

MlModeScan_Begin:       112

CardioTriggerDelay:     ""
Comment1:       ""
Comment1Source: MlInherited
Comment2:       ""
Comment2Source: MlInherited
ReconMode:      MlReconSliceMode
SliceEffective: 5.00
SliceEffectiveTiltCorrected:    5
SlicesPerScan:  16
SpiralPrePostRotation:  1.057
AddScan:        0
AEC_Aref:       600
AEC_AttenuationDataAP:  ""
AEC_AttenuationDataLat: ""
AEC_BeginPos:   68.000
AEC_CurrentDOMmax:      0
AEC_CurrentMean:        0
AEC_CurrentProfileAP:   ""
AEC_CurrentProfileLat:  ""
AEC_DoseProfile:        ""
AEC_EndPos:     -127.000
AEC_MDS:        ""
AEC_PDS:        ""
AEC_PDSMean:    0
AEC_PositionExceed:     0
AEC_PowerExceed:        0
AEC_Range:      -1.9697
AEC_TopoExceed: 0
AECDoseModulationType:  MlAutomaticExposureControl
AECReferenceMAs:        20
AngleType:      MlTubePosLateral
ApiId:  -1
ASICCont1:      15
ASICCont2:      135
AssignmentTest: 0
AutoFeed:       0
AutoLoad:       0
AutoTilt:       0
AverageRawData: MlAverageRDOff
BaseReconRangeBegin:    71.500
BaseReconRangeEnd:      -184.500
BeginPos:       71.500
Biopsy: 0
BodyRegion:     MlBodyRegionBody
Breathing:      18.000
Capacitor:      MlCapacitorNotused
Cardio: 0
CardioAverage:  MlCardioAverageLast3
CardioSyntheticTrigger: 0
Care:   MlOff
CareDoseType:   MlCareDoseAEC
CareVisionTableMode:    MlTableMoveContinuous
CareVisionTableStep:    2.5
Clustered:      0
ClusteredUsed:  0
Contrast:       0
CoolingTime:    0.000
CTDIw:  7.8
CTDIwEffective: 7.8
Current:        250
CurrentCorrection:      1.25
CurrentEffective:       250
CurrentPeak:    250
CurrentStd:     200
CustomMAs:      100
CycleTime:      0.000
CycleTimeMin:   0.000
CycleTimeUser:  0.000
DASCont1:       79
DASCont2:       0
DestinationRequestID:   "ct48501---------------------20071113-071740-0021-1044D480-00000"
DiscCheckSource:        MlDiscCheckNone
Displayed:      1
DLPEffective:   157.56
DoseModulationType:     MlNoModulation
ECGPulsing:     MlOff
EffectiveMAs:   100
EndPos: -130.500
FeedLastScan:   0.0
FeedScan:       0.0
Focus:  MlSmallFocus
FrameOfReferenceUID:    "1.3.12.2.1107.5.1.4.48501.30000007111306074039000000021"
FuseBolusModes: 0
GantryRotating: 1
HandCare:       MlNone
InterPosHori:   71.500
InterPosTilt:   0.0
IrsAcceptsMissingTables:        0
KeepFBAD:       0
Kind:   MlSpiral
mAs:    100
MasterAdjustOrTestNumber:       0
MasterAsymmetricStartAngle:     0
MasterCombActive:       0
MasterCompensatorActive:        1
MasterDataTransfer:     1
MasterDose:     1755
MasterDoseAmplification:        0
MasterDoseControl:      1
MasterDynamicFocusDeflection:   0
MasterFilament: 1
MasterFilamentCurrent:  7016
MasterFixedReadings:    0
MasterFocusAmplitude:   0
MasterFocusDelay:       0
MasterFocusOffset:      -7
MasterGantryDisplay:    1
MasterGantryRotation:   1
MasterIgnoreTubeArcing: 1
MasterIntegrationMode:  4
MasterIntegrationTime:  431
MasterITControl:        0
MasterLateralPosition:  0
MasterLightMarkerInScanExecute: 0
MasterMoveAllowedInScanExecute: 0
MasterPhiControl:       1
MasterRotAnodeFrequency:        50
MasterRotAnodeFrequencyChanged: 1
MasterRotatingAnode:    1
MasterSyntheticTrigger: 0
MasterTestPattern:      0
MasterTubeCollimatorMovement:   1
MasterTubeCurrent:      199
MasterTubeVoltage:      120000
MasterUseNominalValues: 1
MasterUseStartAngle:    0
MasterXray:     1
MasterZControl: 1
MasterZControlDynamic:  0
MBH:    0
MultiScanTime:  1.000
NoOfClustersPerRange:   1
NoOfScans:      1
NoOfScansDone:  0
NoOfScansInLastCluster: 0
NoOfScansPerCluster:    1
NoOfSlicesAfterPrep:    16
NoOfSlicesDetector:     16
NoOfSlicesPrep: 16
OfflineReconstruction:  1
OrganCharacteristicOverride:    MlOff
OrganCharacteristics:   MlOrgCharThorax
Pitch:  20.0
PitchFactor:    1.2500000
PitchLowerLimit:        7.0
PitchUpperLimit:        8.0
Power:  30000
PreLoad:        0
ProcessSteps:   4294967295
ProspectiveDoseSaving:  0
RangeName:      "CT"
RangeStart:     MlRangeStartConsole
RawDataFile:    "0001_RCT"
RawDataLoid:    "4.0.311407191"
Readings:       15150
ReconRangeBeginPos:     51.500
ReconRangeBeginTime:    0.000
ReconRangeEndPos:       -110.500
ReconRangeEndTime:      0.000
ReconRangeFirstImageTime:       "0"
ReconRangeLastImageTime:        "0"
RevolAngle:     360
RotKind:        MlRotNormal
RotNum: 13.029
RotTime:        0.500
RPP:    MlRpp1
ScanLabel:      ""
ScanNumber:     1
ScanState:      MlStateScanned
ScanTime:       6.530
ScanTrigger:    MlScanTriggerAuto
SequenceGap:    0.0
SequenceReconRangeEndPos:       142.000
SequenceRotTime:        0.500
SequenceScanTime:       0.750
Serio:  0
SliceDetector:  0.75
SliceGain:      0.000
SlicePhysical:  0.75
SliceSelect:    128
SourceRequestID:        ""
SpecialMeas:    MlSpecialMeasNone
SpiralFeedRot:  15.0
SpiralLength:   162.0
SpiralReconRangeEndPos: -110.500
SpiralRotTime:  0.500
SpiralScanTime: 6.530
StartAngleNumber:       90.0
StartDelay:     4.000
StartDelayCalc: 2.000
StartDelayUser: 4.000
StaticRotTime:  0.500
StaticTime:     1.000
TableDirection: MlIn
TableDirectionPatient:  MlCraniocaudal
TiltPos:        0.0
TopoLength:     0.0
TopoLengthList: 512.0
TopoLoid:       "4.0.311400561"
TopoReconRangeEndPos:   142.000
TopoScanTime:   0.000
TubeCollimator: 5100
TubeCollimatorClosed:   0
TubeNotify:     0
TubePosition:   0.0
UHR:    MlOff
UseAdjustAirCal:        0
UseAdjustBeamHard:      0
UseMasterGeneratorSettings:     0
VertPos:        106.0
VertPosValid:   1
Voltage:        120.000


MlModeScan_End: 112

First_MlModeRecon_Is_NULL:

No_Of_Valid_Recons: 1

MlModeRecon_Begin:      112

CardioTriggerDelay:     ""
Comment1:       ""
Comment1Source: MlInherited
Comment2:       ""
Comment2Source: MlInherited
ReconMode:      MlReconSliceMode
SliceEffective: 5.00
SliceEffectiveTiltCorrected:    5
SlicesPerScan:  16
SpiralPrePostRotation:  1.057
AdaptFilter:    1
Algorithm:      MlSlim
AutoRecon:      0
AutoReferenceLinesActive:       MlOff
Balancing:      1
BalancingSteps: 5
BodyPartExamined:       "CHEST"
CardioBiPhase:  1
CardioListOfEditSyncs:  ""
CardioListOfTimeStamps: ""
CardioMultiPhase:       0
CardioMultiPhaseTriggerDelay:   ""
CardioNoOfMultiPhase:   0
CardioNoOfTimeStampLists:       "0"
CardioReadyForRecon:    0
CareViewHead:   MlLeft
CenterX:        0
CenterY:        0
CrossSectionChanged:    0
CTScale:        MlCTScaleStandard
ExtendedFOV:    1
FilmImageInterval:      1
Filming:        0
FirstReconSlice:        0
FOV:    0
FoVHorLength:   700
FoVHorVec:      1.000;0.000;0.000
FoVVertLength:  700
FoVVertVec:     0.000;1.000;0.000
FuseModesP30:   1
ImaDisplay:     1
ImageMatrix:    512
ImageOrder:     MlIO_Craniocaudal
ImageReconType: MlPrimary
ImaStore:       1
IRSReconTime:   6.999
Kernel: "B30f medium smooth"
MCA:    0
Mirror: MlMirrorNone
ModeReconJMUID: ""
ModeReconUID:   4
MPPSDescription:        ""
MultiReconIncr: 1.000
NonLinearLookUpTable:   0
NoOfImages:     33
NoOfImagesEntryDone:    0
Obese:  1
OnlineReconPossible:    1
ORAFilter:      0
OrganFoV:       380
PFO:    MlOff
PostProcessingCommand:  "NON"
PostProcessingID:       "Ml3DNone"
ReconBeginPos:  0.000
ReconBeginTime: 0.000
ReconBeginVec:  0.000;0.000;51.500
ReconDirection: MlAxial
ReconEndPos:    0.000
ReconEndTime:   0.000
ReconEndVec:    0.000;0.000;-110.500
ReconIncrementManualChange:     MlUnchanged
ReconKind:      MlMetroRecon
ReconLabel:     ""
ReconPriority:  0
ReconSelected:  1
ReconState:     MlReconStateActive
ReconStateJM:   MlReconStateJMCreated
ReconstructionVolumeBeginVec:   0.000;0.000;0.000
ReconstructionVolumeEndVec:     0.000;0.000;0.000
ReconTaskNumber:        1
ReconType:      MlAxialRJ
ReferenceSeriesLoid:    ""
Resolution:     ResModeUltraFast
SeriesDescription:      "CT  5.0  eFoV  "
SeriesLoid:     ""
SeriesLoidKind: MlSeriesNew
SpiralBaseFunction:     MlSpiralBaseTrapezium06
SpiralPrePostLengthCorrection:  0.000
SpiralReconIncr:        5.000
ToBeReconBeginPos:      0.000
ToBeReconBeginTime:     0.000
ToBeReconBeginVec:      0.000;0.000;51.500
ToBeReconEndPos:        0.000
ToBeReconEndTime:       0.000
ToBeReconEndVec:        0.000;0.000;-110.500
TopoZoom:       1
Transfer:       MlOff
Transfer1:      ""
Transfer2:      ""
Transfer3:      ""
Ui3DViewCurrentPlanningVolumeLoid:      ""
Ui3DViewCutlineDirectionVec:    0.000;0.000;0.000
Ui3DViewFoVSegmentIndex:        0
Ui3DViewPanX:   0.000;0.000;0.000
Ui3DViewPanY:   0.000;0.000;0.000
Ui3DViewPivotVec:       0.000;0.000;0.000
Ui3DViewPVImageType:    MlMPR
Ui3DViewTopographicsSegmentIndex:       0
Ui3DViewTransformationVec1:     0.000;0.000;0.000
Ui3DViewTransformationVec2:     0.000;0.000;0.000
Ui3DViewWindowCenter1:  40.000;40.000;40.000
Ui3DViewWindowCenter2:  40.000;40.000;40.000
Ui3DViewWindowWidth1:   400.000;400.000;400.000
Ui3DViewWindowWidth2:   400.000;400.000;400.000
Ui3DViewZoomX:  1.000;1.000;1.000
Ui3DViewZoomY:  1.000;1.000;1.000
Viewing:        MlOff
ViewingDirection:       MlIO_Craniocaudal
Window[READ_ONLY]:      "Mediastinum"
Window.ResID:   33
Window1Center:  40
Window1Width:   400
Window2Center:  -600
Window2Width:   1200
WindowImageLoid:        ""


MlModeRecon_End:        112


MlModeEntry_End:        112

MlScanProtocol_End:     112


 */

struct DataSetFormatEntry
{
  Tag t;
  VR  vr;
};

static DataSetFormatEntry DataSetFormatDict[] = {
 { Tag(0x0000,0x0004),VR::LT },
 { Tag(0x0000,0x0005),VR::FD },
 { Tag(0x0000,0x0006),VR::FD },
 { Tag(0x0000,0x0007),VR::SL },
 { Tag(0x0000,0x0008),VR::SL },
 { Tag(0x0000,0x000c),VR::FD },
 { Tag(0x0000,0x000d),VR::SL },
 { Tag(0x0000,0x000e),VR::SL },
 { Tag(0x0000,0x0012),VR::FD },
 { Tag(0x0000,0x0013),VR::SL },
 { Tag(0x0000,0x0014),VR::SL },
 { Tag(0x0000,0x0016),VR::SL },
 { Tag(0x0000,0x0018),VR::SL },
 { Tag(0x0000,0x001a),VR::SL },
 { Tag(0x0000,0x001d),VR::LT }, // Defined Terms: [A.B.D.O.M.E.N], [C.H.E.S.T], [E.X.T.R.E.M.I.T.Y], [H.E.A.D], [N.E.C.K], [P.E.L.V.I.S], [S.P.I.N.E]
 { Tag(0x0000,0x001e),VR::FD },
 { Tag(0x0000,0x001f),VR::FD },
 { Tag(0x0000,0x0020),VR::FD },
 { Tag(0x0000,0x0021),VR::SL },
 { Tag(0x0000,0x0022),VR::SL },
 { Tag(0x0000,0x0025),VR::SL },
 { Tag(0x0000,0x0026),VR::FD },
 { Tag(0x0000,0x0027),VR::FD },
 { Tag(0x0000,0x0028),VR::SL },
 { Tag(0x0000,0x0029),VR::SL },
 { Tag(0x0000,0x002b),VR::LT },
 { Tag(0x0000,0x002c),VR::SL },
 { Tag(0x0000,0x002d),VR::SL },
 { Tag(0x0000,0x002e),VR::SL },
 { Tag(0x0000,0x002f),VR::FD },
 { Tag(0x0000,0x0030),VR::LT },
 { Tag(0x0000,0x0033),VR::SL },
 { Tag(0x0000,0x0035),VR::SL },
 { Tag(0x0000,0x0036),VR::CS },
 { Tag(0x0000,0x0037),VR::SL },
 { Tag(0x0000,0x0038),VR::SL },
 { Tag(0x0000,0x0039),VR::SL },
 { Tag(0x0000,0x003a),VR::FD },
 { Tag(0x0000,0x003b),VR::SL },
 { Tag(0x0000,0x003c),VR::SL },
 { Tag(0x0000,0x003d),VR::FD },
 { Tag(0x0000,0x003e),VR::SL },
 { Tag(0x0000,0x003f),VR::SL },
 { Tag(0x0000,0x0101),VR::FD },
 { Tag(0x0000,0x0102),VR::FD },
 { Tag(0x0000,0x0103),VR::FD },
 { Tag(0x0000,0x0105),VR::IS },
 { Tag(0x0006,0x0006),VR::FD },
 { Tag(0x0006,0x0007),VR::FD },
 { Tag(0x0006,0x0008),VR::CS },
 { Tag(0x0006,0x000a),VR::LT },
 { Tag(0x0006,0x000b),VR::CS },
 { Tag(0x0006,0x000c),VR::FD },
 { Tag(0x0006,0x000e),VR::CS },
 { Tag(0x0006,0x000f),VR::SL },
 { Tag(0x0006,0x0024),VR::FD },
 { Tag(0xffff,0xffff),VR::CS }, // ENDS!
};

/*
Apparently tag <-> vr has no relation ... it must be derived from something else

(0000,0003) FD 500                                      #   8, 1 RequestedSOPClassUID
(0000,0004) FD 1040                                     #   8, 1 Unknown Tag & Data
(0000,0005) FD 570                                      #   8, 1 Unknown Tag & Data
(0000,0008) LT [0]                                      #   2, 1 Unknown Tag & Data
(0000,0010) DT [20071113071752.765000]                  #  22, 1 ACR_NEMA_CommandRecognitionCode
(0000,0020) SL 2                                        #   4, 1 Unknown Tag & Data
(0000,0025) FD (no value available)                     #   0, 0 Unknown Tag & Data
(0000,0026) FD 0.7                                      #   8, 1 Unknown Tag & Data
(0000,0028) ?? (no value available)                     #   0, 1 Unknown Tag & Data
(0000,0030) SL 30                                       #   4, 1 Unknown Tag & Data
(0000,0040) LT [C]                                      #   4, 1 Unknown Tag & Data
(0000,0a01) ?? 4d\6c\53\63\61\6e\50\72\6f\74\6f\63\6f\6c\5f\42\65\67\69\6e\3a\09... # 8788, 1 Unknown Tag & Data
(0000,fe10) CS [SCANPROT]                               #  10, 1 Unknown Tag & Data
(ffff,ffff) CS [END!]                                   #  10, 1 Unknown Tag & Data
*/

VR GetVRFromDataSetFormatDict( const Tag& t )
{
  static const unsigned int nentries = sizeof(DataSetFormatDict) / sizeof(*DataSetFormatDict);
  VR ret = VR::VR_END;
  //static const Tag tend = Tag(0xffff,0xffff);
  for( unsigned int i = 0; i < nentries; ++i)
    {
    const DataSetFormatEntry &entry = DataSetFormatDict[i];
    if( entry.t == t )
      {
      ret = entry.vr;
      break;
      }
    }
  return ret;
}

/*
 * http://www.healthcare.siemens.com/magnetom/phoenix-gallery/orthopedics/images/phoenix/29642762.ima
Image shadow data (0029,xx10)

0 - 'EchoLinePosition' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '427     '
1 - 'EchoColumnPosition' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '224     '
2 - 'EchoPartitionPosition' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '8       '
3 - 'UsedChannelMask' VM 1, VR UL, SyngoDT 9, NoOfItems 6, Data '63      '
4 - 'Actual3DImaPartNumber' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
5 - 'ICE_Dims' VM 1, VR LO, SyngoDT 19, NoOfItems 6, Data 'X_1_1_1_1_1_1_1_1_1_1_1_41'
6 - 'B_value' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
7 - 'Filter1' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
8 - 'Filter2' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
9 - 'ProtocolSliceNumber' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '6       '
10 - 'RealDwellTime' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '8600    '
11 - 'PixelFile' VM 1, VR UN, SyngoDT 0, NoOfItems 0, Data
12 - 'PixelFileName' VM 1, VR UN, SyngoDT 0, NoOfItems 0, Data
13 - 'SliceMeasurementDuration' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '338142.50000000'
14 - 'SequenceMask' VM 1, VR UL, SyngoDT 9, NoOfItems 6, Data '134217728'
15 - 'AcquisitionMatrixText' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data '421*448s'
16 - 'MeasuredFourierLines' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '0       '
17 - 'FlowEncodingDirection' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
18 - 'FlowVenc' VM 1, VR FD, SyngoDT 4, NoOfItems 0, Data
19 - 'PhaseEncodingDirectionPositive' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '1       '
20 - 'NumberOfImagesInMosaic' VM 1, VR US, SyngoDT 10, NoOfItems 0, Data
21 - 'DiffusionGradientDirection' VM 3, VR FD, SyngoDT 4, NoOfItems 0, Data
22 - 'ImageGroup' VM 1, VR US, SyngoDT 10, NoOfItems 0, Data
23 - 'SliceNormalVector' VM 3, VR FD, SyngoDT 4, NoOfItems 0, Data
24 - 'DiffusionDirectionality' VM 1, VR CS, SyngoDT 16, NoOfItems 0, Data
25 - 'TimeAfterStart' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.00000000'
26 - 'FlipAngle' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
27 - 'SequenceName' VM 1, VR SH, SyngoDT 22, NoOfItems 0, Data
28 - 'RepetitionTime' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
29 - 'EchoTime' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
30 - 'NumberOfAverages' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
31 - 'VoxelThickness' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
32 - 'VoxelPhaseFOV' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
33 - 'VoxelReadoutFOV' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
34 - 'VoxelPositionSag' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
35 - 'VoxelPositionCor' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
36 - 'VoxelPositionTra' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
37 - 'VoxelNormalSag' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
38 - 'VoxelNormalCor' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
39 - 'VoxelNormalTra' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
40 - 'VoxelInPlaneRot' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
41 - 'ImagePositionPatient' VM 3, VR DS, SyngoDT 3, NoOfItems 0, Data
42 - 'ImageOrientationPatient' VM 6, VR DS, SyngoDT 3, NoOfItems 0, Data
43 - 'PixelSpacing' VM 2, VR DS, SyngoDT 3, NoOfItems 0, Data
44 - 'SliceLocation' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
45 - 'SliceThickness' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
46 - 'SpectrumTextRegionLabel' VM 1, VR SH, SyngoDT 22, NoOfItems 0, Data
47 - 'Comp_Algorithm' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
48 - 'Comp_Blended' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
49 - 'Comp_ManualAdjusted' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
50 - 'Comp_AutoParam' VM 1, VR LT, SyngoDT 20, NoOfItems 0, Data
51 - 'Comp_AdjustedParam' VM 1, VR LT, SyngoDT 20, NoOfItems 0, Data
52 - 'Comp_JobID' VM 1, VR LT, SyngoDT 20, NoOfItems 0, Data
53 - 'FMRIStimulInfo' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
54 - 'FlowEncodingDirectionString' VM 1, VR SH, SyngoDT 22, NoOfItems 0, Data
55 - 'RepetitionTimeEffective' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
56 - 'CsiImagePositionPatient' VM 3, VR DS, SyngoDT 3, NoOfItems 0, Data
57 - 'CsiImageOrientationPatient' VM 6, VR DS, SyngoDT 3, NoOfItems 0, Data
58 - 'CsiPixelSpacing' VM 2, VR DS, SyngoDT 3, NoOfItems 0, Data
59 - 'CsiSliceLocation' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
60 - 'CsiSliceThickness' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
61 - 'OriginalSeriesNumber' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
62 - 'OriginalImageNumber' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
63 - 'ImaAbsTablePosition' VM 3, VR SL, SyngoDT 7, NoOfItems 6, Data '0       '\'0       '\'-1952   '
64 - 'NonPlanarImage' VM 1, VR US, SyngoDT 10, NoOfItems 6, Data '1       '
65 - 'MoCoQMeasure' VM 1, VR US, SyngoDT 10, NoOfItems 0, Data
66 - 'LQAlgorithm' VM 1, VR SH, SyngoDT 22, NoOfItems 0, Data
67 - 'SlicePosition_PCS' VM 3, VR FD, SyngoDT 4, NoOfItems 6, Data '-47.43732992'\'-135.75159147'\'19.57638496'
68 - 'RBMoCoTrans' VM 3, VR FD, SyngoDT 4, NoOfItems 0, Data
69 - 'RBMoCoRot' VM 3, VR FD, SyngoDT 4, NoOfItems 0, Data
70 - 'MultistepIndex' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '0       '
71 - 'ImaRelTablePosition' VM 3, VR IS, SyngoDT 6, NoOfItems 6, Data '0       '\'0       '\'39      '
72 - 'ImaCoilString' VM 1, VR LO, SyngoDT 19, NoOfItems 6, Data 'T:BO1,2'
73 - 'RFSWDDataType' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data 'measured'
74 - 'GSWDDataType' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data 'measured'
75 - 'NormalizeManipulated' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
76 - 'ImaPATModeText' VM 1, VR LO, SyngoDT 19, NoOfItems 6, Data 'p2'
77 - 'B_matrix' VM 6, VR FD, SyngoDT 4, NoOfItems 0, Data
78 - 'BandwidthPerPixelPhaseEncode' VM 1, VR FD, SyngoDT 4, NoOfItems 0, Data
79 - 'FMRIStimulLevel' VM 1, VR FD, SyngoDT 4, NoOfItems 0, Data
Series shadow data (0029,xx20)

0 - 'UsedPatientWeight' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '72      '
1 - 'NumberOfPrescans' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '0       '
2 - 'TransmitterCalibration' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '541.65400000'
3 - 'PhaseGradientAmplitude' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.00000000'
4 - 'ReadoutGradientAmplitude' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.00000000'
5 - 'SelectionGradientAmplitude' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.00000000'
6 - 'GradientDelayTime' VM 3, VR DS, SyngoDT 3, NoOfItems 6, Data '13.00000000'\'14.00000000'\'10.00000000'
7 - 'RfWatchdogMask' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '0       '
8 - 'RfPowerErrorIndicator' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
9 - 'SarWholeBody' VM 3, VR DS, SyngoDT 3, NoOfItems 0, Data
10 - 'Sed' VM 3, VR DS, SyngoDT 3, NoOfItems 6, Data '1000000.00000000'\'725.84052985'\'725.71234997'
11 - 'SequenceFileOwner' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data 'SIEMENS'
12 - 'Stim_mon_mode' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '2       '
13 - 'Operation_mode_flag' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '2       '
14 - 'dBdt_max' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.00000000'
15 - 't_puls_max' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.00000000'
16 - 'dBdt_thresh' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.00000000'
17 - 'dBdt_limit' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.00000000'
18 - 'SW_korr_faktor' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '1.00000000'
19 - 'Stim_max_online' VM 3, VR DS, SyngoDT 3, NoOfItems 6, Data '2.14339137'\'17.54720879'\'0.45053142'
20 - 'Stim_max_ges_norm_online' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.63422704'
21 - 'Stim_lim' VM 3, VR DS, SyngoDT 3, NoOfItems 6, Data '45.73709869'\'27.64929962'\'31.94370079'
22 - 'Stim_faktor' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '1.00000000'
23 - 'CoilForGradient' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data 'void'
24 - 'CoilForGradient2' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data 'AS092'
25 - 'CoilTuningReflection' VM 2, VR DS, SyngoDT 3, NoOfItems 0, Data
26 - 'CoilId' VM 0, VR IS, SyngoDT 6, NoOfItems 12, Data '255     '\'83      '\'238     '\'238     '\'238     '\'238     '\'238     '\'177     '\'238     '\'178     '\'238     '
27 - 'MiscSequenceParam' VM 38, VR IS, SyngoDT 6, NoOfItems 42, Data '0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '\'1086    '\'0       '\'0       '\'0       '\'0       '\'0       '\'0       '
28 - 'MrProtocolVersion' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '0       '
29 - 'DataFileName' VM 1, VR LO, SyngoDT 19, NoOfItems 0, Data
30 - 'RepresentativeImage' VM 1, VR UI, SyngoDT 25, NoOfItems 0, Data
31 - 'PositivePCSDirections' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data '+LPH'
32 - 'RelTablePosition' VM 3, VR IS, SyngoDT 6, NoOfItems 6, Data '0       '\'0       '\'39      '
33 - 'ReadoutOS' VM 1, VR FD, SyngoDT 4, NoOfItems 6, Data '2.00000000'
34 - 'LongModelName' VM 1, VR LO, SyngoDT 19, NoOfItems 6, Data 'TrioTim'
35 - 'SliceArrayConcatenations' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '1       '
36 - 'SliceResolution' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '1.00000000'
37 - 'AbsTablePosition' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '-1952   '
38 - 'AutoAlignMatrix' VM 16, VR FL, SyngoDT 5, NoOfItems 0, Data
39 - 'MeasurementIndex' VM 1, VR FL, SyngoDT 5, NoOfItems 0, Data
40 - 'CoilString' VM 1, VR LO, SyngoDT 19, NoOfItems 6, Data 'T:BO1,2'
41 - 'PATModeText' VM 1, VR LO, SyngoDT 19, NoOfItems 6, Data 'p2'
42 - 'PatReinPattern' VM 1, VR ST, SyngoDT 23, NoOfItems 6, Data '1;HFS;72.00;15.00;2;0;2;-794520928'
43 - 'ProtocolChangeHistory' VM 1, VR US, SyngoDT 10, NoOfItems 6, Data '0       '
44 - 'Isocentered' VM 1, VR US, SyngoDT 10, NoOfItems 6, Data '1       '
45 - 'MrPhoenixProtocol' VM 1, VR UN, SyngoDT 0, NoOfItems 6, Data '<XProtocol>
<...>
46 - 'GradientMode' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data 'Fast'
47 - 'FlowCompensation' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data 'No'
48 - 'PostProcProtocol' VM 1, VR UT, SyngoDT 27, NoOfItems 0, Data
49 - 'RFSWDOperationMode' VM 1, VR SS, SyngoDT 8, NoOfItems 6, Data '+0      '
50 - 'RFSWDMostCriticalAspect' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data 'Whole Body'
51 - 'SARMostCriticalAspect' VM 3, VR DS, SyngoDT 3, NoOfItems 6, Data '2.00000000'\'1.02534234'\'0.97963309'
52 - 'TablePositionOrigin' VM 3, VR SL, SyngoDT 7, NoOfItems 6, Data '0       '\'0       '\'-1991   '
53 - 'MrProtocol' VM 1, VR UN, SyngoDT 0, NoOfItems 0, Data
54 - 'MrEvaProtocol' VM 1, VR UN, SyngoDT 0, NoOfItems 0, Data
*
*
WARNING: I think this is context dependant so 0029,1010 and 0029,1110 are not supposed to mean the same thing, eg:
(CSA image data)

(0029,0010)siemens csa header
Image shadow data (0029,xx10)

0 - 'ImageNumber' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
1 - 'ImageComments' VM 1, VR LT, SyngoDT 20, NoOfItems 0, Data
2 - 'ReferencedImageSequence' VM 0, VR UI, SyngoDT 25, NoOfItems 6, Data '1.2.840.10008.5.1.4.1.1.4'\'1.3.12.2.1107.5.2.30.25299.3.200803181402241188330606'\'1.2.840.10008.5.1.4.1.1.4'\'1.3.12.2.1107.5.2.30.25299.3.2008031814031374741230990'\'1.2.840.10008.5.1.4.1.1.4'\'1.3.12.2.1107.5.2.30.25299.3.200803181402241589130608'
3 - 'PatientOrientation' VM 1, VR CS, SyngoDT 16, NoOfItems 0, Data
4 - 'ScanningSequence' VM 0, VR CS, SyngoDT 16, NoOfItems 6, Data 'RM'
5 - 'SequenceName' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data 'tfi2d1_20'
6 - 'RepetitionTime' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '29.60000000'
7 - 'EchoTime' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '1.25000000'
8 - 'InversionTime' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
9 - 'NumberOfAverages' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '1.00000000'
10 - 'ImagingFrequency' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '63.61952800'
11 - 'ImagedNucleus' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data '1H'
12 - 'EchoNumbers' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '1       '
13 - 'MagneticFieldStrength' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '1.50000000'
14 - 'NumberOfPhaseEncodingSteps' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '100     '
15 - 'EchoTrainLength' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '1       '
16 - 'PercentSampling' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '32.00000000'
17 - 'PercentPhaseFieldOfView' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '100.00000000'
18 - 'TriggerTime' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '82.50000000'
19 - 'ReceivingCoil' VM 1, VR SH, SyngoDT 22, NoOfItems 0, Data
20 - 'TransmittingCoil' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data 'Body'
21 - 'AcquisitionMatrix' VM 4, VR US, SyngoDT 10, NoOfItems 6, Data '256     '\'0       '\'0       '\'82      '
22 - 'PhaseEncodingDirection' VM 1, VR CS, SyngoDT 16, NoOfItems 6, Data 'COL'
23 - 'FlipAngle' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '20.00000000'
24 - 'VariableFlipAngleFlag' VM 1, VR CS, SyngoDT 16, NoOfItems 6, Data 'N'
25 - 'SAR' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.21757985'
26 - 'dBdt' VM 3, VR DS, SyngoDT 3, NoOfItems 6, Data '0.00000000'
27 - 'SliceThickness' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '7.00000000'
28 - 'ImagePositionPatient' VM 3, VR DS, SyngoDT 3, NoOfItems 6, Data '117.38499069'\'-48.94067860'\'0.00000000'
29 - 'ImageOrientationPatient' VM 6, VR DS, SyngoDT 3, NoOfItems 6, Data '-1.00000000'\'0.00000000'\'0.00000000'\'0.00000000'\'1.00000000'\'0.00000000'
30 - 'SliceLocation' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '0.00000000'
31 - 'EchoLinePosition' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '50      '
32 - 'EchoColumnPosition' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '128     '
33 - 'EchoPartitionPosition' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '8       '
34 - 'Actual3DImaPartNumber' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
35 - 'RealDwellTime' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '2300    '
36 - 'ProtocolSliceNumber' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '0       '
37 - 'DataFile' VM 1, VR UN, SyngoDT 0, NoOfItems 0, Data
38 - 'DataFileName' VM 1, VR UN, SyngoDT 0, NoOfItems 0, Data
39 - 'ICE_Dims' VM 1, VR LO, SyngoDT 19, NoOfItems 6, Data '1_1_2_1_4_1_1_1_1_1_1_1_259'
40 - 'PixelSpacing' VM 2, VR DS, SyngoDT 3, NoOfItems 6, Data '1.25000000'\'1.25000000'
41 - 'SourceImageSequence' VM 0, VR UI, SyngoDT 25, NoOfItems 0, Data
42 - 'PixelBandwidth' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '850.00000000'
43 - 'SliceMeasurementDuration' VM 1, VR DS, SyngoDT 3, NoOfItems 6, Data '4112.50000000'
44 - 'SequenceMask' VM 1, VR UL, SyngoDT 9, NoOfItems 6, Data '0       '
45 - 'AcquisitionMatrixText' VM 1, VR SH, SyngoDT 22, NoOfItems 6, Data '82*256s'
46 - 'MeasuredFourierLines' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
47 - 'CsiGridshiftVector' VM 3, VR DS, SyngoDT 3, NoOfItems 0, Data
48 - 'MultistepIndex' VM 1, VR IS, SyngoDT 6, NoOfItems 6, Data '0       '
49 - 'SpectroscopyAcquisitionPhaseColumns' VM 1, VR UL, SyngoDT 9, NoOfItems 0, Data
50 - 'SpectroscopyAcquisitionPhaseRows' VM 1, VR UL, SyngoDT 9, NoOfItems 0, Data
51 - 'SpectroscopyAcquisitionOut-of-planePhaseSteps' VM 1, VR UL, SyngoDT 9, NoOfItems 0, Data
52 - 'SpectroscopyAcquisitionDataColumns' VM 1, VR UL, SyngoDT 9, NoOfItems 0, Data
53 - 'DataPointRows' VM 1, VR UL, SyngoDT 9, NoOfItems 0, Data
54 - 'DataPointColumns' VM 1, VR UL, SyngoDT 9, NoOfItems 0, Data
55 - 'DataRepresentation' VM 1, VR CS, SyngoDT 16, NoOfItems 0, Data
56 - 'SignalDomainColumns' VM 1, VR CS, SyngoDT 16, NoOfItems 0, Data
57 - 'Columns' VM 1, VR US, SyngoDT 10, NoOfItems 6, Data '256     '
58 - 'Rows' VM 1, VR US, SyngoDT 10, NoOfItems 6, Data '100     '
59 - 'NumberOfFrames' VM 1, VR IS, SyngoDT 6, NoOfItems 0, Data
60 - 'MixingTime' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
61 - 'k-spaceFiltering' VM 1, VR CS, SyngoDT 16, NoOfItems 0, Data
62 - 'HammingFilterWidth' VM 1, VR DS, SyngoDT 3, NoOfItems 0, Data
63 - 'TransmitterReferenceAmplitude' VM 1, VR FD, SyngoDT 4, NoOfItems 0, Data
64 - 'ResonantNucleus' VM 1, VR CS, SyngoDT 16, NoOfItems 0, Data
65 - 'VoiThickness' VM 1, VR FD, SyngoDT 4, NoOfItems 0, Data
66 - 'VoiPhaseFoV' VM 1, VR FD, SyngoDT 4, NoOfItems 0, Data
67 - 'VoiReadoutFoV' VM 1, VR FD, SyngoDT 4, NoOfItems 0, Data
68 - 'VoiOrientation' VM 3, VR FD, SyngoDT 4, NoOfItems 0, Data
69 - 'VoiPosition' VM 3, VR FD, SyngoDT 4, NoOfItems 0, Data
70 - 'VoiInPlaneRotation' VM 1, VR FD, SyngoDT 4, NoOfItems 0, Data
71 - 'RSatThickness' VM 0, VR FD, SyngoDT 4, NoOfItems 0, Data
72 - 'RSatOrientationSag' VM 0, VR FD, SyngoDT 4, NoOfItems 0, Data
73 - 'RSatOrientationCor' VM 0, VR FD, SyngoDT 4, NoOfItems 0, Data
74 - 'RSatOrientationTra' VM 0, VR FD, SyngoDT 4, NoOfItems 0, Data
75 - 'RSatPositionSag' VM 0, VR FD, SyngoDT 4, NoOfItems 0, Data
76 - 'RSatPositionCor' VM 0, VR FD, SyngoDT 4, NoOfItems 0, Data
77 - 'RSatPositionTra' VM 0, VR FD, SyngoDT 4, NoOfItems 0, Data
78 - 'SpacingBetweenSlices' VM 1, VR FD, SyngoDT 4, NoOfItems 0, Data
79 - 'DataSetInfo' VM 1, VR UN, SyngoDT 0, NoOfItems 0, Data
80 - 'ImaCoilString' VM 1, VR LO, SyngoDT 19, NoOfItems 6, Data 'BO1'
81 - 'BandwidthPerPixelPhaseEncode' VM 1, VR FD, SyngoDT 4, NoOfItems 0, Data



*/
struct equ
{
  uint32_t syngodt;
  const char vr[2+1];
};

// Looks like there is mapping in between syngodt and vr...
//  O <=> UN
//  3 <=> DS
//  4 <=> FD
//  5 <=> FL
//  6 <=> IS
//  9 <=> UL
// 10 <=> US
// 16 <=> CS
// 19 <=> LO
// 20 <=> LT
// 22 <=> SH
// 25 <=> UI
static equ mapping[] = {
  {  0 , "UN" },
  {  3 , "DS" },
  {  4 , "FD" },
  {  5 , "FL" },
  {  6 , "IS" },
  {  7 , "SL" },
  {  8 , "SS" },
  {  9 , "UL" },
  { 10 , "US" },
  { 16 , "CS" },
  { 19 , "LO" },
  { 20 , "LT" },
  { 22 , "SH" },
  { 23 , "ST" },
  { 25 , "UI" },
  { 27 , "UT" }
};

bool check_mapping(uint32_t syngodt, const char *vr)
{
  static const unsigned int max = sizeof(mapping) / sizeof(equ);
  const equ *p = mapping;
  assert( syngodt <= mapping[max-1].syngodt ); (void)max;
  while(p->syngodt < syngodt )
    {
    //std::cout << "mapping:" << p->vr << std::endl;
    ++p;
    }
  assert( p->syngodt == syngodt ); // or else need to update mapping
  const char* lvr = p->vr;
  int check = strcmp(vr, lvr) == 0;
  assert( check ); (void)check;
  return true;
}

bool checkallzero(std::istream &is)
{
  bool res = true;
  char c;
  while( is >> c )
    {
    if( c != 0 )
      {
      res = false;
      break;
      }
    }
  return res;
}

CSAHeader::CSAHeaderType CSAHeader::GetFormat() const
{
  return InternalType;
}

// dcmInfo.exe print like this:
// 67 - 'SlicePosition_PCS' VM 3, VR FD, SyngoDT 4, NoOfItems 6, Data '-185.77913332'\'-163.80459213'\'72.73944092'
bool CSAHeader::LoadFromDataElement(DataElement const &de)
{
  if( de.IsEmpty() ) return false;

  InternalCSADataSet.clear();
  InternalDataSet.Clear();
  gdcmDebugMacro( "Entering print" );
  InternalType = UNKNOWN; // reset
  gdcm::Tag t1(0x0029,0x0010);
  gdcm::Tag t2(0x0029,0x0020);
  uint16_t v = (uint16_t)(de.GetTag().GetElement() << 8);
  uint16_t v2 = (uint16_t)(v >> 8);
  //if( de.GetTag().GetPrivateCreator() == t1 )
  if( v2 == t1.GetElement() )
    {
    //std::cout << "Image shadow data (0029,xx10)\n\n";
    DataElementTag = t1;;
    }
  //else if( de.GetTag().GetPrivateCreator() == t2 )
  else if( v2 == t2.GetElement() )
    {
    //std::cout << "Series shadow data (0029,xx20)\n\n";
    DataElementTag = t2;;
    }
  else
    {
    //  std::cerr << "Unhandled tag: " << de.GetTag() << std::endl;
    DataElementTag = de.GetTag();
    }
  gdcmDebugMacro( "found type" );

  const ByteValue *bv = de.GetByteValue();
  assert( bv );
  const char *p = bv->GetPointer();
  assert( p );
  std::string s( bv->GetPointer(), bv->GetLength() );
  std::stringstream ss;
  ss.str( s );
  char signature[4+1];
  signature[4] = 0;
  if( !ss.read(signature, 4) )
    {
    gdcmErrorMacro( "Too short" );
    return false;
    }
  //std::cout << signature << std::endl;
  // 1. NEW FORMAT
  // 2. OLD FORMAT
  // 3. Zero out
  // 4. DATASET FORMAT (Explicit Little Endian), with group=0x0 elements:
  if( strcmp( signature, "SV10" ) != 0 )
    {
    if( checkallzero(ss) )
      {
      //std::cout << "Zeroed out" << std::endl;
      InternalType = ZEROED_OUT;
      return true;
      }
    else if( strcmp(signature, "!INT" ) == 0 )
      {
      InternalType = INTERFILE;
      InterfileData = p;
      return true;
      }
    // cannot use strcmp / strncmp in the following ... doh !
    else if( memcmp(signature, "\0\0" , 2 ) == 0
          || memcmp(signature, "\6\0" , 2 ) == 0 )
    {
      // Most often start with an element (0000,xxxx)
      // And ends with element:
      // (ffff,ffff)  CS  10  END!
      ss.seekg( 0, std::ios::beg );
      // SIEMENS-JPEG-CorruptFragClean.dcm
      InternalType = DATASET_FORMAT;
      DataSet &ds = InternalDataSet;
      DataElement xde;
      try
        {
        while( xde.Read<ExplicitDataElement,SwapperNoOp>( ss ) )
          {
          ds.InsertDataElement( xde ); // Cannot use Insert since Group = 0x0 (< 0x8)
          //VR refvr = GetVRFromDataSetFormatDict( xde.GetTag() );
          //assert( xde.GetVR() == refvr );
          }
        //std::cout << ds << std::endl;
        assert( ss.eof() );
        }
      catch(std::exception &)
        {
        gdcmErrorMacro( "Something went wrong while decoding... please report" );
        return false;
        }
      return true;
      }
    else
      {
      //assert(0);
      ss.seekg( 0, std::ios::beg );
      // No magic number for this one:
      // SIEMENS_Sonata-16-MONO2-Value_Multiplicity.dcm
      InternalType = NOMAGIC;
      }
    }
  if( strcmp( signature, "SV10" ) == 0 )
    {
    // NEW FORMAT !
    ss.read(signature, 4);
    assert( strcmp( signature, "\4\3\2\1" ) == 0 );
    InternalType = SV10;
    }
  assert( InternalType != UNKNOWN );
  gdcmDebugMacro( "Found Type: " << (int)InternalType );

  uint32_t n;
  ss.read((char*)&n, sizeof(n));
  SwapperNoOp::SwapArray(&n,1);
  uint32_t unused;
  ss.read((char*)&unused, sizeof(unused));
  SwapperNoOp::SwapArray(&unused,1);
  if( unused != 77 )
    {
    gdcmErrorMacro( "Must be a new format. Giving up" );
    return false;
    }
  assert( unused == 77 ); // 'M' character...

  for(uint32_t i = 0; i < n; ++i)
    {
    CSAElement csael;
    //std::cout << i;
    csael.SetKey( i );
    //std::cout << " - ";
    char name[64+1];
    name[64] = 0; // security
    ss.read(name, 64);
    csael.SetName( name );
    //std::cout << "'" << name << "' ";
    uint32_t vm;
    ss.read((char*)&vm, sizeof(vm));
    SwapperNoOp::SwapArray(&vm,1);
    csael.SetVM( VM::GetVMTypeFromLength(vm,1) );
    //assert( csael.GetVM() != VM::VM0 );
    //std::cout << "VM " << vm <<  ", ";
    char vr[4];
    ss.read(vr, 4);
    // In dataset without magic signature (OLD FORMAT) vr[3] is garbage...
    assert( /*vr[3] == 0 &&*/ vr[2] == 0 );
    csael.SetVR( VR::GetVRTypeFromFile(vr) );
    //std::cout << "VR " << vr << ", ";
    uint32_t syngodt;
    ss.read((char*)&syngodt, sizeof(syngodt));
    SwapperNoOp::SwapArray(&syngodt,1);
    bool cm = check_mapping(syngodt, vr);
    if( !cm )
      {
      gdcmErrorMacro( "SyngoDT is not handled, please submit bug report" );
      return false;
      }
    csael.SetSyngoDT( syngodt );
    //std::cout << "SyngoDT " << syngodt << ", ";
    uint32_t nitems;
    ss.read((char*)&nitems, sizeof(nitems));
    SwapperNoOp::SwapArray(&nitems,1);
    csael.SetNoOfItems( nitems );
    //std::cout << "NoOfItems " << nitems << ", ";
    uint32_t xx;
    ss.read((char*)&xx, sizeof(xx));
    SwapperNoOp::SwapArray(&xx,1);
    //std::cout << "xx=" << xx<< std::endl;
    assert( xx == 77 || xx == 205 );

    //std::cout << "Data ";
    std::ostringstream os;
    for( uint32_t j = 0; j < nitems; ++j)
      {
      uint32_t item_xx[4];
      ss.read((char*)&item_xx, 4*sizeof(uint32_t));
      SwapperNoOp::SwapArray(item_xx,4);
      assert( item_xx[2] == 77 || item_xx[2] == 205 );
      uint32_t len = item_xx[1]; // 2nd element
      assert( item_xx[0] == item_xx[1] && item_xx[1] == item_xx[3] );
      if( len )
        {
        char *val = new char[len+1];
        val[len] = 0; // security
        ss.read(val,len);
        // WARNING vr does not means anything AFAIK,
        // simply print the value as if it was IS/DS or LO (ASCII)
        if( j )
          {
          //std::cout << '\\';
          os << '\\';
          }
        //std::cout << "'" << val << "'";
        os << val;

        char dummy[4];
        uint32_t dummy_len = (4 - len % 4) % 4;
        ss.read(dummy, dummy_len );

        for(uint32_t d= 0; d < dummy_len; ++d)
          {
          // dummy[d]  is zero in the NEW format
          //assert( dummy[d] == 0 );
          //for the old format there appears to be some garbage:
          if( dummy[d] )
            {
            //std::cout << "dummy=" << (int)dummy[d] << std::endl;
            }
          }
        delete[] val;
        }
      }
    std::string str = os.str();
    if( !str.empty() )
      csael.SetByteValue( &str[0], (uint32_t)str.size());
    //std::cout << std::endl;
    InternalCSADataSet.insert( csael );
    }
  return true;
}

void CSAHeader::Print(std::ostream &os) const
{
  std::set<CSAElement>::const_iterator it = InternalCSADataSet.begin();
  gdcm::Tag t1(0x0029,0x0010);
  gdcm::Tag t2(0x0029,0x0020);
  if( DataElementTag == t1 )
    {
    os << "Image shadow data (0029,xx10)\n\n";
    }
  else if( DataElementTag == t2 )
    {
    os << "Series shadow data (0029,xx20)\n\n";
    }
  else
    {
    std::cerr << "Unhandled tag: " << DataElementTag << std::endl;
    }

  for(; it != InternalCSADataSet.end(); ++it)
    {
    std::cout << *it << std::endl;
    }
}

const CSAElement &CSAHeader::GetCSAElementByName(const char *name)
{
  if( name )
    {
    //int s =  InternalCSADataSet.size();
    std::set<CSAElement>::const_iterator it = InternalCSADataSet.begin();
    for(; it != InternalCSADataSet.end(); ++it)
      {
      const char *itname = it->GetName();
      assert( itname );
      if( strcmp(name, itname) == 0 )
        {
        return *it;
        }
      }
    }
  return GetCSAEEnd();
}

bool CSAHeader::FindCSAElementByName(const char *name)
{
  if( name )
    {
    std::set<CSAElement>::const_iterator it = InternalCSADataSet.begin();
    for(; it != InternalCSADataSet.end(); ++it)
      {
      const char *itname = it->GetName();
      assert( itname );
      if( strcmp(name, itname) == 0 )
        {
        return true;
        }
      }
    }
  return false;
}

static const char csaheader[] = "SIEMENS CSA HEADER";
static const gdcm::PrivateTag t1(0x0029,0x0010,csaheader); // CSA Image Header Info
static const gdcm::PrivateTag t2(0x0029,0x0020,csaheader); // CSA Series Header Info

//static const char csaheader2[] = "SIEMENS MEDCOM HEADER2";
//static const gdcm::PrivateTag t4(0x0029,0x0010,csaheader2); // CSA Image Header Info
//static const gdcm::PrivateTag t5(0x0029,0x0020,csaheader2); // CSA Series Header Info

static const char csanonimage[] = "SIEMENS CSA NON-IMAGE";
static const gdcm::PrivateTag t3(0x0029,0x0010,csanonimage); // CSA Data Info

const PrivateTag & CSAHeader::GetCSAImageHeaderInfoTag()
{
  return t1;
}

const PrivateTag & CSAHeader::GetCSASeriesHeaderInfoTag()
{
  return t2;
}

const PrivateTag & CSAHeader::GetCSADataInfo()
{
  return t3;
}

} // end namespace gdcm