Bsoft  2.1.0
Bernard's software package
rwmgEMX.cpp
Go to the documentation of this file.
1 
9 #ifdef HAVE_XML
10 #include "rwxml.h"
11 #endif
12 
13 #include "mg_processing.h"
14 #include "mg_img_proc.h"
15 #include "mg_tomography.h"
16 #include "rwmg.h"
17 #include "file_util.h"
18 #include "linked_list.h"
19 #include "utilities.h"
20 
21 #define CONV_SWITCH 0 // Bad convention if 1
22 
23 // Declaration of global variables
24 extern int verbose; // Level of output to the screen
25 
26 // Internal function prototypes
27 #ifdef HAVE_XML
28 int emx_to_project(xmlDocPtr doc, Bproject* project, Bstring& filename);
29 int project_to_emx(Bproject* project, xmlDocPtr doc, int mg_select, int rec_select);
30 
31 Vector3<int> emx_get_integer_vector2(xmlNodePtr parent, const char* tag)
32 {
33  Vector3<int> vec;
34 
35  xmlNodePtr node = xml_find_node(parent, tag);
36 
37  if ( !node ) return vec;
38 
39  vec[0] = xml_get_integer(node, "X");
40  vec[1] = xml_get_integer(node, "Y");
41 
42  return vec;
43 }
44 
45 Vector3<double> emx_get_real_vector2(xmlNodePtr parent, const char* tag)
46 {
47  Vector3<double> vec;
48 
49  xmlNodePtr node = xml_find_node(parent, tag);
50 
51  if ( !node ) return vec;
52 
53  vec[0] = xml_get_real(node, "X");
54  vec[1] = xml_get_real(node, "Y");
55 
56  return vec;
57 }
58 
59 int emx_get_transformation(xmlNodePtr parent, Matrix3& mat, Vector3<double>& origin)
60 {
61  xmlNodePtr node = xml_find_node(parent, "transformationMatrix");
62 
63  if ( !node ) return -1;
64 
65  mat[0][0] = xml_get_real(node, "t11");
66  mat[0][1] = xml_get_real(node, "t12");
67  mat[0][2] = xml_get_real(node, "t13");
68  mat[1][0] = xml_get_real(node, "t21");
69  mat[1][1] = xml_get_real(node, "t22");
70  mat[1][2] = xml_get_real(node, "t23");
71  mat[2][0] = xml_get_real(node, "t31");
72  mat[2][1] = xml_get_real(node, "t32");
73  mat[2][2] = xml_get_real(node, "t33");
74 
75  origin[0] = xml_get_real(node, "t14");
76  origin[1] = xml_get_real(node, "t24");
77  origin[2] = xml_get_real(node, "t34");
78 
79  Matrix3 mattr = mat.transpose();
80 
81 #if CONV_SWITCH
82 // 20150218 - convention T
83  origin = mattr * origin;
84  origin = -origin;
85 #else
86 // 20150323 - convention T-1
87  mat = mattr;
88 #endif
89 
90  return 0;
91 }
92 
93 xmlNodePtr emx_set_real_vector2(xmlNodePtr parent, const char* tag, double v1, double v2, const char* unit)
94 {
95  xmlNodePtr node = xmlNewChild(parent, NULL, BAD_CAST tag, NULL);
96  xmlNodePtr node2 = xml_set_real(node, "X", v1, "%g");
97  xmlNewProp(node2, BAD_CAST "unit", BAD_CAST unit);
98  node2 = xml_set_real(node, "Y", v2, "%g");
99  xmlNewProp(node2, BAD_CAST "unit", BAD_CAST unit);
100 
101  return node;
102 }
103 
104 xmlNodePtr emx_set_real_unit(xmlNodePtr parent, const char* tag, double v, const char* unit)
105 {
106  xmlNodePtr node = xml_set_real(parent, tag, v, "%g");
107 
108  if ( unit ) xmlNewProp(node, BAD_CAST "unit", BAD_CAST unit);
109 
110  return node;
111 }
112 
113 xmlNodePtr emx_set_transformation(xmlNodePtr parent, Matrix3 mat, Vector3<double> origin)
114 {
115 #if CONV_SWITCH
116 // 20150218 - convention T
117  origin = mat * origin;
118  origin = -origin;
119 #else
120 // 20150323 - convention T-1
121  mat = mat.transpose();
122 #endif
123 
124  xmlNodePtr node = xmlNewChild(parent, NULL, BAD_CAST "transformationMatrix", NULL);
125 
126  xml_set_real(node, "t11", mat[0][0], "%g");
127  xml_set_real(node, "t12", mat[0][1], "%g");
128  xml_set_real(node, "t13", mat[0][2], "%g");
129  xml_set_real(node, "t21", mat[1][0], "%g");
130  xml_set_real(node, "t22", mat[1][1], "%g");
131  xml_set_real(node, "t23", mat[1][2], "%g");
132  xml_set_real(node, "t31", mat[2][0], "%g");
133  xml_set_real(node, "t32", mat[2][1], "%g");
134  xml_set_real(node, "t33", mat[2][2], "%g");
135 
136  emx_set_real_unit(node, "t14", origin[0], "px");
137  emx_set_real_unit(node, "t24", origin[1], "px");
138  emx_set_real_unit(node, "t34", origin[2], "px");
139 
140  return node;
141 }
142 
143 xmlNodePtr emx_set_transformation(xmlNodePtr parent, View& view, Vector3<double> origin)
144 {
145  Matrix3 mat = view.matrix();
146 
147  return emx_set_transformation(parent, mat, origin);
148 }
149 
150 #endif
151 
159 #if defined(HAVE_XML)
160 int read_project_emx(Bstring& filename, Bproject* project, Bstring& xsdfile)
161 {
162  if ( filename.length() < 1 ) {
163  error_show("No file names found!", __FILE__, __LINE__);
164  return -1;
165  }
166 
167  int err(0);
168  xmlDocPtr doc;
169  xmlNodePtr emx_node;
170 
172 
173  doc = xmlParseFile(filename.c_str());
174  if (doc == NULL) return -1;
175 
176  if ( verbose & VERB_PROCESS )
177  cout << "# Reading EMX file: " << filename << endl;
178 
179  if ( xsdfile.length() ) xml_validate(doc, xsdfile);
180 
181  emx_node = xmlDocGetRootElement(doc);
182  if ( !emx_node ) {
183  error_show(filename.c_str(), __FILE__, __LINE__);
184  xmlFreeDoc(doc);
185  return -1;
186  }
187 
188  if ( xmlStrcmp(emx_node->name, (const xmlChar *) "EMX") ) {
189  cerr << "Error: The document " << filename << " is not an EMX file!" << endl;
190  xmlFreeDoc(doc);
191  return -1;
192  }
193 
194  xmlChar* content = xmlGetProp(emx_node, BAD_CAST "version");
195  if ( verbose ) {
196  if ( content ) cout << "EMX version " << content << endl;
197  else cout << "EMX version ?" << endl;
198  }
199 
200 // xmlDocDump(stderr, doc);
201 // xmlElemDump(stderr, doc, node);
202 
203  err = emx_to_project(doc, project, filename);
204 
205  xmlFreeDoc(doc);
206 
207  xmlCleanupParser();
208 
210 
211  return err;
212 }
213 
214 int read_project_emx(Bstring* file_list, Bproject* project, Bstring& xsdfile)
215 {
216  if ( !file_list ) {
217  error_show("No file names found!", __FILE__, __LINE__);
218  return -1;
219  }
220 
221  // Get the list of filenames
222  int err(0);
223  Bstring* thisfile = NULL;
224 
225  if ( verbose & VERB_DEBUG_STAR ) {
226  cout << "DEBUG read_project_emx: EMX filenames:" << endl;
227  for ( thisfile = file_list; thisfile; thisfile = thisfile->next )
228  cout << " " << *thisfile;
229  cout << endl;
230  }
231 
232  for ( thisfile = file_list; thisfile; thisfile = thisfile->next ) {
233  err = read_project_emx(*thisfile, project, xsdfile);
234  }
235 
237 
238  return err;
239 }
240 #else
241 int read_project_emx(Bstring& filename, Bproject* project, Bstring& xsdfile)
242 {
243  cerr << "Error: EMX files are not supported!" << endl << endl;
244 
245  return -1;
246 }
247 #endif
248 
257 #if defined(HAVE_XML)
258 int write_project_emx(Bstring& filename, Bproject* project, int mg_select, int rec_select)
259 {
260  int i, err(0);
261  Bstring name;
262 
263  xmlDocPtr doc;
264 
265  Bfield* field;
266  Bmicrograph* mg;
267 // Breconstruction* rec;
268  char format[32];
269 
270  snprintf(format, 32, "_%%0%dd.", project->split);
271 
272  if ( project->split ) {
273  for ( i=0, field = project->field; field; field=field->next ) {
274  for ( mg=field->mg; mg; mg=mg->next, i++ ) {
275  if ( project->split == 9 && mg->id.length() > 0 ) {
276  name = mg->id + ".xml";
277  name = name.replace(' ', '_');
278  } else {
279  name = filename.pre_rev('.') + Bstring(i, format) + filename.post_rev('.');
280  }
281  if ( verbose & VERB_PROCESS )
282  cout << "# Writing file: " << name << endl;
283  doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
284  if ( doc == NULL ) {
285  cerr << "Error: The XML document tree was not created!" << endl;
286  return -1;
287  }
288  err = project_to_emx(project, doc, i, 0);
289  if ( err == 0 ) {
290  if ( verbose & VERB_PROCESS )
291  cout << "# Writing EMX file: " << filename << endl;
292  err = xmlSaveFormatFile(name.c_str(), doc, 1);
293  }
294  xmlFreeDoc(doc);
295  }
296  }
297  } else {
298  if ( verbose & VERB_PROCESS )
299  cout << "# Writing file: " << filename << endl;
300  doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
301  if ( !doc ) {
302  cerr << "Error: The XML document tree was not created!" << endl;
303  return -1;
304  }
305  err = project_to_emx(project, doc, 0, 0);
306  if ( err == 0 ) {
307  if ( verbose & VERB_PROCESS )
308  cout << "# Writing EMX file: " << filename << endl;
309  err = xmlSaveFormatFile(filename.c_str(), doc, 1);
310  }
311  xmlFreeDoc(doc);
312  }
313 
314  return err;
315 }
316 #else
317 int write_project_emx(Bstring& filename, Bproject* project, int mg_select, int rec_select)
318 {
319  cerr << "Error: EMX files are not supported!" << endl << endl;
320 
321  return -1;
322 }
323 #endif
324 
325 #ifdef HAVE_XML
326 
327 
328 /*
329 @brief Converts micrograph data from an EMX document to a project structure.
330 @param xmlDocPtr doc XML document pointer.
331 @param *project project structure.
332 @param &filename file name to resolve paths.
333 @return int error code (<0 means failure).
334 
335  The function sets up the project hierarchy from a XML file.
336  All angles given in the document are assumed to be in degrees,
337  and are converted here only to radians.
338 
339 **/
340 int emx_to_project(xmlDocPtr doc, Bproject* project, Bstring& filename)
341 {
342  int err(0);
343 
344  xmlNodePtr emx_node = xmlDocGetRootElement(doc);
345  xmlNodePtr mg_node = NULL;
346  xmlNodePtr part_node = NULL;
347  xmlNodePtr part_mg_node = NULL;
348  xmlNodePtr node = NULL;
349 
350  Bfield* field = project->field;
351  Bmicrograph* mg = NULL;
352 // Breconstruction* rec = NULL;
353  Bparticle* part = NULL;
354 
355  Bstring id, mg_file, part_file, prev_mg_file;
356  long i, pid, img_num;
357  double defU, defV;
358  Vector3<double> origin, center;
359  Matrix3 mat;
360 
361  for ( i=0, node = emx_node->xmlChildrenNode; node; node = node->next ) {
362  mg_file = 0;
363  part_file = 0;
364  if ( !xmlStrcmp(node->name, BAD_CAST "micrograph") ) {
365  mg_node = node;
366  mg_file = (char *) xmlGetProp(mg_node, BAD_CAST "fileName");
367  if ( verbose & VERB_DEBUG )
368  cout << "DEBUG emx_to_project: mg=" << mg_file << endl;
369  id = Bstring(++i, "%d");
370  if ( mg_file.length() ) id = mg_file.pre_rev('.');
371  if ( id.length() < 1 ) id = Bstring(i, "%d");;
372 // if ( !field ) field = field_add(&project->field, id);
373  if ( prev_mg_file != mg_file ) field = field_add(&project->field, id);
374  if ( verbose & VERB_DEBUG )
375  cout << "DEBUG emx_to_project: id=" << id << endl;
376  mg = micrograph_add(&field->mg, id);
377  mg->block = i;
378  mg->fmg = mg_file;
379  mg->img_num = xml_get_integer_attribute(mg_node, "index") - 1;
380  if ( mg->img_num < 0 ) {
381  if ( verbose & VERB_FULL )
382  cerr << "Warning: " << mg->id << " index number is less than 1" << endl;
383  mg->img_num = 0;
384  }
385  if ( verbose & VERB_DEBUG )
386  cout << "DEBUG emx_to_project: mg: mg=" << mg_file << " img_num=" << mg->img_num << endl;
387 
388  center = micrograph_get_nominal_origin(mg);
389 
390  emx_get_transformation(mg_node, mg->matrix, origin);
391  mg->origin = center + origin;
392 
393  mg->select = xml_get_integer(mg_node, "activeFlag");
394  mg->fom = xml_get_real(mg_node, "fom");
395 
396  if ( xml_find_node(mg_node, "pixelSpacing") )
397  mg->pixel_size = emx_get_real_vector2(mg_node, "pixelSpacing");
398 
399  if ( xml_check_for_node(mg_node, "defocusU") || xml_check_for_node(mg_node, "acceleratingVoltage") ) {
400  mg->ctf = new CTFparam;
401  mg->ctf->volt(1e3 * xml_get_real(mg_node, "acceleratingVoltage"));
402  mg->ctf->amp_shift(asin(xml_get_real(mg_node, "amplitudeContrast")));
403  mg->ctf->Cs(1e7 * xml_get_real(mg_node, "cs"));
404  defU = 10*xml_get_real(mg_node, "defocusU");
405  defV = 10*xml_get_real(mg_node, "defocusV");
406  if ( defU < 100 ) defU *= 1e3;
407  if ( defV < 100 ) defV *= 1e3;
408  mg->ctf->defocus_average((defU + defV)/2);
409  mg->ctf->defocus_deviation(fabs(defU - defV)/2);
410  mg->ctf->astigmatism_angle(xml_get_real(node, "defocusUAngle") * M_PI/180.0);
411  }
412  prev_mg_file = mg_file;
413  } else if ( !xmlStrcmp(node->name, BAD_CAST "particle") ) {
414  part_node = node;
415  part_file = (char *) xmlGetProp(part_node, BAD_CAST "fileName");
416  pid = xml_get_integer_attribute(part_node, "index");
417  if ( verbose & VERB_DEBUG )
418  cout << "DEBUG emx_to_project: part=" << part_file << " pid=" << pid << endl;
419 
420  part_mg_node = xml_find_node(part_node, "micrograph");
421  if ( part_mg_node) {
422  mg = NULL;
423  mg_file = (char *) xmlGetProp(part_mg_node, BAD_CAST "fileName");
424 // cout << "***" << mg_file << "***" << endl;
425  if ( mg_file.length() ) {
426  img_num = xml_get_integer_attribute(part_mg_node, "index") - 1;
427  if ( img_num < 0 ) img_num = 0;
428 // cout << "***" << mg_file << "***" << img_num << "***" << endl;
429 // cout << "***" << field->mg->fmg << "***" << field->mg->img_num << "***" << endl;
430  for ( field = project->field; field; field = field->next ) {
431  for ( mg = field->mg; mg; mg = mg->next ) {
432  if ( mg->fmg == mg_file && mg->img_num == img_num ) break;
433  }
434  if ( mg ) break;
435  }
436  if ( verbose & VERB_DEBUG )
437  cout << "DEBUG emx_to_project: part: mg=" << mg->fmg << " img_num=" << mg->img_num << endl;
438  } else {
439  cerr << "Warning: No micrograph file name specified!" << endl;
440  }
441  }
442 
443  if ( !mg ) {
444  if ( verbose & VERB_FULL )
445  cerr << "Warning: No micrograph for particle " << pid << " found!" << endl;
446  id = Bstring(++i, "%d");
447  if ( !field ) {
448  if ( verbose )
449  cout << "Generating a new field-of-view record with id: " << id << endl;
450  field = field_add(&project->field, id);
451  }
452  if ( verbose )
453  cout << "Generating a new micrograph record with id: " << id << endl;
454  mg = micrograph_add(&field->mg, id);
455  }
456 
457 // mg->fpart = (char *) xmlGetProp(part_node, BAD_CAST "fileName");
458 
459  if ( xml_find_node(part_node, "boxSize") )
460  mg->box_size = emx_get_integer_vector2(part_node, "boxSize");
461 
462  if ( verbose & VERB_DEBUG )
463  cout << "Particle " << pid << endl;
464  part = particle_add(&mg->part, pid);
465 
466  part->fpart = part_file;
467 
468  if ( mg->box_size.volume() < 1 )
469  mg->box_size = particle_get_box_size(part);
470 
471  if ( xml_find_node(part_node, "pixelSpacing") )
472  part->pixel_size = emx_get_real_vector2(part_node, "pixelSpacing");
473 
474  if ( part->pixel_size[0] <= 0 )
475  part->pixel_size = Vector3<double>(1,1,1);
476 
477  part->loc = emx_get_real_vector2(part_node, "centerCoord");
478 
479  emx_get_transformation(part_node, mat, origin);
480  part->ori = origin + mg->box_size/2;
481  part->view = View(mat);
482 
483  defU = 10*xml_get_real(part_node, "defocusU");
484  defV = 10*xml_get_real(part_node, "defocusV");
485  if ( defU < 100 ) defU *= 1e3;
486  if ( defV < 100 ) defV *= 1e3;
487  part->def = (defU + defV)/2;
488  part->dev = fabs(defU - defV)/2;
489  part->ast = xml_get_real(part_node, "defocusUAngle") * M_PI/180.0;
490 
491  part->sel = xml_get_integer(part_node, "activeFlag");
492  part->fom[0] = xml_get_real(part_node, "fom");
493  }
494  }
495 
496  return err;
497 }
498 
499 
500 /*
501 @brief Converts micrograph data from an project structure to a XML document.
502 @param Bproject* project parameter structure.
503 @param xmlDocPtr doc XML document.
504 @param mg_select flag to only write selected micrographs.
505 @param rec_select flag to only convert selected reconstructions.
506 @return int error code (<0 means failure).
507 
508  The function packes new micrograph data back into an existing XML
509  document from which the old project parameters were obtained.
510  All angles used internally are in radians, and are converted here
511  to degrees for output. The angles within the micrograph structure
512  are left in radians.
513  The stylesheet written into the document is "Bsoft_micrograph.xsl".
514 **/
515 int project_to_emx(Bproject* project, xmlDocPtr doc, int mg_select, int rec_select)
516 {
517  int err(0);
518 
519  Bfield* field = NULL;
520  Bmicrograph* mg = NULL;
521  Bparticle* part = NULL;
522 
523  xmlNodePtr root_node = xmlNewDocPI(doc, BAD_CAST "xml-stylesheet",
524  BAD_CAST "href=\"emx.xsl\" type=\"text/xsl\"");
525  xmlDocSetRootElement(doc, root_node);
526 
527  xmlNodePtr emx_node = xmlNewNode(NULL, BAD_CAST "EMX");
528 
529  xmlAddSibling(root_node, emx_node);
530 
531  xmlNewProp(emx_node, BAD_CAST "version", BAD_CAST "1.0");
532 
533  Bstring cmnt(" Written by Bsoft ");
534  cmnt += BVERSION;
535  xmlNodePtr cmnt_node = xmlNewComment(BAD_CAST cmnt.c_str());
536  xmlAddChild(emx_node, cmnt_node);
537 
538  xmlNodePtr mg_node = NULL;
539  xmlNodePtr part_node = NULL;
540  xmlNodePtr node = NULL;
541 
542  double angle;
543  Vector3<double> center;
544  Bstring filename;
545 
546  for ( field=project->field; field; field=field->next ) {
547  for ( mg=field->mg; mg; mg=mg->next ) {
548  if ( mg->fmg.length() ) filename = mg->fmg;
549  else filename = "dummy.mrc";
550  mg_node = xmlNewChild(emx_node, NULL, BAD_CAST "micrograph", NULL);
551  xmlNewProp(mg_node, BAD_CAST "fileName", BAD_CAST filename.c_str());
552  xml_set_integer_attribute(mg_node, "index", mg->img_num+1, "%d");
553 
554  center = micrograph_get_nominal_origin(mg);
555 
556  emx_set_real_vector2(mg_node, "pixelSpacing", mg->pixel_size[0], mg->pixel_size[1], "A/px");
557 
558  emx_set_transformation(mg_node, mg->matrix, mg->origin - center);
559 
560  if ( mg->ctf ) {
561  emx_set_real_unit(mg_node, "acceleratingVoltage", mg->ctf->volt()/1e3, "kV");
562  emx_set_real_unit(mg_node, "amplitudeContrast", sin(mg->ctf->amp_shift()), NULL);
563  emx_set_real_unit(mg_node, "cs", mg->ctf->Cs()/1e7, "mm");
564  emx_set_real_unit(mg_node, "defocusU", (mg->ctf->defocus_average() + mg->ctf->defocus_deviation())/10, "nm");
565  emx_set_real_unit(mg_node, "defocusV", (mg->ctf->defocus_average() - mg->ctf->defocus_deviation())/10, "nm");
566  angle = mg->ctf->astigmatism_angle()*180.0/M_PI;
567  if ( angle < 0 ) angle += 180;
568  emx_set_real_unit(mg_node, "defocusUAngle", angle, "deg");
569  }
570 
571  xml_set_integer(mg_node, "activeFlag", mg->select, "%d");
572  xml_set_real(mg_node, "fom", mg->fom, "%g");
573  }
574  }
575 
576  for ( field=project->field; field; field=field->next ) {
577  for ( mg=field->mg; mg; mg=mg->next ) {
578  if ( mg->fmg.length() ) filename = mg->fmg;
579  else filename = "dummy.mrc";
580  center = mg->box_size/2;
581  for ( part=mg->part; part; part=part->next ) {
582  part_node = xmlNewChild(emx_node, NULL, BAD_CAST "particle", NULL);
583  if ( part->fpart.length() )
584  xmlNewProp(part_node, BAD_CAST "fileName", BAD_CAST part->fpart.c_str());
585  else
586  xmlNewProp(part_node, BAD_CAST "fileName", BAD_CAST mg->fpart.c_str());
587  xml_set_integer_attribute(part_node, "index", part->id, "%d");
588 
589  node = xmlNewChild(part_node, NULL, BAD_CAST "micrograph", NULL);
590  xmlNewProp(node, BAD_CAST "fileName", BAD_CAST filename.c_str());
591  xml_set_integer_attribute(node, "index", mg->img_num+1, "%d");
592 
593  emx_set_real_vector2(part_node, "pixelSpacing", part->pixel_size[0], part->pixel_size[1], "A/px");
594 
595  emx_set_real_vector2(part_node, "boxSize", mg->box_size[0], mg->box_size[1], "px");
596  emx_set_real_vector2(part_node, "centerCoord", part->loc[0], part->loc[1], "px");
597 
598  emx_set_transformation(part_node, part->view, part->ori - center);
599 
600  if ( part->def ) {
601  emx_set_real_unit(part_node, "defocusU", (part->def + part->dev)/10, "nm");
602  emx_set_real_unit(part_node, "defocusV", (part->def - part->dev)/10, "nm");
603  angle = part->ast*180.0/M_PI;
604  if ( angle < 0 ) angle += 180;
605  emx_set_real_unit(part_node, "defocusUAngle", angle, "deg");
606  }
607 
608  xml_set_integer(part_node, "activeFlag", part->sel, "%d");
609  xml_set_real(part_node, "fom", part->fom[0], "%g");
610  }
611  }
612  }
613 
614  return err;
615 }
616 
617 #endif
618 
Bmicrograph::id
Bstring id
Definition: mg_processing.h:203
Bmicrograph
Definition: mg_processing.h:201
rwxml.h
Reads and writes micrograph XML files.
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:116
Bparticle::view
View view
Definition: mg_processing.h:102
file_util.h
Header file for file checking functions.
Bstring
Definition: Bstring.h:29
field_add
Bfield * field_add(Bfield **field, Bstring &field_id)
Adds a field-of-view parameter structure to a linked list.
Definition: mg_processing.cpp:121
micrograph_get_nominal_origin
Vector3< double > micrograph_get_nominal_origin(Bmicrograph *mg)
Gets the nominal origin for a micrograph.
Definition: mg_img_proc.cpp:741
Bproject::split
int split
Definition: mg_processing.h:340
Bparticle
Definition: mg_processing.h:90
Matrix3::transpose
Matrix3 transpose() const
Definition: Matrix3.h:268
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:436
Bproject::field
Bfield * field
Definition: mg_processing.h:346
Bstring::replace
Bstring replace(char cold, char cnew)
Definition: Bstring.cpp:465
CTFparam::astigmatism_angle
double astigmatism_angle()
Definition: ctf.h:110
Vector3< int >
Bparticle::ast
double ast
Definition: mg_processing.h:98
Bmicrograph::img_num
int img_num
Definition: mg_processing.h:212
error_show
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:719
Bparticle::fom
double fom[NFOM]
Definition: mg_processing.h:103
Bmicrograph::part
Bparticle * part
Definition: mg_processing.h:242
xml_set_integer
xmlNodePtr xml_set_integer(xmlNodePtr parent, const char *tag, long value, const char *format)
xml_get_real
double xml_get_real(xmlNodePtr parent, const char *tag)
View
Definition: View.h:26
Bmicrograph::fpart
Bstring fpart
Definition: mg_processing.h:208
Bfield
Definition: mg_processing.h:260
xml_check_for_node
int xml_check_for_node(xmlNodePtr parent, const char *tag)
length
double length(vector< T > v)
Definition: Vector3.h:530
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:111
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
project_calculate_angles
int project_calculate_angles(Bproject *project)
Calculates tilt and tilt axis angles from matrices in a project parameter structure.
Definition: mg_tomography.cpp:1966
project
Bproject * project
Definition: bshow.cpp:33
xml_validate
int xml_validate(const xmlDocPtr doc, Bstring &xsdfile)
Matrix3
Definition: Matrix3.h:18
rwmg.h
Header file for reading and writing micrograph parameters.
Bparticle::fpart
Bstring fpart
Definition: mg_processing.h:92
BVERSION
#define BVERSION
Definition: utilities.h:9
read_project_emx
int read_project_emx(Bstring &filename, Bproject *project, Bstring &xsdfile)
Reading micrograph parameters from XML files.
Definition: rwmgEMX.cpp:241
write_project_emx
int write_project_emx(Bstring &filename, Bproject *project, int mg_select, int rec_select)
Writing micrograph parameters to an EMX file.
Definition: rwmgEMX.cpp:317
Bmicrograph::origin
Vector3< double > origin
Definition: mg_processing.h:223
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:421
detect_and_fix_carriage_return
int detect_and_fix_carriage_return(const char *filename)
Detects carriage returns in text files and converts them to new-lines.
Definition: file_util.cpp:377
xml_find_node
xmlNodePtr xml_find_node(xmlNodePtr parent, const char *tag)
Bproject
Definition: mg_processing.h:336
Bparticle::sel
long sel
Definition: mg_processing.h:104
VERB_DEBUG_STAR
#define VERB_DEBUG_STAR
Definition: utilities.h:117
Bparticle::pixel_size
Vector3< double > pixel_size
Definition: mg_processing.h:99
mg_img_proc.h
Header file for image processing from micrograph structures.
CTFparam::volt
double volt()
Definition: ctf.h:87
CTFparam::defocus_deviation
double defocus_deviation()
Definition: ctf.h:108
Bparticle::loc
Vector3< double > loc
Definition: mg_processing.h:100
M_PI
#define M_PI
Definition: utilities.h:63
utilities.h
Header file for general utilities.
Bmicrograph::box_size
Vector3< long > box_size
Definition: mg_processing.h:233
particle_get_box_size
Vector3< long > particle_get_box_size(Bparticle *part)
Gets the box size from particle image file.
Definition: mg_img_proc.cpp:937
Bstring::length
long length() const
Definition: Bstring.cpp:263
verbose
int verbose
Bparticle::def
double def
Definition: mg_processing.h:96
Bmicrograph::matrix
Matrix3 matrix
Definition: mg_processing.h:225
Bmicrograph::fmg
Bstring fmg
Definition: mg_processing.h:206
CTFparam
Definition: ctf.h:28
Vector3::volume
double volume()
Definition: Vector3.h:237
Bmicrograph::fom
double fom
Definition: mg_processing.h:239
particle_add
Bparticle * particle_add(Bparticle **part, int pid)
Adds a particle parameter structure to a linked list.
Definition: mg_processing.cpp:221
Bmicrograph::ctf
CTFparam * ctf
Definition: mg_processing.h:241
Bparticle::dev
double dev
Definition: mg_processing.h:97
Bfield::next
Bfield * next
Definition: mg_processing.h:261
Bstring::next
Bstring * next
Definition: Bstring.h:31
Bparticle::ori
Vector3< double > ori
Definition: mg_processing.h:101
mg_processing.h
Header file for micrograph processing.
CTFparam::defocus_average
double defocus_average()
Definition: ctf.h:106
Bmicrograph::block
int block
Definition: mg_processing.h:205
micrograph_add
Bmicrograph * micrograph_add(Bmicrograph **mg, Bstring &mg_id)
Adds a micrograph parameter structure to a linked list.
Definition: mg_processing.cpp:154
Bparticle::next
Bparticle * next
Definition: mg_processing.h:91
linked_list.h
Header file for generalized linked list functions.
Bmicrograph::select
long select
Definition: mg_processing.h:204
VERB_FULL
#define VERB_FULL
Definition: utilities.h:113
Bmicrograph::pixel_size
Vector3< double > pixel_size
Definition: mg_processing.h:215
CTFparam::amp_shift
double amp_shift()
Definition: ctf.h:99
View::matrix
Matrix3 matrix()
Definition: View.h:153
xml_set_real
xmlNodePtr xml_set_real(xmlNodePtr parent, const char *tag, double value, const char *format)
xml_get_integer_attribute
long xml_get_integer_attribute(xmlNodePtr parent, const char *tag)
xml_set_integer_attribute
xmlAttrPtr xml_set_integer_attribute(xmlNodePtr parent, const char *tag, long value, const char *format)
Bmicrograph::next
Bmicrograph * next
Definition: mg_processing.h:202
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:267
Bparticle::id
int id
Definition: mg_processing.h:93
xml_get_integer
long xml_get_integer(xmlNodePtr parent, const char *tag)
CTFparam::Cs
double Cs()
Definition: ctf.h:91
mg_tomography.h
Header file for single particle image processing in Bsoft.