11 #ifndef __itkTrackvisHeader_h 12 #define __itkTrackvisHeader_h 31 char id_string[6]=
"TRACK";
35 short int n_scalars=0;
36 char scalar_name[10][20];
37 short int n_properties=0;
38 char property_name[10][20];
39 float vox_to_ras[4][4];
41 char voxel_order[4]=
"RAS";
43 float image_orientation_patient[6];
59 memcpy(&hTo, &hFrom, 1000);
66 for (
int i = 0; i < 3; ++i )
89 inline std::vector<std::string>
95 inline std::vector<std::string>
115 for (
int i = 0; i < header.
n_scalars; ++i )
128 for (
int i = 0; i < header.
n_scalars; ++i )
166 for (
int j = i; j+1 < header.
n_scalars; ++j )
198 file = fopen(filename.c_str(),
"rb");
203 fseek (file, 0, SEEK_SET);
204 int hsize = fread((
char*)(&header), 1, 1000, file);
209 fseek (file, 0, SEEK_END);
210 long fsize = ftell(file);
217 fseek (file, offset, SEEK_SET);
219 fread((
char*)&numPoints,
sizeof(
int), 1, file);
220 offset += 4+ numPoints*(3+dim_scalars)*4 + dim_properties*4;
228 msg(
"The number of tracts in the header does not match the actual number of tracts in the file. We set n_count as the actual number of tracts in the file");
238 fseek(file, 0, SEEK_SET);
239 int hsize = fwrite((
char*)&header, 1, 1000, file);
249 os <<
"id_string : " << header.
id_string << std::endl;
250 os <<
"version : " << header.
version << std::endl;
251 os <<
"dim : " << header.
dim[0] <<
", " << header.
dim[1] <<
", " << header.
dim[2] << std::endl;
253 os <<
"origin : " << header.
origin[0] <<
", " << header.
origin[1] <<
", " << header.
origin[2] << std::endl;
254 os <<
"number of tracks : " << header.
n_count << std::endl;
255 os <<
"number of scalars : " << header.
n_scalars << std::endl;
256 for (
int i = 0; i < header.
n_scalars; ++i )
258 os <<
"scalar_name[" << i <<
"] : " << std::string(header.
scalar_name[i]) << std::endl;
260 os <<
"number of properties : " << header.
n_properties << std::endl;
265 os <<
"property_name[" << i <<
"] : " << std::string(header.
property_name[i]) << std::endl;
274 os <<
"voxel_order : " << header.
voxel_order << std::endl;
277 os <<
"image_orientation : " << a[0]<<
","<<a[1]<<
","<<a[2]<<
","<<a[3]<<
","<<a[4]<<
","<<a[5]<< std::endl;
bool IsSameStructure(const TrackVisHeaderType &h1, const TrackVisHeaderType &h2)
void RemoveScalarName(TrackVisHeaderType &header, const std::string &name)
void RemovePropertyName(TrackVisHeaderType &header, const std::string &name)
bool HasPropertyName(const TrackVisHeaderType &header, const std::string &name)
void PrintTractVisHeader(const TrackVisHeaderType &header, std::ostream &os=std::cout)
void CopyTrackvisHeader(const TrackVisHeaderType &hFrom, TrackVisHeaderType &hTo)
#define utlSAGlobalWarning(expr)
std::vector< std::string > CovertChar2DArrayToStringArray(const char arr[][M], int N)
#define utlGlobalException(cond, expout)
int GetDimensionOfScalars(const TrackVisHeaderType &header)
std::vector< std::string > GetPropertyNames(const TrackVisHeaderType &header)
int GetScalarsDimentionByName(const std::string &name)
bool HasScalarName(const TrackVisHeaderType &header, const std::string &name)
void ReadTrackVisHeader(const std::string &filename, TrackVisHeaderType &header)
void WriteTrackVisHeader(const TrackVisHeaderType &header, FILE *file)
std::vector< std::string > GetScalarNames(const TrackVisHeaderType &header)
int GetDimensionOfProperties(const TrackVisHeaderType &header)