| Bsoft 2.0.5 Bernard's software package

tcltk_bmg.cpp
Go to the documentation of this file.
1
9 // Tk must be included before anything else to remedy symbol conflicts
10 #include <tk.h>
11
12 //#include "tcltk_bmg.h"
13 #include "tcltk_bbox.h"
14 #include "tcltk_bfil.h"
15 #include "tcltk_bhelix.h"
16 #include "tcltk_bxtal.h"
17 #include "tcltk_bmarker.h"
18 #include "mg_processing.h"
19 #include "mg_multiple.h"
20 #include "mg_img_proc.h"
21 #include "mg_ctf.h"
22 #include "mg_ctf_fit.h"
23 #include "mg_tomography.h"
24 #include "rwmg.h"
25 #include "rwimg.h"
26 #include "linked_list.h"
27 #include "timer.h"
28 #include "utilities.h"
29
30 #include <sys/stat.h>
31
32 // Declaration of global variables
33 extern int verbose; // Level of output to the screen
34 extern Bproject* project;
35 extern Bimage* imglist;
36
37 // Internal function prototypes
38 Tcl_Obj* do_get(Bproject* project, int objc, Tcl_Obj *CONST objv[]);
39 int do_set(Bproject* project, int objc, Tcl_Obj *CONST objv[]);
40 Tcl_Obj* do_rps(Bproject* project, int objc, Tcl_Obj *CONST objv[]);
41 Tcl_Obj* do_ctf_fit(Bproject* project, int objc, Tcl_Obj *CONST objv[]);
42
125 int project_processing(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
126 {
127 // verbose = 967;
128
129 Tcl_ResetResult(interp);
130
131 if ( objc < 2 ) {
132 Tcl_AppendResult(interp, "wrong # args", (char *)NULL);
133 return TCL_ERROR;
134 }
135
136 Bstring action = Tcl_GetStringFromObj(objv[1], NULL);
137 if ( verbose & VERB_DEBUG )
138 cout << "DEBUG BmgCmd: Action: " << action << " (" << action.length() << ")" << endl;
139
140 Tcl_Obj* returnObj = Tcl_NewObj();
141
142 char string[128] = " ";
143 Tcl_SetStringObj(returnObj, string, 1);
144
145 // int nmg(1), nrec(0);
146 // int type(1);
147 Bstring imgtype("mg");
148 Bstring filename;
149 Bstring* files = NULL;
150 Bfield* field = NULL;
151 Bmicrograph* mg = NULL;
152 Breconstruction* rec = NULL;
153 Bparticle* part = NULL;
154
155 time_t ti = time(NULL);
156
157 // if ( project ) cout << "Flag active = %d\n", project->select);
158
159 if ( action == "create" ) {
160 if ( objc > 2 ) filename = Tcl_GetStringFromObj(objv[2], NULL);
161 if ( objc > 3 ) imgtype = Tcl_GetStringFromObj(objv[3], NULL);
162 if ( imglist ) {
163 project = project_create_from_image(imglist, imgtype);
164 } else {
165 // string_add(&files, filename);
166 // project = project_create_from_images(files, imgtype);
167 project = project_create_from_images(&filename, imgtype);
168 // string_kill(files);
169 }
170 } else if ( action == "exists" ) {
171 if ( project ) Tcl_SetIntObj(returnObj, 1);
172 else Tcl_SetIntObj(returnObj, 0);
173 } else if ( action == "read" ) {
174 if ( objc < 2 ) {
175 Tcl_AppendResult(interp, "No file name given!", (char *)NULL);
176 return TCL_ERROR;
177 }
178 filename = Tcl_GetStringFromObj(objv[2], NULL);
179 if ( verbose & VERB_DEBUG )
180 cout << "DEBUG BmgCmd: File name: " << filename << " (" << filename.length() << ")" << endl;
181 if ( project ) project_kill(project);
182 project = read_project(filename);
183 if ( project->field ) {
184 mg = project->field->mg; // Only use the first micrograph
185 Tcl_SetStringObj(returnObj, mg->id.c_str(), mg->id.length());
186 }
187 // cout << "nrec=" << project_count_reconstructions(project) << endl;
188 } else if ( action == "add" ) {
189 if ( objc < 2 ) {
190 Tcl_AppendResult(interp, "No file name given!", (char *)NULL);
191 return TCL_ERROR;
192 }
193 filename = Tcl_GetStringFromObj(objv[2], NULL);
194 if ( verbose & VERB_DEBUG )
195 cout << "DEBUG BmgCmd: File name: " << filename << " (" << filename.length() << ")" << endl;
196 files = filename.split();
197 project_multi_add(project, files, 0);
198 string_kill(files);
199 if ( project->field ) {
200 mg = project->field->mg; // Only use the first micrograph
201 Tcl_SetStringObj(returnObj, (char *)mg->id.c_str(), mg->id.length());
202 }
203 } else if ( action == "write" ) {
204 if ( objc < 2 ) {
205 Tcl_AppendResult(interp, "No file name given!", (char *)NULL);
206 return TCL_ERROR;
207 }
208 // cout << "nrec=" << project_count_reconstructions(project) << endl;
209 filename = Tcl_GetStringFromObj(objv[2], NULL);
210 if ( verbose & VERB_DEBUG )
211 cout << "DEBUG BmgCmd: File name: " << filename << " (" << filename.length() << ")" << endl;
212 if ( !project ) {
213 Tcl_AppendResult(interp, "No project in memory!", (char *)NULL);
214 return TCL_ERROR;
215 }
216 project->comment += "\n# Written from Bshow\n# " + Bstring(asctime(localtime(&ti))) + "\n";
217 write_project(filename, project);
218 } else if ( action == "kill" ) {
219 project_kill(project);
220 project = NULL;
221 } else if ( action == "ids" ) {
222 for ( field = project->field; field; field = field->next ) {
223 snprintf(string, 128, "Field-of-view %s %ld ", field->id.c_str(), field->select);
224 Tcl_AppendToObj(returnObj, string, strlen(string));
225 for ( mg = field->mg; mg; mg = mg->next ) {
226 snprintf(string, 128, "Micrograph %s %ld ", mg->id.c_str(), mg->select);
227 Tcl_AppendToObj(returnObj, string, strlen(string));
228 for ( part = mg->part; part; part = part->next ) {
229 snprintf(string, 128, "Particle %d %ld ", part->id, part->sel);
230 Tcl_AppendToObj(returnObj, string, strlen(string));
231 }
232 }
233 }
234 for ( rec = project->rec; rec; rec = rec->next ) {
235 snprintf(string, 128, "Reconstruction %s %ld ", rec->id.c_str(), rec->select);
236 Tcl_AppendToObj(returnObj, string, strlen(string));
237 for ( part = rec->part; part; part = part->next ) {
238 snprintf(string, 128, "Particle %d %ld ", part->id, part->sel);
239 Tcl_AppendToObj(returnObj, string, strlen(string));
240 }
241 }
242 // } else if ( action == "item" ) {
243 // returnObj = do_item(project, objc, objv);
244 } else if ( action == "get" ) {
245 returnObj = do_get(project, objc, objv);
246 } else if ( action == "set" ) {
247 do_set(project, objc, objv);
248 } else if ( action == "image_type" ) {
249 imgtype = Tcl_GetStringFromObj(objv[2], NULL);
250 imgtype = image_type(imgtype);
251 Tcl_SetStringObj(returnObj, (char *)imgtype.c_str(), imgtype.length());
252 } else if ( action == "rps" ) {
253 returnObj = do_rps(project, objc, objv);
254 } else if ( action == "ctf_fit" ) {
255 returnObj = do_ctf_fit(project, objc, objv);
256 } else if ( action == "update_matrices" ) {
257 project_set_nominal_mg_origins(project);
258 project_mg_tilt_to_matrix(project);
259 } else if ( action == "transfer" ) {
260 do_tomo_transfer_seed(project, objc, objv);
261 } else if ( action == "findaxis" ) {
262 do_tomo_findaxis(project, objc, objv);
263 } else if ( action == "track" ) {
264 do_tomo_track(project, objc, objv);
265 } else if ( action == "refine" ) {
266 do_tomo_refine(project, objc, objv);
267 } else if ( action == "refine_one" ) {
268 do_tomo_refine_one(project, objc, objv);
269 } else if ( action == "box" ) {
270 returnObj = do_box(project, objc, objv);
271 } else if ( action == "filament" ) {
272 returnObj = do_filament(project, objc, objv);
273 } else if ( action == "node" ) {
274 returnObj = do_node(project, objc, objv);
275 } else if ( action == "layerline" ) {
276 returnObj = do_layerline(project, objc, objv);
277 } else if ( action == "spot" ) {
278 returnObj = do_spot(project, objc, objv);
279 } else if ( action == "marker" ) {
280 returnObj = do_marker(project, objc, objv);
281 } else {
282 cerr << "Error: Action " << action << " not recognized!" << endl;
283 }
284
285 Tcl_SetObjResult(interp, returnObj);
286
287 return TCL_OK;
288 }
289
290 /*
291 Tcl_Obj* do_item(Bproject* project, int objc, Tcl_Obj *CONST objv[])
292 {
293 Tcl_Obj* returnObj = Tcl_NewObj();
294
295 int n(-1), notfound(1);
296 Bstring filename(imglist->file_name());
297 Bstring id;
298 Bfield* field = NULL;
299 Bmicrograph* mg = NULL;
300 Bparticle* part = NULL;
301 Breconstruction* rec = NULL;
302
303 if ( objc > 2 ) Tcl_GetIntFromObj(NULL, objv[2], &n);
304
305 if ( n >= 0 ) {
306 for ( field = project->field; field && id.length() < 1; field = field->next ) {
307 for ( mg = field->mg; mg && id.length() < 1; mg = mg->next ) {
308 if ( filename == mg->fmg && n == mg->img_num )
309 id = "Micrograph:" + mg->id;
310 else if ( filename == mg->fpart && n == mg->img_num )
311 id = "Micrograph:" + mg->id;
312 else for ( part = mg->part; part && id.length() < 1; part = part->next ) {
313 if ( filename == part->fpart && n == part->id - 1 )
314 id = "Particle:" + mg->id;
315 }
316
317 return returnObj;
318 }
319 */
320
321 Bstring get_all_file_names(Bproject* project)
322 {
323 Bstring bstr;
324 Bstring* strlist = NULL;
325
326 Bfield* field = NULL;
327 Bmicrograph* mg = NULL;
328 Bparticle* part = NULL;
329 Breconstruction* rec = NULL;
330
331 if ( verbose & VERB_DEBUG )
332 cout << "DEBUG get_all_file_names: Getting all file names" << endl;
333
334 for ( field = project->field; field; field = field->next ) {
335 mg = field->mg;
336 if ( mg && mg->next && mg->fmg.length() && mg->fmg == mg->next->fmg ) {
337 bstr = mg->fmg + ":mg:Field:" + field->id + " ";
338 string_add(&strlist, bstr);
339 } else {
340 for ( mg = field->mg; mg; mg = mg->next ) {
341 if ( mg->fmg.length() ) {
342 bstr = mg->fmg + ":mg:Micrograph:" + mg->id + " ";
343 string_add(&strlist, bstr);
344 }
345 if ( mg->fframe.length() ) {
346 bstr = mg->fframe + ":frame:Micrograph:" + mg->id + " ";
347 string_add(&strlist, bstr);
348 }
349 }
350 }
351 if ( mg && mg->next && mg->fps.length() && mg->fps == mg->next->fps ) {
352 bstr = mg->fps + ":ps:Field:" + field->id + " ";
353 string_add(&strlist, bstr);
354 } else {
355 for ( mg = field->mg; mg; mg = mg->next ) {
356 if ( mg->fps.length() ) {
357 bstr = mg->fps + ":ps:Micrograph:" + mg->id + " ";
358 string_add(&strlist, bstr);
359 }
360 }
361 }
362 for ( mg = field->mg; mg; mg = mg->next ) {
363 if ( mg->fpart.length() ) {
364 bstr = mg->fpart + ":part:Micrograph:" + mg->id + " ";
365 string_add(&strlist, bstr);
366 } else for ( part = mg->part; part; part = part->next ) {
367 if ( part->fpart.length() ) {
368 bstr = part->fpart + ":part:Micrograph:" + mg->id + " ";
369 string_add(&strlist, bstr);
370 }
371 }
372 if ( mg->ffil.length() ) {
373 bstr = mg->ffil + ":fil:Micrograph:" + mg->id + " ";
374 string_add(&strlist, bstr);
375 }
376 if ( mg->fft.length() ) {
377 bstr = mg->fft + ":ft:Micrograph:" + mg->id + " ";
378 string_add(&strlist, bstr);
379 }
380 }
381 }
382
383 for ( rec = project->rec; rec ; rec = rec->next ) {
384 if ( rec->frec.length() ) {
385 bstr = rec->frec + ":rec:Reconstruction:" + rec->id + " ";
386 string_add(&strlist, bstr);
387 }
388 if ( rec->fpart.length() ) {
389 bstr = rec->fpart + ":part:Reconstruction:" + rec->id + " ";
390 string_add(&strlist, bstr);
391 } else for ( part = rec->part; part; part = part->next ) {
392 if ( part->fpart.length() ) {
393 bstr = part->fpart + ":part:Reconstruction:" + rec->id + " ";
394 string_add(&strlist, bstr);
395 }
396 }
397 if ( rec->ffil.length() ) {
398 bstr = rec->ffil + ":fil:Reconstruction:" + rec->id + " ";
399 string_add(&strlist, bstr);
400 }
401 if ( rec->fps.length() ) {
402 bstr = rec->fps + ":ps:Reconstruction:" + rec->id + " ";
403 string_add(&strlist, bstr);
404 }
405 if ( rec->fft.length() ) {
406 bstr = rec->fft + ":ft:Reconstruction:" + rec->id + " ";
407 string_add(&strlist, bstr);
408 }
409 }
410
411 for ( part = project->class_avg; part; part = part->next ) {
412 if ( part->fpart.length() && part->fpart != bstr ) {
413 bstr = part->fpart + ":part:Class:1 ";
414 string_add(&strlist, bstr);
415 bstr = part->fpart;
416 }
417 }
418
419 if ( verbose & VERB_DEBUG )
420 cout << "DEBUG get_all_file_names: Last file name: " << bstr << endl;
421
422 bstr = string_catenate(strlist);
423
424 string_kill(strlist);
425
426 if ( verbose & VERB_DEBUG )
427 cout << "DEBUG get_all_file_names: Catenation done" << endl;
428
429 return bstr;
430 }
431
432 Tcl_Obj* part_select(Bparticle* part, int objc, Tcl_Obj *CONST objv[])
433 {
434 Tcl_Obj* returnObj = Tcl_NewObj();
435
436 int id(0), sel(-1);
437
438 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
439 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &sel);
440
441 if ( id > 0 ) {
442 for ( ; part && part->id != id; part = part->next ) ;
443 if ( part ) {
444 if ( sel >= 0 ) part->sel = sel;
445 else sel = part->sel;
446 }
447 }
448
449 Tcl_SetIntObj(returnObj, sel);
450
451 return returnObj;
452 }
453
454 Tcl_Obj* part_fom(Bparticle* part, int objc, Tcl_Obj *CONST objv[])
455 {
456 Tcl_Obj* returnObj = Tcl_NewObj();
457
458 int id(0), fom_index(0);
459 char string[MAXLINELEN] = "";
460
461 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
462 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &fom_index);
463
464 if ( id > 0 ) {
465 for ( ; part && part->id != id; part = part->next ) ;
466 if ( part ) {
467 snprintf(string, MAXLINELEN, "%f", part->fom[fom_index]);
468 Tcl_SetStringObj(returnObj, string, strlen(string));
469 }
470 }
471
472 // cout << "fom for " << id << ": " << string << endl;
473
474 return returnObj;
475 }
476
477
478 Tcl_Obj* do_get(Bproject* project, int objc, Tcl_Obj *CONST objv[])
479 {
480 Tcl_Obj* returnObj = Tcl_NewObj();
481
482 int i, n(-1), mgi(0), nmg(0), nrec(0), npart(0), err(0);
483 char string[MAXLINELEN] = "";
484 Bstring bstr, imgtype, filename;
485 Vector3<int> size;
486 View v;
487 Bfield* field = NULL;
488 Bmicrograph* mg = NULL;
489 Bparticle* part = NULL;
490 Breconstruction* rec = NULL;
491
492 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
493
494 Bstring property = Tcl_GetStringFromObj(objv[3], NULL);
495
496 Bstring id = item.post(':');
497 id = id.remove(' ');
498 item = item.pre(':');
499
500 if ( verbose & VERB_DEBUG ) {
501 cout << "DEBUG do_get: Item: " << item << " (" << item.length() << ")" << endl;
502 cout << "DEBUG do_get: ID: " << id << " (" << id.length() << ")" << endl;
503 cout << "DEBUG do_get: Property: " << property << " (" << property.length() << ")" << endl;
504 }
505
506 // verbose = 512;
507 // cout << "id = \"" << id << "\"" << endl;
508
509 if ( item.contains("all" ) ) {
510 field = project->field;
511 if ( field ) mg = field->mg;
512 rec = project->rec;
513 nmg = project_count_micrographs(project);
514 nrec = project_count_reconstructions(project);
515 } else if ( item.contains("Field") ) {
516 for ( field = project->field; field && field->id != id; field = field->next ) ;
517 if ( !field ) err++;
518 } else if ( item.contains("Micrograph") ) {
519 for ( field = project->field; field; field = field->next ) {
520 for ( mg = field->mg; mg && mg->id != id; mg = mg->next) mgi++;
521 if ( mg ) break;
522 }
523 if ( !mg ) err++;
524 } else if ( item.contains("Reconstruction") ) {
525 project->select = 1;
526 for ( rec = project->rec; rec && rec->id != id; rec = rec->next ) ;
527 if ( !rec ) err++;
528 } else if ( item.contains("Class") ) {
529 part = project->class_avg;
530 } else {
531 cerr << "Error in do_get: item \"" << item << "\" not supported! (property: " << property << ")" << endl;
532 return returnObj;
533 }
534
535 if ( err ) cerr << "Error in do_get: " << item << " not found! (property: " << property << ")" << endl;
536
537
538 if ( !project || property.empty() ) {
539 Tcl_SetIntObj(returnObj, 0);
540 } else if ( property == "active" ) {
541 Tcl_SetIntObj(returnObj, project->select);
542 } else if ( property == "id" ) {
543 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &n);
544 if ( project->select && rec ) {
545 Tcl_SetStringObj(returnObj, (char *)rec->id.c_str(), rec->id.length());
546 } else if ( mg ) {
547 // if ( n >= 0 && field )
548 // for ( ; field; field = field->next ) {
549 // if ( mg && mg->img_num == n ) break;
550 // else for ( mg = field->mg; mg && mg->img_num != n; mg = mg->next ) ;
551 // }
552 if ( !mg ) {
553 cerr << "Error: No micrograph specified!" << endl;
554 mg = field->mg;
555 }
556 Tcl_SetStringObj(returnObj, (char *)mg->id.c_str(), mg->id.length());
557 } else if ( field ) {
558 if ( n >= 0 ) {
559 for ( i=0, mg = field->mg; mg && i != n; mg = mg->next, i++ ) ;
560 if ( !mg ) {
561 cerr << "Error: No micrograph specified!" << endl;
562 mg = field->mg;
563 }
564 Tcl_SetStringObj(returnObj, (char *)mg->id.c_str(), mg->id.length());
565 } else {
566 Tcl_SetStringObj(returnObj, (char *)field->id.c_str(), field->id.length());
567 }
568 }
569 } else if ( property == "field" ) {
570 if ( !field ) field = project->field;
571 if ( field )
572 Tcl_SetStringObj(returnObj, (char *)field->id.c_str(), field->id.length());
573 } else if ( property == "number_of_mg" ) {
574 if ( !nmg && field ) for ( nmg=0, mg = field->mg; mg; mg = mg->next) nmg++;
575 Tcl_SetIntObj(returnObj, nmg);
576 // cout << "Number of micrographs = " << nmg << endl;
577 } else if ( property == "index_of_mg" ) {
578 for ( mgi=0, field = project->field; field; field = field->next ) {
579 for ( mg = field->mg; mg && mg->id != id; mg = mg->next) mgi++;
580 if ( mg ) break;
581 }
582 Tcl_SetIntObj(returnObj, ++mgi);
583 } else if ( property == "number_of_rec" ) {
584 for ( nrec=0, rec = project->rec; rec; rec = rec->next ) nrec++;
585 Tcl_SetIntObj(returnObj, nrec);
586 } else if ( property == "number_of_part" ) {
587 if ( !part ) {
588 if ( mg ) part = mg->part;
589 if ( rec ) part = rec->part;
590 }
591 for ( npart=0; part; part = part->next ) npart++;
592 Tcl_SetIntObj(returnObj, npart);
593 } else if ( property == "image_filenames" ) {
594 bstr = get_all_file_names(project);
595 Tcl_AppendToObj(returnObj, bstr.c_str(), bstr.length());
596 } else if ( property == "filename" ) {
597 imgtype = Tcl_GetStringFromObj(objv[4], NULL);
598 if ( mg ) {
599 // cout << "Get: id=" << mg->id << " file=" << mg->fps << " imgtype=" << imgtype << endl;
600 if ( imgtype == "mg" )
601 Tcl_SetStringObj(returnObj, (char *)mg->fmg.c_str(), mg->fmg.length());
602 else if ( imgtype == "frame" )
603 Tcl_SetStringObj(returnObj, (char *)mg->fframe.c_str(), mg->fframe.length());
604 else if ( imgtype == "part" )
605 Tcl_SetStringObj(returnObj, (char *)mg->fpart.c_str(), mg->fpart.length());
606 else if ( imgtype == "fil" )
607 Tcl_SetStringObj(returnObj, (char *)mg->ffil.c_str(), mg->ffil.length());
608 else if ( imgtype == "ft" )
609 Tcl_SetStringObj(returnObj, (char *)mg->fft.c_str(), mg->fft.length());
610 else if ( imgtype == "ps" )
611 Tcl_SetStringObj(returnObj, (char *)mg->fps.c_str(), mg->fps.length());
612 } else if ( rec ) {
613 if ( imgtype == "rec" )
614 Tcl_SetStringObj(returnObj, (char *)rec->frec.c_str(), rec->frec.length());
615 else if ( imgtype == "part" )
616 Tcl_SetStringObj(returnObj, (char *)rec->fpart.c_str(), rec->fpart.length());
617 else if ( imgtype == "fil" )
618 Tcl_SetStringObj(returnObj, (char *)rec->ffil.c_str(), rec->ffil.length());
619 else if ( imgtype == "ft" )
620 Tcl_SetStringObj(returnObj, (char *)rec->fft.c_str(), rec->fft.length());
621 else if ( imgtype == "ps" )
622 Tcl_SetStringObj(returnObj, (char *)rec->fps.c_str(), rec->fps.length());
623 } else if ( part ) {
624 if ( imgtype == "part" )
625 Tcl_SetStringObj(returnObj, (char *)part->fpart.c_str(), part->fpart.length());
626 }
627 imgtype = 0;
628 } else if ( property == "select" ) {
629 if ( project->select && rec ) {
630 Tcl_SetIntObj(returnObj, rec->select);
631 } else if ( mg ) {
632 Tcl_SetIntObj(returnObj, mg->select);
633 } else if ( field ) {
634 Tcl_SetIntObj(returnObj, field->select);
635 } else if ( part ) {
636 returnObj = part_select(part, objc, objv);
637 } else {
638 Tcl_SetIntObj(returnObj, 0);
639 }
640 } else if ( property == "fom" ) {
641 if ( project->select && rec ) {
642 Tcl_SetDoubleObj(returnObj, rec->fom);
643 } else if ( mg ) {
644 Tcl_SetDoubleObj(returnObj, mg->fom);
645 } else if ( part ) {
646 returnObj = part_fom(part, objc, objv);
647 // Tcl_SetDoubleObj(returnObj, part->fom[0]);
648 } else {
649 Tcl_SetDoubleObj(returnObj, 0);
650 }
651 } else if ( property == "pixel_size" ) {
652 if ( objc > 4 ) imgtype = Tcl_GetStringFromObj(objv[4], NULL);
653 if ( field && !mg ) mg = field->mg;
654 // if ( part ) {
655 // if ( project->select && project->rec ) rec = project->rec;
656 // else if ( ( field = project->field ) && field->mg ) mg = field->mg;
657 // }
658 if ( part ) Tcl_SetDoubleObj(returnObj, part->pixel_size);
659 else if ( imgtype == "part" ) {
660 if ( project->select && rec && rec->part )
661 Tcl_SetDoubleObj(returnObj, rec->part->pixel_size);
662 else if ( mg && mg->part )
663 Tcl_SetDoubleObj(returnObj, mg->part->pixel_size);
664 } else if ( mg ) {
665 Tcl_SetDoubleObj(returnObj, mg->pixel_size);
666 } else if ( rec ) {
667 Tcl_SetDoubleObj(returnObj, rec->voxel_size);
668 }
669 } else if ( property == "size" ) {
670 if ( !mg && field ) mg = field->mg;
671 if ( mg ) {
672 size = micrograph_get_size(mg);
673 snprintf(string, 128, "%d %d %d ", size[0], size[1], size[2]);
674 Tcl_AppendToObj(returnObj, string, strlen(string));
675 }
676 } else if ( property == "origin" ) {
677 if ( project->select && rec ) {
678 snprintf(string, 128, "%g %g %g ", rec->origin[0], rec->origin[1], rec->origin[2]);
679 Tcl_AppendToObj(returnObj, string, strlen(string));
680 } else if ( mg ) {
681 snprintf(string, 128, "%g %g %g ", mg->origin[0], mg->origin[1], mg->origin[2]);
682 Tcl_AppendToObj(returnObj, string, strlen(string));
683 } else if ( field ) {
684 for ( mg = field->mg; mg; mg = mg->next ) {
685 snprintf(string, 128, "%g %g %g ", mg->origin[0], mg->origin[1], mg->origin[2]);
686 Tcl_AppendToObj(returnObj, string, strlen(string));
687 }
688 } else if ( part ) {
689 for ( part = project->class_avg; part; part = part->next ) {
690 snprintf(string, 128, "%g %g %g ", part->ori[0], part->ori[1], part->ori[2]);
691 Tcl_AppendToObj(returnObj, string, strlen(string));
692 }
693 }
694 } else if ( property == "part_origin" ) {
695 if ( !part ) {
696 if ( mg ) part = mg->part;
697 else if ( rec ) part = rec->part;
698 }
699 if ( part ) {
700 if ( objc > 4 ) filename = Tcl_GetStringFromObj(objv[4], NULL);
701 if ( filename.length() < 1 || ( mg && filename == mg->fpart ) ||
702 ( rec && filename == rec->fpart ) ) {
703 for ( ; part; part = part->next ) {
704 snprintf(string, 128, "%g %g %g ", part->ori[0], part->ori[1], part->ori[2]);
705 Tcl_AppendToObj(returnObj, string, strlen(string));
706 }
707 } else {
708 for ( ; part; part = part->next ) if ( filename == part->fpart ) {
709 snprintf(string, 128, "%g %g %g ", part->ori[0], part->ori[1], part->ori[2]);
710 Tcl_AppendToObj(returnObj, string, strlen(string));
711 break;
712 }
713 }
714 }
715 } else if ( property == "scale" ) {
716 if ( project->select && rec ) {
717 snprintf(string, 128, "%g %g %g ", rec->scale[0], rec->scale[1], rec->scale[2]);
718 Tcl_AppendToObj(returnObj, string, strlen(string));
719 } else if ( mg ) {
720 snprintf(string, 128, "%g %g %g ", mg->scale[0], mg->scale[1], mg->scale[2]);
721 Tcl_AppendToObj(returnObj, string, strlen(string));
722 } else if ( field ) {
723 for ( mg = field->mg; mg; mg = mg->next ) {
724 snprintf(string, 128, "%g %g %g ", mg->scale[0], mg->scale[1], mg->scale[2]);
725 Tcl_AppendToObj(returnObj, string, strlen(string));
726 }
727 }
728 } else if ( property == "defocus_deviation" ) {
729 if ( project->select && rec ) {
730 if ( !rec->ctf ) rec->ctf = new CTFparam;
731 Tcl_SetDoubleObj(returnObj, rec->ctf->defocus_deviation());
732 } else if ( mg ) {
733 if ( !mg->ctf ) mg->ctf = new CTFparam;
734 Tcl_SetDoubleObj(returnObj, mg->ctf->defocus_deviation());
735 }
736 } else if ( property == "defocus" ) {
737 if ( project->select && rec ) {
738 if ( !rec->ctf ) rec->ctf = new CTFparam;
739 Tcl_SetDoubleObj(returnObj, rec->ctf->defocus_average());
740 } else if ( mg ) {
741 if ( !mg->ctf ) mg->ctf = new CTFparam;
742 Tcl_SetDoubleObj(returnObj, mg->ctf->defocus_average());
743 // cout << "Micrograph: " << mg->id << " defocus=" << mg->ctf->defocus_average() << endl;
744 }
745 } else if ( property == "astigmatism_angle" ) {
746 if ( project->select && rec ) {
747 if ( !rec->ctf ) rec->ctf = new CTFparam;
748 Tcl_SetDoubleObj(returnObj, rec->ctf->astigmatism_angle()*180/M_PI);
749 } else if ( mg ) {
750 if ( !mg->ctf ) mg->ctf = new CTFparam;
751 Tcl_SetDoubleObj(returnObj, mg->ctf->astigmatism_angle()*180/M_PI);
752 }
753 } else if ( property == "volt" ) {
754 if ( project->select && rec ) {
755 if ( !rec->ctf ) rec->ctf = new CTFparam;
756 Tcl_SetDoubleObj(returnObj, rec->ctf->volt());
757 } else if ( mg ) {
758 if ( !mg->ctf ) mg->ctf = new CTFparam;
759 Tcl_SetDoubleObj(returnObj, mg->ctf->volt());
760 }
761 } else if ( property == "Cs" ) {
762 if ( project->select && rec ) {
763 if ( !rec->ctf ) rec->ctf = new CTFparam;
764 Tcl_SetDoubleObj(returnObj, rec->ctf->Cs());
765 } else if ( mg ) {
766 if ( !mg->ctf ) mg->ctf = new CTFparam;
767 Tcl_SetDoubleObj(returnObj, mg->ctf->Cs());
768 }
769 } else if ( property == "amp_fac" ) {
770 if ( project->select && rec ) {
771 if ( !rec->ctf ) rec->ctf = new CTFparam;
772 Tcl_SetDoubleObj(returnObj, sin(rec->ctf->amp_shift()));
773 } else if ( mg ) {
774 if ( !mg->ctf ) mg->ctf = new CTFparam;
775 Tcl_SetDoubleObj(returnObj, sin(mg->ctf->amp_shift()));
776 }
777 } else if ( property == "baseline" ) {
778 if ( project->select && rec ) {
779 if ( !rec->ctf ) rec->ctf = new CTFparam;
780 bstr = rec->ctf->baseline_equation();
781 Tcl_SetStringObj(returnObj, bstr.c_str(), bstr.length());
782 } else if ( mg ) {
783 if ( !mg->ctf ) mg->ctf = new CTFparam;
784 bstr = mg->ctf->baseline_equation();
785 Tcl_SetStringObj(returnObj, bstr.c_str(), bstr.length());
786 }
787 } else if ( property == "baseline_type" ) {
788 if ( project->select && rec ) {
789 if ( !rec->ctf ) rec->ctf = new CTFparam;
790 Tcl_SetIntObj(returnObj, rec->ctf->baseline_type());
791 } else if ( mg ) {
792 if ( !mg->ctf ) mg->ctf = new CTFparam;
793 Tcl_SetIntObj(returnObj, mg->ctf->baseline_type());
794 }
795 } else if ( property == "envelope" ) {
796 if ( project->select && rec ) {
797 if ( !rec->ctf ) rec->ctf = new CTFparam;
798 bstr = rec->ctf->envelope_equation();
799 Tcl_SetStringObj(returnObj, bstr.c_str(), bstr.length());
800 } else if ( mg ) {
801 if ( !mg->ctf ) mg->ctf = new CTFparam;
802 bstr = mg->ctf->envelope_equation();
803 Tcl_SetStringObj(returnObj, bstr.c_str(), bstr.length());
804 }
805 } else if ( property == "envelope_type" ) {
806 if ( project->select && rec ) {
807 if ( !rec->ctf ) rec->ctf = new CTFparam;
808 Tcl_SetIntObj(returnObj, rec->ctf->envelope_type());
809 } else if ( mg ) {
810 if ( !mg->ctf ) mg->ctf = new CTFparam;
811 Tcl_SetIntObj(returnObj, mg->ctf->envelope_type());
812 }
813 } else if ( property == "zero" ) {
814 if ( project->select && rec ) {
815 if ( rec->ctf )
816 Tcl_SetDoubleObj(returnObj, rec->ctf->zero(1));
817 } else if ( mg ) {
818 if ( mg->ctf )
819 Tcl_SetDoubleObj(returnObj, mg->ctf->zero(1));
820 }
821 } else if ( property == "view" ) {
822 if ( mg ) v = View(mg->matrix);
823 else if ( rec ) v = rec->view;
824 snprintf(string, 128, "%g %g %g %g ", v[0], v[1], v[2], v.angle());
825 Tcl_AppendToObj(returnObj, string, strlen(string));
826 } else if ( property == "axis" ) {
827 if ( !mg && field ) mg = field->mg;
828 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->tilt_axis*180.0/M_PI);
829 else Tcl_SetDoubleObj(returnObj, 0);
830 } else if ( property == "tilt" ) {
831 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->tilt_angle*180.0/M_PI);
832 else Tcl_SetDoubleObj(returnObj, 0);
833 } else if ( property == "level" ) {
834 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->level_angle*180.0/M_PI);
835 else Tcl_SetDoubleObj(returnObj, 0);
836 } else if ( property == "unitcell" ) {
837 if ( mg )
838 snprintf(string, 128, "%g %g %g %g ", mg->hvec[0], mg->hvec[1], mg->kvec[0], mg->kvec[1]);
839 Tcl_AppendToObj(returnObj, string, strlen(string));
840 } else if ( property == "helix_axis" ) {
841 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->helix_axis*180.0/M_PI);
842 else Tcl_SetDoubleObj(returnObj, 0.0);
843 } else if ( property == "helix_rise" ) {
844 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->helix_rise);
845 else Tcl_SetDoubleObj(returnObj, 0.0);
846 } else if ( property == "helix_angle" ) {
847 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->helix_angle*180.0/M_PI);
848 else Tcl_SetDoubleObj(returnObj, 0.0);
849 } else if ( property == "helix_radius" ) {
850 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->helix_radius);
851 else Tcl_SetDoubleObj(returnObj, 0.0);
852 } else if ( property == "box_size" ) {
853 if ( project->select && rec ) snprintf(string, 128, "%ld %ld %ld", rec->box_size[0], rec->box_size[1], rec->box_size[2]);
854 else {
855 if ( !mg ) mg = field->mg;
856 if ( mg ) snprintf(string, 128, "%ld %ld %ld", mg->box_size[0], mg->box_size[1], mg->box_size[2]);
857 }
858 Tcl_SetStringObj(returnObj, string, strlen(string));
859 } else if ( property == "bad_radius" ) {
860 if ( project->select && rec ) Tcl_SetDoubleObj(returnObj, rec->bad_radius);
861 else {
862 if ( !mg ) mg = field->mg;
863 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->bad_radius);
864 }
865 } else if ( property == "filament_width" ) {
866 if ( project->select && rec ) Tcl_SetDoubleObj(returnObj, rec->filament_width);
867 else {
868 if ( !mg ) mg = field->mg;
869 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->filament_width);
870 }
871 } else if ( property == "filament_node_radius" ) {
872 if ( project->select && rec ) Tcl_SetDoubleObj(returnObj, rec->fil_node_radius);
873 else {
874 if ( !mg ) mg = field->mg;
875 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->fil_node_radius);
876 }
877 } else if ( property == "sf_radius" ) {
878 if ( project->select && rec ) Tcl_SetDoubleObj(returnObj, rec->sf_radius);
879 else {
880 if ( !mg ) mg = field->mg;
881 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->sf_radius);
882 }
883 } else if ( property == "marker_radius" ) {
884 if ( part ) Tcl_SetDoubleObj(returnObj, 0.0);
885 else if ( project->select && rec ) Tcl_SetDoubleObj(returnObj, rec->mark_radius);
886 else {
887 if ( !mg && field ) mg = field->mg;
888 if ( mg ) Tcl_SetDoubleObj(returnObj, mg->mark_radius);
889 }
890 } else {
891 cerr << "Error in do_get: Property " << property << " not recognized!" << endl;
892 }
893
894 return returnObj;
895 }
896
897
898 int do_set(Bproject* project, int objc, Tcl_Obj *CONST objv[])
899 {
900 if ( !project )
901 return error_show("Error: No project defined!\n", __FILE__, __LINE__);
902
903 int update(0);
904
905 int i, n(-1), err(0);
906 double value;
907 Vector3<float> origin, scale;
908
909 Bstring name, imgtype;
910 Bfield* field = NULL;
911 Bmicrograph* mg = NULL;
912 Breconstruction* rec = NULL;
913 Bparticle* part = NULL;
914
915 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
916
917 Bstring property = Tcl_GetStringFromObj(objv[3], NULL);
918
919 Bstring id = item.post(':');
920 id = id.remove(' ');
921 item = item.pre(':');
922
923 if ( verbose & VERB_DEBUG ) {
924 cout << "DEBUG do_set: Item: " << item << " (" << item.length() << ")" << endl;
925 cout << "DEBUG do_set: ID: " << id << " (" << id.length() << ")" << endl;
926 cout << "DEBUG do_set: Property: " << property << " (" << property.length() << ")" << endl;
927 }
928
929 if ( item.contains("all" ) ) {
930 } else if ( property == "id" ) {
931 if ( item.contains("Field") ) {
932 field = project->field;
933 } else if ( item.contains("Micrograph") ) {
934 field = project->field;
935 if ( field ) mg = field->mg;
936 } else if ( item.contains("Reconstruction") ) {
937 project->select = 1;
938 rec = project->rec;
939 } else err++;
940 } else if ( item.contains("Field") ) {
941 for ( field = project->field; field && field->id != id; field = field->next ) ;
942 if ( !field ) err++;
943 // cout << "field id = " << project->field->id << endl;
944 } else if ( item.contains("Micrograph") ) {
945 for ( field = project->field; field; field = field->next ) {
946 for ( mg = field->mg; mg && mg->id != id; mg = mg->next) ;
947 if ( mg ) break;
948 }
949 if ( !mg ) err++;
950 // cout << "set mg id: " << mg->id << endl;
951 } else if ( item.contains("Reconstruction") ) {
952 for ( rec = project->rec; rec && rec->id != id; rec = rec->next ) ;
953 if ( !rec ) rec = project->rec;
954 if ( !rec ) err++;
955 } else if ( item.contains("Class") ) {
956 part = project->class_avg;
957 } else {
958 cerr << "Error in do_set: item \"" << item << "\" not supported! (property: " << property << ")" << endl;
959 return update;
960 }
961
962 if ( err ) cerr << "Error in do_set: " << item << " not found! (property: " << property << ")" << endl;
963
964 if ( !project || property.empty() || objc < 4 ) {
965 return update;
966 } else if ( property == "active" ) {
967 Tcl_GetIntFromObj(NULL, objv[4], &project->select);
968 if ( project->select && !project->rec ) rec = reconstruction_add(&project->rec, id);
969 } else if ( property == "id" ) {
970 id = Tcl_GetStringFromObj(objv[4], NULL);
971 // cout << "Setting item " << item << " to id " << id << endl;
972 if ( project->select ) {
973 if ( rec ) {
974 rec->id = id;
975 } else {
976 rec = project->rec;
977 if ( !rec->next ) rec->id = id;
978 else for ( n=0, rec = project->rec; rec; rec = rec->next, n++ ) {
979 rec->id = id + Bstring(n, "_%03d");
980 }
981 }
982 } else if ( !mg && field ) {
983 field->id = id;
984 } else if ( mg ) {
985 mg = field->mg;
986 if ( !mg->next ) mg->id = id;
987 else for ( n=0, mg = field->mg; mg; mg = mg->next, n++ ) {
988 mg->id = id + Bstring(n, "_%03d");
989 }
990 }
991 } else if ( property == "filename" ) {
992 name = Tcl_GetStringFromObj(objv[4], NULL);
993 imgtype = Tcl_GetStringFromObj(objv[5], NULL);
994 // cout << "filename=" << name << " imgtype=" << imgtype << endl;
995 if ( mg ) {
996 // cout << "Set: id=" << id << " file=" << name << " imgtype=" << imgtype << endl;
997 if ( imgtype == "mg" ) mg->fmg = name;
998 else if ( imgtype == "frame" ) mg->fframe = name;
999 else if ( imgtype == "part" ) mg->fpart = name;
1000 else if ( imgtype == "fil" ) mg->ffil = name;
1001 else if ( imgtype == "ft" ) mg->fft = name;
1002 else if ( imgtype == "ps" ) mg->fps = name;
1003 } else if ( field ) {
1004 if ( imgtype == "mg" ) {
1005 for ( i=0, mg = field->mg; mg; mg = mg->next, i++ ) {
1006 mg->fmg = name;
1007 mg->img_num = i;
1008 }
1009 } else if ( imgtype == "ps" ) {
1010 for ( mg = field->mg; mg; mg = mg->next )
1011 mg->fps = name;
1012 }
1013 } else if ( rec ) {
1014 if ( imgtype == "rec" ) rec->frec = name;
1015 else if ( imgtype == "part" ) rec->fpart = name;
1016 else if ( imgtype == "fil" ) rec->ffil = name;
1017 else if ( imgtype == "ft" ) rec->fft = name;
1018 else if ( imgtype == "ps" ) rec->fps = name;
1019 } else if ( part ) {
1020 if ( imgtype == "part" ) part->fpart = name;
1021 if ( part == project->class_avg )
1022 for ( ; part; part = part->next ) part->fpart = name;
1023 }
1024 imgtype = 0;
1025 name = 0;
1026 } else if ( property == "select" ) {
1027 Tcl_GetIntFromObj(NULL, objv[4], &i);
1028 if ( project->select && rec ) rec->select = i;
1029 else if ( mg ) mg->select = i;
1030 else if ( field ) field->select = i;
1031 else if ( part ) part->sel = i;
1032 } else if ( property == "pixel_size" ) {
1033 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1034 if ( project->select && rec ) rec->voxel_size = value;
1035 else if ( mg ) mg->pixel_size = value;
1036 else if ( field ) for ( mg = field->mg; mg; mg = mg->next ) mg->pixel_size = value;
1037 } else if ( property == "origin" ) {
1038 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1039 origin[0] = value;
1040 Tcl_GetDoubleFromObj(NULL, objv[5], &value);
1041 origin[1] = value;
1042 Tcl_GetDoubleFromObj(NULL, objv[6], &value);
1043 origin[2] = value;
1044 if ( project->select && rec ) rec->origin = origin;
1045 else if ( mg ) mg->origin = origin;
1046 else if ( field ) for ( mg = field->mg; mg; mg = mg->next ) mg->origin = origin;
1047 } else if ( property == "scale" ) {
1048 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1049 scale[0] = value;
1050 Tcl_GetDoubleFromObj(NULL, objv[5], &value);
1051 scale[1] = value;
1052 Tcl_GetDoubleFromObj(NULL, objv[6], &value);
1053 scale[2] = value;
1054 if ( project->select && rec ) rec->scale = scale;
1055 else if ( mg ) mg->scale = scale;
1056 else if ( field ) for ( mg = field->mg; mg; mg = mg->next ) mg->scale = scale;
1057 } else if ( property == "defocus_deviation" ) {
1058 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1059 if ( project->select && rec ) {
1060 if ( !rec->ctf ) rec->ctf = new CTFparam;
1061 rec->ctf->defocus_deviation(value);
1062 } else if ( mg ) {
1063 if ( !mg->ctf ) mg->ctf = new CTFparam;
1064 mg->ctf->defocus_deviation(value);
1065 }
1066 } else if ( property == "defocus" ) {
1067 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1068 if ( project->select && rec ) {
1069 if ( !rec->ctf ) rec->ctf = new CTFparam;
1070 rec->ctf->defocus_average(value);
1071 } else if ( mg ) {
1072 if ( !mg->ctf ) mg->ctf = new CTFparam;
1073 mg->ctf->defocus_average(value);
1074 }
1075 } else if ( property == "astigmatism_angle" ) {
1076 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1077 value *= M_PI/180.0;
1078 if ( project->select && rec ) {
1079 if ( !rec->ctf ) rec->ctf = new CTFparam;
1080 rec->ctf->astigmatism_angle(value);
1081 } else if ( mg ) {
1082 if ( !mg->ctf ) mg->ctf = new CTFparam;
1083 mg->ctf->astigmatism_angle(value);
1084 }
1085 } else if ( property == "volt" ) {
1086 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1087 project_set_volts(project, value);
1088 } else if ( property == "Cs" ) {
1089 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1090 project_set_Cs(project, value);
1091 } else if ( property == "amp_fac" ) {
1092 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1093 project_set_amp_shift(project, asin(value));
1094 } else if ( property == "baseline_type" ) {
1095 if ( project->select && rec ) {
1096 if ( !rec->ctf ) rec->ctf = new CTFparam;
1097 Tcl_GetIntFromObj(NULL, objv[4], &i);
1098 rec->ctf->baseline_type(i);
1099 } else if ( mg ) {
1100 if ( !mg->ctf ) mg->ctf = new CTFparam;
1101 Tcl_GetIntFromObj(NULL, objv[4], &i);
1102 mg->ctf->baseline_type(i);
1103 // cout << "Micrograph: " << mg->id << " baseline_type: " << mg->ctf->baseline_type() << endl;
1104 }
1105 } else if ( property == "baseline" ) {
1106 if ( project->select && rec ) {
1107 if ( !rec->ctf ) rec->ctf = new CTFparam;
1108 rec->ctf->parse_baseline_equation(Tcl_GetStringFromObj(objv[4], NULL));
1109 } else if ( mg ) {
1110 if ( !mg->ctf ) mg->ctf = new CTFparam;
1111 mg->ctf->parse_baseline_equation(Tcl_GetStringFromObj(objv[4], NULL));
1112 }
1113 } else if ( property == "envelope_type" ) {
1114 if ( project->select && rec ) {
1115 if ( !rec->ctf ) rec->ctf = new CTFparam;
1116 Tcl_GetIntFromObj(NULL, objv[4], &i);
1117 rec->ctf->envelope_type(i);
1118 } else if ( mg ) {
1119 if ( !mg->ctf ) mg->ctf = new CTFparam;
1120 Tcl_GetIntFromObj(NULL, objv[4], &i);
1121 mg->ctf->envelope_type(i);
1122 // cout << "Micrograph: " << mg->id << " envelope_type: " << mg->ctf->envelope_type() << endl;
1123 }
1124 } else if ( property == "envelope" ) {
1125 if ( project->select && rec ) {
1126 if ( !rec->ctf ) rec->ctf = new CTFparam;
1127 rec->ctf->parse_envelope_equation(Tcl_GetStringFromObj(objv[4], NULL));
1128 } else if ( mg ) {
1129 if ( !mg->ctf ) mg->ctf = new CTFparam;
1130 mg->ctf->parse_envelope_equation(Tcl_GetStringFromObj(objv[4], NULL));
1131 }
1132 } else if ( property == "axis" ) {
1133 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1134 value *= M_PI/180.0;
1135 if ( field ) {
1136 if ( objc > 5 ) {
1137 Tcl_GetIntFromObj(NULL, objv[5], &n);
1138 for ( i=0, mg = field->mg; mg && i<n; mg = mg->next, i++ ) ;
1139 if ( mg ) mg->tilt_axis = value;
1140 } else {
1141 for ( mg = field->mg; mg; mg = mg->next ) mg->tilt_axis = value;
1142 }
1143 } else if ( mg ) {
1144 mg->tilt_axis = value;
1145 }
1146 } else if ( property == "tilt" ) {
1147 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1148 value *= M_PI/180.0;
1149 // cout << "Trying to set tilt angle for item " << item << " to " << value*180/M_PI << endl;
1150 if ( !mg && field ) {
1151 Tcl_GetIntFromObj(NULL, objv[5], &n);
1152 for ( i=0, mg = field->mg; mg && i<n; mg = mg->next, i++ ) ;
1153 // cout << "Trying to set tilt angle for mg " << n << " to " << value*180/M_PI << endl;
1154 }
1155 // if ( mg ) cout << "Set tilt for mg " << n << " to " << value*180/M_PI << endl;
1156 if ( mg ) mg->tilt_angle = value;
1157 } else if ( property == "level" ) {
1158 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1159 value *= M_PI/180.0;
1160 if ( !mg && field ) {
1161 Tcl_GetIntFromObj(NULL, objv[5], &n);
1162 for ( i=0, mg = field->mg; mg && i<n; mg = mg->next, i++ ) ;
1163 }
1164 if ( mg ) mg->level_angle = value;
1165 } else if ( property == "unitcell" ) {
1166 if ( mg ) {
1167 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1168 mg->hvec[0] = value;
1169 Tcl_GetDoubleFromObj(NULL, objv[5], &value);
1170 mg->hvec[1] = value;
1171 Tcl_GetDoubleFromObj(NULL, objv[6], &value);
1172 mg->kvec[0] = value;
1173 Tcl_GetDoubleFromObj(NULL, objv[7], &value);
1174 mg->kvec[1] = value;
1175 }
1176 } else if ( property == "helix_axis" ) {
1177 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1178 if ( mg ) mg->helix_axis = value*M_PI/180.0;
1179 } else if ( property == "helix_rise" ) {
1180 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1181 if ( mg ) mg->helix_rise = value;
1182 } else if ( property == "helix_angle" ) {
1183 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1184 if ( mg ) mg->helix_angle = value*M_PI/180.0;
1185 } else if ( property == "helix_radius" ) {
1186 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1187 if ( mg ) mg->helix_radius = value;
1188 } else if ( property == "box_size" ) {
1189 if ( objc > 4 ) {
1190 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1191 if ( project->select && project->rec ) {
1192 for ( rec = project->rec; rec; rec = rec->next ) rec->box_size[0] = (int)value;
1193 } else if ( mg ) {
1194 mg->box_size[0] = (int)value;
1195 } else if ( field ) {
1196 for ( mg = field->mg; mg; mg = mg->next ) mg->box_size[0] = (int)value;
1197 }
1198 }
1199 if ( objc > 5 ) {
1200 Tcl_GetDoubleFromObj(NULL, objv[5], &value);
1201 if ( project->select && project->rec ) {
1202 for ( rec = project->rec; rec; rec = rec->next ) rec->box_size[1] = (int)value;
1203 } else if ( mg ) {
1204 mg->box_size[1] = (int)value;
1205 } else if ( field ) {
1206 for ( mg = field->mg; mg; mg = mg->next ) mg->box_size[1] = (int)value;
1207 }
1208 }
1209 if ( objc > 6 ) {
1210 Tcl_GetDoubleFromObj(NULL, objv[6], &value);
1211 if ( project->select && project->rec ) {
1212 for ( rec = project->rec; rec; rec = rec->next ) rec->box_size[2] = (int)value;
1213 } else if ( mg ) {
1214 mg->box_size[2] = (int)value;
1215 } else if ( field ){
1216 for ( mg = field->mg; mg; mg = mg->next ) mg->box_size[2] = (int)value;
1217 }
1218 }
1219 } else if ( property == "bad_radius" ) {
1220 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1221 if ( project->select && rec )
1222 for ( rec=project->rec; rec; rec=rec->next ) rec->bad_radius = value;
1223 else if ( mg ) mg->bad_radius = value;
1224 else if ( field )
1225 for ( mg = field->mg; mg; mg = mg->next ) mg->bad_radius = value;
1226 } else if ( property == "filament_width" ) {
1227 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1228 if ( project->select && rec )
1229 for ( rec=project->rec; rec; rec=rec->next ) rec->filament_width = value;
1230 else if ( mg ) mg->filament_width = value;
1231 else if ( field )
1232 for ( mg = field->mg; mg; mg = mg->next ) mg->filament_width = value;
1233 } else if ( property == "filament_node_radius" ) {
1234 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1235 if ( project->select && rec )
1236 for ( rec=project->rec; rec; rec=rec->next ) rec->fil_node_radius = value;
1237 else if ( mg ) mg->fil_node_radius = value;
1238 else if ( field )
1239 for ( mg = field->mg; mg; mg = mg->next ) mg->fil_node_radius = value;
1240 } else if ( property == "sf_radius" ) {
1241 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1242 if ( project->select && rec )
1243 for ( rec=project->rec; rec; rec=rec->next ) rec->sf_radius = value;
1244 else if ( mg ) mg->sf_radius = value;
1245 else if ( field )
1246 for ( mg = field->mg; mg; mg = mg->next ) mg->sf_radius = value;
1247 } else if ( property == "marker_radius" ) {
1248 Tcl_GetDoubleFromObj(NULL, objv[4], &value);
1249 if ( project->select && rec )
1250 for ( rec=project->rec; rec; rec=rec->next ) rec->mark_radius = value;
1251 else if ( mg ) mg->mark_radius = value;
1252 else if ( field )
1253 for ( mg = field->mg; mg; mg = mg->next ) mg->mark_radius = value;
1254 } else {
1255 cerr << "Error in do_set: Property " << property << " not recognized!" << endl;
1256 }
1257
1258 return update;
1259 }
1260
1261 Tcl_Obj* do_rps(Bproject* project, int objc, Tcl_Obj *CONST objv[])
1262 {
1263 Tcl_Obj* returnObj = Tcl_NewObj();
1264
1265 int err(0);
1266 long img_num(0);
1267 Bfield* field = NULL;
1268 Bmicrograph* mg = NULL;
1269 Breconstruction* rec = NULL;
1270 CTFparam* em_ctf = NULL;
1271 Bimage* p = NULL;
1272 Bstring filename, filename2;
1273
1274 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
1275 if ( verbose & VERB_DEBUG )
1276 cout << "DEBUG do_rps: Item: " << item << " (" << item.length() << ")" << endl;
1277
1278 Bstring id = item.post(':');
1279 id = id.remove(' ');
1280 item = item.pre(':');
1281
1282 if ( verbose & VERB_DEBUG ) {
1283 cout << "DEBUG do_rps: Item: " << item << " (" << item.length() << ")" << endl;
1284 cout << "DEBUG do_rps: ID: " << id << " (" << id.length() << ")" << endl;
1285 }
1286
1287 if ( item.contains("Micrograph") ) {
1288 for ( field = project->field; field; field = field->next ) {
1289 for ( mg = field->mg; mg && mg->id != id; mg = mg->next) ;
1290 if ( mg ) break;
1291 }
1292 if ( !mg ) err++;
1293 else {
1294 img_num = mg->img_num;
1295 if ( !mg->ctf ) mg->ctf = new CTFparam;
1296 em_ctf = mg->ctf;
1297 filename = mg->fps;
1298 if ( filename.contains("/") ) filename = filename.post_rev('/');
1299 for ( p = imglist; p; p = p->next ) {
1300 filename2 = p->file_name();
1301 if ( filename2.contains(filename) ) break;
1302 }
1303 if ( p ) p->sampling(mg->pixel_size, mg->pixel_size, 1);
1304 else err++;
1305 }
1306 } else if ( item.contains("Reconstruction") ) {
1307 for ( rec = project->rec; rec && rec->id != id; rec = rec->next ) ;
1308 if ( !rec ) err++;
1309 else {
1310 if ( !rec->ctf ) rec->ctf = new CTFparam;
1311 em_ctf = rec->ctf;
1312 filename = rec->fps;
1313 if ( filename.contains("/") ) filename = filename.post_rev('/');
1314 for ( p = imglist; p; p = p->next ) {
1315 filename2 = p->file_name();
1316 if ( filename2.contains(filename) ) break;
1317 }
1318 if ( p ) p->sampling(rec->voxel_size, rec->voxel_size, rec->voxel_size);
1319 else err++;
1320 }
1321 } else {
1322 cerr << "Error in do_rps: item \"" << item << "\" not supported!" << endl;
1323 return returnObj;
1324 }
1325
1326 if ( !p ) {
1327 cerr << "Warning in do_rps: No image! " << endl;
1328 return returnObj;
1329 }
1330
1331 if ( img_num >= p->images() ) img_num = 0;
1332
1333 if ( verbose & VERB_DEBUG ) {
1334 cout << "DEBUG do_rps: image id = " << p->identifier() << endl;
1335 cout << "DEBUG do_rps: image = " << p->file_name() << tab << img_num << endl;
1336 }
1337
1338 if ( em_ctf->defocus_average() <= 1 ||
1339 em_ctf->defocus_average() >= 2e5 )
1340 em_ctf->defocus_average(2e4);
1341
1342 /* if ( objc > 3 ) {
1343 Tcl_GetDoubleFromObj(NULL, objv[3], &defocus_avg);
1344 em_ctf->defocus_average(defocus_avg);
1345 }
1346
1347 if ( objc > 4 ) {
1348 Tcl_GetDoubleFromObj(NULL, objv[4], &defocus_dev);
1349 em_ctf->defocus_deviation(defocus_dev);
1350 }
1351
1352 if ( objc > 5 ) {
1353 Tcl_GetDoubleFromObj(NULL, objv[5], &astigmatism_angle);
1354 em_ctf->astigmatism_angle(astigmatism_angle);
1355 }
1356 */
1357 char string[128];
1358 Bimage* prps = img_ctf_radial_average(p, img_num, *em_ctf);
1359
1360 if ( !prps ) {
1361 snprintf(string, 128, "Warning: Radial average failed!");
1362 Tcl_AppendToObj(returnObj, string, strlen(string));
1363 return returnObj;
1364 }
1365
1366 if ( prps->sizeX() < 1 ) {
1367 snprintf(string, 128, "Warning: Radial average has zero values!");
1368 Tcl_AppendToObj(returnObj, string, strlen(string));
1369 return returnObj;
1370 }
1371
1372 long i;
1373
1374 double wri = img_water_ring_index(prps);
1375
1376 for ( i=0; i<prps->sizeX(); i++ ) {
1377 if ( !isfinite((*prps)[i]) ) {
1378 cerr << "Warning in do_rps: Point " << i << " is a NaN!" << endl;
1379 Tcl_AppendToObj(returnObj, string, strlen(string));
1380 return returnObj;
1381 }
1382 snprintf(string, 128, " %g", (*prps)[i]);
1383 Tcl_AppendToObj(returnObj, string, strlen(string));
1384 // cout << i << tab << (*prps)[i] << endl;
1385 }
1386
1387 delete prps;
1388
1389 snprintf(string, 128, " %g", wri);
1390 Tcl_AppendToObj(returnObj, string, strlen(string));
1391
1392 if ( verbose & VERB_DEBUG )
1393 cout << "DEBUG do_rps: done" << endl;
1394
1395 return returnObj;
1396 }
1397
1398 Tcl_Obj* do_ctf_fit(Bproject* project, int objc, Tcl_Obj *CONST objv[])
1399 {
1400 Tcl_Obj* returnObj = Tcl_NewObj();
1401
1402 int err(0);
1403 int level(0); // 0=quick, 1=baseline, 2=defocus, 3=astigmatism
1404 long img_num(0);
1405 double lores(1e10), hires(0.1);
1406 double def_start(1e3), def_end(2e5), def_inc(1e3);
1407 Bfield* field = NULL;
1408 Bmicrograph* mg = NULL;
1409 Breconstruction* rec = NULL;
1410 CTFparam* em_ctf = NULL;
1411 Bimage* p = NULL;
1412 Bstring filename, filename2;
1413
1414 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
1415 if ( verbose & VERB_DEBUG )
1416 cout << "DEBUG do_ctf_fit: Item: " << item << " (" << item.length() << ")" << endl;
1417
1418 Bstring id = item.post(':');
1419 id = id.remove(' ');
1420 item = item.pre(':');
1421
1422 // cout << "id = " << id << endl;
1423
1424 if ( item.contains("Micrograph") ) {
1425 for ( field = project->field; field; field = field->next ) {
1426 for ( mg = field->mg; mg && mg->id != id; mg = mg->next) ;
1427 if ( mg ) break;
1428 }
1429 if ( !mg ) err++;
1430 else {
1431 img_num = mg->img_num;
1432 if ( !mg->ctf ) mg->ctf = new CTFparam;
1433 em_ctf = mg->ctf;
1434 filename = mg->fps;
1435 if ( filename.contains("/") ) filename = filename.post_rev('/');
1436 for ( p = imglist; p; p = p->next ) {
1437 filename2 = p->file_name();
1438 if ( filename2.contains(filename) ) break;
1439 }
1440 if ( p ) p->sampling(mg->pixel_size, mg->pixel_size, 1);
1441 else err++;
1442 }
1443 } else if ( item.contains("Reconstruction") ) {
1444 for ( rec = project->rec; rec && rec->id != id; rec = rec->next ) ;
1445 if ( !rec ) err++;
1446 else {
1447 if ( !rec->ctf ) rec->ctf = new CTFparam;
1448 em_ctf = rec->ctf;
1449 filename = rec->fps;
1450 if ( filename.contains("/") ) filename = filename.post_rev('/');
1451 for ( p = imglist; p; p = p->next ) {
1452 filename2 = p->file_name();
1453 if ( filename2.contains(filename) ) break;
1454 }
1455 if ( p ) p->sampling(rec->voxel_size, rec->voxel_size, rec->voxel_size);
1456 else err++;
1457 }
1458 } else {
1459 cerr << "Error in do_ctf_fit: item \"" << item << "\" not supported!" << endl;
1460 return returnObj;
1461 }
1462
1463 if ( !p ) {
1464 cerr << "Warning in do_ctf_fit: No image! " << endl;
1465 return returnObj;
1466 }
1467
1468 if ( img_num >= p->images() ) img_num = 0;
1469
1470 if ( verbose & VERB_DEBUG )
1471 cout << "DEBUG do_rps: image id = " << p->identifier() << endl;
1472
1473 if ( objc > 3 ) Tcl_GetIntFromObj(NULL, objv[3], &level);
1474 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &lores);
1475 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &hires);
1476 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &def_start);
1477 if ( objc > 7 ) Tcl_GetDoubleFromObj(NULL, objv[7], &def_end);
1478 if ( objc > 8 ) Tcl_GetDoubleFromObj(NULL, objv[8], &def_inc);
1479
1480 if ( level == 0 || em_ctf->defocus_average() == 0 ) {
1481 em_ctf->defocus_deviation(0);
1482 em_ctf->astigmatism_angle(0);
1483 img_ctf_find_defocus(p, img_num, *em_ctf, lores, hires, def_start, def_end, def_inc);
1484 img_ctf_fit_baseline(p, img_num, *em_ctf, lores, hires);
1485 img_ctf_fit_envelope(p, img_num, *em_ctf, lores, hires);
1486 }
1487
1488 if ( level == 1 )
1489 img_ctf_fit_baseline(p, img_num, *em_ctf, lores, hires);
1490
1491 if ( level == 2 )
1492 img_ctf_fit_envelope(p, img_num, *em_ctf, lores, hires);
1493
1494 if ( level == 3 )
1495 img_ctf_find_defocus(p, img_num, *em_ctf, lores, hires,
1496 em_ctf->defocus_average()/1.2, em_ctf->defocus_average()*1.2,
1497 em_ctf->defocus_average()*0.2);
1498
1499 if ( level == 4 )
1500 img_ctf_fit_astigmatism(p, img_num, *em_ctf, lores, hires);
1501
1502 Bstring base_eq = em_ctf->baseline_equation();
1503 Bstring env_eq = em_ctf->envelope_equation();
1504
1505 // cout << base_eq << endl;
1506
1507 char string[MAXLINELEN] = "";
1508 if ( base_eq.length() )
1509 snprintf(string, MAXLINELEN, "\"%s\" \"%s\" %g %g %g", base_eq.c_str(), env_eq.c_str(),
1510 em_ctf->defocus_average(), em_ctf->defocus_deviation(), em_ctf->astigmatism_angle()*180.0/M_PI);
1511
1512 Tcl_SetStringObj(returnObj, string, strlen(string));
1513
1514 return returnObj;
1515 }
1516
1517
write_project
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Definition: rwmg.cpp:320
Bparticle::id
int id
Definition: mg_processing.h:92
rwmg.h
Header file for reading and writing micrograph parameters.
part_fom
Tcl_Obj * part_fom(Bparticle *part, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmg.cpp:454
CTFparam::zero
double zero(int i)
Definition: ctf.h:218
CTFparam::Cs
double Cs()
Definition: ctf.h:87
Bparticle::pixel_size
double pixel_size
Definition: mg_processing.h:98
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
CTFparam::baseline_type
long baseline_type()
Definition: ctf.h:106
do_rps
Tcl_Obj * do_rps(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmg.cpp:1261
do_tomo_transfer_seed
int do_tomo_transfer_seed(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmarker.cpp:68
Bproject::rec
Breconstruction * rec
Definition: mg_processing.h:344
micrograph_get_size
Vector3< long > micrograph_get_size(Bmicrograph *mg)
Gets the size of a micrograph.
Definition: mg_img_proc.cpp:602
Bstring::post
Bstring post(char c)
Definition: Bstring.cpp:394
imglist
Bimage * imglist
Definition: bshow.cpp:30
Bfield::select
long select
Definition: mg_processing.h:262
tcltk_bbox.h
Bimage::sampling
Vector3< double > sampling()
Definition: Bimage.h:505
Breconstruction::part
Bparticle * part
Definition: mg_processing.h:304
Breconstruction::fpart
Bstring fpart
Definition: mg_processing.h:288
project_set_nominal_mg_origins
int project_set_nominal_mg_origins(Bproject *project)
Sets micrograph origins to the centers of the micrographs.
Definition: mg_img_proc.cpp:660
Bmicrograph::id
Bstring id
Definition: mg_processing.h:202
Bmicrograph::helix_rise
double helix_rise
Definition: mg_processing.h:227
Bmicrograph::img_num
int img_num
Definition: mg_processing.h:211
do_get
Tcl_Obj * do_get(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmg.cpp:478
Breconstruction::filament_width
double filament_width
Definition: mg_processing.h:297
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
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:112
Bmicrograph::filament_width
double filament_width
Definition: mg_processing.h:231
Breconstruction
Definition: mg_processing.h:280
tcltk_bhelix.h
Breconstruction::sf_radius
double sf_radius
Definition: mg_processing.h:300
mg_img_proc.h
Header file for image processing from micrograph structures.
project_create_from_images
Bproject * project_create_from_images(Bstring *file_list, Bstring type)
Creates a project structure using image file names.
Definition: mg_img_proc.cpp:224
do_tomo_findaxis
int do_tomo_findaxis(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmarker.cpp:97
project_multi_add
int project_multi_add(Bproject *project, Bstring *file_list, int fom_index)
Merges multiple projects with an existing one.
Definition: mg_multiple.cpp:204
Bparticle::fom
double fom[NFOM]
Definition: mg_processing.h:102
read_project
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Definition: rwmg.cpp:140
Bimage::identifier
void identifier(Bstring s)
Definition: Bimage.h:216
Bstring::length
long length() const
Definition: Bstring.cpp:263
Bmicrograph::pixel_size
double pixel_size
Definition: mg_processing.h:214
Bmicrograph::kvec
Vector3< double > kvec
Definition: mg_processing.h:224
project_processing
int project_processing(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
Implements the "Bmg" command in Tcl/Tk to access micrograph parameter files through Bsoft.
Definition: tcltk_bmg.cpp:125
Breconstruction::ctf
CTFparam * ctf
Definition: mg_processing.h:303
Bstring::remove
Bstring remove(const char c)
Definition: Bstring.cpp:465
img_ctf_fit_envelope
double img_ctf_fit_envelope(Bimage *p, long n, CTFparam &em_ctf, double lores, double hires)
Fits only the envelope for a given CTF.
Definition: mg_ctf_fit.cpp:332
MAXLINELEN
#define MAXLINELEN
Definition: utilities.h:44
project_create_from_image
Bproject * project_create_from_image(Bimage *p, Bstring type)
Creates a project structure using image file names.
Definition: mg_img_proc.cpp:67
img_ctf_radial_average
Bimage * img_ctf_radial_average(Bimage *p, long n, CTFparam &em_ctf)
Calculates the power spectrum radial average corrected for astigmatism.
Definition: mg_ctf_fit.cpp:46
part_select
Tcl_Obj * part_select(Bparticle *part, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmg.cpp:432
Bimage::file_name
void file_name(string s)
Definition: Bimage.h:230
project_count_micrographs
long project_count_micrographs(Bproject *project)
Counts all the micrographs in the project structure.
Definition: mg_processing.cpp:746
mg_ctf.h
Functions for CTF (contrast transfer function) processing.
do_tomo_refine_one
int do_tomo_refine_one(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmarker.cpp:178
do_box
Tcl_Obj * do_box(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:113
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
Breconstruction::origin
Vector3< double > origin
Definition: mg_processing.h:293
mg_multiple.h
Selection of single particle parameters from multiple files for classification.
Bfield::next
Bfield * next
Definition: mg_processing.h:258
Bmicrograph::part
Bparticle * part
Definition: mg_processing.h:239
timer.h
Utilities for timing functions.
Breconstruction::mark_radius
double mark_radius
Definition: mg_processing.h:301
Bmicrograph::matrix
Matrix3 matrix
Definition: mg_processing.h:222
Bimage
General image parameter class.
Definition: Bimage.h:163
Bmicrograph::fpart
Bstring fpart
Definition: mg_processing.h:207
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
Bstring::contains
bool contains(const Bstring &s)
Definition: Bstring.cpp:584
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.
isfinite
bool isfinite(complex< T > &value)
project_set_volts
int project_set_volts(Bproject *project, double volts)
Sets the acceleration voltage of all the micrographs.
Definition: mg_ctf.cpp:1510
Bmicrograph::ctf
CTFparam * ctf
Definition: mg_processing.h:238
Bmicrograph::fframe
Bstring fframe
Definition: mg_processing.h:206
Bfield::id
Bstring id
Definition: mg_processing.h:259
do_spot
Tcl_Obj * do_spot(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bxtal.cpp:68
Bmicrograph::select
long select
Definition: mg_processing.h:203
Bmicrograph::mark_radius
double mark_radius
Definition: mg_processing.h:235
Bstring::pre
Bstring pre(char c)
Definition: Bstring.cpp:381
Bproject::field
Bfield * field
Definition: mg_processing.h:343
do_filament
Tcl_Obj * do_filament(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bfil.cpp:76
img_ctf_fit_astigmatism
double img_ctf_fit_astigmatism(Bimage *p, long n, CTFparam &em_ctf, double lores, double hires)
Fits the astigmatism with a given defocus, baseline and envelope.
Definition: mg_ctf_fit.cpp:557
img_water_ring_index
double img_water_ring_index(Bimage *p, long img_num, CTFparam &em_ctf)
Calculates the water ring index from a power spectrum.
Definition: mg_ctf_fit.cpp:651
CTFparam::parse_baseline_equation
int parse_baseline_equation(Bstring base_eq)
Extracts the coefficients from the baseline string.
Definition: ctf.cpp:242
Bmicrograph::helix_axis
double helix_axis
Definition: mg_processing.h:226
img_ctf_fit_baseline
double img_ctf_fit_baseline(Bimage *p, long n, CTFparam &em_ctf, double lores, double hires)
Fits only the baseline for a given CTF.
Definition: mg_ctf_fit.cpp:299
CTFparam::defocus_deviation
double defocus_deviation()
Definition: ctf.h:102
project_mg_tilt_to_matrix
int project_mg_tilt_to_matrix(Bproject *project)
Sets the matrix from the tilt and axis angles for each micrograph.
Definition: mg_tomography.cpp:1960
get_all_file_names
Bstring get_all_file_names(Bproject *project)
Definition: tcltk_bmg.cpp:321
tcltk_bxtal.h
Bmicrograph::level_angle
double level_angle
Definition: mg_processing.h:218
Bmicrograph
Definition: mg_processing.h:200
CTFparam::envelope_equation
Bstring envelope_equation()
Generates an envelope equation string from 4 coefficients.
Definition: ctf.cpp:209
mg_tomography.h
Header file for single particle image processing in Bsoft.
Bmicrograph::origin
Vector3< double > origin
Definition: mg_processing.h:220
Bproject::class_avg
Bparticle * class_avg
Definition: mg_processing.h:345
Breconstruction::fil_node_radius
double fil_node_radius
Definition: mg_processing.h:298
CTFparam::parse_envelope_equation
int parse_envelope_equation(Bstring env_eq)
Extracts the coefficients from the envelope string.
Definition: ctf.cpp:287
Bmicrograph::hvec
Vector3< double > hvec
Definition: mg_processing.h:223
CTFparam::envelope_type
long envelope_type()
Definition: ctf.h:113
string_catenate
Bstring string_catenate(Bstring *list)
Catenates a string linked list into one string.
Definition: Bstring.cpp:739
level
size_t level(0)
Bparticle::fpart
Bstring fpart
Definition: mg_processing.h:91
Bparticle::ori
Vector3< double > ori
Definition: mg_processing.h:100
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
do_node
Tcl_Obj * do_node(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bfil.cpp:533
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:428
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:264
project
Bproject * project
Definition: bshow.cpp:31
Bimage::next
Bimage * next
Definition: Bimage.h:165
Breconstruction::fft
Bstring fft
Definition: mg_processing.h:290
Bmicrograph::fps
Bstring fps
Definition: mg_processing.h:210
Bparticle
Definition: mg_processing.h:89
Bmicrograph::helix_angle
double helix_angle
Definition: mg_processing.h:228
Bstring
Definition: Bstring.h:29
image_type
Bstring image_type(Bstring type)
Converts an image type string to a standard form.
Definition: mg_img_proc.cpp:36
Bimage::sizeX
void sizeX(long nx)
Definition: Bimage.h:377
Bmicrograph::fft
Bstring fft
Definition: mg_processing.h:209
project_kill
int project_kill(Bproject *project)
Frees a whole project.
Definition: mg_processing.cpp:1224
Bproject::select
int select
Definition: mg_processing.h:339
Breconstruction::bad_radius
double bad_radius
Definition: mg_processing.h:299
CTFparam::volt
double volt()
Definition: ctf.h:83
Breconstruction::select
long select
Definition: mg_processing.h:283
project_count_reconstructions
long project_count_reconstructions(Bproject *project)
Counts all the reconstructions in the project structure.
Definition: mg_processing.cpp:780
do_tomo_track
int do_tomo_track(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmarker.cpp:120
Bmicrograph::box_size
Vector3< long > box_size
Definition: mg_processing.h:230
Breconstruction::scale
Vector3< double > scale
Definition: mg_processing.h:294
do_tomo_refine
int do_tomo_refine(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmarker.cpp:145
Breconstruction::ffil
Bstring ffil
Definition: mg_processing.h:289
tcltk_bmarker.h
A shared object to manage markers in micrograph parameter files in TCL/Tk.
do_ctf_fit
Tcl_Obj * do_ctf_fit(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmg.cpp:1398
CTFparam::baseline_equation
Bstring baseline_equation()
Generates a baseline equation string from 4 to 10 coefficients.
Definition: ctf.cpp:165
do_layerline
Tcl_Obj * do_layerline(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bhelix.cpp:71
Vector3< int >
Bmicrograph::fmg
Bstring fmg
Definition: mg_processing.h:205
Bmicrograph::fil_node_radius
double fil_node_radius
Definition: mg_processing.h:232
View::angle
double angle()
Definition: View.h:95
View
Definition: View.h:26
Bmicrograph::fom
double fom
Definition: mg_processing.h:236
CTFparam::defocus_average
double defocus_average()
Definition: ctf.h:100
do_marker
Tcl_Obj * do_marker(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmarker.cpp:240
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
do_set
int do_set(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmg.cpp:898
Breconstruction::voxel_size
double voxel_size
Definition: mg_processing.h:292
project_set_Cs
int project_set_Cs(Bproject *project, double Cs)
Sets the spherical aberation constant of all the micrographs.
Definition: mg_ctf.cpp:1540
rwimg.h
Header file for 2D and 3D image I/O.
Bproject::comment
Bstring comment
Definition: mg_processing.h:336
Bimage::images
long images()
Definition: Bimage.h:491
CTFparam::amp_shift
double amp_shift()
Definition: ctf.h:95
mg_ctf_fit.h
Header file for CTF (contrast transfer function) functions.
Bmicrograph::bad_radius
double bad_radius
Definition: mg_processing.h:233
Bparticle::next
Bparticle * next
Definition: mg_processing.h:90
project_set_amp_shift
int project_set_amp_shift(Bproject *project, double amp_shift)
Sets the amplitude contribution of all the micrographs.
Definition: mg_ctf.cpp:1568
Bmicrograph::scale
Vector3< double > scale
Definition: mg_processing.h:221
Breconstruction::view
View view
Definition: mg_processing.h:295
Breconstruction::next
Breconstruction * next
Definition: mg_processing.h:281
error_show
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:755
tab
ostream & tab(ostream &out)
Definition: utilities.cpp:21
img_ctf_find_defocus
double img_ctf_find_defocus(Bimage *p, long n, CTFparam &em_ctf, double lores, double hires, double def_start=1e3, double def_end=2e5, double def_inc=1e3)
Searches for the defocus based on correlation.
Definition: mg_ctf_fit.cpp:391
Bproject
Definition: mg_processing.h:333
Breconstruction::id
Bstring id
Definition: mg_processing.h:282
Bstring::split
Bstring * split()
Definition: Bstring.cpp:597
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:760
CTFparam
Definition: ctf.h:26
verbose
int verbose
tcltk_bfil.h
Bmicrograph::next
Bmicrograph * next
Definition: mg_processing.h:201