The TAG file format is loosely based on the university of Waterloo IM format.
The image file is composed of two sections:
•The header
•the image binary data.
The Header
The header is entirely composed of lines of ASCII text. Each line is terminated by the characters <CR> and <LF> (0x0D and 0x0A). The header is terminated by a <FF> character (0x0C).
Everything on a line following a "*" will be considered as comments and can be disregarded by the program.
The header is composed of a series of keywords value pairs. The keyword and values are separated by ":". Each pair of keyword and values are separated by one or more separation characters. The recognized separators are: " " (space), "," (comma), "\t" (tab) or "\n" (new-line). You can use lowercase or uppercase indifferently in the keywords, the program converts all the keywords characters to uppercase before parsing the header.
The recognized keywords and their permitted values are:
|
x: |
"X" resolution (in pixels). |
|
y: |
"Y" resolution (in pixels). |
|
z: |
Number of images in the file. |
|
type: |
Gives the size of each pixel, the values supported by the program are BYTE or SHORT (only BYTE is used for the ".tag" files). |
|
org_x: |
Position in "x", "y" and "z" of the center of the top left pixel of the image.
|
|
org_y: |
|
|
org_z: |
|
|
dim_x: |
Total dimension in "x" and "y" of the image (in millimeters).
|
|
dim_y: |
|
|
inc_x: |
Distance between 2 consecutive pixels in "x" and "y" of the image (in millimeters).
|
|
inc_y: |
|
|
epais: |
Slice thickness. |
|
dir_h_x: |
X, y and z components of the horizontal direction vector (in patient system).
|
|
dir_h_y: |
|
|
dir_h_z: |
|
|
dir_v_x: |
X, y and z components of the vertical direction vector (in patient system).
|
|
dir_v_y: |
|
|
dir_v_z: |
|
|
uid: |
Unique number used to make sure this tag is associated with the correct GLI image. |
|
chksum: |
Checksum of the original GLI image. |
|
x:256 y:256 z:9 type:BYTE org_x:-204.2221 org_y:-181.8909 org_z:-250.0000 inc_x:0.7105 inc_y:0.7105 epais:5.0000 dir_h_x:1.0000 dir_h_y:0.0000 dir_h_z:0.0000 dir_v_x:0.0000 dir_v_y:1.0000 dir_v_z:0.0000 uid:AFCCCAC6 chksum:09F1588D bin:256 * number of echos: 0 ^L |
|
Sample TAG header |
The Image Data
The image data is written in binary form. There are X x Y x Z pixels in the image data. The values for X, Y and Z come from the header. Each pixel takes 1 or 2 bytes according to the value associated with the "type" keyword (tag files use "Byte", so one byte per pixel). The pixels are written using the algorithm:
for each image k
for each line j (starting at the top)
for each pixel i (starting at the left)
write pixel [k][j][i] ;