-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDICOM.txt
132 lines (103 loc) · 6.88 KB
/
DICOM.txt
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
## File format (cf DICOM standard Part 10 Sect 7.1)
A DICOM file is composed of:
- 128 bytes (which may be empty or application related informations) followed by
- the magic word "DICM" followed by
- the meta information headers followed by
- a list of tags
## Meta information header (cf DICOM standard Part 6 Chapt 7)
The Meta information header is a list of explicitely typed tags (see Tags
formats) which provide general and meta information about the DICOM file. Those
data are essential to properly decode the rest of the file.
All meta information tags are of the group 0x0002 and this group contains only
meta information tags.
### Transfert types (Cf DICOM standard Part 6 Chapt A[3]):
The most important meta information tag is the transfer type. It shall be read
in order to properly decode tags belonging to groups > 0x0002.
* 1.2.840.10008.1.2: Implicit VR Endian: Default Transfer Syntax for DICOM
* 1.2.840.10008.1.2.1: Explicit VR Little Endian
* 1.2.840.10008.1.2.1.99: Deflated Explicit VR Little Endian
* 1.2.840.10008.1.2.2: Explicit VR Big Endian
A DICOM file shall only contain explicit or implicit tags. This is determined by
the tag (0x0002,0x0010) TransferSyntaxUID. Depending on the value of that tags,
the tags will either be implicit or explicit. However, even in implicitly tagged
DICOM files, the DICOM Meta Element (the header tags (0002, XXXX)) will be
explicitely defined.
> For a list of DICOM Meta Element refer to the DICOM standard Part 6 Chapt 7[5]
## Tags formats (cf DICOM standard Part 5 Sect 7.1[1])
Data Element with Explicit VR of OB, OD, OF, OL, OW, SQ, UC, UR, UT or UN:
XXXX XXXX XXXX 0000 XXXXXXXX ...................................................
^^^^ ^^^^ ^^^^ ^^^^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | | | \__ VL bytes of data
| | | | \_________ Value length (4 bytes)
| | | \________________ Reserved (2 bytes)
| | \_____________________ Value representation (2 bytes)
| \__________________________ Element number (2 bytes)
\_______________________________ Group number (2 bytes)
Data Element with Explicit VR other than as shown in
XXXX XXXX XXXX XXXX ............................................................
^^^^ ^^^^ ^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | | \___________ VL bytes of data
| | | \________________ Value length (2 bytes) /!\
| | \_____________________ Value representation (2 bytes)
| \__________________________ Element number (2 bytes)
\_______________________________ Group number (2 bytes)
Data Element with Implicit VR:
XXXX XXXX XXXXXXXX .............................................................
^^^^ ^^^^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | \____________ VL bytes of data
| | \___________________ Value length (4 bytes)
| \__________________________ Element number (2 bytes)
\_______________________________ Group number (2 bytes)
When implicitely tagged, tags have their types defined in the DICOM data
dictionnary (Cf DICOM standard Part 6 Chapt 6[2])
## Value representation (Cf DICOM standard Part 5 Sect 6.2[4])
Tags' value representations are either implicitly or explicitly. In any case,
each tag has a value reprensentation (a type). Most value representation will
define a tag as a string of characters or some form of decimal value. But they
can carry more specific meaning. A tag UI, for example, will contain a string,
but of a particular type: a Unique Id. So that tag can be read with a specific
parser.
## Sequence (cf DICOM standard Part 5 Sect 7.5[6])
the `SQ` tag is a special type of tag. It contains other DICOM tags. This means
that the DICOM format can contain a tree of tags.
Data Element with Implicit VR Defined as a Sequence of Items with defined size
XXXX EEEE XXXXXXXX FFFEE000 XXXXXXXX ... FFFEE000 XXXXXXXX ... FFFEE000 XXXXXXXX
^^^^ ^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^
| | | | | | | \_____________________ etc
| | | | | | \_______ Second item tag (4 bytes)
| | | | | \______________ Tag data (variable length)
| | | | \_______________________ Item tag size (4 bytes)
| | | \______________________________________ Item tag (4 bytes)
| | \__________________________________________ Value length (4 bytes)
| \_______________________________________________ Element number (2 bytes)
\______________________________________________________ Group number (2 bytes)
Data Element with Implicit VR Defined as a Sequence of Items With SDI*
XXXX EEEE FFFFFFFF FFFEE000 XXXXXXXX ... FFFEE000 XXXXXXXX ... FFFEE0DD.00000000
^^^^ ^^^^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | | | | \_ SDI (4 b)*
| | | | | \______________ Tag data (variable length)
| | | | \_______________________ Item tag size (4 bytes)
| | | \______________________________________ Item tag (4 bytes)
| | \________________________________________________ Unused (4 bytes)
| \_______________________________________________ Element number (2 bytes)
\______________________________________________________ Group number (2 bytes)
* Sequence Delimitation Item
Data Element with Explicit VR Defined as a Sequence of Items
XXXX EEEE 53510000 FFFFFFFF FFFEE000 XXXXXXXX ................ FFFEE0DD.00000000
^^^^ ^^^^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | | | | | | \_ SDI (4 b)*
| | | | | | | \_ Tag data (variable length)
| | | | | | \______________ Item tag size (4 bytes)
| | | | | \____________________________ Item tag (4 bytes)
| | | | \________________________________________ Unused (4 bytes)
| | | \______________________________________________ Unused (2 bytes)
| | \____________________________________ Value representation (2 bytes)
| \_______________________________________________ Element number (2 bytes)
\______________________________________________________ Group number (2 bytes)
* Sequence Delimitation Item
[1] http://dicom.nema.org/medical/dicom/current/output/html/part05.html#sect_7.1
[2] http://dicom.nema.org/medical/dicom/current/output/html/part06.html#chapter_6
[3] http://dicom.nema.org/medical/dicom/current/output/html/part06.html#chapter_A
[4] http://dicom.nema.org/medical/dicom/current/output/html/part05.html#sect_6.2
[5] http://dicom.nema.org/medical/dicom/current/output/html/part06.html#chapter_7
[6] http://dicom.nema.org/medical/dicom/current/output/html/part05.html#sect_7.5