EMAN2
testutil.cpp
Go to the documentation of this file.
1/*
2 * Author: Liwei Peng, 12/16/2004 (sludtke@bcm.edu)
3 * Copyright (c) 2000-2006 Baylor College of Medicine
4 *
5 * This software is issued under a joint BSD/GNU license. You may use the
6 * source code in this file under either license. However, note that the
7 * complete EMAN2 and SPARX software packages have some GPL dependencies,
8 * so you are responsible for compliance with the licenses of these packages
9 * if you opt to use BSD licensing. The warranty disclaimer below holds
10 * in either instance.
11 *
12 * This complete copyright notice must be included in any revised version of the
13 * source code. Additional authorship citations may be added, but existing
14 * author citations must be preserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * */
31
32#ifdef _WIN32
33#include <windows.h>
34 #define MAXPATHLEN MAX_PATH
35#else
36#include <sys/param.h>
37#endif //_WIN32
38
39#include "testutil.h"
40#include "xydata.h"
41
42#include <algorithm>
43#include "emassert.h"
44//#include <stdlib.h>
45
46using std::vector;
47using std::string;
48using std::map;
49
50using namespace EMAN;
51
52int TestUtil::ti[] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
53float TestUtil::tf[] = {1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5};
54
55const char * TestUtil::EMDATA_HEADER_EXT = ".head";
56const char * TestUtil::EMDATA_DATA_EXT = ".data";
57
58string TestUtil::progname = "";
59
60int TestUtil::get_debug_int(int i)
61{
62 return ti[i];
63}
64
66{
67 return tf[i];
68}
69
71{
72 char a[32];
73 sprintf(a, "%d%d", i+1, i+1);
74 return string(a);
75}
76
78{
79 vector<Transform> v(3);
80 for (int j=0; j<3; j++) {
81 Transform t;
82 t.set_trans(j, j+1, j+2);
83 v[j] = t;
84 }
85 return v[i];
86}
87
88string TestUtil::get_debug_image(const string & imagename)
89{
90 char imgpath[MAXPATHLEN];
91 char * path_env = getenv("DEBUG_IMAGE_PATH");
92 if (path_env) {
93 sprintf(imgpath, "%s/%s", path_env, imagename.c_str());
94 }
95 else {
96 sprintf(imgpath, "%s/images/%s", getenv("HOME"), imagename.c_str());
97 }
98 return string(imgpath);
99}
100
101string TestUtil::get_golden_image(const string & imagename)
102{
103 char imgpath[MAXPATHLEN];
104 char * path_env = getenv("DEBUG_IMAGE_PATH");
105 if (path_env) {
106 sprintf(imgpath, "%s/testdata/%s", path_env, imagename.c_str());
107 }
108 else {
109 sprintf(imgpath, "%s/images/testdata/%s", getenv("HOME"), imagename.c_str());
110 }
111 return string(imgpath);
112}
113
115{
116 if (d.has_key("floatarray")) {
117 vector<float> array = d["floatarray"];
118 for (size_t i = 0; i < array.size(); i++) {
119 Assert(array[i] == tf[i]);
120 LOGDEBUG("floatarray[%d] = %f\n", i, array[i]);
121 }
122 }
123
124 if (d.has_key("emdata")) {
125 EMData * img = d["emdata"];
126 if (img) {
127 int nx = img->get_xsize();
128 int ny = img->get_ysize();
129 int nz = img->get_zsize();
130 Assert(nx == ti[0]);
131 Assert(ny == ti[1]);
132 Assert(nz == ti[2]);
133 LOGDEBUG("image size = (%d, %d, %d)\n", nx, ny, nz);
134 }
135 }
136
137 if (d.has_key("int")) {
138 int n = d["int"];
139 Assert(n == ti[0]);
140 LOGDEBUG("int n = %d\n", n);
141 }
142
143 if (d.has_key("float")) {
144 float f = d["float"];
145 Assert(f == tf[0]);
146 LOGDEBUG("float f = %f\n", f);
147 }
148
149 if (d.has_key("long")) {
150 int l = (int)d["long"];
151 Assert(l == ti[0]);
152 LOGDEBUG("long l = %d\n", l);
153 }
154
155 if (d.has_key("string")) {
156 string s = (const char*)d["string"];
157 string s2 = get_debug_string(0);
158 Assert(s == s2);
159 }
160
161
162 if (d.has_key("xydata")) {
163 XYData *xyd = d["xydata"];
164 size_t nitems = xyd->get_size();
165 for (size_t i = 0; i < nitems; i++) {
166 float xi = xyd->get_x(i);
167 float yi = xyd->get_y(i);
168 LOGDEBUG("xydata[%d] = (%f,%f)\n", i, xi, yi);
169 Assert(xi == tf[i]);
170 Assert(yi == tf[i]);
171 }
172 }
173
174 if (d.has_key("stringarray")) {
175 vector<string> array = d["stringarray"];
176 for (size_t i = 0; i < array.size(); i++) {
177 Assert(array[i] == get_debug_string(i));
178 LOGDEBUG("stringarray[%d] = %s\n", i, array[i].c_str());
179 }
180 }
181
182 if (d.has_key("transformarray")) {
183 vector<Transform> array = d["transformarray"];
184 for (size_t i = 0; i < array.size(); i++) {
185// array[i].printme();
186 Assert(array[i] == get_debug_transform(i));
187// LOGDEBUG("transformarray[%d] = %s\n", i, array[i].to_str());
188 }
189 }
190}
191
192
194{
195 Assert(p[0] == ti[0]);
196 Assert(p[1] == ti[1]);
197 Assert(p[2] == ti[2]);
198 LOGDEBUG("IntPoint p = (%d, %d, %d)\n", p[0], p[1], p[2]);
199 return IntPoint(ti[0], ti[1], ti[2]);
200}
201
203{
204 Assert(p[0] == tf[0]);
205 Assert(p[1] == tf[1]);
206 Assert(p[2] == tf[2]);
207 LOGDEBUG("FloatPoint p = (%f, %f, %f)\n", p[0], p[1], p[2]);
208 return FloatPoint(tf[0], tf[1], tf[2]);
209}
210
211
213{
214 Assert(p[0] == ti[0]);
215 Assert(p[1] == ti[1]);
216 Assert(p[2] == ti[2]);
217 LOGDEBUG("IntSize p = (%d, %d, %d)\n", p[0], p[1], p[2]);
218 return IntSize(ti[0], ti[1], ti[2]);
219}
220
221
223{
224 Assert(p[0] == tf[0]);
225 Assert(p[1] == tf[1]);
226 Assert(p[2] == tf[2]);
227 LOGDEBUG("FloatSize p = (%f, %f, %f)\n", p[0], p[1], p[2]);
228 return FloatSize(tf[0], tf[1], tf[2]);
229}
230
231
233{
234 Assert(p[0] == ti[0]);
235 Assert(p[1] == ti[1]);
236 Assert(p[2] == ti[2]);
237 LOGDEBUG("Vec3i p = (%d, %d, %d)\n", p[0], p[1], p[2]);
238 return Vec3i(ti[0], ti[1], ti[2]);
239}
240
242{
243 Assert(p[0] == tf[0]);
244 Assert(p[1] == tf[1]);
245 Assert(p[2] == tf[2]);
246 LOGDEBUG("Vec3f p = (%f, %f, %f)\n", p[0], p[1], p[2]);
247 return Vec3f(tf[0], tf[1], tf[2]);
248}
249
250
251map<string, int> TestUtil::test_map_int(const map<string, int>& d)
252{
253 map<string, int> r;
254 map<string, int>::const_iterator p;
255 for (p = d.begin(); p != d.end(); p++) {
256 LOGDEBUG("map[\"%s\"] = %d; ", p->first.c_str(), p->second);
257 r[p->first] = p->second;
258 }
259 LOGDEBUG("\n");
260 return r;
261}
262
263map<string, long> TestUtil::test_map_long(const map<string, long>& d)
264{
265 map<string, long> r;
266 map<string, long>::const_iterator p;
267 for (p = d.begin(); p != d.end(); p++) {
268 LOGDEBUG("map[\"%s\"] = %d; ", p->first.c_str(), p->second);
269 r[p->first] = p->second;
270 }
271 LOGDEBUG("\n");
272 return r;
273}
274
275map<string, float> TestUtil::test_map_float(const map<string, float>& d)
276{
277 map<string, float> r;
278 map<string, float>::const_iterator p;
279 for (p = d.begin(); p != d.end(); p++) {
280 LOGDEBUG("map[\"%s\"] = %f; ", p->first.c_str(), p->second);
281 r[p->first] = p->second;
282 }
283 LOGDEBUG("\n");
284 return r;
285}
286
287map<string, string> TestUtil::test_map_string(const map<string, string>& d)
288{
289 map<string, string> r;
290 map<string, string>::const_iterator p;
291 for (p = d.begin(); p != d.end(); p++) {
292 LOGDEBUG("map[\"%s\"] = %s; ", p->first.c_str(), p->second.c_str());
293 r[p->first] = p->second;
294 }
295 LOGDEBUG("\n");
296 return r;
297}
298
299map<string, EMObject> TestUtil::test_map_emobject(const map<string, EMObject>& d)
300{
301 map<string, EMObject> r;
302 map<string, EMObject>::const_iterator p;
303 for (p = d.begin(); p != d.end(); p++) {
304 LOGDEBUG("map[\"%s\"] = %f; ", p->first.c_str(), (float)(p->second));
305 r[p->first] = EMObject(p->second);
306 }
307 LOGDEBUG("\n");
308 return r;
309}
310
311map<string, vector<string> > TestUtil::test_map_vecstring(const map<string,
312 vector<string> >&)
313{
314 map<string, vector<string> > r;
315 return r;
316}
317
318
319vector<int> TestUtil::test_vector_int(const vector<int> & v)
320{
321 vector<int> r;
322 for (size_t i = 0; i < v.size(); i++) {
323 LOGDEBUG("v[%d]=%d; ", i, v[i]);
324 Assert(v[i] == ti[i]);
325 r.push_back(v[i]);
326 }
327 LOGDEBUG("\n");
328 return r;
329}
330
331vector<float> TestUtil::test_vector_float(const vector<float> & v)
332{
333 vector<float> r;
334 for (size_t i = 0; i < v.size(); i++) {
335 LOGDEBUG("v[%d]=%f; ", i, v[i]);
336 Assert(v[i] == tf[i]);
337 r.push_back(v[i]);
338 }
339 LOGDEBUG("\n");
340 return r;
341}
342
343vector<long> TestUtil::test_vector_long(const vector<long> & v)
344{
345 vector<long> r;
346 for (size_t i = 0; i < v.size(); i++) {
347 LOGDEBUG("v[%d]=%d; ", i, (int)v[i]);
348 Assert((int)v[i] == ti[i]);
349 r.push_back(v[i]);
350 }
351 LOGDEBUG("\n");
352 return r;
353}
354
355vector<string> TestUtil::test_vector_string(const vector<string> & v)
356{
357 vector<string> r;
358 for (size_t i = 0; i < v.size(); i++) {
359 LOGDEBUG("v[%d]=%s; ", i, v[i].c_str());
360 r.push_back(v[i]);
361 }
362 LOGDEBUG("\n");
363 return r;
364}
365
366vector<EMData*> TestUtil::test_vector_emdata(const vector<EMData*> & v)
367{
368 vector<EMData*> r;
369 for (size_t i = 0; i < v.size(); i++) {
370 EMData * e = v[i];
371 LOGDEBUG("Image(%d,%d,%d); ", e->get_xsize(), e->get_ysize(), e->get_zsize());
372 r.push_back(v[i]);
373 }
374 LOGDEBUG("\n");
375 return r;
376}
377
378vector<Pixel> TestUtil::test_vector_pixel(const vector<Pixel> & v)
379{
380 vector<Pixel> r;
381 for (size_t i = 0; i < v.size(); i++) {
382 Pixel p = v[i];
383 LOGDEBUG("Pixel(%d,%d,%d)=%4.2f; ", p.x, p.y, p.z, p.value);
384 Pixel p2(p.x, p.y, p.z, p.value);
385 r.push_back(p2);
386 }
387
388 return r;
389}
390
392{
393 Dict r;
394
395 vector<string> keys = d.keys();
396 sort(keys.begin(), keys.end());
397
398 for (size_t i = 0; i < keys.size(); i++) {
399 LOGDEBUG("keys[%s] = %f\n", keys[i].c_str(), (float)d[keys[i]]);
400 Assert(keys[i] == get_debug_string(i));
401 Assert(((float)d[keys[i]]) == tf[i]);
402 r[keys[i]] = d[keys[i]];
403 }
404
405 return r;
406}
407
408
409int TestUtil::check_image(const string& imagefile, EMData * image)
410{
411#if DEBUG
412 string headerfile1 = Util::sbasename(imagefile) + EMDATA_HEADER_EXT;
413 string datafile1 = Util::sbasename(imagefile) + EMDATA_DATA_EXT;
414
415 char imgpath[MAXPATHLEN];
416 char * path_env = getenv("DEBUG_IMAGE_PATH");
417 if (path_env) {
418 sprintf(imgpath, "%s/testdata/%s/", path_env, progname.c_str());
419 }
420 else {
421 sprintf(imgpath, "%s/images/testdata/%s/", getenv("HOME"), progname.c_str());
422 }
423
424 string headerfile2 = string(imgpath) + headerfile1;
425 string datafile2 = string(imgpath) + datafile1;
426
427
428 if (image) {
429 dump_emdata(image, imagefile);
430 }
431 else {
432 dump_image_from_file(imagefile);
433 }
434
435 if (!Util::is_file_exist(headerfile2) ||
436 !Util::is_file_exist(datafile2)) {
437 return 0;
438 }
439
440 string diffcmd1 = "diff " + headerfile1 + " " + headerfile2;
441
442 int err = system(diffcmd1.c_str());
443 if (!err) {
444 string diffcmd2 = "diff " + datafile1 + " " + datafile2;
445 err = system(diffcmd2.c_str());
446 }
447 if (err) {
448 LOGERR("check_image on %s FAILED\n", imagefile.c_str());
449 }
450
451 return err;
452#endif
453 return 0;
454}
455
456void TestUtil::dump_image_from_file(const string & filename)
457{
458 EMData * e = new EMData();
459 e->read_image(filename);
460 dump_emdata(e, filename);
461 if( e )
462 {
463 delete e;
464 e = 0;
465 }
466}
467
468void TestUtil::dump_emdata(EMData * image, const string & filename)
469{
470 string filebase = Util::sbasename(filename);
471 string headerfile = filebase + EMDATA_HEADER_EXT;
472 string datafile = filebase + EMDATA_DATA_EXT;
473
474 FILE *hfile = fopen(headerfile.c_str(), "wb");
475 if (!hfile) {
476 throw FileAccessException(headerfile);
477 }
478#if 0
479 vector<string> excl_keys;
480 excl_keys.push_back("MRC.label");
481 excl_keys.push_back("IMAGIC.minute");
482 excl_keys.push_back("IMAGIC.sec");
483
484 Dict attr_dict = image->get_attr_dict();
485 vector < string > keys = attr_dict.keys();
486
487
488
489 for (size_t i = 0; i < keys.size(); i++) {
490
491 bool is_exclude = false;
492 for (size_t j = 0; j < excl_keys.size(); j++) {
493 if (Util::sstrncmp(keys[i].c_str(), excl_keys[j].c_str())) {
494 is_exclude = true;
495 break;
496 }
497 }
498 if (!is_exclude) {
499 fprintf(hfile, "%s = %s\n", keys[i].c_str(),
500 attr_dict[keys[i]].to_str().c_str());
501 }
502 }
503#endif
504
505 fprintf(hfile, "nx = %d\n", image->get_xsize());
506 fprintf(hfile, "ny = %d\n", image->get_ysize());
507 fprintf(hfile, "nz = %d\n", image->get_zsize());
508
509 fclose(hfile);
510 hfile = 0;
511
512 FILE *dfile = fopen(datafile.c_str(), "wb");
513 if (!dfile) {
514 throw FileAccessException(datafile);
515 }
516
517 int nx = image->get_xsize();
518 int ny = image->get_ysize();
519 int nz = image->get_zsize();
520
521 size_t row_size = nx * sizeof(float);
522 size_t nxy = nx * ny;
523 float * rdata = image->get_data();
524
525 for (int i = 0; i < nz; i++) {
526 for (int j = 0; j < ny; j++) {
527 fwrite(&rdata[i * nxy + j * nx], row_size, 1, dfile);
528 }
529 }
530 fclose(dfile);
531 dfile = 0;
532}
533
534void TestUtil::set_progname(const string & cur_progname)
535{
536 progname = Util::sbasename(cur_progname);
537}
538
539
540void TestUtil::make_image_file_by_mode(const string & filename,
541 EMUtil::ImageType image_type, int mode,
542 EMUtil::EMDataType datatype,
543 int nx, int ny, int nz)
544{
545 EMData * e = new EMData();
546 e->set_size(nx, ny, nz);
547 bool is_complex = EMUtil::is_complex_type(datatype);
548
549 e->set_attr("is_complex", (int)is_complex);
550 e->set_attr("datatype", (int)datatype);
551 float * data = e->get_data();
552
553 size_t l = 0;
554 for (int i = 0; i < nz; i++) {
555 for (int j = 0; j < ny; j++) {
556 for (int k = 0; k < nx; k++) {
557 if (mode == 1) {
558 data[l] = get_pixel_value_by_dist1(nx, ny, nz, k, j, i);
559 }
560 else if (mode == 2) {
561 data[l] = get_pixel_value_by_dist2(nx, ny, nz, k, j, i);
562 }
563 l++;
564 }
565 }
566 }
567
568 if (!is_complex) {
569 e->write_image(filename, 0, image_type, false, 0, datatype, true);
570 }
571 else {
572 e->update();
573 e->set_attr("is_complex", false);
574 EMData * fft = e->do_fft();
575 fft->write_image(filename, 0, image_type, false, 0, datatype, true);
576 if( fft )
577 {
578 delete fft;
579 fft = 0;
580 }
581 }
582
583 if( e )
584 {
585 delete e;
586 e = 0;
587 }
588}
589
590int TestUtil::verify_image_file_by_mode(const string & filename,
591 EMUtil::ImageType, int mode,
592 EMUtil::EMDataType datatype,
593 int nx, int ny, int nz)
594{
595 int err = 0;
596
597 EMData * e = new EMData();
598 e->read_image(filename);
599
600 Dict attr_dict = e->get_attr_dict();
601 bool is_complex = EMUtil::is_complex_type(datatype);
602
603 if (is_complex) {
604 nx = (nx+2);
605 }
606
607 if (nx != (int) attr_dict["nx"]) {
608 LOGERR("nx: %d != %d\n", nx, (int) attr_dict["nx"]);
609 return 1;
610 }
611
612 if (ny != (int) attr_dict["ny"]) {
613 LOGERR("ny: %d != %d\n", ny, (int) attr_dict["ny"]);
614 return 1;
615 }
616
617 if (nz != (int) attr_dict["nz"]) {
618 LOGERR("nz: %d != %d\n", nz, (int) attr_dict["nz"]);
619 return 1;
620 }
621
622 if (datatype != (int) attr_dict["datatype"]) {
623 LOGERR("datatype: %d != %d\n", datatype, (int) attr_dict["datatype"]);
624 return 1;
625 }
626
627
628 if ((int)is_complex != (int) attr_dict["is_complex"]) {
629 LOGERR("is_complex: %d != %d\n", is_complex, (int) attr_dict["is_complex"]);
630 return 1;
631 }
632
633
634 if (!is_complex) {
635 float * data = e->get_data();
636 size_t l = 0;
637 for (int i = 0; i < nz; i++) {
638 for (int j = 0; j < ny; j++) {
639 for (int k = 0; k < nx; k++) {
640
641 int d2 = 0;
642 if (mode == 1) {
643 d2 = (int)get_pixel_value_by_dist1(nx,ny,nz,k,j,i);
644 }
645 else if (mode == 2) {
646 d2 = (int)get_pixel_value_by_dist2(nx,ny,nz,k,j,i);
647 }
648
649 if ((int)data[l] != d2) {
650 LOGERR("(%d,%d,%d): %d != %d\n", i,j,k,(int)data[l], d2);
651 break;
652 err = 1;
653 }
654 l++;
655 }
656 }
657 }
658 }
659
660 return err;
661}
662
664{
665 return EMObject(b);
666}
667
669{
670 return EMObject(un);
671}
672
674{
675 return EMObject(n);
676}
677
679{
680 return EMObject(f);
681}
682
684{
685 return EMObject(f);
686}
687
689{
690 return EMObject(str);
691}
692
693
695{
696 return EMObject(emdata);
697}
698
699
701{
702 return EMObject(xydata);
703}
704
705
707{
708 vector<float> v(3);
709 for (int i = 0; i < 3; i++) {
710 v[i] = tf[i];
711 }
712 return EMObject(v);
713}
714
715
717{
718 vector<string> v(3);
719 for (int i = 0; i < 3; i++) {
720 v[i] = get_debug_string(i);
721 }
722 return EMObject(v);
723}
724
726{
727 vector<Transform> v(3);
728 for (int i=0; i<3; i++) {
729 Transform t;
730 t.set_trans(i, i+1, i+2);
731 v[i] = t;
732 }
733 return EMObject(v);
734}
735
737{
738 return EMObject(t);
739}
740
742{
743 return EMObject(ctf_);
744}
745
746
747
748
#define rdata(i)
Definition: analyzer.cpp:592
Ctf is the base class for all CTF model.
Definition: ctf.h:60
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
Definition: emobject.h:511
vector< string > keys() const
Get a vector containing all of the (string) keys in this dictionary.
Definition: emobject.h:475
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType.
Definition: emobject.h:123
EMDataType
Image pixel data type used in EMAN.
Definition: emutil.h:92
static bool is_complex_type(EMDataType datatype)
Definition: emutil.cpp:1231
ImageType
Image format types.
Definition: emutil.h:112
FloatPoint defines a float-coordinate point in a 1D/2D/3D space.
Definition: geometry.h:278
FloatSize is used to describe a 1D, 2D or 3D rectangular size in floating numbers.
Definition: geometry.h:105
IntPoint defines an integer-coordinate point in a 1D/2D/3D space.
Definition: geometry.h:192
IntSize is used to describe a 1D, 2D or 3D rectangular size in integers.
Definition: geometry.h:49
Pixel describes a 3D pixel's coordinates and its intensity value.
Definition: geometry.h:452
float value
Definition: geometry.h:483
static map< string, string > test_map_string(const map< string, string > &d)
Definition: testutil.cpp:287
static string get_golden_image(const string &imagename)
Definition: testutil.cpp:101
static vector< int > test_vector_int(const vector< int > &v)
Definition: testutil.cpp:319
static string get_debug_image(const string &imagename)
Definition: testutil.cpp:88
static const char * EMDATA_HEADER_EXT
Definition: testutil.h:51
static vector< long > test_vector_long(const vector< long > &v)
Definition: testutil.cpp:343
static void set_progname(const string &cur_progname)
Definition: testutil.cpp:534
static string get_debug_string(int i)
Definition: testutil.cpp:70
static float get_pixel_value_by_dist2(int nx, int ny, int nz, int x, int y, int z)
Definition: testutil.h:187
static vector< EMData * > test_vector_emdata(const vector< EMData * > &v)
Definition: testutil.cpp:366
static int ti[10]
Definition: testutil.h:145
static float get_pixel_value_by_dist1(int nx, int ny, int nz, int x, int y, int z)
Definition: testutil.h:159
static int verify_image_file_by_mode(const string &filename, EMUtil::ImageType image_type, int mode, EMUtil::EMDataType datatype=EMUtil::EM_FLOAT, int nx=16, int ny=16, int nz=1)
Definition: testutil.cpp:590
static EMObject emobject_transformarray_to_py()
Definition: testutil.cpp:725
static int check_image(const string &imagefile, EMData *image=0)
Definition: testutil.cpp:409
static EMObject emobject_farray_to_py()
Definition: testutil.cpp:706
static float get_debug_float(int i)
Definition: testutil.cpp:65
static map< string, long > test_map_long(const map< string, long > &d)
Definition: testutil.cpp:263
static IntSize test_IntSize(const IntSize &p)
Definition: testutil.cpp:212
static void dump_image_from_file(const string &filename)
Definition: testutil.cpp:456
static Dict test_dict(const Dict &d)
Definition: testutil.cpp:391
static Vec3i test_Vec3i(const Vec3i &p)
Definition: testutil.cpp:232
static const char * EMDATA_DATA_EXT
Definition: testutil.h:52
static map< string, vector< string > > test_map_vecstring(const map< string, vector< string > > &d)
Definition: testutil.cpp:311
static vector< Pixel > test_vector_pixel(const vector< Pixel > &v)
Definition: testutil.cpp:378
static void make_image_file_by_mode(const string &filename, EMUtil::ImageType image_type, int mode, EMUtil::EMDataType datatype=EMUtil::EM_FLOAT, int nx=16, int ny=16, int nz=1)
Definition: testutil.cpp:540
static void to_emobject(const Dict &d)
Definition: testutil.cpp:114
static FloatSize test_FloatSize(const FloatSize &p)
Definition: testutil.cpp:222
static EMObject emobject_strarray_to_py()
Definition: testutil.cpp:716
static IntPoint test_IntPoint(const IntPoint &p)
Definition: testutil.cpp:193
static Transform get_debug_transform(int i)
Definition: testutil.cpp:77
static map< string, int > test_map_int(const map< string, int > &d)
Definition: testutil.cpp:251
static EMObject emobject_to_py(bool b)
Definition: testutil.cpp:663
static FloatPoint test_FloatPoint(const FloatPoint &p)
Definition: testutil.cpp:202
static vector< string > test_vector_string(const vector< string > &v)
Definition: testutil.cpp:355
static Vec3f test_Vec3f(const Vec3f &p)
Definition: testutil.cpp:241
static map< string, EMObject > test_map_emobject(const map< string, EMObject > &d)
Definition: testutil.cpp:299
static vector< float > test_vector_float(const vector< float > &v)
Definition: testutil.cpp:331
static void dump_emdata(EMData *image, const string &filename)
Definition: testutil.cpp:468
static string progname
Definition: testutil.h:146
static map< string, float > test_map_float(const map< string, float > &d)
Definition: testutil.cpp:275
static float tf[10]
Definition: testutil.h:144
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
void set_trans(const float &x, const float &y, const float &z=0)
Set the post translation component.
Definition: transform.cpp:1036
static bool sstrncmp(const char *s1, const char *s2)
Safe string compare.
Definition: util.cpp:306
static bool is_file_exist(const string &filename)
check whether a file exists or not
Definition: util.cpp:253
static string sbasename(const string &filename)
Get a filename's basename.
Definition: util.cpp:505
XYData defines a 1D (x,y) data set.
Definition: xydata.h:47
size_t get_size() const
Definition: xydata.h:127
float get_y(size_t i) const
Definition: xydata.h:95
float get_x(size_t i) const
Definition: xydata.h:84
#define Assert(s)
Define Assert() function that is effective only when -DDEBUG is used.
Definition: emassert.h:42
bool is_complex() const
Is this a complex image?
#define FileAccessException(filename)
Definition: exception.h:187
#define LOGDEBUG
Definition: log.h:55
#define LOGERR
Definition: log.h:51
const char * to_str(Gatan::TagData::Type type)
Definition: dm3io.cpp:925
E2Exception class.
Definition: aligner.h:40
Vec3< float > Vec3f
Definition: vec3.h:693
Vec3< int > Vec3i
Definition: vec3.h:694