NPL
Neurological Programs and Libraries
trackfile_headers.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2014 Micah C Chambers (micahc.vt@gmail.com)
3  *
4  * NPL is free software: you can redistribute it and/or modify it under the
5  * terms of the BSD 2-Clause License available in LICENSE or at
6  * http://opensource.org/licenses/BSD-2-Clause
7  *
8  ******************************************************************************/
9 
10 #ifndef TRACKFILE_HEADERS_H
11 #define TRACKFILE_HEADERS_H
12 
13 //id_string[6] char 6 ID string for track file. The first 5
14 // characters must be "TRACK".
15 //dim[3] short int Dimension of the image volume.
16 //voxel_size[3] float Voxel size of the image volume.
17 //origin[3] float Origin of the image volume. This field is not yet
18 // being used by TrackVis. That means the origin is
19 // always (0, 0, 0).
20 //n_scalars short int 2 Number of scalars saved at each track point
21 // (besides x, y and z coordinates).
22 //scalar_name[10][20] char Name of each scalar. Can not be longer than
23 // 20 characters each.
24 //n_properties short int Number of properties saved at each track.
25 //property_name[10][20] char Name of each property. Can not be longer than
26 // 20 characters each. Can only store up to 10 names.
27 //vox_to_ras[4][4] float 4x4 matrix for voxel to RAS (crs to xyz)
28 // transformation. If vox_to_ras[3][3] is 0, it
29 // means the matrix is not recorded. This field is
30 // added from version 2.
31 //reserved[444] char Reserved space for future version.
32 //voxel_order[4] char Storing order of the original image data. Explained here.
33 //pad2[4] char 4 Paddings.
34 //image_orientation_patient[6] float 24 Image orientation of the original image.
35 // As defined in the DICOM header.
36 //pad1[2] char 2 Paddings.
37 //invert_x unsigned char 1 Inversion/rotation flags used to generate
38 // this track file. For internal use only.
39 //invert_y unsigned char 1 As above.
40 //invert_z unsigned char 1 As above.
41 //swap_xy unsigned char 1 As above.
42 //swap_yz unsigned char 1 As above.
43 //swap_zx unsigned char 1 As above.
44 //n_count int 4 Number of tracks stored in this track file.
45 // 0 means the number was NOT stored.
46 //version int 4 Version number. Current version is 1.
47 //hdr_size int 4 Size of the header. Used to determine byte swap.
48 // Should be 1000.
49 //<---------------------BODY-------------------------->
50 //From Experience these coordinates are index*spacing
51 //
52 //Track #1 int 4 Number of points in this track, as m.
53 // float (3+n_s)*4 Track Point #1. Contains 3 plus n_s float
54 // numbers. First 3 float numbers are the
55 // x/y/z coordinate of this track point,
56 // followed by n_s float numbers representing
57 // each of its scalars.
58 // float(3+n_s)*4 Track Point #2. Same as above.
59 //... ... ...
60 // float(3+n_s)*4 Track Point #m. Same as above.
61 // float n_p*4 n_p float numbers representing each
62 // of the properties of this track.
63 //Track #2 Same as above.
64 //
65 //... Same as above.
66 //
67 //Track #n Same as above.
68 
69 typedef struct
70 {
71  char id_string[6];
72 
73  short int dim[3];
74  float voxel_size[3];
75  float origin[3];
76 
77  short int n_scalars;
78  char scalar_name[10][20];
79 
80  short int n_properties;
81  char property_name[10][20];
82 
83  float vox_to_ras[4][4];
84 
85  char reserved[444];
86 
87  char voxel_order[4];
88  char padA4[4];
89  float image_orientation_patient[6];
90  char padB2[2];
91 
92  unsigned char invert_x;
93  unsigned char invert_y;
94  unsigned char invert_z;
95  unsigned char swap_xy;
96  unsigned char swap_yz;
97  unsigned char swap_zx;
98 
99  int n_count;
100  int version;
101  int hdr_size; //shouldbe 1000
102 
103  unsigned char data[0];
104 } TrkHead;
105 
106 /* reads a Brainsuite .dft file */
107 //0 magic char[8] An 8 character string designating the filetype
108 // (‘DFC_LE\0\0′ or ‘DFC_BE\0\0′*).
109 //8 version uint8[4] 4 unsigned characters, representing the version number
110 // (e.g., 1.0.0.2)
111 //12 header size int32 size of the stored header
112 //16 data start int32 offset from beginning of file to where the curves
113 // are stored
114 //20 metadata offset int32 offset from beginning of file to where the
115 // metadata are stored
116 //24 subject data offset int32 offset from beginning of file to where the
117 // subject data are stored (not currently used)
118 //28 # of contours int32 number of curves stored in file
119 //32 # of seedpoints int64 number of seedpoints stored in file
120 //Cuve0 Curve1 … CurveNC-1
121 //
122 //N x0 y0 z0 x1 y1 z1 … xN-1 yN-1 zN-1
123 
124 typedef struct
125 {
126  char id_string[8]; // "DFT_LE "
127  uint8_t version[4];
128  int32_t header_size;
129  int32_t data_start;
132  int32_t num_contours;
133  int64_t seedpoints;
134  char padding[24];
135 } DftHead;
136 
137 #endif //TRACKFILE_HEADERS_H
138 #define TRACKS_H
unsigned char swap_xy
int32_t data_start
int32_t header_size
unsigned char invert_x
unsigned char invert_y
int32_t num_contours
int32_t metadata_offset
short int n_scalars
short int n_properties
int32_t subject_data_offset
unsigned char invert_z
int64_t seedpoints
unsigned char swap_yz
unsigned char swap_zx