| Bsoft 2.0.5 Bernard's software package

rwmgXML.cpp
Go to the documentation of this file.
1
9 #ifdef HAVE_XML
10 #include "rwxml.h"
11 #endif
12
13 #include "mg_tags.h"
14 #include "mg_processing.h"
15 #include "rwmg.h"
16 #include "file_util.h"
17 #include "linked_list.h"
18 #include "utilities.h"
19
20 // Declaration of global variables
21 extern int verbose; // Level of output to the screen
22
23 // Internal function prototypes
24 #ifdef HAVE_XML
25 int xml_to_project(xmlDocPtr doc, Bproject* project, Bstring& filename);
26 int project_to_xml(Bproject* project, xmlDocPtr doc, int mg_select, int rec_select);
27 Bparticle* particle_from_xml(xmlNodePtr node, Bparticle** partlist, FOMType fom_tag[NFOM]);
28 xmlNodePtr particle_to_xml(Bparticle* part, xmlNodePtr parent, int euler_flag, int omega_flag, FOMType fom_tag[NFOM]);
29 #endif
30
37 #if defined(HAVE_XML)
38 int read_project_xml(Bstring& filename, Bproject* project)
39 {
40 if ( filename.length() < 1 ) {
41 error_show("No file names found!", __FILE__, __LINE__);
42 return -1;
43 }
44
45 int err(0);
46 xmlDocPtr doc;
47 xmlNodePtr node;
48
49 detect_and_fix_carriage_return(filename.c_str());
50
51 doc = xmlParseFile(filename.c_str());
52 if (doc == NULL) return -1;
53
54 if ( verbose & VERB_PROCESS )
55 cout << "# Reading XML file: " << filename << endl;
56
57 node = xmlDocGetRootElement(doc);
58 if ( node == NULL ) {
59 error_show(filename.c_str(), __FILE__, __LINE__);
60 xmlFreeDoc(doc);
61 return -1;
62 }
63
64 if ( xmlStrcmp(node->name, (const xmlChar *) PROJECT) ) {
65 cerr << "Error: The document " << filename << " is not a micrograph parameter file!" << endl;
66 xmlFreeDoc(doc);
67 return -1;
68 }
69
70 // xmlDocDump(stderr, doc);
71 // xmlElemDump(stderr, doc, node);
72
73 err = xml_to_project(doc, project, filename);
74
75 xmlFreeDoc(doc);
76
77 xmlCleanupParser();
78
79 return err;
80 }
81
82 int read_project_xml(Bstring* file_list, Bproject* project)
83 {
84 if ( !file_list ) {
85 error_show("No file names found!", __FILE__, __LINE__);
86 return -1;
87 }
88
89 // Get the list of filenames
90 int err(0);
91 Bstring* thisfile = NULL;
92
93 if ( verbose & VERB_DEBUG_STAR ) {
94 cout << "DEBUG read_project_xml: XML filenames:" << endl;
95 for ( thisfile = file_list; thisfile; thisfile = thisfile->next )
96 cout << " " << *thisfile;
97 cout << endl;
98 }
99
100 for ( thisfile = file_list; thisfile; thisfile = thisfile->next ) {
101 err = read_project_xml(*thisfile, project);
102 }
103
104 return err;
105 }
106
107 Bparticle* read_particle_xml(Bstring& filename, Bparticle** partlist, FOMType fom_tag[NFOM])
108 {
109 if ( filename.length() < 1 ) {
110 error_show("No file name found!", __FILE__, __LINE__);
111 return NULL;
112 }
113
114 xmlDocPtr doc;
115 xmlNodePtr node;
116
117 doc = xmlParseFile(filename.c_str());
118 if (doc == NULL) return NULL;
119
120 if ( verbose & VERB_FULL )
121 cout << "# Reading XML file: " << filename << endl;
122
123 node = xmlDocGetRootElement(doc);
124 if ( node == NULL ) {
125 error_show(filename.c_str(), __FILE__, __LINE__);
126 xmlFreeDoc(doc);
127 return NULL;
128 }
129
130 if ( xmlStrcmp(node->name, (const xmlChar *) PARTICLE) ) {
131 cerr << "Error: The document " << filename << " is not a particle parameter file!" << endl;
132 xmlFreeDoc(doc);
133 return NULL;
134 }
135
136 Bparticle* part = particle_from_xml(node, partlist, fom_tag);
137
138 xmlFreeDoc(doc);
139
140 return part;
141 }
142
143 #else
144 int read_project_xml(Bstring& filename, Bproject* project)
145 {
146 cerr << "Error: XML files are not supported!" << endl << endl;
147
148 return -1;
149 }
150 #endif
151
160 #if defined(HAVE_XML)
161 int write_project_xml(Bstring& filename, Bproject* project, int mg_select, int rec_select)
162 {
163 int i, err(0);
164 Bstring name;
165
166 xmlDocPtr doc;
167
168 Bfield* field;
169 Bmicrograph* mg;
170 Breconstruction* rec;
171 char format[32];
172
173 snprintf(format, 32, "_%%0%dd.", project->split);
174
175 if ( project->split ) {
176 for ( i=0, field = project->field; field; field=field->next ) {
177 for ( mg=field->mg; mg; mg=mg->next, i++ ) {
178 if ( project->split == 9 && mg->id.length() > 0 ) {
179 name = mg->id + ".xml";
180 name = name.replace(' ', '_');
181 } else {
182 name = filename.pre_rev('.') + Bstring(i, format) + filename.post_rev('.');
183 }
184 if ( verbose & VERB_PROCESS )
185 cout << "# Writing file: " << name << endl;
186 doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
187 if ( doc == NULL ) {
188 cerr << "Error: The XML document tree was not created!" << endl;
189 return -1;
190 }
191 err = project_to_xml(project, doc, i, 0);
192 if ( err == 0 )
193 err = xmlSaveFormatFile(name.c_str(), doc, 1);
194 xmlFreeDoc(doc);
195 }
196 }
197 for ( i=0, rec = project->rec; rec; rec = rec->next ) {
198 if ( project->split == 9 && rec->id.length() > 0 ) {
199 name = rec->id + ".xml";
200 name = name.replace(' ', '_');
201 } else {
202 name = filename.pre_rev('.') + Bstring(i, format) + filename.post_rev('.');
203 }
204 if ( verbose & VERB_PROCESS )
205 cout << "# Writing file: " << name << endl;
206 doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
207 if ( doc == NULL ) {
208 cerr << "Error: The XML document tree was not created!" << endl;
209 return -1;
210 }
211 err = project_to_xml(project, doc, 0, i);
212 if ( err == 0 )
213 err = xmlSaveFormatFile(name.c_str(), doc, 1);
214 xmlFreeDoc(doc);
215 }
216 } else {
217 if ( verbose & VERB_PROCESS )
218 cout << "# Writing file: " << filename << endl;
219 doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
220 if ( doc == NULL ) {
221 cerr << "Error: The XML document tree was not created!" << endl;
222 return -1;
223 }
224 err = project_to_xml(project, doc, 0, 0);
225 if ( err == 0 )
226 err = xmlSaveFormatFile(filename.c_str(), doc, 1);
227 xmlFreeDoc(doc);
228 }
229
230 return err;
231 }
232
233 int write_particle_xml(Bstring& filename, Bparticle* part, int euler_flag, int omega_flag, FOMType fom_tag[NFOM])
234 {
235 xmlDocPtr doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
236 if (doc == NULL) return -1;
237
238 if ( verbose & VERB_PROCESS )
239 cout << "# Writing XML file: " << filename << endl;
240
241 xmlNodePtr node = xmlNewDocPI(doc, BAD_CAST "xml-stylesheet",
242 BAD_CAST "href=\"Bsoft_particle.xsl\" type=\"text/xsl\"");
243 xmlDocSetRootElement(doc, node);
244
245 xmlNodePtr part_node = particle_to_xml(part, NULL, euler_flag, omega_flag, fom_tag);
246 // cout << "part_node=" << part_node << endl;
247
248 xmlAddSibling(node, part_node);
249
250 if ( xmlSaveFormatFile(filename.c_str(), doc, 1) < 0 )
251 cerr << "Error: XML file " << filename << " not written!" << endl;
252
253 xmlFreeDoc(doc);
254
255 return 0;
256 }
257 #else
258 int write_project_xml(Bstring& filename, Bproject* project, int mg_select, int rec_select)
259 {
260 cerr << "Error: XML files are not supported!" << endl << endl;
261
262 return -1;
263 }
264 #endif
265
266 #ifdef HAVE_XML
267
268 CTFparam* ctf_from_xml(xmlNodePtr node)
269 {
270 if ( !xml_check_for_node(node, CTF_DEF_AVG) ) return NULL;
271
272 char string[256];
273 CTFparam* ctf = new CTFparam;
274
275 ctf->volt(xml_get_real(node, CTF_VOLTAGE));
276 if ( xml_find_node(node, CTF_AMP_SHIFT) )
277 ctf->amp_shift(xml_get_real(node, CTF_AMP_SHIFT));
278 else
279 ctf->amp_shift(asin(xml_get_real(node, CTF_AMP)));
280 ctf->defocus_average(xml_get_real(node, CTF_DEF_AVG));
281 ctf->defocus_deviation(xml_get_real(node, CTF_DEF_DEV));
282 ctf->astigmatism_angle(xml_get_real(node, CTF_AST_ANG) * M_PI/180.0);
283 ctf->Cs(xml_get_real(node, CTF_CS));
284 ctf->Cc(xml_get_real(node, CTF_CC));
285 ctf->alpha(xml_get_real(node, CTF_ALPHA));
286 ctf->dE(xml_get_real(node, CTF_DE));
287 ctf->zero(1);
288 xml_copy_string(string, node, CTF_BASELINE);
289 ctf->parse_baseline_equation(string);
290 xml_copy_string(string, node, CTF_ENVELOPE);
291 ctf->parse_envelope_equation(string);
292
293 return ctf;
294 }
295
296 Bframe* frame_from_xml(xmlNodePtr node, Bframe** framelist)
297 {
298 xmlChar* frame_id;
299 Bframe* frame = NULL;
300
301 frame_id = xmlGetProp(node, BAD_CAST ID);
302 frame = frame_add(framelist, atoi((char *) frame_id));
303 xmlFree(frame_id);
304 if ( !frame ) return frame;
305
306 frame->shift[0] = xml_get_real(node, MICROGRAPH_FRAME_SHIFT_X);
307 frame->shift[1] = xml_get_real(node, MICROGRAPH_FRAME_SHIFT_Y);
308 frame->fom = xml_get_real(node, MICROGRAPH_FRAME_FOM);
309 frame->sel = xml_get_integer(node, MICROGRAPH_FRAME_SELECT);
310
311 return frame;
312 }
313
314 Bparticle* particle_from_xml(xmlNodePtr node, Bparticle** partlist, FOMType fom_tag[NFOM])
315 {
316 int f, euler_flag, omega_flag;
317 char tag[128];
318 xmlChar* part_id;
319 Bparticle* part = NULL;
320 Euler euler;
321
322 part_id = xmlGetProp(node, BAD_CAST ID);
323 part = particle_add(partlist, atoi((char *) part_id));
324 xmlFree(part_id);
325 if ( !part ) return part;
326
327 part->fpart = (char *) xmlGetProp(node, BAD_CAST PARTICLE_FILE);
328 part->group = xml_get_integer(node, PARTICLE_GROUP);
329 part->def = xml_get_real(node, PARTICLE_DEFOCUS);
330 part->dev = xml_get_real(node, PARTICLE_DEF_DEV);
331 part->ast = xml_get_real(node, PARTICLE_AST_ANG);
332 part->mag = xml_get_real(node, PARTICLE_MAGNIF);
333 part->loc[0] = xml_get_real(node, PARTICLE_X);
334 part->loc[1] = xml_get_real(node, PARTICLE_Y);
335 part->loc[2] = xml_get_real(node, PARTICLE_Z);
336 part->pixel_size = xml_get_real(node, PARTICLE_PIXEL);
337 part->ori[0] = xml_get_real(node, PARTICLE_ORIGIN_X);
338 part->ori[1] = xml_get_real(node, PARTICLE_ORIGIN_Y);
339 part->ori[2] = xml_get_real(node, PARTICLE_ORIGIN_Z);
340 euler_flag = xml_check_for_node(node, PARTICLE_THETA);
341 if ( euler_flag == 0 ) {
342 part->view[0] = xml_get_real(node, PARTICLE_VIEW_X);
343 part->view[1] = xml_get_real(node, PARTICLE_VIEW_Y);
344 part->view[2] = xml_get_real(node, PARTICLE_VIEW_Z);
345 part->view[3] = xml_get_real(node, PARTICLE_VIEW_ANGLE)*M_PI/180.0;
346 } else {
347 omega_flag = xml_check_for_node(node, PARTICLE_OMEGA);
348 if ( omega_flag )
349 euler[0] = -xml_get_real(node, PARTICLE_OMEGA)*M_PI/180.0;
350 else
351 euler[0] = xml_get_real(node, PARTICLE_PSI)*M_PI/180.0;
352 euler[1] = xml_get_real(node, PARTICLE_THETA)*M_PI/180.0;
353 euler[2] = xml_get_real(node, PARTICLE_PHI)*M_PI/180.0;
354 part->view = euler.view();
355 }
356 for ( f=0; f<NFOM; f++ ) if ( fom_tag[f] ) {
357 get_fom_tag(fom_tag[f], tag);
358 part->fom[f] = xml_get_real(node, tag);
359 }
360 part->sel = xml_get_integer(node, PARTICLE_SELECT);
361
362 return part;
363 }
364
365 Bfilament* filament_from_xml(xmlNodePtr node, Bfilament** fillist)
366 {
367 xmlChar* fil_id;
368 xmlNodePtr fnode_node = NULL;
369 Bfilament* fil = NULL;
370 Bfilnode* fnode = NULL;
371
372 fil_id = xmlGetProp(node, BAD_CAST ID);
373 fil = filament_add(fillist, atoi((char *) fil_id));
374 xmlFree(fil_id);
375 for ( fnode_node = node->xmlChildrenNode; fnode_node; fnode_node = fnode_node->next ) {
376 if ( !xmlStrcmp(fnode_node->name, BAD_CAST FILAMENT_NODE) ) {
377 fil_id = xmlGetProp(node, BAD_CAST ID);
378 fnode = filament_node_add(&fil->node, atoi((char *) fil_id));
379 xmlFree(fil_id);
380 fnode->loc[0] = xml_get_real(node, FILAMENT_NODE_X);
381 fnode->loc[1] = xml_get_real(node, FILAMENT_NODE_Y);
382 fnode->loc[2] = xml_get_real(node, FILAMENT_NODE_Z);
383 }
384 }
385
386 return fil;
387 }
388
389 Bbadarea* badarea_from_xml(xmlNodePtr node, Bbadarea** badlist)
390 {
391 Bbadarea* bad = (Bbadarea *) add_item((char **) badlist, sizeof(Bbadarea));
392
393 bad->loc[0] = xml_get_real(node, PARTICLE_BAD_X);
394 bad->loc[1] = xml_get_real(node, PARTICLE_BAD_Y);
395 bad->loc[2] = xml_get_real(node, PARTICLE_BAD_Z);
396
397 return bad;
398 }
399
400 Bmarker* marker_from_xml(xmlNodePtr node, Bmarker** marklist)
401 {
402 xmlChar* mark_id;
403 Bmarker* mark = (Bmarker *) add_item((char **) marklist, sizeof(Bmarker));
404
405 mark_id = xmlGetProp(node, BAD_CAST ID);
406 mark->id = atoi((char *) mark_id);
407 xmlFree(mark_id);
408 mark->fom = 1;
409 mark->loc[0] = xml_get_real(node, MARKER_X);
410 mark->loc[1] = xml_get_real(node, MARKER_Y);
411 mark->loc[2] = xml_get_real(node, MARKER_Z);
412 mark->err[0] = xml_get_real(node, MARKER_ERROR_X);
413 mark->err[1] = xml_get_real(node, MARKER_ERROR_Y);
414 mark->err[2] = xml_get_real(node, MARKER_ERROR_Z);
415 mark->res = xml_get_real(node, MARKER_RESIDUAL);
416 mark->fom = xml_get_real(node, MARKER_FOM);
417 mark->sel = xml_get_integer(node, MARKER_SELECT);
418
419 return mark;
420 }
421
422 Bstrucfac* strucfac_from_xml(xmlNodePtr node, Bstrucfac** sflist)
423 {
424 Bstrucfac* sf = (Bstrucfac *) add_item((char **) sflist, sizeof(Bstrucfac));
425
426 sf->fom = sf->sel = 1;
427 sf->index[0] = xml_get_integer(node, REFLEX_H);
428 sf->index[1] = xml_get_integer(node, REFLEX_K);
429 sf->index[2] = xml_get_integer(node, REFLEX_L);
430 sf->loc[0] = xml_get_real(node, REFLEX_X);
431 sf->loc[1] = xml_get_real(node, REFLEX_Y);
432 sf->loc[2] = xml_get_real(node, REFLEX_Z);
433 sf->amp = xml_get_real(node, REFLEX_AMP);
434 sf->sigamp = xml_get_real(node, REFLEX_SIGAMP);
435 sf->phi = xml_get_real(node, REFLEX_PHI);
436 sf->sigphi = xml_get_real(node, REFLEX_SIGPHI);
437 sf->fom = xml_get_real(node, REFLEX_FOM);
438 sf->sel = xml_get_integer(node, REFLEX_STATUS);
439
440 return sf;
441 }
442
443 Blayerline* layerline_from_xml(xmlNodePtr node, Blayerline** linelist)
444 {
445 Blayerline* line = (Blayerline *) add_item((char **) linelist, sizeof(Blayerline));
446
447 line->fom = line->sel = 1;
448 line->number = xml_get_integer(node, LAYERLINE_NUMBER);
449 line->order = xml_get_integer(node, LAYERLINE_ORDER);
450 line->distance = xml_get_real(node, LAYERLINE_DISTANCE);
451 line->freq = xml_get_real(node, LAYERLINE_FREQ);
452 line->amp = xml_get_real(node, LAYERLINE_AMP);
453 line->fom = xml_get_real(node, LAYERLINE_FOM);
454 line->sel = xml_get_integer(node, LAYERLINE_SELECT);
455
456 return line;
457 }
458
459 /*
460 @brief Converts micrograph data from a XML document to a project structure.
461 @param xmlDocPtr doc XML document pointer.
462 @param *project project structure.
463 @param &filename file name to resolve paths.
464 @return int error code (<0 means failure).
465
466 The function sets up the project hierarchy from a XML file.
467 All angles given in the XML document are assumed to be in degrees,
468 and are converted here only to radians.
469
470 **/
471 int xml_to_project(xmlDocPtr doc, Bproject* project, Bstring& filename)
472 {
473 int err(0);
474
475 Bfield* field = project->field;
476 Bmicrograph* mg = NULL;
477 Breconstruction* rec = NULL;
478
479 int i, f;
480 xmlChar *xstring, *id;
481 Bstring bid;
482 char string[256];
483
484 xmlNodePtr project_node = xmlDocGetRootElement(doc);
485 xmlNodePtr child_node = NULL;
486 xmlNodePtr mg_node = NULL;
487 xmlNodePtr node = NULL;
488
489 // Make sure FOM tags are properly set up
490 if ( xml_check_for_node_in_tree(project_node, PARTICLE_FOM) ) project->fom_tag[0] = FOM;
491 if ( xml_check_for_node_in_tree(project_node, PARTICLE_FOM_CV) ) project->fom_tag[1] = FOM_CV;
492 if ( xml_check_for_node_in_tree(project_node, PARTICLE_HANDA_FOM) ) project->fom_tag[1] = FOM_HAND_A;
493 if ( xml_check_for_node_in_tree(project_node, PARTICLE_HANDB_FOM) ) project->fom_tag[2] = FOM_HAND_B;
494
495 for ( f=i=0; f<NFOM; f++ ) i += project->fom_tag[f];
496 if ( i < 2 ) project->fom_tag[0] = FOM;
497
498 for ( i=0, child_node = project_node->xmlChildrenNode; child_node; child_node = child_node->next ) {
499 if ( project->comment.empty() ) {
500 if ( !xmlStrcmp(child_node->name, BAD_CAST COMMENT) )
501 project->comment = (char *) xmlNodeGetContent(child_node);
502 }
503 if ( !project->reference ) {
504 if ( !xmlStrcmp(child_node->name, BAD_CAST MAP_REFERENCE) ) {
505 xstring = xmlNodeGetContent(child_node);
506 string_add(&project->reference, (char *) xstring);
507 xmlFree(xstring);
508 }
509 }
510 if ( !xmlStrcmp(child_node->name, BAD_CAST FIELD) ) {
511 id = xmlGetProp(child_node, BAD_CAST ID);
512 bid = (char *) id;
513 for ( field=project->field; field; field=field->next )
514 if ( field->id == bid ) break;
515 if ( !field ) field = field_add(&project->field, bid);
516 xmlFree(id);
517 for ( mg_node = child_node->xmlChildrenNode; mg_node; mg_node = mg_node->next ) {
518 if ( !xmlStrcmp(mg_node->name, BAD_CAST MICROGRAPH) ) {
519 id = xmlGetProp(mg_node, BAD_CAST ID);
520 bid = (char *) id;
521 mg = micrograph_add(&field->mg, bid);
522 xmlFree(id);
523 mg->block = i++;
524 mg->fmg = xml_get_string(mg_node, MICROGRAPH_FILE);
525 mg->fframe = xml_get_string(mg_node, MICROGRAPH_FRAMES_FILE);
526 mg->fpart = xml_get_string(mg_node, PARTICLE_FILE);
527 mg->ffil = xml_get_string(mg_node, FILAMENT_FILE);
528 mg->fft = xml_get_string(mg_node, MICROGRAPH_TRANSFORM_FILE);
529 mg->fps = xml_get_string(mg_node, MICROGRAPH_POWERSPEC_FILE);
530 mg->img_num = xml_get_integer(mg_node, MICROGRAPH_NUMBER);
531 mg->select = xml_get_integer(mg_node, MICROGRAPH_SELECT);
532 mg->fom = xml_get_real(mg_node, MICROGRAPH_FOM);
533 mg->magnification = xml_get_real(mg_node, MICROGRAPH_MAGNIFICATION);
534 mg->sampling = xml_get_real(mg_node, MICROGRAPH_SAMPLING);
535 mg->pixel_size = xml_get_real(mg_node, MICROGRAPH_PIXEL);
536 mg->dose = xml_get_real(mg_node, MICROGRAPH_DOSE);
537 mg->tilt_axis = xml_get_real(mg_node, MICROGRAPH_TILT_AXIS);
538 mg->tilt_angle = xml_get_real(mg_node, MICROGRAPH_TILT_ANGLE);
539 mg->rot_angle = xml_get_real(mg_node, MICROGRAPH_ROT_ANGLE);
540 mg->origin[0] = xml_get_real(mg_node, MICROGRAPH_ORIGIN_X);
541 mg->origin[1] = xml_get_real(mg_node, MICROGRAPH_ORIGIN_Y);
542 mg->origin[2] = xml_get_real(mg_node, MICROGRAPH_ORIGIN_Z);
543 mg->scale[0] = xml_get_real(mg_node, MICROGRAPH_SCALE_X);
544 mg->scale[1] = xml_get_real(mg_node, MICROGRAPH_SCALE_Y);
545 mg->scale[2] = xml_get_real(mg_node, MICROGRAPH_SCALE_Z);
546 mg->matrix[0][0] = xml_get_real(mg_node, MICROGRAPH_MATRIX_1_1);
547 mg->matrix[0][1] = xml_get_real(mg_node, MICROGRAPH_MATRIX_1_2);
548 mg->matrix[0][2] = xml_get_real(mg_node, MICROGRAPH_MATRIX_1_3);
549 mg->matrix[1][0] = xml_get_real(mg_node, MICROGRAPH_MATRIX_2_1);
550 mg->matrix[1][1] = xml_get_real(mg_node, MICROGRAPH_MATRIX_2_2);
551 mg->matrix[1][2] = xml_get_real(mg_node, MICROGRAPH_MATRIX_2_3);
552 mg->matrix[2][0] = xml_get_real(mg_node, MICROGRAPH_MATRIX_3_1);
553 mg->matrix[2][1] = xml_get_real(mg_node, MICROGRAPH_MATRIX_3_2);
554 mg->matrix[2][2] = xml_get_real(mg_node, MICROGRAPH_MATRIX_3_3);
555 mg->hvec[0] = xml_get_real(mg_node, MICROGRAPH_HVEC_X);
556 mg->hvec[1] = xml_get_real(mg_node, MICROGRAPH_HVEC_Y);
557 mg->hvec[2] = xml_get_real(mg_node, MICROGRAPH_HVEC_Z);
558 mg->kvec[0] = xml_get_real(mg_node, MICROGRAPH_KVEC_X);
559 mg->kvec[1] = xml_get_real(mg_node, MICROGRAPH_KVEC_Y);
560 mg->kvec[2] = xml_get_real(mg_node, MICROGRAPH_KVEC_Z);
561 mg->lvec[0] = xml_get_real(mg_node, MICROGRAPH_LVEC_X);
562 mg->lvec[1] = xml_get_real(mg_node, MICROGRAPH_LVEC_Y);
563 mg->lvec[2] = xml_get_real(mg_node, MICROGRAPH_LVEC_Z);
564 mg->helix_axis = xml_get_real(mg_node, MICROGRAPH_HELIX_AXIS);
565 mg->helix_rise = xml_get_real(mg_node, MICROGRAPH_HELIX_RISE);
566 mg->helix_angle = xml_get_real(mg_node, MICROGRAPH_HELIX_ANGLE);
567 mg->helix_radius = xml_get_real(mg_node, MICROGRAPH_HELIX_RADIUS);
568 if ( mg->sampling < 1e3 ) mg->sampling *= 1e4;
569 if ( mg->magnification < 1e3 ) mg->magnification *= 1e3;
570 mg->ctf = ctf_from_xml(mg_node);
571 mg->tilt_axis *= M_PI/180.0;
572 mg->tilt_angle *= M_PI/180.0;
573 mg->rot_angle *= M_PI/180.0;
574 if ( xml_check_for_node(mg_node, PARTICLE_BOX_RADIUS) )
575 mg->box_size[0] = mg->box_size[1] = mg->box_size[2] =
576 2 * xml_get_integer(mg_node, PARTICLE_BOX_RADIUS);
577 if ( xml_check_for_node(mg_node, PARTICLE_BOX_RADIUS_X) ) {
578 mg->box_size[0] = 2 * xml_get_integer(mg_node, PARTICLE_BOX_RADIUS_X);
579 mg->box_size[1] = 2 * xml_get_integer(mg_node, PARTICLE_BOX_RADIUS_Y);
580 mg->box_size[2] = 2 * xml_get_integer(mg_node, PARTICLE_BOX_RADIUS_Z);
581 }
582 if ( xml_check_for_node(mg_node, PARTICLE_BOX_SIZE) )
583 mg->box_size[0] = mg->box_size[1] = mg->box_size[2] =
584 xml_get_integer(mg_node, PARTICLE_BOX_SIZE);
585 if ( xml_check_for_node(mg_node, PARTICLE_BOX_SIZE_X) ) {
586 mg->box_size[0] = xml_get_integer(mg_node, PARTICLE_BOX_SIZE_X);
587 mg->box_size[1] = xml_get_integer(mg_node, PARTICLE_BOX_SIZE_Y);
588 mg->box_size[2] = xml_get_integer(mg_node, PARTICLE_BOX_SIZE_Z);
589 }
590 mg->filament_width = xml_get_real(mg_node, FILAMENT_WIDTH);
591 mg->fil_node_radius = xml_get_real(mg_node, FILNODE_RADIUS);
592 mg->bad_radius = xml_get_real(mg_node, PARTICLE_BAD_RADIUS);
593 mg->sf_radius = xml_get_real(mg_node, REFLEX_RADIUS);
594 mg->mark_radius = xml_get_real(mg_node, MARKER_RADIUS);
595 for ( node = mg_node->xmlChildrenNode; node; node = node->next ) {
596 if ( !xmlStrcmp(node->name, BAD_CAST MICROGRAPH_FRAME) )
597 frame_from_xml(node, &mg->frame);
598 if ( !xmlStrcmp(node->name, BAD_CAST PARTICLE) )
599 particle_from_xml(node, &mg->part, project->fom_tag);
600 if ( !xmlStrcmp(node->name, BAD_CAST FILAMENT) )
601 filament_from_xml(node, &mg->fil);
602 if ( !xmlStrcmp(node->name, BAD_CAST PARTICLE_BAD) )
603 badarea_from_xml(node, &mg->bad);
604 if ( !xmlStrcmp(node->name, BAD_CAST MARKER) )
605 marker_from_xml(node, &mg->mark);
606 if ( !xmlStrcmp(node->name, BAD_CAST REFLEX) )
607 strucfac_from_xml(node, &mg->sf);
608 if ( !xmlStrcmp(node->name, BAD_CAST LAYERLINE) )
609 layerline_from_xml(node, &mg->layer);
610 }
611 }
612 }
613 } else if ( !xmlStrcmp(child_node->name, BAD_CAST MAP) ) {
614 id = xmlGetProp(child_node, BAD_CAST ID);
615 bid = (char *) id;
616 rec = reconstruction_add(&rec, bid);
617 if ( !project->rec ) project->rec = rec;
618 xmlFree(id);
619 rec->block = i++;
620 rec->select = 1;
621 rec->frec = xml_get_string(child_node, MAP_RECONSTRUCTION);
622 rec->fpart = xml_get_string(child_node, PARTICLE_FILE);
623 rec->ffil = xml_get_string(child_node, FILAMENT_FILE);
624 rec->fft = xml_get_string(child_node, MAP_TRANSFORM_FILE);
625 rec->fps = xml_get_string(child_node, MAP_POWERSPEC_FILE);
626 xml_copy_string(string, child_node, MAP_MODEL);
627 if ( strlen(string) ) string_add(&rec->model, string);
628 rec->select = xml_get_integer(child_node, MAP_SELECT);
629 rec->fom = xml_get_real(child_node, MAP_FOM);
630 rec->origin[0] = xml_get_real(child_node, MAP_ORIGIN_X);
631 rec->origin[1] = xml_get_real(child_node, MAP_ORIGIN_Y);
632 rec->origin[2] = xml_get_real(child_node, MAP_ORIGIN_Z);
633 rec->scale[0] = xml_get_real(child_node, MAP_SCALE_X);
634 rec->scale[1] = xml_get_real(child_node, MAP_SCALE_Y);
635 rec->scale[2] = xml_get_real(child_node, MAP_SCALE_Z);
636 rec->voxel_size = xml_get_real(child_node, MAP_VOXEL_SIZE);
637 rec->symmetry = xml_get_string(child_node, MAP_SYMMETRY);
638 if ( xml_check_for_node(child_node, CTF_DEF_AVG) )
639 rec->ctf = ctf_from_xml(child_node);
640 if ( xml_check_for_node(child_node, PARTICLE_BOX_RADIUS) )
641 rec->box_size[0] = rec->box_size[1] = rec->box_size[2] =
642 2 * xml_get_integer(child_node, PARTICLE_BOX_RADIUS);
643 if ( xml_check_for_node(child_node, PARTICLE_BOX_RADIUS_X) ) {
644 rec->box_size[0] = 2 * xml_get_integer(child_node, PARTICLE_BOX_RADIUS_X);
645 rec->box_size[1] = 2 * xml_get_integer(child_node, PARTICLE_BOX_RADIUS_Y);
646 rec->box_size[2] = 2 * xml_get_integer(child_node, PARTICLE_BOX_RADIUS_Z);
647 }
648 if ( xml_check_for_node(child_node, PARTICLE_BOX_SIZE) )
649 rec->box_size[0] = rec->box_size[1] = rec->box_size[2] =
650 xml_get_integer(child_node, PARTICLE_BOX_SIZE);
651 if ( xml_check_for_node(child_node, PARTICLE_BOX_SIZE_X) ) {
652 rec->box_size[0] = xml_get_integer(child_node, PARTICLE_BOX_SIZE_X);
653 rec->box_size[1] = xml_get_integer(child_node, PARTICLE_BOX_SIZE_Y);
654 rec->box_size[2] = xml_get_integer(child_node, PARTICLE_BOX_SIZE_Z);
655 }
656 rec->filament_width = xml_get_real(child_node, FILAMENT_WIDTH);
657 rec->fil_node_radius = xml_get_real(child_node, FILNODE_RADIUS);
658 rec->bad_radius = xml_get_real(child_node, PARTICLE_BAD_RADIUS);
659 rec->sf_radius = xml_get_real(child_node, REFLEX_RADIUS);
660 rec->mark_radius = xml_get_real(child_node, MARKER_RADIUS);
661 rec->view[0] = xml_get_real(child_node, MAP_VIEW_X);
662 rec->view[1] = xml_get_real(child_node, MAP_VIEW_Y);
663 rec->view[2] = xml_get_real(child_node, MAP_VIEW_Z);
664 rec->view[3] = xml_get_real(child_node, MAP_VIEW_ANGLE)*M_PI/180.0;
665 for ( node = child_node->xmlChildrenNode; node; node = node->next ) {
666 if ( !xmlStrcmp(node->name, BAD_CAST PARTICLE) )
667 particle_from_xml(node, &rec->part, project->fom_tag);
668 if ( !xmlStrcmp(node->name, BAD_CAST FILAMENT) )
669 filament_from_xml(node, &rec->fil);
670 if ( !xmlStrcmp(node->name, BAD_CAST PARTICLE_BAD) )
671 badarea_from_xml(node, &rec->bad);
672 if ( !xmlStrcmp(node->name, BAD_CAST MARKER) )
673 marker_from_xml(node, &rec->mark);
674 if ( !xmlStrcmp(node->name, BAD_CAST REFLEX) )
675 strucfac_from_xml(node, &rec->sf);
676 }
677 } else if ( !xmlStrcmp(child_node->name, BAD_CAST CLASS_AVERAGE) ) {
678 for ( node = child_node->xmlChildrenNode; node; node = node->next )
679 if ( !xmlStrcmp(node->name, BAD_CAST PARTICLE) )
680 particle_from_xml(node, &project->class_avg, project->fom_tag);
681 }
682 }
683
684 return err;
685 }
686
687 int ctf_to_xml(CTFparam* ctf, xmlNodePtr parent)
688 {
689 if ( !ctf ) return -1;
690
691 Bstring s;
692
693 xml_set_real(parent, CTF_VOLTAGE, ctf->volt(), "%g");
694 xml_set_real(parent, CTF_CS, ctf->Cs(), "%g");
695 xml_set_real(parent, CTF_CC, ctf->Cc(), "%g");
696 xml_set_real(parent, CTF_ALPHA, ctf->alpha(), "%g");
697 xml_set_real(parent, CTF_DE, ctf->dE(), "%g");
698 xml_set_real(parent, CTF_AMP_SHIFT, ctf->amp_shift(), "%g");
699 xml_set_real(parent, CTF_DEF_AVG, ctf->defocus_average(), "%g");
700 xml_set_real(parent, CTF_DEF_DEV, ctf->defocus_deviation(), "%g");
701 xml_set_real(parent, CTF_AST_ANG, ctf->astigmatism_angle()*180.0/M_PI, "%g");
702 xml_set_real(parent, CTF_ZERO, ctf->zero(1), "%g");
703 if ( ctf->baseline_type() ) {
704 s = ctf->baseline_equation();
705 xmlNewChild(parent, NULL, BAD_CAST CTF_BASELINE, BAD_CAST s.c_str());
706 }
707 if ( ctf->envelope(0) ) {
708 s = ctf->envelope_equation();
709 xmlNewChild(parent, NULL, BAD_CAST CTF_ENVELOPE, BAD_CAST s.c_str());
710 }
711
712 return 1;
713 }
714
715 int frame_to_xml(Bframe* framelist, xmlNodePtr parent)
716 {
717 int nframe(0);
718 Bframe* frame = NULL;
719 xmlNodePtr frame_node = NULL;
720
721 for ( frame=framelist; frame; frame=frame->next, nframe++ ) {
722 frame_node = xmlNewChild(parent, NULL, BAD_CAST MICROGRAPH_FRAME, NULL);
723 xml_set_integer_attribute(frame_node, ID, frame->id, "%d");
724 xml_set_real(frame_node, MICROGRAPH_FRAME_SHIFT_X, frame->shift[0], "%7.3f");
725 xml_set_real(frame_node, MICROGRAPH_FRAME_SHIFT_Y, frame->shift[1], "%7.3f");
726 xml_set_real(frame_node, MICROGRAPH_FRAME_FOM, frame->fom, "%7.4lf");
727 xml_set_integer(frame_node, MICROGRAPH_FRAME_SELECT, frame->sel, "%4d");
728 }
729
730 return nframe;
731 }
732
733 xmlNodePtr particle_to_xml(Bparticle* part, xmlNodePtr parent, int euler_flag, int omega_flag, FOMType fom_tag[NFOM])
734 {
735 int f;
736 char tag[128];
737 Euler euler;
738
739 xmlNodePtr part_node = NULL;
740
741 if ( parent ) part_node = xmlNewChild(parent, NULL, BAD_CAST PARTICLE, NULL);
742 else part_node = xmlNewNode(NULL, BAD_CAST PARTICLE);
743 // cout << "part_node=" << part_node << endl;
744
745 if ( part->fpart.length() )
746 xmlNewProp(part_node, BAD_CAST PARTICLE_FILE, BAD_CAST part->fpart.c_str());
747 xml_set_integer_attribute(part_node, ID, part->id, "%d");
748 xml_set_integer(part_node, PARTICLE_GROUP, part->group, "%d");
749
750 if ( part->def ) {
751 xml_set_real(part_node, PARTICLE_DEFOCUS, part->def, "%g");
752 xml_set_real(part_node, PARTICLE_DEF_DEV, part->dev, "%g");
753 xml_set_real(part_node, PARTICLE_AST_ANG, part->ast, "%g");
754 }
755
756 xml_set_real(part_node, PARTICLE_MAGNIF, part->mag, "%g");
757 xml_set_real(part_node, PARTICLE_X, part->loc[0], "%7.2f");
758 xml_set_real(part_node, PARTICLE_Y, part->loc[1], "%7.2f");
759 xml_set_real(part_node, PARTICLE_Z, part->loc[2], "%7.2f");
760 xml_set_real(part_node, PARTICLE_PIXEL, part->pixel_size, "%7.4f");
761 xml_set_real(part_node, PARTICLE_ORIGIN_X, part->ori[0], "%7.3f");
762 xml_set_real(part_node, PARTICLE_ORIGIN_Y, part->ori[1], "%7.3f");
763 xml_set_real(part_node, PARTICLE_ORIGIN_Z, part->ori[2], "%7.3f");
764
765 if ( euler_flag < 1 ) {
766 xml_set_real(part_node, PARTICLE_VIEW_X, part->view[0], "%7.4lf");
767 xml_set_real(part_node, PARTICLE_VIEW_Y, part->view[1], "%7.4lf");
768 xml_set_real(part_node, PARTICLE_VIEW_Z, part->view[2], "%7.4lf");
769 xml_set_real(part_node, PARTICLE_VIEW_ANGLE, part->view.angle()*180.0/M_PI, "%7.2lf");
770 } else {
771 euler = Euler(part->view);
772 if ( omega_flag ) euler[0] = -euler.psi();
773 xml_set_real(part_node, PARTICLE_PHI, euler.phi()*180.0/M_PI, "%7.2f");
774 xml_set_real(part_node, PARTICLE_THETA, euler.theta()*180.0/M_PI, "%7.2f");
775 xml_set_real(part_node, PARTICLE_PSI, euler.psi()*180.0/M_PI, "%7.2f");
776 }
777
778 for ( f=0; f<NFOM; f++ ) if ( fom_tag[f] ) {
779 get_fom_tag(fom_tag[f], tag);
780 if ( strlen(tag) > 1 ) {
781 xml_set_real(part_node, tag, part->fom[f], "%7.4f");
782 }
783 }
784
785 xml_set_integer(part_node, PARTICLE_SELECT, part->sel, "%4d");
786
787 return part_node;
788 }
789
790 int filament_to_xml(Bfilament* fillist, xmlNodePtr parent)
791 {
792 int nfil(0);
793 Bfilament* fil;
794 Bfilnode* fnode = NULL;
795 xmlNodePtr fil_node = NULL;
796 xmlNodePtr fnode_node = NULL;
797
798 for ( fil=fillist; fil; fil=fil->next, nfil++ ) {
799 fil_node = xmlNewChild(parent, NULL, BAD_CAST FILAMENT, NULL);
800 xml_set_integer_attribute(fil_node, ID, fil->id, "%5d");
801 for ( fnode=fil->node; fnode; fnode=fnode->next ) {
802 fnode_node = xmlNewChild(fil_node, NULL, BAD_CAST FILAMENT_NODE, NULL);
803 xml_set_integer_attribute(fnode_node, ID, fnode->id, "%5d");
804 xml_set_real(fnode_node, FILAMENT_NODE_X, fnode->loc[0], "%7.2f");
805 xml_set_real(fnode_node, FILAMENT_NODE_Y, fnode->loc[1], "%7.2f");
806 xml_set_real(fnode_node, FILAMENT_NODE_Z, fnode->loc[2], "%7.2f");
807 }
808 }
809
810 return nfil;
811 }
812
813 int badarea_to_xml(Bbadarea* badlist, xmlNodePtr parent)
814 {
815 int nbad(0);
816 Bbadarea* bad;
817 xmlNodePtr bad_node = NULL;
818
819 for ( bad=badlist; bad; bad=bad->next, nbad++ ) {
820 bad_node = xmlNewChild(parent, NULL, BAD_CAST PARTICLE_BAD, NULL);
821 xml_set_real(bad_node, PARTICLE_BAD_X, bad->loc[0], "%7.2f");
822 xml_set_real(bad_node, PARTICLE_BAD_Y, bad->loc[1], "%7.2f");
823 xml_set_real(bad_node, PARTICLE_BAD_Z, bad->loc[2], "%7.2f");
824 }
825
826 return nbad;
827 }
828
829 int marker_to_xml(Bmarker* marklist, xmlNodePtr parent)
830 {
831 int nmark(0);
832 Bmarker* mark;
833 xmlNodePtr mark_node = NULL;
834
835 for ( mark=marklist; mark; mark=mark->next, nmark++ ) {
836 mark_node = xmlNewChild(parent, NULL, BAD_CAST MARKER, NULL);
837 xml_set_integer_attribute(mark_node, ID, mark->id, "%5d");
838 xml_set_real(mark_node, MARKER_X, mark->loc[0], "%7.2f");
839 xml_set_real(mark_node, MARKER_Y, mark->loc[1], "%7.2f");
840 xml_set_real(mark_node, MARKER_Z, mark->loc[2], "%7.2f");
841 xml_set_real(mark_node, MARKER_ERROR_X, mark->err[0], "%7.2f");
842 xml_set_real(mark_node, MARKER_ERROR_Y, mark->err[1], "%7.2f");
843 xml_set_real(mark_node, MARKER_ERROR_Z, mark->err[2], "%7.2f");
844 xml_set_real(mark_node, MARKER_RESIDUAL, mark->res, "%7.4f");
845 xml_set_real(mark_node, MARKER_FOM, mark->fom, "%7.4f");
846 xml_set_integer(mark_node, MARKER_SELECT, mark->sel, "%d");
847 }
848
849 return nmark;
850 }
851
852 int strucfac_to_xml(Bstrucfac* sflist, xmlNodePtr parent)
853 {
854 int nsf(0);
855 Bstrucfac* sf = NULL;
856 xmlNodePtr sf_node = NULL;
857
858 for ( sf=sflist; sf; sf=sf->next, nsf++ ) {
859 sf_node = xmlNewChild(parent, NULL, BAD_CAST REFLEX, NULL);
860 xml_set_integer(sf_node, REFLEX_H, sf->index[0], "%4d");
861 xml_set_integer(sf_node, REFLEX_K, sf->index[1], "%4d");
862 xml_set_integer(sf_node, REFLEX_L, sf->index[2], "%4d");
863 xml_set_real(sf_node, REFLEX_X, sf->loc[0], "%7.2f");
864 xml_set_real(sf_node, REFLEX_Y, sf->loc[1], "%7.2f");
865 xml_set_real(sf_node, REFLEX_Z, sf->loc[2], "%7.2f");
866 xml_set_real(sf_node, REFLEX_AMP, sf->amp, "%7.2f");
867 xml_set_real(sf_node, REFLEX_SIGAMP, sf->sigamp, "%7.2f");
868 xml_set_real(sf_node, REFLEX_PHI, sf->phi, "%7.2f");
869 xml_set_real(sf_node, REFLEX_SIGPHI, sf->sigphi, "%7.2f");
870 xml_set_real(sf_node, REFLEX_FOM, sf->fom, "%7.4f");
871 xml_set_integer(sf_node, REFLEX_STATUS, sf->sel, "%4d");
872 }
873
874 return nsf;
875 }
876
877 int layerline_to_xml(Blayerline* linelist, xmlNodePtr parent)
878 {
879 int nll(0);
880 Blayerline* line = NULL;
881 xmlNodePtr ll_node = NULL;
882
883 for ( line=linelist; line; line=line->next, nll++ ) {
884 ll_node = xmlNewChild(parent, NULL, BAD_CAST LAYERLINE, NULL);
885 xml_set_integer(ll_node, LAYERLINE_NUMBER, line->number, "%4d");
886 xml_set_integer(ll_node, LAYERLINE_ORDER, line->order, "%4d");
887 xml_set_real(ll_node, LAYERLINE_DISTANCE, line->distance, "%7.2f");
888 xml_set_real(ll_node, LAYERLINE_FREQ, line->freq, "%7.4f");
889 xml_set_real(ll_node, LAYERLINE_AMP, line->amp, "%7.2f");
890 xml_set_real(ll_node, LAYERLINE_FOM, line->fom, "%7.2f");
891 xml_set_integer(ll_node, LAYERLINE_SELECT, line->sel, "%4d");
892 }
893
894 return nll;
895 }
896
897 /*
898 @brief Converts micrograph data from an project structure to a XML document.
899 @param Bproject* project parameter structure.
900 @param xmlDocPtr doc XML document.
901 @param mg_select flag to only write selected micrographs.
902 @param rec_select flag to only convert selected reconstructions.
903 @return int error code (<0 means failure).
904
905 The function packes new micrograph data back into an existing XML
906 document from which the old project parameters were obtained.
907 All angles used internally are in radians, and are converted here
908 to degrees for output. The angles within the micrograph structure
909 are left in radians.
910 The stylesheet written into the document is "Bsoft_micrograph.xsl".
911 **/
912 int project_to_xml(Bproject* project, xmlDocPtr doc, int mg_select, int rec_select)
913 {
914 int err(0);
915
916 Bfield* field = NULL;
917 Bmicrograph* mg = NULL;
918 Breconstruction* rec = NULL;
919 Bparticle* part;
920 Bstring* data = NULL;
921
922 int i, j, sel, npart(0);
923
924 xmlNodePtr node = xmlNewDocPI(doc, BAD_CAST "xml-stylesheet",
925 BAD_CAST "href=\"Bsoft_micrograph.xsl\" type=\"text/xsl\"");
926 xmlDocSetRootElement(doc, node);
927
928 xmlNodePtr project_node = xmlNewNode(NULL, BAD_CAST PROJECT);
929 // xmlDocSetRootElement(doc, project_node);
930
931 xmlAddSibling(node, project_node);
932
933 xmlNodePtr field_node = NULL;
934 xmlNodePtr mg_node = NULL;
935 xmlNodePtr rec_node = NULL;
936
937 xmlNewChild(project_node, NULL, BAD_CAST COMMENT, BAD_CAST project->comment.c_str());
938
939 for ( data = project->reference; data; data=data->next )
940 xmlNewChild(project_node, NULL, BAD_CAST MAP_REFERENCE, BAD_CAST data->c_str());
941
942 for ( i=0, field=project->field; field; field=field->next ) {
943 sel = 0;
944 if ( project->split ) {
945 if ( mg_select < 0 ) sel = 1;
946 else for ( j=i, mg=field->mg; mg; mg=mg->next, j++ ) if ( j==mg_select ) sel = 1;
947 } else {
948 if ( mg_select < 1 ) sel = 1;
949 else for ( mg=field->mg; mg; mg=mg->next ) if ( mg->select ) sel = 1;
950 }
951 if ( sel ) {
952 field_node = xmlNewChild(project_node, NULL, BAD_CAST FIELD, NULL);
953 xmlNewProp(field_node, BAD_CAST ID, BAD_CAST field->id.c_str());
954 }
955 for ( mg=field->mg; mg; mg=mg->next, i++ ) {
956 sel = 0;
957 if ( project->split ) {
958 if ( i==mg_select || mg_select < 0 ) sel = 1;
959 } else {
960 if ( mg_select < 1 || mg->select > 0 ) sel = 1;
961 }
962 if ( sel ) {
963 mg_node = xmlNewChild(field_node, NULL, BAD_CAST MICROGRAPH, NULL);
964 xmlNewProp(mg_node, BAD_CAST ID, BAD_CAST mg->id.c_str());
965 node = xml_set_integer(mg_node, MICROGRAPH_NUMBER, mg->img_num, "%d");
966 if ( mg->fmg.length() > 0 )
967 xmlNewChild(mg_node, NULL, BAD_CAST MICROGRAPH_FILE, BAD_CAST mg->fmg.c_str());
968 if ( mg->fframe.length() > 0 )
969 xmlNewChild(mg_node, NULL, BAD_CAST MICROGRAPH_FRAMES_FILE, BAD_CAST mg->fframe.c_str());
970 if ( mg->fpart.length() > 0 )
971 xmlNewChild(mg_node, NULL, BAD_CAST PARTICLE_FILE, BAD_CAST mg->fpart.c_str());
972 if ( mg->ffil.length() > 0 )
973 xmlNewChild(mg_node, NULL, BAD_CAST FILAMENT_FILE, BAD_CAST mg->ffil.c_str());
974 if ( mg->fft.length() > 0 )
975 xmlNewChild(mg_node, NULL, BAD_CAST MICROGRAPH_TRANSFORM_FILE, BAD_CAST mg->fft.c_str());
976 if ( mg->fps.length() > 0 )
977 xmlNewChild(mg_node, NULL, BAD_CAST MICROGRAPH_POWERSPEC_FILE, BAD_CAST mg->fps.c_str());
978 xml_set_integer(mg_node, MICROGRAPH_SELECT, mg->select, "%d");
979 xml_set_real(mg_node, MICROGRAPH_FOM, mg->fom, "%g");
980 xml_set_real(mg_node, MICROGRAPH_MAGNIFICATION, mg->magnification, "%g");
981 xml_set_real(mg_node, MICROGRAPH_SAMPLING, mg->sampling, "%g");
982 xml_set_real(mg_node, MICROGRAPH_PIXEL, mg->pixel_size, "%g");
983 xml_set_real(mg_node, MICROGRAPH_DOSE, mg->dose, "%g");
984 xml_set_real(mg_node, MICROGRAPH_TILT_AXIS, mg->tilt_axis*180.0/M_PI, "%g");
985 xml_set_real(mg_node, MICROGRAPH_TILT_ANGLE, mg->tilt_angle*180.0/M_PI, "%g");
986 xml_set_real(mg_node, MICROGRAPH_ROT_ANGLE, mg->rot_angle*180.0/M_PI, "%g");
987 xml_set_real(mg_node, MICROGRAPH_ORIGIN_X, mg->origin[0], "%g");
988 xml_set_real(mg_node, MICROGRAPH_ORIGIN_Y, mg->origin[1], "%g");
989 xml_set_real(mg_node, MICROGRAPH_ORIGIN_Z, mg->origin[2], "%g");
990 xml_set_real(mg_node, MICROGRAPH_SCALE_X, mg->scale[0], "%g");
991 xml_set_real(mg_node, MICROGRAPH_SCALE_Y, mg->scale[1], "%g");
992 xml_set_real(mg_node, MICROGRAPH_SCALE_Z, mg->scale[2], "%g");
993 xml_set_real(mg_node, MICROGRAPH_MATRIX_1_1, mg->matrix[0][0], "%g");
994 xml_set_real(mg_node, MICROGRAPH_MATRIX_1_2, mg->matrix[0][1], "%g");
995 xml_set_real(mg_node, MICROGRAPH_MATRIX_1_3, mg->matrix[0][2], "%g");
996 xml_set_real(mg_node, MICROGRAPH_MATRIX_2_1, mg->matrix[1][0], "%g");
997 xml_set_real(mg_node, MICROGRAPH_MATRIX_2_2, mg->matrix[1][1], "%g");
998 xml_set_real(mg_node, MICROGRAPH_MATRIX_2_3, mg->matrix[1][2], "%g");
999 xml_set_real(mg_node, MICROGRAPH_MATRIX_3_1, mg->matrix[2][0], "%g");
1000 xml_set_real(mg_node, MICROGRAPH_MATRIX_3_2, mg->matrix[2][1], "%g");
1001 xml_set_real(mg_node, MICROGRAPH_MATRIX_3_3, mg->matrix[2][2], "%g");
1002 xml_set_real(mg_node, MICROGRAPH_HVEC_X, mg->hvec[0], "%f");
1003 xml_set_real(mg_node, MICROGRAPH_HVEC_Y, mg->hvec[1], "%f");
1004 xml_set_real(mg_node, MICROGRAPH_HVEC_Z, mg->hvec[2], "%f");
1005 xml_set_real(mg_node, MICROGRAPH_KVEC_X, mg->kvec[0], "%f");
1006 xml_set_real(mg_node, MICROGRAPH_KVEC_Y, mg->kvec[1], "%f");
1007 xml_set_real(mg_node, MICROGRAPH_KVEC_Z, mg->kvec[2], "%f");
1008 xml_set_real(mg_node, MICROGRAPH_LVEC_X, mg->lvec[0], "%f");
1009 xml_set_real(mg_node, MICROGRAPH_LVEC_Y, mg->lvec[1], "%f");
1010 xml_set_real(mg_node, MICROGRAPH_LVEC_Z, mg->lvec[2], "%f");
1011 xml_set_real(mg_node, MICROGRAPH_HELIX_AXIS, mg->helix_axis*180.0/M_PI, "%f");
1012 xml_set_real(mg_node, MICROGRAPH_HELIX_RISE, mg->helix_rise, "%f");
1013 xml_set_real(mg_node, MICROGRAPH_HELIX_ANGLE, mg->helix_angle*180.0/M_PI, "%f");
1014 xml_set_real(mg_node, MICROGRAPH_HELIX_RADIUS, mg->helix_radius, "%f");
1015 xml_set_real(mg_node, PARTICLE_BOX_SIZE_X, mg->box_size[0], "%g");
1016 xml_set_real(mg_node, PARTICLE_BOX_SIZE_Y, mg->box_size[1], "%g");
1017 xml_set_real(mg_node, PARTICLE_BOX_SIZE_Z, mg->box_size[2], "%g");
1018 xml_set_real(mg_node, FILAMENT_WIDTH, mg->filament_width, "%g");
1019 xml_set_real(mg_node, FILNODE_RADIUS, mg->fil_node_radius, "%g");
1020 xml_set_real(mg_node, PARTICLE_BAD_RADIUS, mg->bad_radius, "%g");
1021 xml_set_real(mg_node, REFLEX_RADIUS, mg->sf_radius, "%g");
1022 xml_set_real(mg_node, MARKER_RADIUS, mg->mark_radius, "%g");
1023 frame_to_xml(mg->frame, mg_node);
1024 ctf_to_xml(mg->ctf, mg_node);
1025 for ( part=mg->part; part; part=part->next, npart++ )
1026 particle_to_xml(part, mg_node, project->euler_flag, project->omega_flag, project->fom_tag);
1027 filament_to_xml(mg->fil, mg_node);
1028 badarea_to_xml(mg->bad, mg_node);
1029 marker_to_xml(mg->mark, mg_node);
1030 strucfac_to_xml(mg->sf, mg_node);
1031 layerline_to_xml(mg->layer, mg_node);
1032 if ( verbose & VERB_FULL )
1033 cout << "Writing field \"" << field->id << "\", micrograph \""
1034 << mg->id << "\" with " << npart << " particles" << endl;
1035 }
1036 }
1037 }
1038
1039 for ( rec = project->rec; rec; rec = rec->next ) {
1040 sel = 0;
1041 if ( project->split ) {
1042 if ( i==rec_select || rec_select < 0 ) sel = 1;
1043 } else {
1044 if ( rec_select < 1 || rec->select > 0 ) sel = 1;
1045 }
1046 if ( sel ) {
1047 rec_node = xmlNewChild(project_node, NULL, BAD_CAST MAP, NULL);
1048 xmlNewProp(rec_node, BAD_CAST ID, BAD_CAST rec->id.c_str());
1049 if ( rec->frec.length() > 0 )
1050 xmlNewChild(rec_node, NULL, BAD_CAST MAP_RECONSTRUCTION, BAD_CAST rec->frec.c_str());
1051 if ( rec->fft.length() > 0 )
1052 xmlNewChild(rec_node, NULL, BAD_CAST MAP_TRANSFORM_FILE, BAD_CAST rec->fft.c_str());
1053 if ( rec->fps.length() > 0 )
1054 xmlNewChild(rec_node, NULL, BAD_CAST MAP_POWERSPEC_FILE, BAD_CAST rec->fps.c_str());
1055 if ( rec->fpart.length() > 0 && !rec->part->fpart.length() )
1056 xmlNewChild(rec_node, NULL, BAD_CAST PARTICLE_FILE, BAD_CAST rec->fpart.c_str());
1057 if ( rec->ffil.length() > 0 )
1058 xmlNewChild(rec_node, NULL, BAD_CAST FILAMENT_FILE, BAD_CAST rec->ffil.c_str());
1059 // Note: Should be a list
1060 if ( rec->model )
1061 xmlNewChild(rec_node, NULL, BAD_CAST MAP_MODEL, BAD_CAST rec->model->c_str());
1062 xml_set_integer(rec_node, MAP_SELECT, rec->select, "%d");
1063 xml_set_real(rec_node, MAP_FOM, rec->fom, "%g");
1064 xml_set_real(rec_node, MAP_ORIGIN_X, rec->origin[0], "%g");
1065 xml_set_real(rec_node, MAP_ORIGIN_Y, rec->origin[1], "%g");
1066 xml_set_real(rec_node, MAP_ORIGIN_Z, rec->origin[2], "%g");
1067 xml_set_real(rec_node, MAP_SCALE_X, rec->scale[0], "%g");
1068 xml_set_real(rec_node, MAP_SCALE_Y, rec->scale[1], "%g");
1069 xml_set_real(rec_node, MAP_SCALE_Z, rec->scale[2], "%g");
1070 xml_set_real(rec_node, MAP_VOXEL_SIZE, rec->voxel_size, "%g");
1071 if ( rec->symmetry.length() > 0 )
1072 xmlNewChild(rec_node, NULL, BAD_CAST MAP_SYMMETRY, BAD_CAST rec->symmetry.c_str());
1073 ctf_to_xml(rec->ctf, rec_node);
1074 xml_set_real(rec_node, PARTICLE_BOX_SIZE_X, rec->box_size[0], "%g");
1075 xml_set_real(rec_node, PARTICLE_BOX_SIZE_Y, rec->box_size[1], "%g");
1076 xml_set_real(rec_node, PARTICLE_BOX_SIZE_Z, rec->box_size[2], "%g");
1077 xml_set_real(rec_node, PARTICLE_BAD_RADIUS, rec->bad_radius, "%g");
1078 xml_set_real(rec_node, FILAMENT_WIDTH, rec->filament_width, "%g");
1079 xml_set_real(rec_node, FILNODE_RADIUS, rec->fil_node_radius, "%g");
1080 xml_set_real(rec_node, REFLEX_RADIUS, rec->sf_radius, "%g");
1081 xml_set_real(rec_node, MARKER_RADIUS, rec->mark_radius, "%g");
1082 xml_set_real(rec_node, MAP_VIEW_X, rec->view[0], "%g");
1083 xml_set_real(rec_node, MAP_VIEW_Y, rec->view[1], "%g");
1084 xml_set_real(rec_node, MAP_VIEW_Z, rec->view[2], "%g");
1085 xml_set_real(rec_node, MAP_VIEW_ANGLE, rec->view.angle()*180.0/M_PI, "%g");
1086 xml_set_real(rec_node, FILNODE_RADIUS, rec->fil_node_radius, "%g");
1087 xml_set_real(rec_node, FILNODE_RADIUS, rec->fil_node_radius, "%g");
1088 for ( part=rec->part; part; part=part->next, npart++ )
1089 particle_to_xml(part, rec_node, project->euler_flag, project->omega_flag, project->fom_tag);
1090 filament_to_xml(rec->fil, rec_node);
1091 badarea_to_xml(rec->bad, rec_node);
1092 marker_to_xml(rec->mark, rec_node);
1093 strucfac_to_xml(rec->sf, rec_node);
1094 }
1095 }
1096
1097 if ( project->class_avg ) {
1098 xmlNewChild(project_node, NULL, BAD_CAST CLASS_AVERAGE, NULL);
1099 for ( part=project->class_avg; part; part=part->next, npart++ )
1100 particle_to_xml(part, node, project->euler_flag, project->omega_flag, project->fom_tag);
1101 }
1102
1103 return err;
1104 }
1105
1106 #endif
1107
REFLEX_K
#define REFLEX_K
Definition: mg_tags.h:289
Breconstruction::fil
Bfilament * fil
Definition: mg_processing.h:305
Bproject::reference
Bstring * reference
Definition: mg_processing.h:338
filament_node_add
Bfilnode * filament_node_add(Bfilnode **fnode, int pid)
Adds a filament node parameter structure to a linked list.
Definition: mg_processing.cpp:655
Bparticle::id
int id
Definition: mg_processing.h:92
rwmg.h
Header file for reading and writing micrograph parameters.
MICROGRAPH_HELIX_RISE
#define MICROGRAPH_HELIX_RISE
Definition: mg_tags.h:114
MICROGRAPH_MAGNIFICATION
#define MICROGRAPH_MAGNIFICATION
Definition: mg_tags.h:76
CTFparam::zero
double zero(int i)
Definition: ctf.h:218
MICROGRAPH_FRAME_SHIFT_X
#define MICROGRAPH_FRAME_SHIFT_X
Definition: mg_tags.h:63
CTFparam::Cs
double Cs()
Definition: ctf.h:87
PARTICLE_OMEGA
#define PARTICLE_OMEGA
Definition: mg_tags.h:192
Bparticle::pixel_size
double pixel_size
Definition: mg_processing.h:98
Bframe::shift
Vector3< double > shift
Definition: mg_processing.h:77
MARKER_Y
#define MARKER_Y
Definition: mg_tags.h:272
Bmicrograph::sf_radius
double sf_radius
Definition: mg_processing.h:234
string_add
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Definition: Bstring.cpp:705
LAYERLINE_DISTANCE
#define LAYERLINE_DISTANCE
Definition: mg_tags.h:303
CTFparam::baseline_type
long baseline_type()
Definition: ctf.h:106
CTFparam::dE
double dE()
Definition: ctf.h:93
Bparticle::ast
double ast
Definition: mg_processing.h:97
Bproject::rec
Breconstruction * rec
Definition: mg_processing.h:344
Bparticle::mag
double mag
Definition: mg_processing.h:94
MAP_VIEW_ANGLE
#define MAP_VIEW_ANGLE
Definition: mg_tags.h:53
PARTICLE_HANDB_FOM
#define PARTICLE_HANDB_FOM
Definition: mg_tags.h:218
CTF_DEF_DEV
#define CTF_DEF_DEV
Definition: mg_tags.h:163
MAP_MODEL
#define MAP_MODEL
Definition: mg_tags.h:55
MARKER_RESIDUAL
#define MARKER_RESIDUAL
Definition: mg_tags.h:278
PARTICLE_ORIGIN_X
#define PARTICLE_ORIGIN_X
Definition: mg_tags.h:186
MICROGRAPH_SCALE_Z
#define MICROGRAPH_SCALE_Z
Definition: mg_tags.h:86
Euler
Definition: Euler.h:28
xml_check_for_node
int xml_check_for_node(xmlNodePtr parent, const char *tag)
Bparticle::view
View view
Definition: mg_processing.h:101
Breconstruction::part
Bparticle * part
Definition: mg_processing.h:304
CTF_ZERO
#define CTF_ZERO
Definition: mg_tags.h:161
Breconstruction::mark
Bmarker * mark
Definition: mg_processing.h:307
CTF_ALPHA
#define CTF_ALPHA
Definition: mg_tags.h:157
Breconstruction::fpart
Bstring fpart
Definition: mg_processing.h:288
Bmicrograph::id
Bstring id
Definition: mg_processing.h:202
Bbadarea
Definition: mg_processing.h:142
Bmicrograph::helix_rise
double helix_rise
Definition: mg_processing.h:227
FILAMENT_WIDTH
#define FILAMENT_WIDTH
Definition: mg_tags.h:252
xml_get_integer
long xml_get_integer(xmlNodePtr parent, const char *tag)
Bmicrograph::img_num
int img_num
Definition: mg_processing.h:211
PARTICLE_BOX_RADIUS_X
#define PARTICLE_BOX_RADIUS_X
Definition: mg_tags.h:231
MAP_VIEW_Y
#define MAP_VIEW_Y
Definition: mg_tags.h:51
MAP_SCALE_Z
#define MAP_SCALE_Z
Definition: mg_tags.h:45
PARTICLE_Y
#define PARTICLE_Y
Definition: mg_tags.h:181
MICROGRAPH_KVEC_Z
#define MICROGRAPH_KVEC_Z
Definition: mg_tags.h:109
MICROGRAPH_ORIGIN_Z
#define MICROGRAPH_ORIGIN_Z
Definition: mg_tags.h:83
MICROGRAPH_NUMBER
#define MICROGRAPH_NUMBER
Definition: mg_tags.h:73
Bmicrograph::sampling
double sampling
Definition: mg_processing.h:213
Breconstruction::filament_width
double filament_width
Definition: mg_processing.h:297
xml_find_node
xmlNodePtr xml_find_node(xmlNodePtr parent, const char *tag)
Bfilnode
Definition: mg_processing.h:115
utilities.h
Header file for general utilities.
CTFparam::astigmatism_angle
double astigmatism_angle()
Definition: ctf.h:104
Breconstruction::fom
double fom
Definition: mg_processing.h:302
PARTICLE_ORIGIN_Z
#define PARTICLE_ORIGIN_Z
Definition: mg_tags.h:188
MICROGRAPH_MATRIX_1_1
#define MICROGRAPH_MATRIX_1_1
Definition: mg_tags.h:95
PARTICLE_BOX_SIZE_Z
#define PARTICLE_BOX_SIZE_Z
Definition: mg_tags.h:229
Bmicrograph::filament_width
double filament_width
Definition: mg_processing.h:231
Breconstruction
Definition: mg_processing.h:280
Bproject::split
int split
Definition: mg_processing.h:337
Bstrucfac::loc
Vector3< double > loc
Definition: mg_processing.h:157
MARKER_SELECT
#define MARKER_SELECT
Definition: mg_tags.h:280
PARTICLE_BOX_SIZE
#define PARTICLE_BOX_SIZE
Definition: mg_tags.h:226
Breconstruction::sf_radius
double sf_radius
Definition: mg_processing.h:300
MICROGRAPH_MATRIX_2_3
#define MICROGRAPH_MATRIX_2_3
Definition: mg_tags.h:100
PARTICLE_BOX_RADIUS_Y
#define PARTICLE_BOX_RADIUS_Y
Definition: mg_tags.h:232
MARKER_FOM
#define MARKER_FOM
Definition: mg_tags.h:279
Blayerline::sel
long sel
Definition: mg_processing.h:182
MAP_TRANSFORM_FILE
#define MAP_TRANSFORM_FILE
Definition: mg_tags.h:35
Bmicrograph::lvec
Vector3< double > lvec
Definition: mg_processing.h:225
REFLEX_STATUS
#define REFLEX_STATUS
Definition: mg_tags.h:297
PARTICLE_PHI
#define PARTICLE_PHI
Definition: mg_tags.h:191
Bbadarea::loc
Vector3< double > loc
Definition: mg_processing.h:145
MICROGRAPH_LVEC_Y
#define MICROGRAPH_LVEC_Y
Definition: mg_tags.h:111
Bparticle::fom
double fom[NFOM]
Definition: mg_processing.h:102
PARTICLE_PSI
#define PARTICLE_PSI
Definition: mg_tags.h:189
MICROGRAPH_MATRIX_3_2
#define MICROGRAPH_MATRIX_3_2
Definition: mg_tags.h:102
Bmarker
Definition: marker.h:21
add_item
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
Definition: linked_list.cpp:26
rwxml.h
Reads and writes micrograph XML files.
frame_add
Bframe * frame_add(Bframe **frame, int pid)
Adds a movie frame parameter structure to a linked list.
Definition: mg_processing.cpp:495
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
MICROGRAPH_KVEC_Y
#define MICROGRAPH_KVEC_Y
Definition: mg_tags.h:108
Bmicrograph::pixel_size
double pixel_size
Definition: mg_processing.h:214
project
Bproject * project
Definition: bshow.cpp:31
Bmicrograph::kvec
Vector3< double > kvec
Definition: mg_processing.h:224
PARTICLE_GROUP
#define PARTICLE_GROUP
Definition: mg_tags.h:175
FILAMENT_NODE
#define FILAMENT_NODE
Definition: mg_tags.h:247
MICROGRAPH_FILE
#define MICROGRAPH_FILE
Definition: mg_tags.h:60
Breconstruction::ctf
CTFparam * ctf
Definition: mg_processing.h:303
Bmicrograph::dose
double dose
Definition: mg_processing.h:215
REFLEX_Z
#define REFLEX_Z
Definition: mg_tags.h:287
MICROGRAPH_FRAME_FOM
#define MICROGRAPH_FRAME_FOM
Definition: mg_tags.h:66
FILAMENT_NODE_Y
#define FILAMENT_NODE_Y
Definition: mg_tags.h:250
PARTICLE_BOX_SIZE_Y
#define PARTICLE_BOX_SIZE_Y
Definition: mg_tags.h:228
MARKER
#define MARKER
Definition: mg_tags.h:268
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:107
PARTICLE_THETA
#define PARTICLE_THETA
Definition: mg_tags.h:190
FILAMENT_NODE_X
#define FILAMENT_NODE_X
Definition: mg_tags.h:249
MICROGRAPH_PIXEL
#define MICROGRAPH_PIXEL
Definition: mg_tags.h:78
ID
#define ID
Definition: mg_tags.h:22
Bframe::sel
long sel
Definition: mg_processing.h:79
Bproject::omega_flag
int omega_flag
Definition: mg_processing.h:341
MICROGRAPH_HVEC_Y
#define MICROGRAPH_HVEC_Y
Definition: mg_tags.h:105
Bmicrograph::fil
Bfilament * fil
Definition: mg_processing.h:240
MICROGRAPH_FRAME_SHIFT_Y
#define MICROGRAPH_FRAME_SHIFT_Y
Definition: mg_tags.h:64
REFLEX_RADIUS
#define REFLEX_RADIUS
Definition: mg_tags.h:284
read_project_xml
int read_project_xml(Bstring &filename, Bproject *project)
Reading micrograph parameters from XML files.
Definition: rwmgXML.cpp:144
PARTICLE_VIEW_Z
#define PARTICLE_VIEW_Z
Definition: mg_tags.h:195
write_particle_xml
int write_particle_xml(Bstring &filename, Bparticle *part, int euler_flag, int omega_flag, FOMType fom_tag[NFOM])
PARTICLE_X
#define PARTICLE_X
Definition: mg_tags.h:180
Bmicrograph::tilt_angle
double tilt_angle
Definition: mg_processing.h:217
Breconstruction::box_size
Vector3< long > box_size
Definition: mg_processing.h:296
Bmicrograph::ffil
Bstring ffil
Definition: mg_processing.h:208
Bmicrograph::helix_radius
double helix_radius
Definition: mg_processing.h:229
MICROGRAPH_KVEC_X
#define MICROGRAPH_KVEC_X
Definition: mg_tags.h:107
PARTICLE
#define PARTICLE
Definition: mg_tags.h:171
Breconstruction::origin
Vector3< double > origin
Definition: mg_processing.h:293
MICROGRAPH_MATRIX_3_1
#define MICROGRAPH_MATRIX_3_1
Definition: mg_tags.h:101
MICROGRAPH_HVEC_Z
#define MICROGRAPH_HVEC_Z
Definition: mg_tags.h:106
Bfield::next
Bfield * next
Definition: mg_processing.h:258
Bmicrograph::sf
Bstrucfac * sf
Definition: mg_processing.h:243
get_fom_tag
Bstring get_fom_tag(FOMType fom_type)
Returns the tag associated with a particular FOM.
Definition: mg_processing.cpp:3971
Bstrucfac::amp
double amp
Definition: mg_processing.h:159
Bstring::replace
Bstring replace(char cold, char cnew)
Definition: Bstring.cpp:457
Bmicrograph::part
Bparticle * part
Definition: mg_processing.h:239
Bfilament::id
int id
Definition: mg_processing.h:131
REFLEX
#define REFLEX
Definition: mg_tags.h:283
Breconstruction::mark_radius
double mark_radius
Definition: mg_processing.h:301
Bfilament::node
Bfilnode * node
Definition: mg_processing.h:132
MARKER_Z
#define MARKER_Z
Definition: mg_tags.h:273
FOM_CV
Definition: mg_processing.h:42
Bframe
Definition: mg_processing.h:74
MICROGRAPH
#define MICROGRAPH
Definition: mg_tags.h:59
Bmicrograph::matrix
Matrix3 matrix
Definition: mg_processing.h:222
Breconstruction::model
Bstring * model
Definition: mg_processing.h:309
Bmicrograph::fpart
Bstring fpart
Definition: mg_processing.h:207
Bfilament::next
Bfilament * next
Definition: mg_processing.h:129
Bmicrograph::tilt_axis
double tilt_axis
Definition: mg_processing.h:216
reconstruction_add
Breconstruction * reconstruction_add(Breconstruction **rec, Bstring &rec_id)
Adds a reconstruction parameter structure to a linked list.
Definition: mg_processing.cpp:704
MICROGRAPH_HELIX_RADIUS
#define MICROGRAPH_HELIX_RADIUS
Definition: mg_tags.h:116
xml_get_string
string xml_get_string(xmlNodePtr parent, const char *tag)
MAP_SYMMETRY
#define MAP_SYMMETRY
Definition: mg_tags.h:56
MAP_ORIGIN_X
#define MAP_ORIGIN_X
Definition: mg_tags.h:40
MARKER_X
#define MARKER_X
Definition: mg_tags.h:271
CTF_AMP_SHIFT
#define CTF_AMP_SHIFT
Definition: mg_tags.h:160
COMMENT
#define COMMENT
Definition: mg_tags.h:21
REFLEX_PHI
#define REFLEX_PHI
Definition: mg_tags.h:294
Bparticle::sel
long sel
Definition: mg_processing.h:103
Bfield
Definition: mg_processing.h:257
CTF_CS
#define CTF_CS
Definition: mg_tags.h:155
M_PI
#define M_PI
Definition: utilities.h:59
linked_list.h
Header file for generalized linked list functions.
MAP_ORIGIN_Z
#define MAP_ORIGIN_Z
Definition: mg_tags.h:42
Bfilnode::id
int id
Definition: mg_processing.h:117
Bstrucfac::phi
double phi
Definition: mg_processing.h:161
Bmicrograph::frame
Bframe * frame
Definition: mg_processing.h:237
Blayerline::order
int order
Definition: mg_processing.h:177
Bmicrograph::ctf
CTFparam * ctf
Definition: mg_processing.h:238
REFLEX_SIGPHI
#define REFLEX_SIGPHI
Definition: mg_tags.h:295
Bstrucfac::sigamp
double sigamp
Definition: mg_processing.h:160
Bstrucfac
Definition: mg_processing.h:155
REFLEX_SIGAMP
#define REFLEX_SIGAMP
Definition: mg_tags.h:293
Euler::psi
double psi()
Definition: Euler.h:56
Euler::phi
double phi()
Definition: Euler.h:58
NFOM
#define NFOM
Definition: mg_processing.h:16
CTF_DEF_AVG
#define CTF_DEF_AVG
Definition: mg_tags.h:162
REFLEX_L
#define REFLEX_L
Definition: mg_tags.h:290
Bmicrograph::fframe
Bstring fframe
Definition: mg_processing.h:206
Blayerline::number
int number
Definition: mg_processing.h:176
Bbadarea::next
Bbadarea * next
Definition: mg_processing.h:143
CTF_BASELINE
#define CTF_BASELINE
Definition: mg_tags.h:167
Bfield::id
Bstring id
Definition: mg_processing.h:259
Bstring::next
Bstring * next
Definition: Bstring.h:31
CTF_ENVELOPE
#define CTF_ENVELOPE
Definition: mg_tags.h:168
Blayerline::next
Blayerline * next
Definition: mg_processing.h:175
Bmicrograph::select
long select
Definition: mg_processing.h:203
Bmicrograph::mark_radius
double mark_radius
Definition: mg_processing.h:235
Bproject::field
Bfield * field
Definition: mg_processing.h:343
MAP_VOXEL_SIZE
#define MAP_VOXEL_SIZE
Definition: mg_tags.h:46
Bproject::fom_tag
FOMType fom_tag[NFOM]
Definition: mg_processing.h:342
CLASS_AVERAGE
#define CLASS_AVERAGE
Definition: mg_tags.h:241
MARKER_RADIUS
#define MARKER_RADIUS
Definition: mg_tags.h:269
MARKER_ERROR_Y
#define MARKER_ERROR_Y
Definition: mg_tags.h:275
FOM_HAND_B
Definition: mg_processing.h:47
CTFparam::parse_baseline_equation
int parse_baseline_equation(Bstring base_eq)
Extracts the coefficients from the baseline string.
Definition: ctf.cpp:242
MICROGRAPH_ORIGIN_X
#define MICROGRAPH_ORIGIN_X
Definition: mg_tags.h:81
REFLEX_FOM
#define REFLEX_FOM
Definition: mg_tags.h:296
Bmicrograph::helix_axis
double helix_axis
Definition: mg_processing.h:226
CTFparam::defocus_deviation
double defocus_deviation()
Definition: ctf.h:102
PARTICLE_DEF_DEV
#define PARTICLE_DEF_DEV
Definition: mg_tags.h:200
MICROGRAPH_MATRIX_1_3
#define MICROGRAPH_MATRIX_1_3
Definition: mg_tags.h:97
MICROGRAPH_TILT_AXIS
#define MICROGRAPH_TILT_AXIS
Definition: mg_tags.h:87
REFLEX_H
#define REFLEX_H
Definition: mg_tags.h:288
PARTICLE_BAD_RADIUS
#define PARTICLE_BAD_RADIUS
Definition: mg_tags.h:235
verbose
int verbose
PROJECT
#define PROJECT
Definition: mg_tags.h:24
Blayerline::freq
double freq
Definition: mg_processing.h:179
Bmicrograph
Definition: mg_processing.h:200
MICROGRAPH_SCALE_Y
#define MICROGRAPH_SCALE_Y
Definition: mg_tags.h:85
CTFparam::envelope_equation
Bstring envelope_equation()
Generates an envelope equation string from 4 coefficients.
Definition: ctf.cpp:209
LAYERLINE_SELECT
#define LAYERLINE_SELECT
Definition: mg_tags.h:307
Bmicrograph::layer
Blayerline * layer
Definition: mg_processing.h:244
MICROGRAPH_MATRIX_2_1
#define MICROGRAPH_MATRIX_2_1
Definition: mg_tags.h:98
Bmicrograph::origin
Vector3< double > origin
Definition: mg_processing.h:220
Bmarker::fom
float fom
Definition: marker.h:28
Bproject::class_avg
Bparticle * class_avg
Definition: mg_processing.h:345
Breconstruction::fil_node_radius
double fil_node_radius
Definition: mg_processing.h:298
Breconstruction::symmetry
Bstring symmetry
Definition: mg_processing.h:286
CTFparam::parse_envelope_equation
int parse_envelope_equation(Bstring env_eq)
Extracts the coefficients from the envelope string.
Definition: ctf.cpp:287
Bparticle::group
int group
Definition: mg_processing.h:93
Bmicrograph::hvec
Vector3< double > hvec
Definition: mg_processing.h:223
mg_tags.h
All STAR and XML file format tags for micrographs and reconstructions.
Bmarker::id
int id
Definition: marker.h:23
Bstrucfac::index
Vector3< int > index
Definition: mg_processing.h:158
file_util.h
Header file for file checking functions.
PARTICLE_PIXEL
#define PARTICLE_PIXEL
Definition: mg_tags.h:198
Bstrucfac::next
Bstrucfac * next
Definition: mg_processing.h:156
CTF_AST_ANG
#define CTF_AST_ANG
Definition: mg_tags.h:166
MAP_RECONSTRUCTION
#define MAP_RECONSTRUCTION
Definition: mg_tags.h:34
Bparticle::fpart
Bstring fpart
Definition: mg_processing.h:91
FOM_HAND_A
Definition: mg_processing.h:46
Bframe::next
Bframe * next
Definition: mg_processing.h:75
MICROGRAPH_TILT_ANGLE
#define MICROGRAPH_TILT_ANGLE
Definition: mg_tags.h:88
PARTICLE_VIEW_Y
#define PARTICLE_VIEW_Y
Definition: mg_tags.h:194
MARKER_ERROR_Z
#define MARKER_ERROR_Z
Definition: mg_tags.h:276
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)
CTF_AMP
#define CTF_AMP
Definition: mg_tags.h:159
FILAMENT_FILE
#define FILAMENT_FILE
Definition: mg_tags.h:245
MAP_REFERENCE
#define MAP_REFERENCE
Definition: mg_tags.h:33
MAP_SELECT
#define MAP_SELECT
Definition: mg_tags.h:47
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
Bmicrograph::mark
Bmarker * mark
Definition: mg_processing.h:242
Bmarker::next
Bmarker * next
Definition: marker.h:22
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:428
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:264
write_project_xml
int write_project_xml(Bstring &filename, Bproject *project, int mg_select, int rec_select)
Writing micrograph parameters to a XML file.
Definition: rwmgXML.cpp:258
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
MICROGRAPH_MATRIX_1_2
#define MICROGRAPH_MATRIX_1_2
Definition: mg_tags.h:96
FOM
Definition: mg_processing.h:40
Bparticle::dev
double dev
Definition: mg_processing.h:96
PARTICLE_ORIGIN_Y
#define PARTICLE_ORIGIN_Y
Definition: mg_tags.h:187
LAYERLINE_AMP
#define LAYERLINE_AMP
Definition: mg_tags.h:305
MAP
#define MAP
Definition: mg_tags.h:31
MICROGRAPH_DOSE
#define MICROGRAPH_DOSE
Definition: mg_tags.h:80
PARTICLE_BAD_Z
#define PARTICLE_BAD_Z
Definition: mg_tags.h:238
REFLEX_Y
#define REFLEX_Y
Definition: mg_tags.h:286
Breconstruction::fft
Bstring fft
Definition: mg_processing.h:290
Euler::theta
double theta()
Definition: Euler.h:57
read_particle_xml
Bparticle * read_particle_xml(Bstring &filename, Bparticle **partlist, FOMType fom_tag[NFOM])
Bmicrograph::fps
Bstring fps
Definition: mg_processing.h:210
LAYERLINE
#define LAYERLINE
Definition: mg_tags.h:300
Bparticle
Definition: mg_processing.h:89
FILAMENT_NODE_Z
#define FILAMENT_NODE_Z
Definition: mg_tags.h:251
Bmicrograph::block
int block
Definition: mg_processing.h:204
Bmicrograph::helix_angle
double helix_angle
Definition: mg_processing.h:228
Bmicrograph::rot_angle
double rot_angle
Definition: mg_processing.h:219
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
Breconstruction::sf
Bstrucfac * sf
Definition: mg_processing.h:308
Bmicrograph::fft
Bstring fft
Definition: mg_processing.h:209
LAYERLINE_FREQ
#define LAYERLINE_FREQ
Definition: mg_tags.h:304
MICROGRAPH_FRAME
#define MICROGRAPH_FRAME
Definition: mg_tags.h:62
PARTICLE_AST_ANG
#define PARTICLE_AST_ANG
Definition: mg_tags.h:201
MICROGRAPH_HVEC_X
#define MICROGRAPH_HVEC_X
Definition: mg_tags.h:104
Breconstruction::bad_radius
double bad_radius
Definition: mg_processing.h:299
CTFparam::volt
double volt()
Definition: ctf.h:83
xml_copy_string
int xml_copy_string(char *string, xmlNodePtr parent, const char *tag)
FOMType
FOMType
Definition: mg_processing.h:38
xml_get_real
double xml_get_real(xmlNodePtr parent, const char *tag)
Breconstruction::select
long select
Definition: mg_processing.h:283
MICROGRAPH_FRAMES_FILE
#define MICROGRAPH_FRAMES_FILE
Definition: mg_tags.h:61
MICROGRAPH_POWERSPEC_FILE
#define MICROGRAPH_POWERSPEC_FILE
Definition: mg_tags.h:70
Bmicrograph::box_size
Vector3< long > box_size
Definition: mg_processing.h:230
MICROGRAPH_ORIGIN_Y
#define MICROGRAPH_ORIGIN_Y
Definition: mg_tags.h:82
REFLEX_AMP
#define REFLEX_AMP
Definition: mg_tags.h:291
PARTICLE_BOX_RADIUS_Z
#define PARTICLE_BOX_RADIUS_Z
Definition: mg_tags.h:233
Breconstruction::scale
Vector3< double > scale
Definition: mg_processing.h:294
filament_add
Bfilament * filament_add(Bfilament **fil, int pid)
Adds a filament parameter structure to a linked list.
Definition: mg_processing.cpp:625
MICROGRAPH_MATRIX_3_3
#define MICROGRAPH_MATRIX_3_3
Definition: mg_tags.h:103
PARTICLE_Z
#define PARTICLE_Z
Definition: mg_tags.h:182
Breconstruction::ffil
Bstring ffil
Definition: mg_processing.h:289
MICROGRAPH_ROT_ANGLE
#define MICROGRAPH_ROT_ANGLE
Definition: mg_tags.h:90
CTF_CC
#define CTF_CC
Definition: mg_tags.h:156
FIELD
#define FIELD
Definition: mg_tags.h:25
Breconstruction::bad
Bbadarea * bad
Definition: mg_processing.h:306
FILAMENT
#define FILAMENT
Definition: mg_tags.h:244
PARTICLE_FOM
#define PARTICLE_FOM
Definition: mg_tags.h:203
MAP_FOM
#define MAP_FOM
Definition: mg_tags.h:48
CTFparam::baseline_equation
Bstring baseline_equation()
Generates a baseline equation string from 4 to 10 coefficients.
Definition: ctf.cpp:165
xml_set_integer
xmlNodePtr xml_set_integer(xmlNodePtr parent, const char *tag, long value, const char *format)
MICROGRAPH_SELECT
#define MICROGRAPH_SELECT
Definition: mg_tags.h:74
MAP_SCALE_X
#define MAP_SCALE_X
Definition: mg_tags.h:43
Bmicrograph::fmg
Bstring fmg
Definition: mg_processing.h:205
Bparticle::loc
Vector3< double > loc
Definition: mg_processing.h:99
MICROGRAPH_LVEC_Z
#define MICROGRAPH_LVEC_Z
Definition: mg_tags.h:112
LAYERLINE_FOM
#define LAYERLINE_FOM
Definition: mg_tags.h:306
Bmicrograph::fil_node_radius
double fil_node_radius
Definition: mg_processing.h:232
FILNODE_RADIUS
#define FILNODE_RADIUS
Definition: mg_tags.h:253
Bfilnode::next
Bfilnode * next
Definition: mg_processing.h:116
View::angle
double angle()
Definition: View.h:95
Bstrucfac::sigphi
double sigphi
Definition: mg_processing.h:162
PARTICLE_BAD_X
#define PARTICLE_BAD_X
Definition: mg_tags.h:236
Bmarker::err
Vector3< float > err
Definition: marker.h:26
Bmicrograph::bad
Bbadarea * bad
Definition: mg_processing.h:241
Bmicrograph::magnification
double magnification
Definition: mg_processing.h:212
MARKER_ERROR_X
#define MARKER_ERROR_X
Definition: mg_tags.h:274
Bmicrograph::fom
double fom
Definition: mg_processing.h:236
PARTICLE_MAGNIF
#define PARTICLE_MAGNIF
Definition: mg_tags.h:197
CTF_VOLTAGE
#define CTF_VOLTAGE
Definition: mg_tags.h:154
Bmarker::loc
Vector3< float > loc
Definition: marker.h:25
CTFparam::defocus_average
double defocus_average()
Definition: ctf.h:100
MICROGRAPH_MATRIX_2_2
#define MICROGRAPH_MATRIX_2_2
Definition: mg_tags.h:99
Bparticle::def
double def
Definition: mg_processing.h:95
Euler::view
View view()
Definition: Euler.h:62
PARTICLE_BOX_RADIUS
#define PARTICLE_BOX_RADIUS
Definition: mg_tags.h:230
PARTICLE_DEFOCUS
#define PARTICLE_DEFOCUS
Definition: mg_tags.h:199
LAYERLINE_NUMBER
#define LAYERLINE_NUMBER
Definition: mg_tags.h:301
Breconstruction::block
int block
Definition: mg_processing.h:284
Blayerline::fom
double fom
Definition: mg_processing.h:181
VERB_DEBUG_STAR
#define VERB_DEBUG_STAR
Definition: utilities.h:113
Breconstruction::fps
Bstring fps
Definition: mg_processing.h:291
mg_processing.h
Header file for micrograph processing.
Breconstruction::frec
Bstring frec
Definition: mg_processing.h:287
PARTICLE_FILE
#define PARTICLE_FILE
Definition: mg_tags.h:172
LAYERLINE_ORDER
#define LAYERLINE_ORDER
Definition: mg_tags.h:302
Breconstruction::voxel_size
double voxel_size
Definition: mg_processing.h:292
Bframe::id
int id
Definition: mg_processing.h:76
Blayerline::amp
double amp
Definition: mg_processing.h:180
PARTICLE_VIEW_ANGLE
#define PARTICLE_VIEW_ANGLE
Definition: mg_tags.h:196
CTFparam::envelope
vector< double > & envelope()
Definition: ctf.h:115
Bframe::fom
double fom
Definition: mg_processing.h:78
Bproject::comment
Bstring comment
Definition: mg_processing.h:336
MICROGRAPH_SAMPLING
#define MICROGRAPH_SAMPLING
Definition: mg_tags.h:77
CTFparam::amp_shift
double amp_shift()
Definition: ctf.h:95
Bmicrograph::bad_radius
double bad_radius
Definition: mg_processing.h:233
MAP_POWERSPEC_FILE
#define MAP_POWERSPEC_FILE
Definition: mg_tags.h:36
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:413
Blayerline
Definition: mg_processing.h:174
PARTICLE_BAD
#define PARTICLE_BAD
Definition: mg_tags.h:234
PARTICLE_BOX_SIZE_X
#define PARTICLE_BOX_SIZE_X
Definition: mg_tags.h:227
MAP_VIEW_X
#define MAP_VIEW_X
Definition: mg_tags.h:50
Bstring::empty
bool empty()
Definition: Bstring.h:71
MICROGRAPH_FRAME_SELECT
#define MICROGRAPH_FRAME_SELECT
Definition: mg_tags.h:65
Bparticle::next
Bparticle * next
Definition: mg_processing.h:90
MICROGRAPH_LVEC_X
#define MICROGRAPH_LVEC_X
Definition: mg_tags.h:110
VERB_FULL
#define VERB_FULL
Definition: utilities.h:109
PARTICLE_SELECT
#define PARTICLE_SELECT
Definition: mg_tags.h:202
MAP_SCALE_Y
#define MAP_SCALE_Y
Definition: mg_tags.h:44
PARTICLE_VIEW_X
#define PARTICLE_VIEW_X
Definition: mg_tags.h:193
Bproject::euler_flag
int euler_flag
Definition: mg_processing.h:340
PARTICLE_BAD_Y
#define PARTICLE_BAD_Y
Definition: mg_tags.h:237
Bmicrograph::scale
Vector3< double > scale
Definition: mg_processing.h:221
Bfilnode::loc
Vector3< double > loc
Definition: mg_processing.h:118
micrograph_add
Bmicrograph * micrograph_add(Bmicrograph **mg, Bstring &mg_id)
Adds a micrograph parameter structure to a linked list.
Definition: mg_processing.cpp:461
Bmarker::res
float res
Definition: marker.h:27
CTFparam::Cc
double Cc()
Definition: ctf.h:89
Breconstruction::view
View view
Definition: mg_processing.h:295
REFLEX_X
#define REFLEX_X
Definition: mg_tags.h:285
MICROGRAPH_FOM
#define MICROGRAPH_FOM
Definition: mg_tags.h:75
Breconstruction::next
Breconstruction * next
Definition: mg_processing.h:281
MICROGRAPH_HELIX_ANGLE
#define MICROGRAPH_HELIX_ANGLE
Definition: mg_tags.h:115
xml_check_for_node_in_tree
int xml_check_for_node_in_tree(xmlNodePtr parent, const char *tag)
Bmarker::sel
int sel
Definition: marker.h:29
MICROGRAPH_HELIX_AXIS
#define MICROGRAPH_HELIX_AXIS
Definition: mg_tags.h:113
Blayerline::distance
double distance
Definition: mg_processing.h:178
error_show
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:755
CTFparam::alpha
double alpha()
Definition: ctf.h:91
Bproject
Definition: mg_processing.h:333
PARTICLE_FOM_CV
#define PARTICLE_FOM_CV
Definition: mg_tags.h:204
PARTICLE_HANDA_FOM
#define PARTICLE_HANDA_FOM
Definition: mg_tags.h:217
MAP_VIEW_Z
#define MAP_VIEW_Z
Definition: mg_tags.h:52
Bstrucfac::fom
double fom
Definition: mg_processing.h:163
Breconstruction::id
Bstring id
Definition: mg_processing.h:282
MICROGRAPH_TRANSFORM_FILE
#define MICROGRAPH_TRANSFORM_FILE
Definition: mg_tags.h:69
CTF_DE
#define CTF_DE
Definition: mg_tags.h:158
Bfilament
Definition: mg_processing.h:128
CTFparam
Definition: ctf.h:26
MAP_ORIGIN_Y
#define MAP_ORIGIN_Y
Definition: mg_tags.h:41
MICROGRAPH_SCALE_X
#define MICROGRAPH_SCALE_X
Definition: mg_tags.h:84
Bstrucfac::sel
long sel
Definition: mg_processing.h:164
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)