| Bsoft 2.0.5 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
171 detect_and_fix_carriage_return(filename.c_str());
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
209 project_calculate_angles(project);
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
236 project_calculate_angles(project);
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> px, 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 px = emx_get_real_vector2(mg_node, "pixelSpacing");
398 mg->pixel_size = px[0];
399 }
400
401 if ( xml_check_for_node(mg_node, "defocusU") || xml_check_for_node(mg_node, "acceleratingVoltage") ) {
402 mg->ctf = new CTFparam;
403 mg->ctf->volt(1e3 * xml_get_real(mg_node, "acceleratingVoltage"));
404 mg->ctf->amp_shift(asin(xml_get_real(mg_node, "amplitudeContrast")));
405 mg->ctf->Cs(1e7 * xml_get_real(mg_node, "cs"));
406 defU = 10*xml_get_real(mg_node, "defocusU");
407 defV = 10*xml_get_real(mg_node, "defocusV");
408 if ( defU < 100 ) defU *= 1e3;
409 if ( defV < 100 ) defV *= 1e3;
410 mg->ctf->defocus_average((defU + defV)/2);
411 mg->ctf->defocus_deviation(fabs(defU - defV)/2);
412 mg->ctf->astigmatism_angle(xml_get_real(node, "defocusUAngle") * M_PI/180.0);
413 }
414 prev_mg_file = mg_file;
415 } else if ( !xmlStrcmp(node->name, BAD_CAST "particle") ) {
416 part_node = node;
417 part_file = (char *) xmlGetProp(part_node, BAD_CAST "fileName");
418 pid = xml_get_integer_attribute(part_node, "index");
419 if ( verbose & VERB_DEBUG )
420 cout << "DEBUG emx_to_project: part=" << part_file << " pid=" << pid << endl;
421
422 part_mg_node = xml_find_node(part_node, "micrograph");
423 if ( part_mg_node) {
424 mg = NULL;
425 mg_file = (char *) xmlGetProp(part_mg_node, BAD_CAST "fileName");
426 // cout << "***" << mg_file << "***" << endl;
427 if ( mg_file.length() ) {
428 img_num = xml_get_integer_attribute(part_mg_node, "index") - 1;
429 if ( img_num < 0 ) img_num = 0;
430 // cout << "***" << mg_file << "***" << img_num << "***" << endl;
431 // cout << "***" << field->mg->fmg << "***" << field->mg->img_num << "***" << endl;
432 for ( field = project->field; field; field = field->next ) {
433 for ( mg = field->mg; mg; mg = mg->next ) {
434 if ( mg->fmg == mg_file && mg->img_num == img_num ) break;
435 }
436 if ( mg ) break;
437 }
438 if ( verbose & VERB_DEBUG )
439 cout << "DEBUG emx_to_project: part: mg=" << mg->fmg << " img_num=" << mg->img_num << endl;
440 } else {
441 cerr << "Warning: No micrograph file name specified!" << endl;
442 }
443 }
444
445 if ( !mg ) {
446 if ( verbose & VERB_FULL )
447 cerr << "Warning: No micrograph for particle " << pid << " found!" << endl;
448 id = Bstring(++i, "%d");
449 if ( !field ) {
450 if ( verbose )
451 cout << "Generating a new field-of-view record with id: " << id << endl;
452 field = field_add(&project->field, id);
453 }
454 if ( verbose )
455 cout << "Generating a new micrograph record with id: " << id << endl;
456 mg = micrograph_add(&field->mg, id);
457 }
458
459 // mg->fpart = (char *) xmlGetProp(part_node, BAD_CAST "fileName");
460
461 if ( xml_find_node(part_node, "boxSize") )
462 mg->box_size = emx_get_integer_vector2(part_node, "boxSize");
463
464 if ( xml_find_node(part_node, "pixelSpacing") ) {
465 px = emx_get_real_vector2(part_node, "pixelSpacing");
466 mg->pixel_size = px[0];
467 }
468
469 if ( mg->pixel_size <= 0 ) mg->pixel_size = 1;
470
471 if ( verbose & VERB_DEBUG )
472 cout << "Particle " << pid << endl;
473 part = particle_add(&mg->part, pid);
474
475 part->fpart = part_file;
476
477 if ( mg->box_size.volume() < 1 )
478 mg->box_size = particle_get_box_size(part);
479
480 part->loc = emx_get_real_vector2(part_node, "centerCoord");
481 // emx_get_transformation(part_node, part);
482 emx_get_transformation(part_node, mat, origin);
483 part->ori = origin + mg->box_size/2;
484 part->view = View(mat);
485
486 defU = 10*xml_get_real(part_node, "defocusU");
487 defV = 10*xml_get_real(part_node, "defocusV");
488 if ( defU < 100 ) defU *= 1e3;
489 if ( defV < 100 ) defV *= 1e3;
490 part->def = (defU + defV)/2;
491 part->dev = fabs(defU - defV)/2;
492 part->ast = xml_get_real(part_node, "defocusUAngle") * M_PI/180.0;
493
494 part->sel = xml_get_integer(part_node, "activeFlag");
495 part->fom[0] = xml_get_real(part_node, "fom");
496 }
497 }
498
499 return err;
500 }
501
502
503 /*
504 @brief Converts micrograph data from an project structure to a XML document.
505 @param Bproject* project parameter structure.
506 @param xmlDocPtr doc XML document.
507 @param mg_select flag to only write selected micrographs.
508 @param rec_select flag to only convert selected reconstructions.
509 @return int error code (<0 means failure).
510
511 The function packes new micrograph data back into an existing XML
512 document from which the old project parameters were obtained.
513 All angles used internally are in radians, and are converted here
514 to degrees for output. The angles within the micrograph structure
515 are left in radians.
516 The stylesheet written into the document is "Bsoft_micrograph.xsl".
517 **/
518 int project_to_emx(Bproject* project, xmlDocPtr doc, int mg_select, int rec_select)
519 {
520 int err(0);
521
522 Bfield* field = NULL;
523 Bmicrograph* mg = NULL;
524 Bparticle* part = NULL;
525
526 xmlNodePtr root_node = xmlNewDocPI(doc, BAD_CAST "xml-stylesheet",
527 BAD_CAST "href=\"emx.xsl\" type=\"text/xsl\"");
528 xmlDocSetRootElement(doc, root_node);
529
530 xmlNodePtr emx_node = xmlNewNode(NULL, BAD_CAST "EMX");
531
532 xmlAddSibling(root_node, emx_node);
533
534 xmlNewProp(emx_node, BAD_CAST "version", BAD_CAST "1.0");
535
536 Bstring cmnt(" Written by Bsoft ");
537 cmnt += BVERSION;
538 xmlNodePtr cmnt_node = xmlNewComment(BAD_CAST cmnt.c_str());
539 xmlAddChild(emx_node, cmnt_node);
540
541 xmlNodePtr mg_node = NULL;
542 xmlNodePtr part_node = NULL;
543 xmlNodePtr node = NULL;
544
545 double angle;
546 Vector3<double> center;
547 Bstring filename;
548
549 for ( field=project->field; field; field=field->next ) {
550 for ( mg=field->mg; mg; mg=mg->next ) {
551 if ( mg->fmg.length() ) filename = mg->fmg;
552 else filename = "dummy.mrc";
553 mg_node = xmlNewChild(emx_node, NULL, BAD_CAST "micrograph", NULL);
554 xmlNewProp(mg_node, BAD_CAST "fileName", BAD_CAST filename.c_str());
555 xml_set_integer_attribute(mg_node, "index", mg->img_num+1, "%d");
556
557 center = micrograph_get_nominal_origin(mg);
558
559 emx_set_real_vector2(mg_node, "pixelSpacing", mg->pixel_size, mg->pixel_size, "A/px");
560
561 emx_set_transformation(mg_node, mg->matrix, mg->origin - center);
562
563 if ( mg->ctf ) {
564 emx_set_real_unit(mg_node, "acceleratingVoltage", mg->ctf->volt()/1e3, "kV");
565 emx_set_real_unit(mg_node, "amplitudeContrast", sin(mg->ctf->amp_shift()), NULL);
566 emx_set_real_unit(mg_node, "cs", mg->ctf->Cs()/1e7, "mm");
567 emx_set_real_unit(mg_node, "defocusU", (mg->ctf->defocus_average() + mg->ctf->defocus_deviation())/10, "nm");
568 emx_set_real_unit(mg_node, "defocusV", (mg->ctf->defocus_average() - mg->ctf->defocus_deviation())/10, "nm");
569 angle = mg->ctf->astigmatism_angle()*180.0/M_PI;
570 if ( angle < 0 ) angle += 180;
571 emx_set_real_unit(mg_node, "defocusUAngle", angle, "deg");
572 }
573
574 xml_set_integer(mg_node, "activeFlag", mg->select, "%d");
575 xml_set_real(mg_node, "fom", mg->fom, "%g");
576 }
577 }
578
579 for ( field=project->field; field; field=field->next ) {
580 for ( mg=field->mg; mg; mg=mg->next ) {
581 if ( mg->fmg.length() ) filename = mg->fmg;
582 else filename = "dummy.mrc";
583 center = mg->box_size/2;
584 for ( part=mg->part; part; part=part->next ) {
585 part_node = xmlNewChild(emx_node, NULL, BAD_CAST "particle", NULL);
586 if ( part->fpart.length() )
587 xmlNewProp(part_node, BAD_CAST "fileName", BAD_CAST part->fpart.c_str());
588 else
589 xmlNewProp(part_node, BAD_CAST "fileName", BAD_CAST mg->fpart.c_str());
590 xml_set_integer_attribute(part_node, "index", part->id, "%d");
591
592 node = xmlNewChild(part_node, NULL, BAD_CAST "micrograph", NULL);
593 xmlNewProp(node, BAD_CAST "fileName", BAD_CAST filename.c_str());
594 xml_set_integer_attribute(node, "index", mg->img_num+1, "%d");
595
596 emx_set_real_vector2(part_node, "pixelSpacing", mg->pixel_size, mg->pixel_size, "A/px");
597
598 emx_set_real_vector2(part_node, "boxSize", mg->box_size[0], mg->box_size[1], "px");
599 emx_set_real_vector2(part_node, "centerCoord", part->loc[0], part->loc[1], "px");
600
601 emx_set_transformation(part_node, part->view, part->ori - center);
602
603 if ( part->def ) {
604 emx_set_real_unit(part_node, "defocusU", (part->def + part->dev)/10, "nm");
605 emx_set_real_unit(part_node, "defocusV", (part->def - part->dev)/10, "nm");
606 angle = part->ast*180.0/M_PI;
607 if ( angle < 0 ) angle += 180;
608 emx_set_real_unit(part_node, "defocusUAngle", angle, "deg");
609 }
610
611 xml_set_integer(part_node, "activeFlag", part->sel, "%d");
612 xml_set_real(part_node, "fom", part->fom[0], "%g");
613 }
614 }
615 }
616
617 return err;
618 }
619
620 #endif
621
Bparticle::id
int id
Definition: mg_processing.h:92
rwmg.h
Header file for reading and writing micrograph parameters.
CTFparam::Cs
double Cs()
Definition: ctf.h:87
Bparticle::ast
double ast
Definition: mg_processing.h:97
xml_check_for_node
int xml_check_for_node(xmlNodePtr parent, const char *tag)
Bparticle::view
View view
Definition: mg_processing.h:101
BVERSION
#define BVERSION
Definition: utilities.h:9
Bmicrograph::id
Bstring id
Definition: mg_processing.h:202
xml_get_integer
long xml_get_integer(xmlNodePtr parent, const char *tag)
Bmicrograph::img_num
int img_num
Definition: mg_processing.h:211
xml_find_node
xmlNodePtr xml_find_node(xmlNodePtr parent, const char *tag)
utilities.h
Header file for general utilities.
CTFparam::astigmatism_angle
double astigmatism_angle()
Definition: ctf.h:104
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:112
Bproject::split
int split
Definition: mg_processing.h:337
mg_img_proc.h
Header file for image processing from micrograph structures.
Bparticle::fom
double fom[NFOM]
Definition: mg_processing.h:102
rwxml.h
Reads and writes micrograph XML files.
Matrix3
Definition: Matrix3.h:17
particle_add
Bparticle * particle_add(Bparticle **part, int pid)
Adds a particle parameter structure to a linked list.
Definition: mg_processing.cpp:527
Bstring::length
long length() const
Definition: Bstring.cpp:263
Bmicrograph::pixel_size
double pixel_size
Definition: mg_processing.h:214
project
Bproject * project
Definition: bshow.cpp:31
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:107
Bfield::next
Bfield * next
Definition: mg_processing.h:258
Bstring::replace
Bstring replace(char cold, char cnew)
Definition: Bstring.cpp:457
Bmicrograph::part
Bparticle * part
Definition: mg_processing.h:239
Bmicrograph::matrix
Matrix3 matrix
Definition: mg_processing.h:222
Bmicrograph::fpart
Bstring fpart
Definition: mg_processing.h:207
Bparticle::sel
long sel
Definition: mg_processing.h:103
Bfield
Definition: mg_processing.h:257
M_PI
#define M_PI
Definition: utilities.h:59
linked_list.h
Header file for generalized linked list functions.
Bmicrograph::ctf
CTFparam * ctf
Definition: mg_processing.h:238
xml_get_integer_attribute
long xml_get_integer_attribute(xmlNodePtr parent, const char *tag)
Bstring::next
Bstring * next
Definition: Bstring.h:31
Bmicrograph::select
long select
Definition: mg_processing.h:203
Bproject::field
Bfield * field
Definition: mg_processing.h:343
length
double length(vector< T > v)
Definition: Vector3.h:528
CTFparam::defocus_deviation
double defocus_deviation()
Definition: ctf.h:102
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:827
Bmicrograph
Definition: mg_processing.h:200
mg_tomography.h
Header file for single particle image processing in Bsoft.
Bmicrograph::origin
Vector3< double > origin
Definition: mg_processing.h:220
file_util.h
Header file for file checking functions.
Bparticle::fpart
Bstring fpart
Definition: mg_processing.h:91
Bparticle::ori
Vector3< double > ori
Definition: mg_processing.h:100
xml_set_integer_attribute
xmlAttrPtr xml_set_integer_attribute(xmlNodePtr parent, const char *tag, long value, const char *format)
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:428
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:264
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:120
Bparticle::dev
double dev
Definition: mg_processing.h:96
Bparticle
Definition: mg_processing.h:89
Bmicrograph::block
int block
Definition: mg_processing.h:204
Bstring
Definition: Bstring.h:29
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
View::matrix
Matrix3 matrix()
Definition: View.h:150
xml_validate
int xml_validate(const xmlDocPtr doc, Bstring &xsdfile)
Matrix3::transpose
Matrix3 transpose() const
Definition: Matrix3.h:268
CTFparam::volt
double volt()
Definition: ctf.h:83
xml_get_real
double xml_get_real(xmlNodePtr parent, const char *tag)
Bmicrograph::box_size
Vector3< long > box_size
Definition: mg_processing.h:230
xml_set_integer
xmlNodePtr xml_set_integer(xmlNodePtr parent, const char *tag, long value, const char *format)
Vector3< int >
Bmicrograph::fmg
Bstring fmg
Definition: mg_processing.h:205
Bparticle::loc
Vector3< double > loc
Definition: mg_processing.h:99
View
Definition: View.h:26
Bmicrograph::fom
double fom
Definition: mg_processing.h:236
micrograph_get_nominal_origin
Vector3< double > micrograph_get_nominal_origin(Bmicrograph *mg)
Gets the nominal origin for a micrograph.
Definition: mg_img_proc.cpp:631
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
CTFparam::defocus_average
double defocus_average()
Definition: ctf.h:100
Bparticle::def
double def
Definition: mg_processing.h:95
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:1749
VERB_DEBUG_STAR
#define VERB_DEBUG_STAR
Definition: utilities.h:113
mg_processing.h
Header file for micrograph processing.
CTFparam::amp_shift
double amp_shift()
Definition: ctf.h:95
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:413
Vector3::volume
double volume()
Definition: Vector3.h:235
Bparticle::next
Bparticle * next
Definition: mg_processing.h:90
VERB_FULL
#define VERB_FULL
Definition: utilities.h:109
micrograph_add
Bmicrograph * micrograph_add(Bmicrograph **mg, Bstring &mg_id)
Adds a micrograph parameter structure to a linked list.
Definition: mg_processing.cpp:461
error_show
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:755
Bproject
Definition: mg_processing.h:333
CTFparam
Definition: ctf.h:26
verbose
int verbose
Bmicrograph::next
Bmicrograph * next
Definition: mg_processing.h:201
xml_set_real
xmlNodePtr xml_set_real(xmlNodePtr parent, const char *tag, double value, const char *format)