| Bsoft 2.0.5 Bernard's software package

tcltk_bbox.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_bbox.h"
13 #include "tcltk_bimage.h"
14 #include "mg_img_proc.h"
15 #include "mg_pick.h"
16 #include "mg_ctf.h"
17 #include "mg_extract.h"
18 #include "rwmg.h"
19 #include "linked_list.h"
20 #include "timer.h"
21 #include "utilities.h"
22
23 #include <sys/stat.h>
24
25 // Declaration of global variables
26 extern int verbose; // Level of output to the screen
27 extern Bimage* imglist;
28 extern Bimage* imgtemp;
29
30 // Internal function prototypes
31 Tcl_Obj* box_count(Bproject* project, int objc, Tcl_Obj *CONST objv[]);
32 Tcl_Obj* box_count(Bparticle* part, Bbadarea* bad, int objc, Tcl_Obj *CONST objv[]);
33 Tcl_Obj* box_ids(Bparticle* part, Bbadarea* bad, int objc, Tcl_Obj *CONST objv[]);
34 Tcl_Obj* box_location(Bparticle* part, Bbadarea* bad, int objc, Tcl_Obj *CONST objv[]);
35 Tcl_Obj* box_fom(Bparticle* part, Bbadarea* bad, int objc, Tcl_Obj *CONST objv[]);
36 Tcl_Obj* box_fom_min(Bproject* project, int objc, Tcl_Obj *CONST objv[]);
37 Tcl_Obj* box_fom_max(Bproject* project, int objc, Tcl_Obj *CONST objv[]);
38 Tcl_Obj* box_select(Bparticle* part, int objc, Tcl_Obj *CONST objv[]);
39 Tcl_Obj* box_select(Bparticle* part, Bbadarea* bad, Vector3<float> rad, double badrad, int objc, Tcl_Obj *CONST objv[]);
40 Tcl_Obj* box_select_min(Bproject* project, int objc, Tcl_Obj *CONST objv[]);
41 Tcl_Obj* box_select_max(Bproject* project, int objc, Tcl_Obj *CONST objv[]);
42 Tcl_Obj* box_move(Bparticle* part, Bbadarea* bad, int objc, Tcl_Obj *CONST objv[]);
43 Tcl_Obj* box_create(Bmicrograph* mg, int objc, Tcl_Obj *CONST objv[]);
44 Tcl_Obj* box_create(Breconstruction* rec, int objc, Tcl_Obj *CONST objv[]);
45 Tcl_Obj* box_renumber(Bparticle* part, int objc, Tcl_Obj *CONST objv[]);
46 Tcl_Obj* box_delete(Bproject* project, int objc, Tcl_Obj *CONST objv[]);
47 Tcl_Obj* box_delete(Bmicrograph* mg, int objc, Tcl_Obj *CONST objv[]);
48 Tcl_Obj* box_delete(Breconstruction* rec, int objc, Tcl_Obj *CONST objv[]);
49 Tcl_Obj* box_center(Bmicrograph* mg, Breconstruction* rec, Bimage* p, int objc, Tcl_Obj *CONST objv[]);
50 Tcl_Obj* box_update_template(Bmicrograph* mg, Breconstruction* rec, Bimage* p, int objc, Tcl_Obj *CONST objv[]);
51 Tcl_Obj* box_pickcc(Bmicrograph* mg, Breconstruction* rec, Bimage* p, int objc, Tcl_Obj *CONST objv[]);
52 Tcl_Obj* box_pickvar(Bmicrograph* mg, Breconstruction* rec, Bimage* p, int objc, Tcl_Obj *CONST objv[]);
53 Tcl_Obj* box_extract(Bmicrograph* mg, Breconstruction* rec, Bimage* p, int objc, Tcl_Obj *CONST objv[]);
54
55 /*
56 @brief Functions for particle picking.
57 Box interface syntax:
58 Bmg box [item] [action] [params]
59 Item: Must contain "Micrograph" or "Reconstruction"
60 Actions:
61 count [n] [|"bad"] counts the number of particles or bad areas
62 ids [fc|"bad"] [fi] returns the identifiers of particles or bad areas
63 location [id] returns the location of a particle or bad area
64 fom [id] [fi] returns the fom of a particle with the indicated index
65 fom_min returns minimum FOM value
66 fom_max returns maximum FOM value
67 select [id] [s] sets the selection number of a particle
68 select [x] [y] [z] returns the identifier at the given location
69 select_min returns minimum selection value
70 select_max returns maximum selection value
71 move [id] [dx] [dy] [dz] updates a particle location by the given vector
72 create [x] [y] [z] [n] [t] [s] creates a new particle at the given location
73 renumber [n] renumbers particles
74 delete [all|mg|rec|id] [n] deletes particles or bad areas
75 template updates picked template
76 pickcc [hr] [lr] [fmn] [fmx] [ed] [b] picks particles by cross-correlation with a template
77 pickvar [ak] [vk] [ed] [b] [ns] picks particles from a variance map
78 extract [f] [of] [bf] [nf] [ft] [fv] [mw] [sf] [p] extracts particles from a micrograph
79 Parameters:
80 id identifier
81 t box type: 1=particle, -1=bad area
82 fc FOM cutoff
83 fmn FOM minimum
84 fmx FOM maximum
85 fi FOM index (0-4)
86 s selection number
87 x x location
88 y y location
89 z z location
90 n image number
91 dx change in x
92 dy change in y
93 dz change in z
94 r particle radius
95 e gaussian edge for picking particles
96 hr high resolution limit
97 lr low resolution limit
98 ak averaging kernel edge size
99 av variance kernel edge size
100 ed exclusion distance for picking particles
101 b binning for picking particles
102 ns number of standard deviations for picking particles
103 f file name
104 of flag indicating odd box size
105 bf background correction flag
106 nf normalization flag
107 ft fill type
108 fv fill value
109 mw filament mask width
110 sf split flag
111 p particle path
112 */
113 Tcl_Obj* do_box(Bproject* project, int objc, Tcl_Obj *CONST objv[])
114 {
115 Tcl_Obj* returnObj = NULL;
116
117 Bstring item = Tcl_GetStringFromObj(objv[2], NULL);
118 if ( verbose & VERB_DEBUG )
119 cout << "DEBUG do_box: Item: " << item << " (" << item.length() << ")" << endl;
120
121 if ( item != "all" && !item.contains("Field") && !item.contains("Micrograph") &&
122 !item.contains("Reconstruction") ) {
123 cerr << "Error in do_box: Item " << item << " must be a micrograph or reconstruction!" << endl;
124 returnObj = Tcl_NewObj();
125 return returnObj;
126 }
127
128 Bstring id = item.post(':');
129 id = id.remove(' ');
130 item = item.pre(':');
131
132 Bfield* field = NULL;
133 Bmicrograph* mg = NULL;
134 Breconstruction* rec = NULL;
135 Bparticle* part = NULL;
136 Bbadarea* bad = NULL;
137 Bimage* p = NULL;
138 Bstring filename, filename2, base, delete_what;
139 double badrad(0);
140 Vector3<float> radius;
141
142 if ( item == "all" ) {
143 } else if ( item.contains("Field") ) {
144 for ( field = project->field; field && field->id != id; field = field->next ) ;
145 if ( field ) mg = field->mg;
146 if ( !mg )
147 cerr << "Error in do_box: Field " << id << " not found!" << endl;
148 } else if ( item.contains("Micrograph") ) {
149 for ( field = project->field; field; field = field->next ) {
150 for ( mg = field->mg; mg && mg->id != id; mg = mg->next ) ;
151 if ( mg ) break;
152 }
153 if ( !mg )
154 cerr << "Error in do_box: Micrograph " << id << " not found!" << endl;
155 } else if ( item.contains("Reconstruction") ) {
156 for ( rec = project->rec; rec && rec->id != id; rec = rec->next ) ;
157 if ( !rec )
158 cerr << "Error in do_box: Reconstruction " << id << " not found!" << endl;
159 } else {
160 cerr << "Error in do_box: Item " << item << " must be a field, micrograph or reconstruction!" << endl;
161 returnObj = Tcl_NewObj();
162 return returnObj;
163 }
164
165 if ( mg ) {
166 if ( mg->fmg.length() )
167 filename = mg->fmg;
168 else if ( mg->fframe.length() )
169 filename = mg->fframe;
170 part = mg->part;
171 bad = mg->bad;
172 radius = mg->box_size/2;
173 badrad = mg->bad_radius;
174 } else if ( rec ) {
175 filename = rec->frec;
176 part = rec->part;
177 bad = rec->bad;
178 radius = rec->box_size/2;
179 badrad = rec->bad_radius;
180 }
181
182 if ( filename.length() ) {
183 base = filename.base();
184 for ( p = imglist; p; p = p->next ) {
185 filename2 = p->file_name();
186 if ( filename2.base() == base ) break;
187 }
188 }
189
190 Bstring action = Tcl_GetStringFromObj(objv[3], NULL);
191 if ( verbose & VERB_DEBUG )
192 cout << "DEBUG do_box: Action: " << action << " (" << action.length() << ")" << endl;
193
194 if ( action == "count" ) {
195 if ( item == "all" )
196 returnObj = box_count(project, objc, objv);
197 else
198 returnObj = box_count(part, bad, objc, objv);
199 } else if ( action == "ids" ) {
200 returnObj = box_ids(part, bad, objc, objv);
201 } else if ( action == "location" ) {
202 returnObj = box_location(part, bad, objc, objv);
203 } else if ( action == "fom" ) {
204 returnObj = box_fom(part, bad, objc, objv);
205 } else if ( action == "fom_min" ) {
206 returnObj = box_fom_min(project, objc, objv);
207 } else if ( action == "fom_max" ) {
208 returnObj = box_fom_max(project, objc, objv);
209 } else if ( action == "select" ) {
210 if ( objc < 7 )
211 returnObj = box_select(part, objc, objv);
212 else
213 returnObj = box_select(part, bad, radius, badrad, objc, objv);
214 } else if ( action == "select_min" ) {
215 returnObj = box_select_min(project, objc, objv);
216 } else if ( action == "select_max" ) {
217 returnObj = box_select_max(project, objc, objv);
218 } else if ( action == "move" ) {
219 returnObj = box_move(part, bad, objc, objv);
220 } else if ( action == "create" ) {
221 if ( mg ) returnObj = box_create(mg, objc, objv);
222 else if ( rec ) returnObj = box_create(rec, objc, objv);
223 } else if ( action == "renumber" ) {
224 returnObj = box_renumber(part, objc, objv);
225 } else if ( action == "delete" ) {
226 if ( objc > 4 ) delete_what = Tcl_GetStringFromObj(objv[4], NULL);
227 if ( delete_what == "all" || delete_what == "mg" || delete_what == "rec" )
228 returnObj = box_delete(project, objc, objv);
229 else if ( mg )
230 returnObj = box_delete(mg, objc, objv);
231 else if ( rec )
232 returnObj = box_delete(rec, objc, objv);
233 } else if ( action == "center" ) {
234 if ( p ) returnObj = box_center(mg, rec, p, objc, objv);
235 } else if ( action == "template" ) {
236 if ( p ) returnObj = box_update_template(mg, rec, p, objc, objv);
237 } else if ( action == "pickcc" ) {
238 if ( p ) returnObj = box_pickcc(mg, rec, p, objc, objv);
239 } else if ( action == "pickvar" ) {
240 if ( p ) returnObj = box_pickvar(mg, rec, p, objc, objv);
241 } else if ( action == "extract" ) {
242 if ( p ) returnObj = box_extract(mg, rec, p, objc, objv);
243 } else {
244 cerr << "Error: Action " << action << " not recognized!" << endl;
245 bexit(-1);
246 }
247
248 return returnObj;
249 }
250
251 Tcl_Obj* box_count(Bproject* project, int objc, Tcl_Obj *CONST objv[])
252 {
253 Tcl_Obj* returnObj = Tcl_NewObj();
254
255 int nbox = project_count_mg_particles(project) + project_count_rec_particles(project);
256
257 Tcl_SetIntObj(returnObj, nbox);
258
259 return returnObj;
260 }
261
262 Tcl_Obj* box_count(Bparticle* part, Bbadarea* bad, int objc, Tcl_Obj *CONST objv[])
263 {
264 Tcl_Obj* returnObj = Tcl_NewObj();
265
266 int nbox(0);
267
268 Bstring select_bad;
269 if ( objc > 4 ) select_bad = Tcl_GetStringFromObj(objv[4], NULL);
270
271 if ( select_bad == "bad" ) nbox = count_list((char *) bad);
272 else nbox = count_list((char *) part);
273
274 Tcl_SetIntObj(returnObj, nbox);
275
276 return returnObj;
277 }
278
279 Tcl_Obj* box_ids(Bparticle* part, Bbadarea* bad, int objc, Tcl_Obj *CONST objv[])
280 {
281 Tcl_Obj* returnObj = Tcl_NewObj();
282
283 int fom_index(0);
284 double fom_cut(-1);
285 Bstring select_bad;
286 char string[MAXLINELEN] = "";
287
288 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &fom_cut);
289 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &fom_index);
290 if ( objc > 4 ) select_bad = Tcl_GetStringFromObj(objv[4], NULL);
291
292 if ( select_bad == "bad" ) {
293 for ( ; bad; bad = bad->next ) {
294 snprintf(string, MAXLINELEN, " %d", bad->id);
295 Tcl_AppendToObj(returnObj, string, strlen(string));
296 }
297 } else {
298 for ( ; part; part = part->next ) if ( part->fom[fom_index] >= fom_cut ) {
299 snprintf(string, MAXLINELEN, " %d", part->id);
300 Tcl_AppendToObj(returnObj, string, strlen(string));
301 }
302 }
303
304 return returnObj;
305 }
306
307 Tcl_Obj* box_location(Bparticle* part, Bbadarea* bad, int objc, Tcl_Obj *CONST objv[])
308 {
309 Tcl_Obj* returnObj = Tcl_NewObj();
310
311 int id(0);
312 char string[MAXLINELEN] = "";
313
314 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
315
316 if ( id > 0 ) for ( ; part && part->id != id; part = part->next ) ;
317 else for ( ; bad && bad->id != id; bad = bad->next ) ;
318
319 if ( id > 0 && part ) {
320 snprintf(string, MAXLINELEN, "%f %f %f", part->loc[0], part->loc[1], part->loc[2]);
321 Tcl_SetStringObj(returnObj, string, strlen(string));
322 } else if ( id < 0 && bad ) {
323 snprintf(string, MAXLINELEN, "%f %f %f", bad->loc[0], bad->loc[1], bad->loc[2]);
324 Tcl_SetStringObj(returnObj, string, strlen(string));
325 } else {
326 snprintf(string, MAXLINELEN, "-1 -1 -1");
327 Tcl_SetStringObj(returnObj, string, strlen(string));
328 }
329
330 // cout << "location for " << id << ": " << string << endl;
331
332 return returnObj;
333 }
334
335 Tcl_Obj* box_fom(Bparticle* part, Bbadarea* bad, int objc, Tcl_Obj *CONST objv[])
336 {
337 Tcl_Obj* returnObj = Tcl_NewObj();
338
339 int id(0), fom_index(0);
340 char string[MAXLINELEN] = "";
341
342 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
343 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &fom_index);
344
345 if ( id > 0 ) {
346 for ( ; part && part->id != id; part = part->next ) ;
347 if ( part ) {
348 snprintf(string, MAXLINELEN, "%f", part->fom[fom_index]);
349 Tcl_SetStringObj(returnObj, string, strlen(string));
350 }
351 }
352
353 // cout << "fom for " << id << ": " << string << endl;
354
355 return returnObj;
356 }
357
358 Tcl_Obj* box_fom_min(Bproject* project, int objc, Tcl_Obj *CONST objv[])
359 {
360 Tcl_Obj* returnObj = Tcl_NewObj();
361
362 int fom_index(0);
363 double fom_min(1e30);
364
365 Bfield* field = project->field;
366 Bmicrograph* mg = NULL;
367 Breconstruction* rec = NULL;
368 Bparticle* part = NULL;
369
370 if ( project->select < 1 ) {
371 for ( field = project->field; field; field = field->next )
372 for ( mg = field->mg; mg; mg = mg->next )
373 for ( part = mg->part; part; part = part->next )
374 if ( fom_min > part->fom[fom_index] ) fom_min = part->fom[fom_index];
375 } else {
376 for ( rec = project->rec; rec; rec = rec->next )
377 for ( part = rec->part; part; part = part->next )
378 if ( fom_min > part->fom[fom_index] ) fom_min = part->fom[fom_index];
379 }
380
381 Tcl_SetDoubleObj(returnObj, fom_min);
382
383 return returnObj;
384 }
385
386 Tcl_Obj* box_fom_max(Bproject* project, int objc, Tcl_Obj *CONST objv[])
387 {
388 Tcl_Obj* returnObj = Tcl_NewObj();
389
390 int fom_index(0);
391 double fom_max(-1e30);
392
393 Bfield* field = project->field;
394 Bmicrograph* mg = NULL;
395 Breconstruction* rec = NULL;
396 Bparticle* part = NULL;
397
398 if ( project->select < 1 ) {
399 for ( field = project->field; field; field = field->next )
400 for ( mg = field->mg; mg; mg = mg->next )
401 for ( part = mg->part; part; part = part->next )
402 if ( fom_max < part->fom[fom_index] ) fom_max = part->fom[fom_index];
403 } else {
404 for ( rec = project->rec; rec; rec = rec->next )
405 for ( part = rec->part; part; part = part->next )
406 if ( fom_max < part->fom[fom_index] ) fom_max = part->fom[fom_index];
407 }
408
409 Tcl_SetDoubleObj(returnObj, fom_max);
410
411 return returnObj;
412 }
413
414 Tcl_Obj* box_select(Bparticle* part, int objc, Tcl_Obj *CONST objv[])
415 {
416 Tcl_Obj* returnObj = Tcl_NewObj();
417
418 int id(0), sel(-1);
419
420 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
421 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &sel);
422
423 if ( id > 0 ) {
424 for ( ; part && part->id != id; part = part->next ) ;
425 if ( part ) {
426 if ( sel >= 0 ) part->sel = sel;
427 else sel = part->sel;
428 }
429 }
430
431 Tcl_SetIntObj(returnObj, sel);
432
433 return returnObj;
434 }
435
436 Tcl_Obj* box_select(Bparticle* part, Bbadarea* bad, Vector3<float> rad, double badrad, int objc, Tcl_Obj *CONST objv[])
437 {
438 Tcl_Obj* returnObj = Tcl_NewObj();
439
440 int id(0), i(0);
441 double x(0), y(0), z(0);
442
443 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &x);
444 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &y);
445 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &z);
446
447 double d, dmin;
448 Vector3<float> loc(x, y, z), b, vs, ve;
449
450 // Particle box
451 dmin = 2*rad.length();
452 for ( ; part; part = part->next ) {
453 d = loc.distance(part->loc);
454 if ( dmin > d ) {
455 dmin = d;
456 i = part->id;
457 b = part->loc;
458 }
459 }
460 // if ( dmin <= rad.length() ) id = i;
461 if ( i ) {
462 vs = b - rad;
463 ve = b + rad;
464 if ( loc.within(vs, ve) ) id = i;
465 }
466
467 // Bad area
468 for ( ; bad; bad = bad->next ) {
469 d = loc.distance(bad->loc);
470 if ( dmin > d ) {
471 dmin = d;
472 i = bad->id;
473 }
474 }
475 if ( id == 0 ) if ( dmin <= badrad ) id = i;
476
477 Tcl_SetIntObj(returnObj, id);
478
479 return returnObj;
480 }
481
482 Tcl_Obj* box_select_min(Bproject* project, int objc, Tcl_Obj *CONST objv[])
483 {
484 Tcl_Obj* returnObj = Tcl_NewObj();
485
486 double sel_min(1e30);
487
488 Bfield* field = project->field;
489 Bmicrograph* mg = NULL;
490 Breconstruction* rec = NULL;
491 Bparticle* part = NULL;
492
493 if ( project->select < 1 ) {
494 for ( field = project->field; field; field = field->next )
495 for ( mg = field->mg; mg; mg = mg->next )
496 for ( part = mg->part; part; part = part->next )
497 if ( sel_min > part->sel ) sel_min = part->sel;
498 } else {
499 for ( rec = project->rec; rec; rec = rec->next )
500 for ( part = rec->part; part; part = part->next )
501 if ( sel_min > part->sel ) sel_min = part->sel;
502 }
503
504 Tcl_SetDoubleObj(returnObj, sel_min);
505
506 return returnObj;
507 }
508
509 Tcl_Obj* box_select_max(Bproject* project, int objc, Tcl_Obj *CONST objv[])
510 {
511 Tcl_Obj* returnObj = Tcl_NewObj();
512
513 double sel_max(0);
514
515 Bfield* field = project->field;
516 Bmicrograph* mg = NULL;
517 Breconstruction* rec = NULL;
518 Bparticle* part = NULL;
519
520 if ( project->select < 1 ) {
521 for ( field = project->field; field; field = field->next )
522 for ( mg = field->mg; mg; mg = mg->next )
523 for ( part = mg->part; part; part = part->next )
524 if ( sel_max < part->sel ) sel_max = part->sel;
525 } else {
526 for ( rec = project->rec; rec; rec = rec->next )
527 for ( part = rec->part; part; part = part->next )
528 if ( sel_max < part->sel ) sel_max = part->sel;
529 }
530
531 Tcl_SetDoubleObj(returnObj, sel_max);
532
533 return returnObj;
534 }
535
536 Tcl_Obj* box_move(Bparticle* part, Bbadarea* bad, int objc, Tcl_Obj *CONST objv[])
537 {
538 Tcl_Obj* returnObj = Tcl_NewObj();
539
540 int id(0);
541 double dx(0), dy(0), dz(0);
542
543 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &id);
544 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &dx);
545 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &dy);
546 if ( objc > 7 ) Tcl_GetDoubleFromObj(NULL, objv[7], &dz);
547
548 Vector3<float> d = Vector3<float>(dx, dy, dz);
549
550 if ( id > 0 ) {
551 for ( ; part && part->id != id; part = part->next ) ;
552 if ( part ) part->loc += d;
553 } else if ( id < 0 ) {
554 for ( ; bad && bad->id != id; bad = bad->next ) ;
555 if ( bad ) bad->loc += d;
556 }
557
558 Tcl_SetIntObj(returnObj, id);
559
560 return returnObj;
561 }
562
563 Tcl_Obj* box_create(Bmicrograph* mg, int objc, Tcl_Obj *CONST objv[])
564 {
565 Tcl_Obj* returnObj = Tcl_NewObj();
566
567 int id(0), sel(1);
568 double x, y, z;
569 Bstring select_bad;
570
571 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &x);
572 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &y);
573 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &z);
574 if ( objc > 7 ) select_bad = Tcl_GetStringFromObj(objv[7], NULL);
575 if ( objc > 8 ) Tcl_GetIntFromObj(NULL, objv[8], &sel);
576
577 Bparticle* part = NULL;
578 Bbadarea* bad = NULL;
579
580 if ( select_bad != "bad" ) {
581 for ( part = mg->part; part; part = part->next )
582 if ( id < part->id ) id = part->id;
583 part = particle_add(&mg->part, ++id);
584 part->loc = Vector3<float>(x, y, z);
585 part->ori = mg->box_size/2;
586 part->sel = sel;
587 } else {
588 for ( bad = mg->bad; bad; bad = bad->next )
589 if ( id > bad->id ) id = bad->id;
590 bad = (Bbadarea *) add_item((char **) &mg->bad, sizeof(Bbadarea));
591 bad->id = --id;
592 bad->loc = Vector3<float>(x, y, z);
593 }
594
595 // cout << "Creating a box " << id << " at " << x << "," << y << "," << z << endl;
596
597 Tcl_SetIntObj(returnObj, id);
598
599 return returnObj;
600 }
601
602 Tcl_Obj* box_create(Breconstruction* rec, int objc, Tcl_Obj *CONST objv[])
603 {
604 Tcl_Obj* returnObj = Tcl_NewObj();
605
606 int id(0), sel(1);
607 double x, y, z;
608 Bstring select_bad;
609
610 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &x);
611 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &y);
612 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &z);
613 if ( objc > 7 ) select_bad = Tcl_GetStringFromObj(objv[7], NULL);
614 if ( objc > 8 ) Tcl_GetIntFromObj(NULL, objv[8], &sel);
615
616 Bparticle* part = NULL;
617 Bbadarea* bad = NULL;
618
619 if ( select_bad != "bad" ) {
620 for ( part = rec->part; part; part = part->next )
621 if ( id < part->id ) id = part->id;
622 part = particle_add(&rec->part, ++id);
623 part->loc = Vector3<float>(x, y, z);
624 part->ori = rec->box_size/2;
625 part->sel = sel;
626 } else {
627 for ( bad = rec->bad; bad; bad = bad->next )
628 if ( id > bad->id ) id = bad->id;
629 bad = (Bbadarea *) add_item((char **) &rec->bad, sizeof(Bbadarea));
630 bad->id = --id;
631 bad->loc = Vector3<float>(x, y, z);
632 }
633
634 // cout << "Creating a box " << id << " at " << x << "," << y << "," << z << endl;
635
636 Tcl_SetIntObj(returnObj, id);
637
638 return returnObj;
639 }
640
641 Tcl_Obj* box_renumber(Bparticle* part, int objc, Tcl_Obj *CONST objv[])
642 {
643 Tcl_Obj* returnObj = Tcl_NewObj();
644
645 int i;
646
647 for ( i=0; part; part = part->next ) part->id = ++i;
648
649 return returnObj;
650 }
651
652 Tcl_Obj* box_delete(Bproject* project, int objc, Tcl_Obj *CONST objv[])
653 {
654 Tcl_Obj* returnObj = Tcl_NewObj();
655
656 int fom_index(0);
657 double fom_cut(0);
658
659 Bstring action = Tcl_GetStringFromObj(objv[4], NULL);
660
661 Bfield* field = project->field;
662 Bmicrograph* mg = NULL;
663 Breconstruction* rec;
664 Bparticle* part = NULL;
665
666 // cout << "Box deletion action: " << action << endl;
667
668 if ( action == "all" || action == "mg" ) {
669 for ( field = project->field; field; field = field->next ) {
670 for ( mg = field->mg; mg; mg = mg->next ) {
671 particle_kill(mg->part);
672 mg->part = NULL;
673 kill_list((char *) mg->bad, sizeof(Bbadarea));
674 mg->bad = NULL;
675 }
676 }
677 }
678
679 if ( action == "all" || action == "rec" ) {
680 for ( rec = project->rec; rec; rec = rec->next ) {
681 particle_kill(rec->part);
682 rec->part = NULL;
683 kill_list((char *) rec->bad, sizeof(Bbadarea));
684 rec->bad = NULL;
685 }
686 }
687
688 if ( action == "fom" ) {
689 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &fom_cut);
690 // cout << "FOM cutoff: " << fom_cut << endl;
691 for ( field = project->field; field; field = field->next ) {
692 for ( mg = field->mg; mg; mg = mg->next ) {
693 for ( part = mg->part; part; part = part->next ) {
694 if ( part->fom[fom_index] < fom_cut )
695 remove_item((char **)&mg->part, (char *)part, sizeof(Bparticle));
696 }
697 }
698 }
699 for ( rec = project->rec; rec; rec = rec->next ) {
700 for ( part = rec->part; part; part = part->next ) {
701 if ( part->fom[fom_index] < fom_cut )
702 remove_item((char **)&rec->part, (char *)part, sizeof(Bparticle));
703 }
704 }
705 }
706
707 return returnObj;
708 }
709
710 Tcl_Obj* box_delete(Bmicrograph* mg, int objc, Tcl_Obj *CONST objv[])
711 {
712 Tcl_Obj* returnObj = Tcl_NewObj();
713
714 int id(0), fom_index(0);
715 double fom_cut(0);
716 Bparticle* part = NULL;
717 Bbadarea* bad = NULL;
718
719 Bstring action;
720 if ( objc > 4 ) {
721 action = Tcl_GetStringFromObj(objv[4], NULL);
722 Tcl_GetIntFromObj(NULL, objv[4], &id);
723 }
724
725 // cout << "Box deletion action: " << action << endl;
726
727 if ( mg ) {
728 if ( action == "fom" ) {
729 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &fom_cut);
730 for ( part = mg->part; part; part = part->next ) {
731 if ( part->fom[fom_index] < fom_cut )
732 remove_item((char **)&mg->part, (char *)part, sizeof(Bparticle));
733 }
734 } else if ( action == "current" ) {
735 particle_kill(mg->part);
736 mg->part = NULL;
737 } else if ( id > 0 ) {
738 for ( part = mg->part; part && part->id != id; part = part->next ) ;
739 if ( part )
740 remove_item((char **)&mg->part, (char *)part, sizeof(Bparticle));
741 } else if ( id < 0 ) {
742 for ( bad = mg->bad; bad && bad->id != id; bad = bad->next ) ;
743 if ( bad )
744 remove_item((char **)&mg->bad, (char *)bad, sizeof(Bbadarea));
745 }
746 }
747
748 Tcl_SetIntObj(returnObj, id);
749
750 return returnObj;
751 }
752
753 Tcl_Obj* box_delete(Breconstruction* rec, int objc, Tcl_Obj *CONST objv[])
754 {
755 Tcl_Obj* returnObj = Tcl_NewObj();
756
757 int id(0), fom_index(0);
758 double fom_cut(0);
759 Bparticle* part = NULL;
760 Bbadarea* bad = NULL;
761
762 Bstring action;
763 if ( objc > 4 ) {
764 action = Tcl_GetStringFromObj(objv[4], NULL);
765 Tcl_GetIntFromObj(NULL, objv[4], &id);
766 }
767
768 // cout << "Box deletion action: " << action << endl;
769
770 if ( rec ) {
771 if ( action == "fom" ) {
772 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &fom_cut);
773 for ( part = rec->part; part; part = part->next ) {
774 if ( part->fom[fom_index] < fom_cut )
775 remove_item((char **)&rec->part, (char *)part, sizeof(Bparticle));
776 }
777 } else if ( action == "current" ) {
778 particle_kill(rec->part);
779 rec->part = NULL;
780 } else if ( id > 0 ) {
781 for ( part = rec->part; part && part->id != id; part = part->next ) ;
782 if ( part )
783 remove_item((char **)&rec->part, (char *)part, sizeof(Bparticle));
784 } else if ( id < 0 ) {
785 for ( bad = rec->bad; bad && bad->id != id; bad = bad->next ) ;
786 if ( bad )
787 remove_item((char **)&rec->bad, (char *)bad, sizeof(Bbadarea));
788 }
789 }
790
791 Tcl_SetIntObj(returnObj, id);
792
793 return returnObj;
794 }
795
796 Tcl_Obj* box_center(Bmicrograph* mg, Breconstruction* rec, Bimage* p, int objc, Tcl_Obj *CONST objv[])
797 {
798 Tcl_Obj* returnObj = Tcl_NewObj();
799
800 box_update_template(mg, rec, p, objc, objv);
801
802 int n(0);
803 double hires(p->sampling()[0]*4), lores(200), tlim(mg->box_size[0]/8);
804 Bparticle* part = NULL;
805 Bimage* p1;
806 Vector3<long> size;
807 Vector3<double> origin;
808
809 // cout << "mg box size = " << mg->box_size << endl;
810
811 if ( mg ) {
812 size = mg->box_size;
813 origin = mg->box_size/2;
814 part = mg->part;
815 } else if ( rec ) {
816 size = rec->box_size;
817 origin = rec->box_size/2;
818 part = rec->part;
819 }
820
821 tlim = size[0]/8;
822
823 for ( ; part; part = part->next ) {
824 p1 = p->extract(0, part->loc - origin, size);
825 p1->find_shift(imgtemp, NULL, hires, lores, tlim, 0, 1);
826 part->loc += imgtemp->image->origin() - p1->image->origin();
827 part->fom[0] = imgtemp->image->FOM();
828 delete p1;
829 n++;
830 }
831
832 Tcl_SetIntObj(returnObj, n);
833
834 return returnObj;
835 }
836
837 Tcl_Obj* box_update_template(Bmicrograph* mg, Breconstruction* rec, Bimage* p, int objc, Tcl_Obj *CONST objv[])
838 {
839 Tcl_Obj* returnObj = Tcl_NewObj();
840
841 int n(0), img_num(0), nn;
842 Bparticle* part = NULL;
843 Bimage* p1;
844 Vector3<long> size;
845 Vector3<double> origin;
846
847 delete imgtemp;
848 imgtemp = NULL;
849
850 if ( mg ) {
851 img_num = mg->img_num;
852 size = mg->box_size;
853 origin = mg->box_size/2;
854 origin[2] = 0;
855 part = mg->part;
856 } else if ( rec ) {
857 size = rec->box_size;
858 origin = rec->box_size/2;
859 part = rec->part;
860 }
861
862 for ( ; part; part = part->next ) {
863 p1 = p->extract(img_num, part->loc - origin, size, FILL_AVERAGE);
864 p1->change_type(Float);
865 if ( imgtemp ) {
866 imgtemp->add(p1);
867 delete p1;
868 } else imgtemp = p1;
869 n++;
870 }
871
872 if ( imgtemp ) {
873 imgtemp->calculate_background();
874 for ( nn=0; nn<imgtemp->images(); nn++ ) {
875 p1 = imgtemp->extract(nn);
876 p1->find_center(NULL, 1000, 20*p->sampling()[0], size[0]/10, 0, 1);
877 // cout << "shift=" << origin - p1->image->origin() << endl;
878 imgtemp->shift(nn, origin - p1->image->origin(), FILL_BACKGROUND);
879 delete p1;
880 }
881 imgtemp->origin(origin);
882 imgtemp->identifier("thetemp");
883 imgtemp->rescale_to_avg_std(0, 1);
884 }
885
886 Tcl_SetIntObj(returnObj, n);
887
888 return returnObj;
889 }
890
891 Tcl_Obj* box_pickcc(Bmicrograph* mg, Breconstruction* rec, Bimage* p, int objc, Tcl_Obj *CONST objv[])
892 {
893 Tcl_Obj* returnObj = Tcl_NewObj();
894
895 if ( !p ) return returnObj;
896
897 int bin(1);
898 double hires(p->sampling()[0]*4), lores(200);
899 double fommin(0), fommax(1e30), excl_dist(0), threshold(0);
900 Bimage* pmask = NULL;
901
902 if ( objc > 4 ) Tcl_GetDoubleFromObj(NULL, objv[4], &hires);
903 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &lores);
904 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &fommin);
905 if ( objc > 7 ) Tcl_GetDoubleFromObj(NULL, objv[7], &fommax);
906 if ( objc > 8 ) Tcl_GetDoubleFromObj(NULL, objv[8], &excl_dist);
907 if ( objc > 9 ) Tcl_GetIntFromObj(NULL, objv[9], &bin);
908
909 if ( imgtemp ) {
910 if ( mg ) {
911 mg->box_size = imgtemp->size();
912 mg->part = particles_pick_cc(p, imgtemp, pmask, hires, lores, fommin, fommax, excl_dist, bin);
913 threshold = mg->fom = imgtemp->image->FOM();
914 } else if ( rec ) {
915 rec->box_size = imgtemp->size();
916 rec->part = particles_pick_cc(p, imgtemp, pmask, hires, lores, fommin, fommax, excl_dist, bin);
917 threshold = rec->fom = imgtemp->image->FOM();
918 }
919 }
920
921 Tcl_SetDoubleObj(returnObj, threshold);
922
923 return returnObj;
924 }
925
926 Tcl_Obj* box_pickvar(Bmicrograph* mg, Breconstruction* rec, Bimage* p, int objc, Tcl_Obj *CONST objv[])
927 {
928 Tcl_Obj* returnObj = Tcl_NewObj();
929
930 if ( !p ) return returnObj;
931
932 int bin(1), avg_kernel(21), var_kernel(301);
933 // double excl_dist(0), threshold(0), nsig(5);
934 double excl_dist(0), threshold(0), cutmin(0.1), cutmax(0.2);
935
936 if ( objc > 4 ) Tcl_GetIntFromObj(NULL, objv[4], &avg_kernel);
937 if ( objc > 5 ) Tcl_GetIntFromObj(NULL, objv[5], &var_kernel);
938 if ( objc > 6 ) Tcl_GetDoubleFromObj(NULL, objv[6], &excl_dist);
939 if ( objc > 7 ) Tcl_GetIntFromObj(NULL, objv[7], &bin);
940 // if ( objc > 8 ) Tcl_GetDoubleFromObj(NULL, objv[8], &nsig);
941 if ( objc > 8 ) Tcl_GetDoubleFromObj(NULL, objv[8], &cutmin);
942 if ( objc > 9 ) Tcl_GetDoubleFromObj(NULL, objv[9], &cutmax);
943
944 // cout << "excl_dist=" << excl_dist << endl;
945
946 if ( mg ) {
947 // mg->part = particles_pick_var(p, avg_kernel, var_kernel, nsig,
948 // mg->box_size[0]/2, excl_dist, bin);
949 mg->part = particles_pick_var(p, avg_kernel, var_kernel, cutmin,
950 cutmax, mg->box_size[0]/2, excl_dist, bin);
951 threshold = mg->fom ;
952 } else if ( rec ) {
953 // rec->part = particles_pick_var(p, avg_kernel, var_kernel, nsig,
954 // rec->box_size[0]/2, excl_dist, bin);
955 rec->part = particles_pick_var(p, avg_kernel, var_kernel, cutmin,
956 cutmax, rec->box_size[0]/2, excl_dist, bin);
957 threshold = rec->fom;
958 }
959
960 Tcl_SetDoubleObj(returnObj, threshold);
961
962 return returnObj;
963 }
964
965 Tcl_Obj* box_extract(Bmicrograph* mg, Breconstruction* rec, Bimage* p, int objc, Tcl_Obj *CONST objv[])
966 {
967 Tcl_Obj* returnObj = Tcl_NewObj();
968
969 if ( !p ) return 0;
970
971 Bstring filename, partpath;
972 int back_flag(0), norm_flag(0), mask_width(0), split(0);
973 int filltype(2), npart(0);
974 double scale(1), fill(0);
975
976 if ( objc > 4 ) filename = Tcl_GetStringFromObj(objv[4], NULL);
977 if ( objc > 5 ) Tcl_GetDoubleFromObj(NULL, objv[5], &scale); /* Extraction scale */
978 if ( objc > 6 ) Tcl_GetIntFromObj(NULL, objv[6], &back_flag); /* Flag for background correction */
979 if ( objc > 7 ) Tcl_GetIntFromObj(NULL, objv[7], &norm_flag); /* Flag for normalization */
980 if ( objc > 8 ) Tcl_GetIntFromObj(NULL, objv[8], &filltype); /* Fill value */
981 if ( objc > 9 ) Tcl_GetDoubleFromObj(NULL, objv[9], &fill);
982 if ( objc > 10 ) Tcl_GetIntFromObj(NULL, objv[10], &mask_width); /* Filament mask width */
983 if ( objc > 11 ) Tcl_GetIntFromObj(NULL, objv[11], &split); /* Flag to split particles into individual images */
984 if ( objc > 12 ) partpath = Tcl_GetStringFromObj(objv[12], NULL); /* Particle image path */
985
986 if ( filltype == 1 ) fill = p->average();
987 else if ( filltype == 2 ) {
988 if ( fabs(p->background(long(0))) < 1e-6 ) p->calculate_background();
989 fill = p->background(long(0));
990 }
991
992 if ( filename.length() ) {
993 if ( mg ) {
994 if ( split ) {
995 particle_setup_filenames(mg->part, filename, partpath);
996 mg->fpart = 0;
997 } else {
998 if ( partpath.length() ) {
999 filename = partpath + "/" + filename;
1000 mkdir(partpath.c_str(), (mode_t)0755);
1001 }
1002 mg->fpart = filename;
1003 }
1004 npart = micrograph_extract_particles(mg, p, scale,
1005 back_flag, norm_flag, fill, mask_width);
1006 } else if ( rec ) {
1007 if ( split ) {
1008 particle_setup_filenames(rec->part, filename, partpath);
1009 rec->fpart = 0;
1010 } else {
1011 if ( partpath.length() ) {
1012 filename = partpath + "/" + filename;
1013 mkdir(partpath.c_str(), (mode_t)0755);
1014 }
1015 rec->fpart = filename;
1016 }
1017 npart = reconstruction_extract_particles(rec, p, scale,
1018 back_flag, norm_flag, fill, mask_width);
1019 }
1020 }
1021
1022 filename = 0;
1023 partpath = 0;
1024
1025 Tcl_SetIntObj(returnObj, npart);
1026
1027 return returnObj;
1028 }
1029
Bimage::change_type
void change_type(char letter)
Get the data type indicated by a single letter code.
Definition: Bimage.cpp:1743
Bparticle::id
int id
Definition: mg_processing.h:92
rwmg.h
Header file for reading and writing micrograph parameters.
Bproject::rec
Breconstruction * rec
Definition: mg_processing.h:344
FILL_BACKGROUND
#define FILL_BACKGROUND
Definition: utilities.h:174
Bstring::post
Bstring post(char c)
Definition: Bstring.cpp:394
tcltk_bbox.h
particle_setup_filenames
int particle_setup_filenames(Bparticle *part, Bstring filename, Bstring partpath)
Sets up individual particle file names for extraction.
Definition: mg_extract.cpp:35
Bimage::sampling
Vector3< double > sampling()
Definition: Bimage.h:505
Vector3::length
double length()
Definition: Vector3.h:222
box_renumber
Tcl_Obj * box_renumber(Bparticle *part, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:641
Breconstruction::part
Bparticle * part
Definition: mg_processing.h:304
Bimage::add
void add(long j, double v)
Definition: Bimage.h:308
box_fom
Tcl_Obj * box_fom(Bparticle *part, Bbadarea *bad, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:335
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::img_num
int img_num
Definition: mg_processing.h:211
utilities.h
Header file for general utilities.
Breconstruction::fom
double fom
Definition: mg_processing.h:302
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:112
Breconstruction
Definition: mg_processing.h:280
mg_img_proc.h
Header file for image processing from micrograph structures.
Bbadarea::loc
Vector3< double > loc
Definition: mg_processing.h:145
kill_list
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
Definition: linked_list.cpp:214
Bparticle::fom
double fom[NFOM]
Definition: mg_processing.h:102
box_update_template
Tcl_Obj * box_update_template(Bmicrograph *mg, Breconstruction *rec, Bimage *p, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:837
add_item
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
Definition: linked_list.cpp:26
Bimage::identifier
void identifier(Bstring s)
Definition: Bimage.h:216
FILL_AVERAGE
#define FILL_AVERAGE
Definition: utilities.h:173
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
project
Bproject * project
Definition: bshow.cpp:31
count_list
long count_list(char *list)
Counts the number of items in a linked list.
Definition: linked_list.cpp:235
project_count_mg_particles
long project_count_mg_particles(Bproject *project)
Counts all the particles in the project structure.
Definition: mg_processing.cpp:811
particle_kill
int particle_kill(Bparticle *part)
Frees a list of particles.
Definition: mg_processing.cpp:1323
Bstring::remove
Bstring remove(const char c)
Definition: Bstring.cpp:465
MAXLINELEN
#define MAXLINELEN
Definition: utilities.h:44
particles_pick_var
Bparticle * particles_pick_var(Bimage *p, long average_kernel, long var_kernel, double nsig, double part_ori, double excl_dist, long bin)
Picks particles in variance map.
Definition: mg_pick.cpp:219
Bimage::file_name
void file_name(string s)
Definition: Bimage.h:230
mg_ctf.h
Functions for CTF (contrast transfer function) processing.
do_box
Tcl_Obj * do_box(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:113
Vector3::distance
double distance(const Vector3 &v)
Definition: Vector3.h:227
Breconstruction::box_size
Vector3< long > box_size
Definition: mg_processing.h:296
box_center
Tcl_Obj * box_center(Bmicrograph *mg, Breconstruction *rec, Bimage *p, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:796
box_extract
Tcl_Obj * box_extract(Bmicrograph *mg, Breconstruction *rec, Bimage *p, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:965
Bfield::next
Bfield * next
Definition: mg_processing.h:258
Bmicrograph::part
Bparticle * part
Definition: mg_processing.h:239
timer.h
Utilities for timing functions.
box_select_min
Tcl_Obj * box_select_min(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:482
Float
Definition: utilities.h:157
project_count_rec_particles
long project_count_rec_particles(Bproject *project)
Counts all the particles in the project structure.
Definition: mg_processing.cpp:902
Bimage
General image parameter class.
Definition: Bimage.h:163
Bmicrograph::fpart
Bstring fpart
Definition: mg_processing.h:207
box_pickcc
Tcl_Obj * box_pickcc(Bmicrograph *mg, Breconstruction *rec, Bimage *p, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:891
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
imgtemp
Bimage * imgtemp
Definition: bshow.cpp:34
linked_list.h
Header file for generalized linked list functions.
Bimage::extract
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
Definition: Bimage_extract.cpp:21
Bimage::shift
int shift(Vector3< double > vec, int fill_type=0, double fill=0)
Shifts an image.
Definition: Bimage_transform.cpp:587
base
string base(string &filename)
Definition: string_util.cpp:28
box_create
Tcl_Obj * box_create(Bmicrograph *mg, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:563
Bmicrograph::fframe
Bstring fframe
Definition: mg_processing.h:206
Bbadarea::next
Bbadarea * next
Definition: mg_processing.h:143
Bfield::id
Bstring id
Definition: mg_processing.h:259
Bstring::pre
Bstring pre(char c)
Definition: Bstring.cpp:381
Bproject::field
Bfield * field
Definition: mg_processing.h:343
Bsub_image::FOM
double FOM()
Definition: Bimage.h:151
Bimage::rescale_to_avg_std
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.
Definition: Bimage_rescale.cpp:163
box_move
Tcl_Obj * box_move(Bparticle *part, Bbadarea *bad, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:536
Bmicrograph
Definition: mg_processing.h:200
mg_extract.h
Header file for functions to extract particles from micrographs.
imglist
Bimage * imglist
Definition: bshow.cpp:30
reconstruction_extract_particles
long reconstruction_extract_particles(Breconstruction *rec, Bimage *p, double scale, int back_flag, int norm_flag, double fill, int mask_width)
Extracts particle images from a reconstruction.
Definition: mg_extract.cpp:363
Bimage::size
Vector3< long > size() const
Definition: Bimage.h:373
Bimage::calculate_background
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
Definition: Bimage_background.cpp:27
particles_pick_cc
Bparticle * particles_pick_cc(Bimage *p, Bimage *ptemp, Bimage *pmask, double hires, double lores, double fommin, double fommax, double excl_dist, long bin=1)
Picks particles using cross-correlation.
Definition: mg_pick.cpp:137
Bsub_image::origin
void origin(double x, double y, double z)
Definition: Bimage.h:127
remove_item
char * remove_item(char **list, char *item, unsigned long size)
Finds the given item and deletes it from the linked list.
Definition: linked_list.cpp:114
Bparticle::ori
Vector3< double > ori
Definition: mg_processing.h:100
box_fom_max
Tcl_Obj * box_fom_max(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:386
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
Bbadarea::id
int id
Definition: mg_processing.h:144
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:264
box_ids
Tcl_Obj * box_ids(Bparticle *part, Bbadarea *bad, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:279
Bimage::next
Bimage * next
Definition: Bimage.h:165
Bstring::base
Bstring base()
Definition: Bstring.cpp:508
Bimage::find_center
int find_center(Bimage *pmask, double hires, double lores, double radius, double sigma, int refine_flag)
Finds the center of mass of an image by cross-correlation with its inverse.
Definition: Bimage_correlate.cpp:1233
Bparticle
Definition: mg_processing.h:89
box_location
Tcl_Obj * box_location(Bparticle *part, Bbadarea *bad, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:307
Bstring
Definition: Bstring.h:29
box_fom_min
Tcl_Obj * box_fom_min(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:358
box_select
Tcl_Obj * box_select(Bparticle *part, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:414
Bproject::select
int select
Definition: mg_processing.h:339
Breconstruction::bad_radius
double bad_radius
Definition: mg_processing.h:299
mg_pick.h
Header file for single particle picking functions.
Bmicrograph::box_size
Vector3< long > box_size
Definition: mg_processing.h:230
Breconstruction::bad
Bbadarea * bad
Definition: mg_processing.h:306
Vector3< float >
Bmicrograph::fmg
Bstring fmg
Definition: mg_processing.h:205
box_count
Tcl_Obj * box_count(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:251
Bparticle::loc
Vector3< double > loc
Definition: mg_processing.h:99
micrograph_extract_particles
long micrograph_extract_particles(Bmicrograph *mg, Bimage *p, double scale, int back_flag, int norm_flag, double fill, int mask_width)
Extracts particle images from a micrograph.
Definition: mg_extract.cpp:332
Bmicrograph::bad
Bbadarea * bad
Definition: mg_processing.h:241
Bmicrograph::fom
double fom
Definition: mg_processing.h:236
Bimage::find_shift
int find_shift(Bimage *pref, Bimage *pmask, double hires, double lores, double radius, double sigma, int refine_flag)
Calculates a cross-correlation map to find the shift for the pair of images.
Definition: Bimage_correlate.cpp:932
tcltk_bimage.h
A shared object to load Bsoft image files in TCL/Tk.
Bimage::average
double average(long cc, double xf, double yf, double zf, long nn, double iscale)
Averages in 3D when scaling is less than 1.
Definition: Bimage.cpp:1349
box_pickvar
Tcl_Obj * box_pickvar(Bmicrograph *mg, Breconstruction *rec, Bimage *p, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:926
Breconstruction::frec
Bstring frec
Definition: mg_processing.h:287
Bimage::images
long images()
Definition: Bimage.h:491
Bmicrograph::bad_radius
double bad_radius
Definition: mg_processing.h:233
split
vector< string > split(const string &s)
Splits a string on whitespace.
Definition: string_util.cpp:92
box_select_max
Tcl_Obj * box_select_max(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:509
verbose
int verbose
Bparticle::next
Bparticle * next
Definition: mg_processing.h:90
Bimage::background
double background(long nn)
Definition: Bimage.h:542
box_delete
Tcl_Obj * box_delete(Bproject *project, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bbox.cpp:652
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:273
Breconstruction::next
Breconstruction * next
Definition: mg_processing.h:281
Bproject
Definition: mg_processing.h:333
Bimage::image
Bsub_image * image
Definition: Bimage.h:188
Bimage::origin
void origin(double ox, double oy, double oz)
Definition: Bimage.h:563
Breconstruction::id
Bstring id
Definition: mg_processing.h:282
Bmicrograph::next
Bmicrograph * next
Definition: mg_processing.h:201