32 #include <boost/filesystem/path.hpp>
35 #pragma warning(disable: 4996)
40 #define HEADER_SIZE 19
73 fread(header,
sizeof(
int),
HEADER_SIZE, Ultrasonix_file);
74 if (ferror(Ultrasonix_file))
92 FILE *Ultrasonix_file=fopen(filename.c_str(),
"rb");
98 fclose(Ultrasonix_file);
99 std::cout <<
"cannot read Ultrasonix header for file [" << filename <<
"]" << std::endl;
103 fseek(Ultrasonix_file,0,SEEK_END);
105 size = (ftell(Ultrasonix_file) - (
HEADER_SIZE+h.
frame) *
sizeof(
int)) /
sizeof(
short);
106 else if (h.
type == 1)
107 size = (ftell(Ultrasonix_file) - (
HEADER_SIZE+h.
frame+4) *
sizeof(
int)) /
sizeof(
char);
109 size = (ftell(Ultrasonix_file) -
HEADER_SIZE *
sizeof(int)) /
sizeof(int);
115 fclose(Ultrasonix_file);
121 std::map <std::string , std::string> &infos, std::vector<std::string> i_attr)
129 FILE *Ultrasonix_file=fopen(filename.c_str(),
"rb");
130 if (!Ultrasonix_file)
132 std::cout <<
"cannot open file [" << filename <<
"]" << std::endl;
138 std::cout <<
"cannot read Ultrasonix header for file [" << filename <<
"]" << std::endl;
139 fclose(Ultrasonix_file);
144 long im_size = frame_size * h.
frame;
146 short *dataRF, *ptrRF;
147 char *dataB8, *ptrB8;
148 int *dataB32, *ptrB32;
155 dataRF = (
short*)malloc(
sizeof(
short)*im_size);
158 for (
int k=0; k<h.
frame; k++)
161 fread(&frame_number,
sizeof(
int), 1, Ultrasonix_file);
162 fread(ptrRF,
sizeof(
short), frame_size, Ultrasonix_file);
165 fclose(Ultrasonix_file);
171 dataB8 = (
char*)malloc(
sizeof(
char)*im_size);
173 for (
int k=0; k<h.
frame; k++)
175 fread(ptrB8,
sizeof(
char), frame_size, Ultrasonix_file);
183 fclose(Ultrasonix_file);
189 dataB32 = (
int*)malloc(
sizeof(
int)*im_size);
191 for (
int k=0; k<h.
frame; k++)
193 fread(ptrB32,
sizeof(
int), frame_size, Ultrasonix_file);
194 ptrB32 += frame_size;
201 fclose(Ultrasonix_file);
215 v.push_back(
"Ultrasonix");
223 std::map<std::string,std::string>& attr)
225 GimmickMessage(2,
"Reading attributes from '" << filename << std::endl);
227 FILE *Ultrasonix_file = fopen(filename.c_str(),
"rb");
228 if (!Ultrasonix_file)
230 std::cout <<
"cannot open RF file [" << filename <<
"]" << std::endl;
237 fclose(Ultrasonix_file);
238 std::cout <<
"cannot read Ultrasonix Attributes for RF file [" << filename <<
"]" << std::endl;
242 fclose(Ultrasonix_file);
246 sprintf(cols,
"%i", h.
width);
249 sprintf(rows,
"%i", h.
height);
252 sprintf(planes,
"%i", h.
frame);
254 char samplingFrequency[128];
257 char transducerFrequency[128];
258 sprintf(transducerFrequency,
"%i", h.
frequency);
261 std::map<std::string,std::string>::iterator i;
262 if ( (i = attr.find(
"FullFileName")) != attr.end())
264 i->second = filename;
266 if ( (i = attr.find(
"D0004_1500")) != attr.end())
268 boost::filesystem::path full_path(filename);
269 std::string f = full_path.leaf().string();
272 if ( (i = attr.find(
"D0028_0010")) != attr.end())
276 if ( (i = attr.find(
"D0028_0011")) != attr.end())
280 if ( (i = attr.find(
"D0028_0012")) != attr.end())
284 if ( (i = attr.find(
"D003a_001a")) != attr.end())
286 i->second = samplingFrequency;
288 if ( (i = attr.find(
"D0018_6030")) != attr.end())
290 i->second = transducerFrequency;