| Bsoft 2.0.5 Bernard's software package

mg_processing.cpp
Go to the documentation of this file.
1
9 #include "mg_processing.h"
10 #include "mg_tags.h"
11 #include "qsort_functions.h"
12 #include "linked_list.h"
13 #include "math_util.h"
14 #include "random_numbers.h"
15 #include "utilities.h"
16 #include <fstream>
17
18 // Declaration of global variables
19 extern int verbose; // Level of output to the screen
20
21
29 Bproject* project_init()
30 {
31 Bproject* project = new Bproject;
32 memset(project, 0, sizeof(Bproject));
33
34 return project;
35 }
36
47 Bproject* project_create(int nmg, int nrec)
48 {
49 int i, j=0;
50 Bstring id("1");
51 Bproject* project = project_init();
52 Bmicrograph* mg = NULL;
53 Breconstruction* rec = NULL;
54
55 if ( nmg > 0 ) {
56 field_add(&project->field, id);
57 for ( i=0; i<nmg; i++, j++ ) {
58 id = Bstring(i, "%03d");
59 mg = micrograph_add(&project->field->mg, id);
60 mg->block = j;
61 mg->img_num = i;
62 }
63 }
64
65 if ( nrec > 0 ) {
66 for ( i=0; i<nrec; i++, j++ ) {
67 id = Bstring(i, "%03d");
68 rec = reconstruction_add(&project->rec, id);
69 rec->block = j;
70 }
71 }
72
73 if ( nmg < 1 && nrec > 0 ) project->select = 1;
74
75 return project;
76 }
77
87 int project_equal_mg_part_files(Bproject* project)
88 {
89 Bfield* field;
90 Bmicrograph* mg;
91
92 if ( verbose & VERB_PROCESS )
93 cout << "Setting micrograph and particle file names to be the same" << endl << endl;
94
95 for ( field = project->field; field; field = field->next ) {
96 for ( mg = field->mg; mg; mg = mg->next ) {
97 // cout << "mg=" << mg->fmg << " part=" << mg->fpart << endl;
98 if ( mg->fmg.length() ) mg->fpart = mg->fmg;
99 else if ( mg->fpart.length() ) mg->fmg = mg->fpart;
100 else cerr << "No file name for micrograph " << mg->id << endl;
101 // cout << "mg=" << mg->fmg << " part=" << mg->fpart << endl;
102 }
103 }
104
105 return 0;
106 }
107
120 Bfield* field_add(Bfield** field, Bstring& field_id)
121 {
122 Bfield* this_field = *field;
123 Bfield* nu_field = new Bfield;
124 memset(nu_field, 0, sizeof(Bfield));
125
126 if ( field_id.length() ) nu_field->id = field_id.c_str();
127
128 nu_field->matrix = Matrix3(1);
129 nu_field->select = 1;
130
131 if ( !this_field )
132 *field = nu_field;
133 else {
134 while ( this_field->next ) this_field = this_field->next;
135 this_field->next = nu_field;
136 }
137
138 return nu_field;
139 }
140
152 Bfield* field_find_id(Bfield* field, Bstring& field_id)
153 {
154 while ( field && field->id != field_id )
155 field = field->next;
156
157 return field;
158 }
159
183 Bmicrograph* field_find_micrograph(Bfield* field, int mg_select, int mg_index, double mg_ang)
184 {
185 Bmicrograph* mg = NULL; // Selected micrograph
186
187 switch ( mg_select ) {
188 case 0:
189 case 1:
190 mg = field_find_micrograph_by_focus(field, mg_select, mg_index);
191 break;
192 case 2:
193 mg = field_find_micrograph_n(field, mg_index);
194 break;
195 case 3:
196 mg = field_find_micrograph_by_rotang(field, mg_ang);
197 break;
198 case 4:
199 mg = field_find_micrograph_by_tiltang(field, mg_ang);
200 break;
201 }
202
203 // Error checking (primarily to catch programming mistakes)
204 if ( !mg )
205 error_show("Error: No appropriate micrograph has been selected!", __FILE__, __LINE__);
206
207 return mg;
208 }
209
223 Bmicrograph* field_find_micrograph_n(Bfield* field, int n)
224 {
225 int i; // index
226 Bmicrograph* mg = NULL; // micrograph
227
228 for ( i=1, mg = field->mg; mg && i < n; mg = mg->next, i++ ) ;
229
230 if ( !mg ) { // Make sure n is in appropriate range
231 cerr << "Error: The micrograph index you wish to find (" << n << ") is greater" << endl;
232 cerr << "than the number of micrographs (" << i << ") in the field (" << field->id << ")" << endl;
233 }
234
235 return mg;
236 }
237
261 Bmicrograph* field_find_micrograph_by_focus(Bfield* field, int focus_opt, int iselect)
262 {
263 int i; // index
264 int nmgs; // number of micrographs in field
265 int count; // used to test if multiple micrographs have same focus level
266 double focus(0); // designated focus level, depends on focus_opt and index
267 Bmicrograph* mg = NULL; // pointer to micrograph at desired focal level
268
269 nmgs = field_count_micrographs(field);
270
271 float* focal_series = new float[nmgs];
272
273 // Put defocal values into an array, then put in order min to max
274 for ( i = 0, mg = field->mg; mg; mg = mg->next, i++ ) {
275 focal_series[i] = 0;
276 if ( mg->ctf ) focal_series[i] = mg->ctf->defocus_average();
277 else cerr << "Warning in field_find_micrograph_by_focus: CTF structure not allocated!" << endl;
278 }
279
280 qsort((void *) focal_series, nmgs, sizeof(float), (int (*)(const void *, const void *)) QsortSmallToLargeFloat);
281
282 // Select (index+1)th closest-to-focus or farthest-from-focus value
283 if ( focus_opt == 0 ) focus = focal_series[0+iselect];
284 if ( focus_opt == 1 ) focus = focal_series[nmgs-1-iselect];
285 for ( count = 0, i=0; i<nmgs; i++ ) if ( focus == focal_series[i] ) count++;
286
287 delete[] focal_series;
288
289 // Find micrograph with the selected focus level
290 for ( mg = field->mg; mg && mg->ctf && mg->ctf->defocus_average() != focus; mg = mg->next ) ;
291
292 if (verbose & VERB_PROCESS)
293 cout << "Focus of selected micrograph: " << focus << endl;
294
295 if ( (count > 1) || (count == 0) ) {
296 cerr << "Error: There are " << count << " micrographs with focus levels of " << focus << endl;
297 cerr << "Please check data or select with a different criterion" << endl;
298 }
299
300 return mg;
301 }
302
318 Bmicrograph* field_find_micrograph_by_rotang(Bfield* field, double rotang)
319 {
320 int count; // used to test if multiple micrographs have same rotang
321 double closest_angle(0); // Closest angle to requested angle
322 double mindiff = 1e37; // Minimum difference between requested and available angle
323 Bmicrograph* mg = NULL; // pointer to micrograph with specified rotang
324
325 // Find micrograph with the input rot. angle
326 for ( mindiff = 1e37, mg = field->mg; mg; mg = mg->next ) {
327 if ( fabs(rotang - mg->rot_angle) < mindiff ) {
328 mindiff = fabs(rotang - mg->rot_angle);
329 closest_angle = mg->rot_angle;
330 }
331 }
332
333 for ( count = 0, mg = field->mg; mg; mg = mg->next)
334 if ( fabs(closest_angle - mg->rot_angle) < 1e-10 ) count++;
335
336 for ( mg = field->mg; mg && closest_angle != mg->rot_angle; mg = mg->next ) ;
337
338 if ( (count > 1) || (count == 0) ) {
339 cerr << "Error: There are " << count << " micrographs with the rotational angle of "
340 << closest_angle*180/M_PI << endl;
341 cerr << "Please check data or select with a different criterion" << endl;
342 }
343
344 return mg;
345 }
346
362 Bmicrograph* field_find_micrograph_by_tiltang(Bfield* field, double tiltang)
363 {
364 int count; // used to test if multiple micrographs have same rotang
365 double closest_angle(0); // Closest angle to requested angle
366 double mindiff = 1e37; // Minimum difference between requested and available angle
367 Bmicrograph* mg = NULL; // pointer to micrograph with specified rotang
368
369 // Find micrograph with the input tilt angle
370 for ( mindiff = 1e37, mg = field->mg; mg; mg = mg->next ) {
371 if ( fabs(tiltang - mg->tilt_angle) < mindiff ) {
372 mindiff = fabs(tiltang - mg->tilt_angle);
373 closest_angle = mg->tilt_angle;
374 }
375 }
376
377 for ( count = 0, mg = field->mg; mg; mg = mg->next)
378 if ( fabs(closest_angle - mg->tilt_angle) < 1e-10 ) count++;
379
380 for ( mg = field->mg; mg && (closest_angle != mg->tilt_angle); mg = mg->next ) ;
381
382 if ( (count > 1) || (count == 0) ) {
383 cerr << "Error: There are " << count << " micrographs with the tilt angle of "
384 << closest_angle*180/M_PI << endl;
385 cerr << "Please check data or select with a different criterion" << endl;
386 }
387
388 return mg;
389 }
390
400 Bmicrograph* field_find_zero_tilt_mg(Bfield* field)
401 {
402 if ( !field ) return NULL;
403
404 double min_angle(M_PI);
405 Bmicrograph* mg;
406 Bmicrograph* mg_ref = field->mg;
407
408 for ( mg = field->mg; mg; mg = mg->next ) {
409 if ( min_angle > fabs(mg->tilt_angle) ) {
410 min_angle = fabs(mg->tilt_angle);
411 mg_ref = mg;
412 }
413 // cout << mg->tilt_angle << tab << min_angle << endl;
414 }
415
416 if ( !mg_ref )
417 cerr << "Warning: No zero tilt micrograph found!" << endl;
418
419 return mg_ref;
420 }
421
431 Bmicrograph* field_find_low_tilt_mg_with_markers(Bfield* field)
432 {
433 if ( !field ) return NULL;
434
435 double min_angle = M_PI;
436 Bmicrograph* mg;
437 Bmicrograph* mg_ref = NULL;
438
439 for ( mg = field->mg; mg; mg = mg->next ) {
440 if ( mg->mark && min_angle > fabs(mg->tilt_angle) ) {
441 min_angle = fabs(mg->tilt_angle);
442 mg_ref = mg;
443 }
444 }
445
446 return mg_ref;
447 }
448
461 Bmicrograph* micrograph_add(Bmicrograph** mg, Bstring& mg_id)
462 {
463 Bmicrograph* this_mg = *mg;
464 Bmicrograph* nu_mg = new Bmicrograph;
465 memset(nu_mg, 0, sizeof(Bmicrograph));
466
467 if ( mg_id.length() ) nu_mg->id = mg_id;
468
469 nu_mg->matrix = Matrix3(1);
470 nu_mg->select = 1;
471 nu_mg->scale = Vector3<float>(1,1,1);
472
473 if ( !this_mg )
474 *mg = nu_mg;
475 else {
476 while ( this_mg->next ) this_mg = this_mg->next;
477 this_mg->next = nu_mg;
478 }
479
480 return nu_mg;
481 }
482
495 Bframe* frame_add(Bframe** frame, int pid)
496 {
497 Bframe* this_frame = *frame;
498 Bframe* nu_frame = new Bframe;
499 memset(nu_frame, 0, sizeof(Bframe));
500
501 nu_frame->id = pid;
502 nu_frame->fom = 1;
503 nu_frame->sel = 1;
504
505 if ( !this_frame )
506 *frame = nu_frame;
507 else {
508 while ( this_frame->next ) this_frame = this_frame->next;
509 this_frame->next = nu_frame;
510 }
511
512 return nu_frame;
513 }
514
527 Bparticle* particle_add(Bparticle** part, int pid)
528 {
529 Bparticle* this_part = *part;
530 Bparticle* nu_part = new Bparticle;
531 memset(nu_part, 0, sizeof(Bparticle));
532
533 nu_part->id = pid;
534 nu_part->group = 1;
535 nu_part->mag = 1;
536 nu_part->view[2] = 1;
537 nu_part->fom[0] = 1;
538 nu_part->sel = 1;
539
540 if ( !this_part )
541 *part = nu_part;
542 else {
543 while ( this_part->next ) this_part = this_part->next;
544 this_part->next = nu_part;
545 }
546
547 return nu_part;
548 }
549
555 int mg_part_links(Bmicrograph* mg)
556 {
557 Bparticle* part;
558
559 // cout << "Setting links from particles to micrographs" << endl;
560
561 for ( part = mg->part; part; part = part->next ) part->mg = mg;
562
563 return 0;
564 }
565
571 int rec_part_links(Breconstruction* rec)
572 {
573 Bparticle* part;
574
575 for ( part = rec->part; part; part = part->next ) part->rec = rec;
576
577 return 0;
578 }
579
580
589 Bparticle* part_find_first(Bproject* project)
590 {
591 Bfield* field;
592 Bmicrograph* mg;
593 Breconstruction* rec;
594 Bparticle* part = NULL;
595
596 if ( project->select < 1 ) {
597 for ( field = project->field; field; field = field->next ) {
598 for ( mg = field->mg; mg; mg = mg->next ) {
599 part = mg->part;
600 if ( part ) return part;
601 }
602 }
603 } else {
604 for ( rec = project->rec; rec; rec = rec->next ) {
605 part = rec->part;
606 if ( part ) return part;
607 }
608 }
609
610 return part;
611 }
612
625 Bfilament* filament_add(Bfilament** fil, int pid)
626 {
627 Bfilament* this_fil = *fil;
628 Bfilament* nu_fil = new Bfilament;
629 memset(nu_fil, 0, sizeof(Bfilament));
630
631 nu_fil->id = pid;
632
633 if ( !this_fil )
634 *fil = nu_fil;
635 else {
636 while ( this_fil->next ) this_fil = this_fil->next;
637 this_fil->next = nu_fil;
638 }
639
640 return nu_fil;
641 }
642
655 Bfilnode* filament_node_add(Bfilnode** fnode, int pid)
656 {
657 Bfilnode* this_fnode = *fnode;
658 Bfilnode* nu_fnode = new Bfilnode;
659 memset(nu_fnode, 0, sizeof(Bfilnode));
660
661 nu_fnode->id = pid;
662
663 if ( !this_fnode )
664 *fnode = nu_fnode;
665 else {
666 while ( this_fnode->next ) this_fnode = this_fnode->next;
667 this_fnode->next = nu_fnode;
668 }
669
670 return nu_fnode;
671 }
672
681 double filament_length(Bfilament* fil)
682 {
683 double length(0);
684 Bfilnode* fnode;
685
686 for ( fnode=fil->node; fnode->next; fnode=fnode->next )
687 length += (fnode->loc - fnode->next->loc).length();
688
689 return length;
690 }
691
704 Breconstruction* reconstruction_add(Breconstruction** rec, Bstring& rec_id)
705 {
706 Breconstruction* this_rec = *rec;
707 Breconstruction* nu_rec = new Breconstruction;
708 memset(nu_rec, 0, sizeof(Breconstruction));
709
710 if ( rec_id.length() ) nu_rec->id = rec_id;
711
712 nu_rec->select = 1;
713 nu_rec->view[2] = 1;
714 nu_rec->scale = Vector3<float>(1,1,1);
715
716 if ( !this_rec )
717 *rec = nu_rec;
718 else {
719 while ( this_rec->next ) this_rec = this_rec->next;
720 this_rec->next = nu_rec;
721 }
722
723 return nu_rec;
724 }
725
731 long project_count_fields(Bproject* project)
732 {
733 Bfield* field;
734 long nfield(0);
735
736 for ( field = project->field; field; field = field->next ) nfield++;
737
738 return nfield;
739 }
740
746 long project_count_micrographs(Bproject* project)
747 {
748 Bfield* field;
749 Bmicrograph* mg;
750 long nmg(0);
751
752 for ( field = project->field; field; field = field->next )
753 for ( mg = field->mg; mg; mg = mg->next ) nmg++;
754
755 return nmg;
756 }
757
763 long project_count_mg_selected(Bproject* project)
764 {
765 Bfield* field;
766 Bmicrograph* mg;
767 long nmg(0);
768
769 for ( field = project->field; field; field = field->next )
770 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select ) nmg++;
771
772 return nmg;
773 }
774
780 long project_count_reconstructions(Bproject* project)
781 {
782 Breconstruction* rec;
783 long nrec(0);
784
785 for ( rec = project->rec; rec; rec = rec->next ) nrec++;
786
787 return nrec;
788 }
789
795 long project_count_rec_selected(Bproject* project)
796 {
797 Breconstruction* rec;
798 long nrec(0);
799
800 for ( rec = project->rec; rec; rec = rec->next )
801 if ( rec->select ) nrec++;
802
803 return nrec;
804 }
805
811 long project_count_mg_particles(Bproject* project)
812 {
813 Bfield* field;
814 Bmicrograph* mg;
815 Bparticle* part;
816 long npart(0);
817
818 for ( field = project->field; field; field = field->next )
819 for ( mg = field->mg; mg; mg = mg->next )
820 for ( part = mg->part; part; part = part->next ) npart++;
821
822 return npart;
823 }
824
833 long project_count_mg_part_selected(Bproject* project)
834 {
835 long nsel(0);
836 Bfield* field = NULL;
837 Bmicrograph* mg = NULL;
838 Bparticle* part = NULL;
839
840 for ( field = project->field; field; field = field->next )
841 for ( mg = field->mg; mg; mg = mg->next )
842 for ( part = mg->part; part; part = part->next )
843 if ( part->sel > 0 ) nsel++;
844
845 return nsel;
846 }
847
857 long project_count_mg_part_selected(Bproject* project, int num_select)
858 {
859 if ( num_select < 0 ) return project_count_mg_part_selected(project);
860
861 long nsel(0);
862 Bfield* field = NULL;
863 Bmicrograph* mg = NULL;
864 Bparticle* part = NULL;
865
866 for ( field = project->field; field; field = field->next )
867 for ( mg = field->mg; mg; mg = mg->next )
868 for ( part = mg->part; part; part = part->next )
869 if ( part->sel == num_select ) nsel++;
870
871 return nsel;
872 }
873
879 long project_count_mg_groups(Bproject* project)
880 {
881 Bfield* field;
882 Bmicrograph* mg;
883 Bparticle* part;
884 long ngrp(0);
885
886 for ( field = project->field; field; field = field->next )
887 for ( mg = field->mg; mg; mg = mg->next ) {
888 for ( part = mg->part; part && part->next; part = part->next )
889 if ( part->group != part->next->group ) ngrp++;
890 if ( part ) ngrp++;
891 }
892
893 return ngrp;
894 }
895
896
902 long project_count_rec_particles(Bproject* project)
903 {
904 Breconstruction* rec;
905 Bparticle* part;
906 long npart(0);
907
908 for ( rec = project->rec; rec; rec = rec->next )
909 for ( part = rec->part; part; part = part->next ) npart++;
910
911 return npart;
912 }
913
919 long project_count_rec_part_selected(Bproject* project)
920 {
921 Breconstruction* rec;
922 Bparticle* part;
923 long npart(0);
924
925 for ( rec = project->rec; rec; rec = rec->next )
926 for ( part = rec->part; part; part = part->next )
927 if ( part->sel ) npart++;
928
929 return npart;
930 }
931
937 long project_count_rec_groups(Bproject* project)
938 {
939 Breconstruction* rec;
940 Bparticle* part;
941 long ngrp(0);
942
943 for ( rec = project->rec; rec; rec = rec->next ) {
944 for ( part = rec->part; part && part->next; part = part->next )
945 if ( part->group != part->next->group ) ngrp++;
946 if ( part ) ngrp++;
947 }
948
949 return ngrp;
950 }
951
960 long project_count_mg_filaments(Bproject* project)
961 {
962 long nfil(0);
963 Bfield* field = NULL;
964 Bmicrograph* mg = NULL;
965 Bfilament* fil = NULL;
966
967 for ( field = project->field; field; field = field->next )
968 for ( mg = field->mg; mg; mg = mg->next )
969 for ( fil=mg->fil; fil; fil=fil->next )
970 nfil++;
971
972 return nfil;
973 }
974
983 long project_count_mg_filament_nodes(Bproject* project)
984 {
985 long nfn(0);
986 Bfield* field = NULL;
987 Bmicrograph* mg = NULL;
988 Bfilament* fil = NULL;
989 Bfilnode* fnode = NULL;
990
991 for ( field = project->field; field; field = field->next )
992 for ( mg = field->mg; mg; mg = mg->next )
993 for ( fil=mg->fil; fil; fil=fil->next )
994 for ( fnode=fil->node; fnode; fnode=fnode->next )
995 nfn++;
996
997 return nfn;
998 }
999
1008 long project_count_rec_filaments(Bproject* project)
1009 {
1010 long nfil(0);
1011 Breconstruction* rec;
1012 Bfilament* fil = NULL;
1013
1014 for ( rec = project->rec; rec; rec = rec->next )
1015 for ( fil = rec->fil; fil; fil = fil->next )
1016 nfil++;
1017
1018 return nfil;
1019 }
1020
1029 long project_count_rec_filament_nodes(Bproject* project)
1030 {
1031 long nfil(0);
1032 Breconstruction* rec;
1033 Bfilament* fil = NULL;
1034 Bfilnode* fnode = NULL;
1035
1036 for ( rec = project->rec; rec; rec = rec->next )
1037 for ( fil = rec->fil; fil; fil = fil->next )
1038 for ( fnode = fil->node; fnode; fnode = fnode->next )
1039 nfil++;
1040
1041 return nfil;
1042 }
1043
1053 long field_count(Bfield* field)
1054 {
1055 long nfield;
1056
1057 for ( nfield=0; field; nfield++ ) field = field->next;
1058
1059 return nfield;
1060 }
1061
1067 long field_count_micrographs(Bfield* field)
1068 {
1069 Bmicrograph* mg;
1070 long nmg(0);
1071
1072 for ( mg = field->mg; mg; mg = mg->next ) nmg++;
1073
1074 return nmg;
1075 }
1076
1082 long field_count_mg_selected(Bfield* field)
1083 {
1084 Bmicrograph* mg;
1085 long nmg(0);
1086
1087 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select ) nmg++;
1088
1089 return nmg;
1090 }
1091
1097 long field_count_particles(Bfield* field)
1098 {
1099 Bmicrograph* mg;
1100 Bparticle* part;
1101 long npart(0);
1102
1103 for ( mg = field->mg; mg; mg = mg->next )
1104 for ( part = mg->part; part; part = part->next ) npart++;
1105
1106 return npart;
1107 }
1108
1118 long micrograph_count(Bmicrograph* mg)
1119 {
1120 long nmg;
1121
1122 for ( nmg=0; mg; nmg++ ) mg = mg->next;
1123
1124 return nmg;
1125 }
1126
1132 long micrograph_count_particles(Bmicrograph* mg)
1133 {
1134 Bparticle* part;
1135 long npart(0);
1136
1137 for ( part = mg->part; part; part = part->next ) npart++;
1138
1139 return npart;
1140 }
1141
1151 long particle_count(Bparticle* part)
1152 {
1153 long npart;
1154
1155 for ( npart=0; part; npart++ ) part = part->next;
1156
1157 return npart;
1158 }
1159
1169 long particle_count_selected(Bparticle* part)
1170 {
1171 long nsel;
1172
1173 for ( nsel=0; part; part=part->next ) if ( part->sel > 0 ) nsel++;
1174
1175 return nsel;
1176 }
1177
1187 long filament_count(Bfilament* fil)
1188 {
1189 long nfil;
1190
1191 for ( nfil=0; fil; fil=fil->next ) nfil++;
1192
1193 return nfil;
1194 }
1195
1205 long filament_node_count(Bfilament* fil)
1206 {
1207 long nfil;
1208 Bfilnode* fnode;
1209
1210 for ( nfil=0; fil; fil=fil->next )
1211 for ( fnode=fil->node; fnode; fnode=fnode->next ) nfil++;
1212
1213 return nfil;
1214 }
1215
1224 int project_kill(Bproject* project)
1225 {
1226 if ( !project ) return 0;
1227
1228 project->comment = 0;
1229 project->filename = 0;
1230
1231 string_kill(project->reference);
1232
1233 Bfield *field, *field2;
1234 Breconstruction *rec, *rec2;
1235
1236 for ( field = project->field; field; ) {
1237 field2 = field->next;
1238 field_kill(field);
1239 field = field2;
1240 }
1241
1242 for ( rec = project->rec; rec; ) {
1243 rec2 = rec->next;
1244 reconstruction_kill(rec);
1245 rec = rec2;
1246 }
1247
1248 delete project;
1249
1250 return 0;
1251 }
1252
1261 int field_kill(Bfield* field)
1262 {
1263 if ( !field ) return 0;
1264
1265 field->id = 0;
1266
1267 Bmicrograph *mg, *mg2;
1268
1269 for ( mg = field->mg; mg; ) {
1270 mg2 = mg->next;
1271 micrograph_kill(mg);
1272 mg = mg2;
1273 }
1274
1275 delete field;
1276
1277 return 0;
1278 }
1279
1288 int micrograph_kill(Bmicrograph* mg)
1289 {
1290 if ( !mg ) return 0;
1291
1292 mg->id = 0;
1293 mg->fmg = 0;
1294 mg->fframe = 0;
1295 mg->fpart = 0;
1296 mg->ffil = 0;
1297 mg->fft = 0;
1298 mg->fps = 0;
1299
1300 delete mg->ctf;
1301
1302 particle_kill(mg->part);
1303 filament_kill(mg->fil);
1304
1305 kill_list((char *) mg->bad, sizeof(Bbadarea));
1306 kill_list((char *) mg->sf, sizeof(Bstrucfac));
1307 kill_list((char *) mg->layer, sizeof(Blayerline));
1308 kill_list((char *) mg->mark, sizeof(Bmarker));
1309
1310 delete mg;
1311
1312 return 0;
1313 }
1314
1323 int particle_kill(Bparticle* part)
1324 {
1325 if ( !part ) return 0;
1326
1327 Bparticle *part2;
1328
1329 for ( ; part; ) {
1330 part2 = part->next;
1331 part->fpart = 0;
1332 delete part;
1333 part = part2;
1334 }
1335
1336 return 0;
1337 }
1338
1347 int filament_kill(Bfilament* fil)
1348 {
1349 if ( !fil ) return 0;
1350
1351 Bfilament *fil2;
1352 Bfilnode *fnode, *fnode2;
1353
1354 for ( ; fil; ) {
1355 for ( fnode=fil->node; fnode; ) {
1356 fnode2 = fnode->next;
1357 delete fnode;
1358 fnode = fnode2;
1359 }
1360 fil2 = fil->next;
1361 fil->ffil = 0;
1362 delete fil;
1363 fil = fil2;
1364 }
1365
1366 return 0;
1367 }
1368
1377 int reconstruction_kill(Breconstruction* rec)
1378 {
1379 if ( !rec ) return 0;
1380
1381 rec->id = 0;
1382 rec->symmetry = 0;
1383 rec->frec = 0;
1384 rec->fpart = 0;
1385 rec->ffil = 0;
1386 rec->fft = 0;
1387 rec->fps = 0;
1388
1389 particle_kill(rec->part);
1390 filament_kill(rec->fil);
1391
1392 kill_list((char *) rec->bad, sizeof(Bbadarea));
1393 kill_list((char *) rec->sf, sizeof(Bstrucfac));
1394 kill_list((char *) rec->mark, sizeof(Bmarker));
1395
1396 string_kill(rec->model);
1397
1398 delete rec;
1399
1400 return 0;
1401 }
1402
1409 Bparticle* particle_copy(Bparticle** partlist, Bparticle* part)
1410 {
1411 int i;
1412 Bparticle* partnu = NULL;
1413
1414 partnu = particle_add(partlist, part->id);
1415 partnu->fpart = part->fpart; // Particle image file name
1416 partnu->group = part->group; // Group membership (such as filaments or crystals)
1417 partnu->mag = part->mag; // Magnification
1418 partnu->def = part->def; // Defocus (angstrom)
1419 partnu->dev = part->dev; // Defocus deviation (angstrom)
1420 partnu->ast = part->ast; // Astigmatism angle (radians)
1421 partnu->loc = part->loc; // Coordinates in the micrograph or tomogram
1422 partnu->pixel_size = part->pixel_size; // Sampling in angstrom/pixel
1423 partnu->ori = part->ori; // Origin of particle in voxel units
1424 partnu->view = part->view; // View: 3-value vector and angle (radians)
1425 for ( i=0; i<NFOM; i++ ) partnu->fom[i] = part->fom[i]; // Figure-of-merit, types defined in project structure
1426 partnu->sel = part->sel; // Selection flag
1427 partnu->mg = part->mg;
1428
1429 return partnu;
1430 }
1431
1437 Bparticle* particle_copy(Bparticle* partlist)
1438 {
1439 Bparticle* part;
1440 Bparticle* partlistnu = NULL;
1441
1442 for ( part = partlist; part; part = part->next )
1443 particle_copy(&partlistnu, part);
1444
1445 return partlistnu;
1446 }
1447
1448 Bbadarea* particle_bad_copy(Bbadarea* badlist)
1449 {
1450 Bbadarea* bad;
1451 Bbadarea* badnu = NULL;
1452 Bbadarea* badlistnu = NULL;
1453
1454 for ( bad = badlist; bad; bad = bad->next ) {
1455 badnu = (Bbadarea *) add_item((char **) &badlistnu, sizeof(Bbadarea));
1456 badnu->id = bad->id;
1457 badnu->loc = bad->loc;
1458 }
1459
1460 return badlistnu;
1461 }
1462
1463 Bfilament* filament_copy(Bfilament* fillist)
1464 {
1465 Bfilament* fil;
1466 Bfilament* filnu = NULL;
1467 Bfilament* fillistnu = NULL;
1468 Bfilnode* fnode = NULL;
1469 Bfilnode* fnodenu = NULL;
1470
1471 for ( fil = fillist; fil; fil = fil->next ) {
1472 filnu = filament_add(&fillistnu, fil->id);
1473 filnu->ffil = fil->ffil;
1474 for ( fnode = fil->node; fnode; fnode = fnode->next ) {
1475 fnodenu = filament_node_add(&filnu->node, fnode->id);
1476 fnodenu->loc = fnode->loc;
1477 }
1478 }
1479
1480 return fillistnu;
1481 }
1482
1483 Bstrucfac* structurefactor_copy(Bstrucfac* sflist)
1484 {
1485 Bstrucfac* sf;
1486 Bstrucfac* sfnu = NULL;
1487 Bstrucfac* sflistnu = NULL;
1488
1489 for ( sf = sflist; sf; sf = sf->next ) {
1490 sfnu = (Bstrucfac *) add_item((char **) &sflistnu, sizeof(Bstrucfac));
1491 sfnu->loc = sf->loc; // Coordinates in the transform
1492 sfnu->index = sf->index; // Miller indices
1493 sfnu->amp = sf->amp; // Amplitude
1494 sfnu->sigamp = sf->sigamp; // Amplitude deviation
1495 sfnu->phi = sf->phi; // Phase
1496 sfnu->sigphi = sf->sigphi; // Phase deviation
1497 sfnu->fom = sf->fom; // Figure-of-merit
1498 sfnu->sel = sf->sel; // Selection flag
1499 }
1500
1501 return sflistnu;
1502 }
1503
1504 Blayerline* layerline_copy(Blayerline* layerlist)
1505 {
1506 Blayerline* line;
1507 Blayerline* linenu = NULL;
1508 Blayerline* linelistnu = NULL;
1509
1510 for ( line = layerlist; line; line = line->next ) {
1511 linenu = (Blayerline *) add_item((char **) &linelistnu, sizeof(Blayerline));
1512 linenu->number = line->number; // Layer line number
1513 linenu->order = line->order; // Bessel order
1514 linenu->distance = line->distance; // Distance along helical axis from origin
1515 linenu->freq = line->freq; // Spatial frequency
1516 linenu->amp = line->amp; // Amplitude
1517 linenu->fom = line->fom; // Figure-of-merit
1518 linenu->sel = line->sel; // Selection flag
1519 }
1520
1521 return linelistnu;
1522 }
1523
1529 Bmicrograph* micrograph_copy(Bmicrograph* mg)
1530 {
1531 Bmicrograph* mgnu = NULL;
1532
1533 if ( verbose & VERB_FULL )
1534 cout << "Copying micrograph " << mg->id << endl;
1535
1536 micrograph_add(&mgnu, mg->id);
1537
1538 mgnu->select = mg->select;
1539 mgnu->fmg = mg->fmg; // Micrograph image file
1540 mgnu->fframe = mg->fframe; // Micrograph frames image file
1541 mgnu->fpart = mg->fpart; // Image file with picked particles
1542 mgnu->ffil = mg->ffil; // Image file with filaments
1543 mgnu->fft = mg->fft; // Image file with Fourier transform
1544 mgnu->fps = mg->fps; // Image file with power spectrum
1545 mgnu->img_num = mg->img_num; // Image number in file
1546 mgnu->magnification = mg->magnification; // Microscope magnification
1547 mgnu->sampling = mg->sampling; // Scanner sampling (angstrom)
1548 mgnu->pixel_size = mg->pixel_size; // Nominal micrograph pixel size
1549 mgnu->tilt_axis = mg->tilt_axis; // Tilt axis angle, origin at x-axis (radians)
1550 mgnu->tilt_angle = mg->tilt_angle; // Tilt angle, right-handed around tilt axis (radians)
1551 mgnu->level_angle = mg->level_angle; // Level angle (radians)
1552 mgnu->rot_angle = mg->rot_angle; // In-plane rotation angle of micrograph or specimen (radians)
1553 mgnu->origin = mg->origin; // Origin within field-of-view
1554 mgnu->scale = mg->scale; // Scale with respect to field-of-view
1555 mgnu->matrix = mg->matrix; // Rotation matrix
1556 mgnu->box_size = mg->box_size; // Particle size
1557 mgnu->bad_radius = mg->bad_radius; // Radius of bad area around coordinates
1558 mgnu->filament_width = mg->filament_width; // Filament width
1559 mgnu->fil_node_radius = mg->fil_node_radius;// Radius of filament node
1560 mgnu->sf_radius = mg->sf_radius; // Radius of marker
1561 mgnu->mark_radius = mg->mark_radius; // Radius of marker
1562 mgnu->fom = mg->fom; // Micrograph figure-of-merit
1563
1564 if ( mg->ctf ) mgnu->ctf->update(mg->ctf);
1565
1566 mgnu->part = particle_copy(mg->part);
1567
1568 mgnu->bad = particle_bad_copy(mg->bad);
1569
1570 mgnu->fil = filament_copy(mg->fil);
1571
1572 mgnu->sf = structurefactor_copy(mg->sf);
1573
1574 mgnu->layer = layerline_copy(mg->layer);
1575
1576 mgnu->mark = markers_copy(mg->mark);
1577
1578 return mgnu;
1579 }
1580
1581
1601 int project_update(Bproject* project, Bproject* proj_new, int fom_index)
1602 {
1603 int notfound;
1604 Bfield *field, *nu_field;
1605 Bmicrograph *mg = NULL, *nu_mg;
1606 Breconstruction *rec = NULL, *nu_rec;
1607
1608 for ( nu_field = proj_new->field; nu_field; nu_field = nu_field->next ) {
1609 for ( nu_mg = nu_field->mg; nu_mg; nu_mg = nu_mg->next ) {
1610 notfound = 1;
1611 for ( field = project->field; field && notfound; field = field->next ) {
1612 for ( mg = field->mg; mg && notfound; ) {
1613 if ( mg->id == nu_mg->id )
1614 notfound = 0;
1615 else
1616 mg = mg->next;
1617 }
1618 }
1619 if ( notfound )
1620 cerr << "Error: Micrograph " << nu_mg->id << " not found!" << endl;
1621 else
1622 micrograph_update(mg, nu_mg, fom_index, 63);
1623 }
1624 }
1625
1626 for ( nu_rec = proj_new->rec; nu_rec; nu_rec = nu_rec->next ) {
1627 notfound = 1;
1628 for ( rec = project->rec; rec && notfound; ) {
1629 if ( rec->id == nu_rec->id )
1630 notfound = 0;
1631 else
1632 rec = rec->next;
1633 }
1634 if ( notfound )
1635 cerr << "Error: Reconstruction " << nu_rec->id << " not found!" << endl;
1636 else
1637 reconstruction_update(rec, nu_rec, fom_index, 63);
1638 }
1639
1640 return 0;
1641 }
1642
1670 int micrograph_update(Bmicrograph* mg, Bmicrograph* nu_mg, int fom_index, int flags)
1671 {
1672 if ( nu_mg->select < 1 ) return 0;
1673
1674 if ( verbose & VERB_DEBUG )
1675 cout << "DEBUG micrograph_update: " << nu_mg->id << tab << nu_mg->select << tab << flags << endl;
1676
1677 if ( verbose & VERB_FULL )
1678 cout << "Updating micrograph " << mg->id << endl;
1679
1680 mg->select = nu_mg->select;
1681 if ( nu_mg->fmg.length() ) mg->fmg = nu_mg->fmg; // Micrograph image file
1682 if ( nu_mg->fframe.length() ) mg->fframe = nu_mg->fframe; // Micrograph frames image file
1683 if ( nu_mg->fpart.length() ) mg->fpart = nu_mg->fpart; // Image file with picked particles
1684 if ( nu_mg->ffil.length() ) mg->ffil = nu_mg->ffil; // Image file with filaments
1685 if ( nu_mg->fft.length() ) mg->fft = nu_mg->fft; // Image file with Fourier transform
1686 if ( nu_mg->fps.length() ) mg->fps = nu_mg->fps; // Image file with power spectrum
1687 if ( nu_mg->img_num ) mg->img_num = nu_mg->img_num; // Image number in file
1688 if ( nu_mg->magnification ) mg->magnification = nu_mg->magnification; // Microscope magnification
1689 if ( nu_mg->sampling ) mg->sampling = nu_mg->sampling; // Scanner sampling (angstrom)
1690 if ( nu_mg->pixel_size ) mg->pixel_size = nu_mg->pixel_size; // Nominal micrograph pixel size
1691 if ( nu_mg->tilt_axis ) mg->tilt_axis = nu_mg->tilt_axis; // Tilt axis angle, origin at x-axis (radians)
1692 if ( nu_mg->tilt_angle ) mg->tilt_angle = nu_mg->tilt_angle; // Tilt angle, right-handed around tilt axis (radians)
1693 if ( nu_mg->rot_angle ) mg->rot_angle = nu_mg->rot_angle; // In-plane rotation angle of micrograph or specimen (radians)
1694 if ( nu_mg->origin.length2() ) mg->origin = nu_mg->origin; // Origin within field-of-view
1695 if ( nu_mg->scale.length2() ) mg->scale = nu_mg->scale; // Scale with respect to field-of-view
1696 if ( nu_mg->box_size[0] ) mg->box_size = nu_mg->box_size; // Particle size
1697 if ( nu_mg->bad_radius ) mg->bad_radius = nu_mg->bad_radius; // Radius of bad area around coordinates
1698 if ( nu_mg->mark_radius ) mg->mark_radius = nu_mg->mark_radius; // Radius of marker
1699
1700 if ( nu_mg->ctf ) {
1701 if ( !mg->ctf ) mg->ctf = new CTFparam;
1702 mg->ctf->update(nu_mg->ctf);
1703 }
1704
1705 if ( flags & 1)
1706 particle_update(&mg->part, nu_mg->part, fom_index);
1707
1708 if ( (flags & 2) && nu_mg->bad ) {
1709 if ( verbose & VERB_PROCESS )
1710 cout << "Replacing bad areas" << endl;
1711 kill_list((char *) mg->bad, sizeof(Bbadarea));
1712 mg->bad = nu_mg->bad;
1713 nu_mg->bad = NULL;
1714 }
1715
1716 if ( (flags & 4) && nu_mg->fil ) {
1717 if ( verbose & VERB_PROCESS )
1718 cout << "Replacing filaments" << endl;
1719 kill_list((char *) mg->fil, sizeof(Bfilament));
1720 mg->fil = nu_mg->fil;
1721 nu_mg->fil = NULL;
1722 }
1723
1724 if ( (flags & 8) && nu_mg->sf ) {
1725 if ( verbose & VERB_PROCESS )
1726 cout << "Replacing structure factors" << endl;
1727 kill_list((char *) mg->sf, sizeof(Bstrucfac));
1728 mg->sf = nu_mg->sf;
1729 nu_mg->sf = NULL;
1730 }
1731
1732 if ( (flags & 16) && nu_mg->layer ) {
1733 if ( verbose & VERB_PROCESS )
1734 cout << "Replacing layer lines" << endl;
1735 kill_list((char *) mg->layer, sizeof(Blayerline));
1736 mg->layer = nu_mg->layer;
1737 nu_mg->layer = NULL;
1738 }
1739
1740 if ( (flags & 32) && nu_mg->mark ) {
1741 if ( verbose & VERB_FULL )
1742 cout << "Replacing markers" << endl;
1743 kill_list((char *) mg->mark, sizeof(Bmarker));
1744 mg->mark = nu_mg->mark;
1745 nu_mg->mark = NULL;
1746 }
1747
1748 return 0;
1749 }
1750
1772 int reconstruction_update(Breconstruction* rec, Breconstruction* nu_rec, int fom_index, int flags)
1773 {
1774 if ( nu_rec->select < 1 ) return 0;
1775
1776 if ( verbose & VERB_DEBUG )
1777 cout << "DEBUG reconstruction_update: " << nu_rec->id << tab << nu_rec->select << tab << flags << endl;
1778
1779 if ( verbose & VERB_FULL )
1780 cout << "Updating reconstruction " << rec->id << endl;
1781
1782 rec->select = nu_rec->select;
1783 rec->fom = nu_rec->fom;
1784 if ( nu_rec->symmetry.length() ) rec->symmetry = nu_rec->symmetry; // Reconstruction symmetry
1785 if ( nu_rec->frec.length() ) rec->frec = nu_rec->frec; // Reconstruction image file
1786 if ( nu_rec->fpart.length() ) rec->fpart = nu_rec->fpart; // Image file with picked particles
1787 if ( nu_rec->ffil.length() ) rec->ffil = nu_rec->ffil; // Image file with filaments
1788 if ( nu_rec->fft.length() ) rec->fft = nu_rec->fft; // Image file with Fourier transform
1789 if ( nu_rec->fps.length() ) rec->fps = nu_rec->fps; // Image file with power spectrum
1790 if ( nu_rec->voxel_size ) rec->voxel_size = nu_rec->voxel_size; // Nominal voxel size
1791 if ( nu_rec->origin.length2() ) rec->origin = nu_rec->origin; // Origin within field-of-view
1792 if ( nu_rec->scale.length2() ) rec->scale = nu_rec->scale; // Scale with respect to field-of-view
1793 if ( nu_rec->box_size[0] ) rec->box_size = nu_rec->box_size; // Particle size
1794 if ( nu_rec->bad_radius ) rec->bad_radius = nu_rec->bad_radius; // Radius of bad area around coordinates
1795 if ( nu_rec->mark_radius ) rec->mark_radius = nu_rec->mark_radius; // Radius of marker
1796 rec->view = nu_rec->view; // Reconstruction orientation
1797
1798 if ( flags & 1)
1799 particle_update(&rec->part, nu_rec->part, fom_index);
1800
1801 return 0;
1802 }
1803
1817 int particle_update(Bparticle** pnt_part, Bparticle* nu_part, int fom_index)
1818 {
1819 if ( verbose & VERB_FULL )
1820 cout << "Updating particles" << endl;
1821
1822 int notfound, f, set_new;
1823 Bparticle* part;
1824
1825 for ( ; nu_part; nu_part = nu_part->next ) {
1826 notfound = 1;
1827 set_new = 0;
1828 for ( part = *pnt_part; part && notfound; ) {
1829 if ( part->id == nu_part->id ) notfound = 0;
1830 else part = part->next;
1831 }
1832 if ( notfound ) {
1833 cerr << "Particle " << nu_part->id << " not found!" << endl;
1834 part = particle_add(pnt_part, nu_part->id);
1835 part->group = 0;
1836 part->sel = 0;
1837 part->fom[fom_index] = 0;
1838 set_new = 1;
1839 }
1840 if ( nu_part->sel > 0 ) {
1841 set_new = 1;
1842 if ( part->sel > 0 ) {
1843 if ( nu_part->fom[fom_index] < part->fom[fom_index] ) set_new = 0;
1844 // if ( nu_part->fom[fom_index] > 0.999 && nu_part->view[2] > 0.999 ) set_new = 0;
1845 }
1846 }
1847 if ( verbose & VERB_DEBUG )
1848 cout << "DEBUG particle_update: " << part->id << tab << part->sel << tab << nu_part->sel << tab
1849 << part->fom[fom_index] << tab << nu_part->fom[fom_index] << tab << set_new << endl;
1850 if ( set_new ) {
1851 if ( nu_part->def > 0 ) {
1852 part->def = nu_part->def;
1853 part->dev = nu_part->dev;
1854 part->ast = nu_part->ast;
1855 }
1856 if ( nu_part->mag > 0 && nu_part->mag != 1 ) part->mag = nu_part->mag;
1857 if ( nu_part->loc.length2() > 0 ) part->loc = nu_part->loc;
1858 if ( nu_part->pixel_size > 0 ) part->pixel_size = nu_part->pixel_size;
1859 if ( nu_part->ori.length2() > 0 ) part->ori = nu_part->ori;
1860 if ( nu_part->view.vector_size() > 0.1 ) part->view = nu_part->view;
1861 for ( f=0; f<NFOM; f++ ) if ( nu_part->fom[f] ) part->fom[f] = nu_part->fom[f];
1862 part->sel = nu_part->sel;
1863 if ( nu_part->fpart.length() ) part->fpart = nu_part->fpart;
1864 }
1865 }
1866
1867 return 0;
1868 }
1869
1876 int project_merge_part_parameters(Bproject* project, Bproject* partproject)
1877 {
1878 if ( !project || ! partproject ) return 0;
1879
1880 Bfield *field, *partfield;
1881 Bmicrograph *mg, *partmg;
1882 Breconstruction *rec, *partrec;
1883
1884 if ( verbose & VERB_PROCESS )
1885 cout << "Merging particle parameters into the main project" << endl << endl;
1886
1887 for ( field=project->field, partfield=partproject->field; field; field=field->next, partfield=partfield->next ) {
1888 for ( mg=field->mg, partmg=partfield->mg; mg && partmg; mg=mg->next, partmg=partmg->next ) {
1889 particle_update(&mg->part, partmg->part, 0);
1890 }
1891 }
1892
1893 for ( rec=project->rec, partrec=partproject->rec; rec && partrec; rec=rec->next, partrec=partrec->next ) {
1894 particle_update(&rec->part, partrec->part, 0);
1895 }
1896
1897 return 0;
1898 }
1899
1900
1906 long project_set_part_links(Bproject* project)
1907 {
1908 long npart(0);
1909 Bfield* field;
1910 Bmicrograph* mg;
1911 Breconstruction* rec;
1912
1913 for ( field = project->field; field; field = field->next )
1914 for ( mg = field->mg; mg; mg = mg->next )
1915 npart += micrograph_set_part_links(mg);
1916
1917 for ( rec = project->rec; rec; rec = rec->next )
1918 npart += reconstruction_set_part_links(rec);
1919
1920 return npart;
1921 }
1922
1928 long micrograph_set_part_links(Bmicrograph* mg)
1929 {
1930 long npart(0);
1931 Bparticle* part;
1932
1933 for ( part = mg->part; part; part = part->next, npart++ ) part->mg = mg;
1934
1935 return npart;
1936 }
1937
1943 long reconstruction_set_part_links(Breconstruction* rec)
1944 {
1945 long npart(0);
1946 Bparticle* part;
1947
1948 for ( part = rec->part; part; part = part->next, npart++ ) part->rec = rec;
1949
1950 return npart;
1951 }
1952
1962 long project_divide(Bproject* project, long n)
1963 {
1964 long i, j, t, nmg(0), ndiv(0);
1965 Bproject* project2 = project;
1966 Bfield* field, *field_prev;
1967 Bmicrograph* mg;
1968
1969 for ( nmg=0, field = project->field; field; field = field->next )
1970 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select)
1971 nmg++;
1972
1973 field = field_prev = project->field;
1974 for ( i=j=0; i<n; i++ ) {
1975 t = (nmg*(i+1))/n;
1976 for ( ; field && j<t; field_prev = field, field = field->next )
1977 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select)
1978 j++;
1979 if ( field ) {
1980 field_prev->next = NULL;
1981 project2->next = project_init();
1982 project2 = project2->next;
1983 project2->field = field;
1984 for ( i=0; i<NFOM; i++ ) project2->fom_tag[i] = project->fom_tag[i];
1985 ndiv++;
1986 }
1987 }
1988
1989 return ndiv;
1990 }
1991
2001 Bmicrograph** project_micrograph_array(Bproject* project, long &nmg)
2002 {
2003 Bfield* field;
2004 Bmicrograph* mg;
2005
2006 for ( nmg=0, field=project->field; field; field=field->next )
2007 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select)
2008 nmg++;
2009
2010 Bmicrograph** mgarr = new Bmicrograph*[nmg];
2011
2012 for ( nmg=0, field=project->field; field; field=field->next )
2013 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select)
2014 mgarr[nmg++] = mg;
2015
2016 return mgarr;
2017 }
2018
2029 Bparticle** project_mg_particle_array(Bproject* project, int part_select, long &npart)
2030 {
2031 Bfield* field;
2032 Bmicrograph* mg;
2033 Bparticle* part;
2034
2035 for ( npart=0, field=project->field; field; field=field->next ) {
2036 for ( mg = field->mg; mg; mg = mg->next ) {
2037 for ( part = mg->part; part; part = part->next ) {
2038 part->mg = mg;
2039 if ( ( part_select<0 && part->sel ) || ( part->sel==part_select ) )
2040 npart++;
2041 else
2042 part->fom[0] = part->fom[1] = part->sel = 0;
2043 }
2044 }
2045 }
2046
2047 Bparticle** partarr = new Bparticle*[npart];
2048
2049 for ( npart=0, field=project->field; field; field=field->next ) {
2050 for ( mg = field->mg; mg; mg = mg->next ) {
2051 for ( part = mg->part; part; part = part->next ) {
2052 if ( ( part_select<0 && part->sel ) || ( part->sel==part_select ) )
2053 partarr[npart++] = part;
2054 }
2055 }
2056 }
2057
2058 return partarr;
2059 }
2060
2071 Bparticle** project_rec_particle_array(Bproject* project, int part_select, long &npart)
2072 {
2073 Breconstruction* rec;
2074 Bparticle* part;
2075
2076 for ( npart=0, rec=project->rec; rec; rec=rec->next ) {
2077 for ( part = rec->part; part; part = part->next ) {
2078 if ( ( part_select<0 && part->sel ) || ( part->sel==part_select ) )
2079 npart++;
2080 else
2081 part->fom[0] = part->fom[1] = part->sel = 0;
2082 }
2083 }
2084
2085 Bparticle** partarr = new Bparticle*[npart];
2086
2087 for ( npart=0, rec=project->rec; rec; rec=rec->next ) {
2088 for ( part = rec->part; part; part = part->next ) {
2089 if ( ( part_select<0 && part->sel ) || ( part->sel==part_select ) )
2090 partarr[npart++] = part;
2091 }
2092 }
2093
2094 return partarr;
2095 }
2096
2107 Bparticle** particle_array(Bparticle* partlist, int part_select, long &npart)
2108 {
2109 Bparticle* part;
2110
2111 for ( npart=0, part = partlist; part; part = part->next ) {
2112 if ( ( part_select<0 && part->sel ) || ( part->sel==part_select ) )
2113 npart++;
2114 else
2115 part->fom[0] = part->fom[1] = part->sel = 0;
2116 }
2117
2118 Bparticle** partarr = new Bparticle*[npart];
2119
2120 for ( npart=0, part = partlist; part; part = part->next )
2121 if ( ( part_select<0 && part->sel ) || ( part->sel==part_select ) )
2122 partarr[npart++] = part;
2123
2124 return partarr;
2125 }
2126
2127
2135 int project_revert_filenames(Bproject* project, Bproject* project_old, int flag)
2136 {
2137 if ( !project ) return 0;
2138 if ( !project_old ) return 0;
2139
2140 Bfield* field, *field_old;
2141 Bmicrograph* mg, *mg_old;
2142 Breconstruction* rec, *rec_old;
2143 Bparticle* part, *part_old;
2144
2145 if ( verbose & VERB_PROCESS )
2146 cout << "Reverting to old particle file names in: " << project_old->filename << endl << endl;
2147
2148 for ( field = project->field; field; field = field->next ) {
2149 for ( field_old = project_old->field; field_old && field_old->id != field->id; field_old = field_old->next ) ;
2150 if ( field_old ) {
2151 for ( mg = field->mg; mg; mg = mg->next ) {
2152 for ( mg_old = field_old->mg; mg_old && mg_old->id != mg->id; mg_old = mg_old->next ) ;
2153 if ( mg_old ) {
2154 if ( flag & 1 ) mg->fmg = mg_old->fmg;
2155 if ( flag & 16 ) mg->fframe = mg_old->fframe;
2156 if ( flag & 2 ) mg->fps = mg_old->fps;
2157 if ( flag & 8 ) {
2158 mg->fpart = mg_old->fpart;
2159 part_old = mg_old->part;
2160 for ( part = mg->part; part; part = part->next ) {
2161 for ( ; part_old && part_old->id != part->id; part_old = part_old->next ) ;
2162 if ( part_old ) {
2163 part->fpart = part_old->fpart;
2164 }
2165 }
2166 }
2167 }
2168 }
2169 }
2170 }
2171
2172 for ( rec = project->rec; rec; rec = rec->next ) {
2173 for ( rec_old = project_old->rec; rec_old && rec_old->id != rec->id; rec_old = rec_old->next ) ;
2174 if ( rec_old ) {
2175 if ( flag & 4 ) rec->frec = rec_old->frec;
2176 if ( flag & 8 ) {
2177 part_old = rec_old->part;
2178 for ( part = rec->part; part; part = part->next ) {
2179 for ( ; part_old && part_old->id != part->id; part_old = part_old->next ) ;
2180 if ( part_old ) {
2181 part->fpart = part_old->fpart;
2182 }
2183 }
2184 }
2185 }
2186 }
2187
2188 return 0;
2189 }
2190
2203 int project_set_field_id(Bproject* project, int nseries, Bstring& field_id)
2204 {
2205 int i(0), nf(0);
2206 Bfield* field;
2207 Bfield* nu_field = NULL;
2208 Bfield* nu_field_start = NULL;
2209 Bmicrograph* mg = NULL;
2210 Bmicrograph* nu_mg = NULL;
2211
2212 for ( field = project->field; field; field = field->next ) {
2213 for ( mg = field->mg; mg; mg = mg->next ) {
2214 if ( i%nseries == 0 ) {
2215 nu_field = field_add(&nu_field, mg->id);
2216 if ( i == 0 ) nu_field_start = nu_field;
2217 else nu_mg->next = NULL;
2218 nu_field->mg = nu_mg = mg;
2219 nf++;
2220 } else {
2221 nu_mg->next = mg;
2222 nu_mg = mg;
2223 }
2224 i++;
2225 }
2226 }
2227
2228 for ( field=project->field; field; ) {
2229 nu_field = field->next;
2230 delete field;
2231 field = nu_field;
2232 }
2233
2234 project->field = nu_field_start;
2235
2236 if ( field_id.length() > 0 ) {
2237 if ( nf < 2 ) {
2238 project->field->id = field_id;
2239 } else {
2240 for ( i=1, field = project->field; field; field = field->next, i++ )
2241 field->id = field_id + Bstring(i, "_%04d");
2242 }
2243 }
2244
2245 return 0;
2246 }
2247
2253 long project_show_hierarchy(Bproject* project)
2254 {
2255 if ( !project ) return 0;
2256
2257 if ( !verbose ) return 0;
2258
2259 long i, j, k, l, nf(0), nmg(0), nmgsel(0);
2260 long npart(0), nsel(0), nfil(0), nfn(0);
2261 double nmgpercent(0), npercent(0);
2262 int g;
2263 Bfield* field = project->field;
2264 Breconstruction* rec = project->rec;
2265 Bmicrograph* mg;
2266 Bparticle* part;
2267
2268 long gmax = 10000000;
2269 int* ng = new int[gmax];
2270 for ( i=0; i<gmax; i++ ) ng[i] = 0;
2271
2272 if ( verbose > VERB_RESULT )
2273 cout << "Project hierarchy:" << endl;
2274 if ( field ) {
2275 for ( field = project->field; field; field = field->next, nf++ ) {
2276 if ( verbose > VERB_RESULT )
2277 cout << "Field: " << field->id << " (" << field->select << ")" << endl;
2278 for ( mg = field->mg; mg; mg = mg->next, nmg++ ) {
2279 if ( mg->select ) nmgsel++;
2280 for ( part = mg->part; part; part = part->next ) {
2281 g = part->group;
2282 if ( g >= gmax ) g = gmax-1;
2283 ng[g]++;
2284 }
2285 i = particle_count(mg->part);
2286 j = particle_count_selected(mg->part);
2287 k = filament_count(mg->fil);
2288 l = filament_node_count(mg->fil);
2289 npart += i;
2290 nsel += j;
2291 nfil += k;
2292 nfn += l;
2293 if ( verbose > VERB_RESULT )
2294 cout << "\tMicrograph: " << mg->id << " ("
2295 << mg->select << ")\tParticles: " << i << " ("
2296 << j << ")\tFilaments: " << k << " (" << l << ")" << endl;
2297 }
2298 }
2299 if ( nmg ) nmgpercent = nmgsel*100.0/nmg;
2300 if ( npart ) npercent = nsel*100.0/npart;
2301 cout << "Totals:" << endl;
2302 cout << nf << " fields\t" << nmg << " micrographs\t"
2303 << nmgsel << " selected\t(" << nmgpercent << "%)" << endl;
2304 if ( npart )
2305 cout << npart << " particles\t" << nsel << " selected\t("
2306 << npercent << "%)" << endl;
2307 if ( nfil )
2308 cout << nfil << " filaments\t" << nfn << " filament nodes" << endl;
2309 if ( npart ) {
2310 cout << "Group\tCount" << endl;
2311 for ( g=0; g<gmax; g++ ) if ( ng[g] )
2312 cout << g << tab << ng[g] << endl;
2313 }
2314 }
2315
2316 for ( g=0; g<gmax; g++ ) ng[g] = 0;
2317 if ( rec ) {
2318 npart = nsel = nfil = nfn = 0;
2319 npercent = 0;
2320 for ( rec = project->rec; rec; rec = rec->next ) {
2321 for ( part = rec->part; part; part = part->next ) {
2322 g = part->group;
2323 if ( g >= gmax ) g = gmax-1;
2324 ng[g]++;
2325 }
2326 if ( verbose > VERB_RESULT ) {
2327 cout << "Reconstruction: " << rec->id;
2328 if ( rec->frec.length() ) cout << ", " << rec->frec;
2329 cout << endl;
2330 }
2331 i = particle_count(rec->part);
2332 j = particle_count_selected(rec->part);
2333 k = filament_count(rec->fil);
2334 l = filament_node_count(rec->fil);
2335 npart += i;
2336 nsel += j;
2337 nfil += k;
2338 nfn += l;
2339 if ( verbose > VERB_RESULT )
2340 cout << "\tParticles: " << i << " (" << j << ")\tFilaments: " << k << " (" << l << ")" << endl;
2341 }
2342 if ( npart ) npercent = nsel*100.0/npart;
2343 cout << "Totals:\t" << npart << " particles\t" << nsel << " selected\t("
2344 << npercent << "%)\t" << nfil << " filaments\t" << nfn << " filament nodes" << endl;
2345 if ( npart ) {
2346 cout << "Group\tCount" << endl;
2347 for ( g=0; g<gmax; g++ ) if ( ng[g] )
2348 cout << g << tab << ng[g] << endl;
2349 }
2350 }
2351
2352 cout << endl;
2353
2354 delete[] ng;
2355
2356 return nsel;
2357 }
2358
2364 long project_maximum_selection(Bproject* project)
2365 {
2366 long smax(0);
2367 Bfield* field = project->field;
2368 Breconstruction* rec = project->rec;
2369 Bmicrograph* mg;
2370 Bparticle* part;
2371
2372 if ( project->select < 1 ) {
2373 for ( field = project->field; field; field = field->next )
2374 for ( mg = field->mg; mg; mg = mg->next )
2375 for ( part = mg->part; part; part = part->next )
2376 if ( smax < part->sel ) smax = part->sel;
2377 } else {
2378 for ( rec = project->rec; rec; rec = rec->next )
2379 for ( part = rec->part; part; part = part->next )
2380 if ( smax < part->sel ) smax = part->sel;
2381 }
2382
2383 return smax;
2384 }
2385
2391 long project_show_selection_numbers(Bproject* project)
2392 {
2393 if ( !project ) return 0;
2394
2395 long i, maxsel, nsel(0);
2396 Bfield* field = project->field;
2397 Breconstruction* rec = project->rec;
2398 Bmicrograph* mg;
2399 Bparticle* part;
2400 int* sel = NULL;
2401
2402 if ( field && field->mg && field->mg->part ) {
2403 for ( maxsel=0, field = project->field; field; field = field->next )
2404 for ( mg = field->mg; mg; mg = mg->next )
2405 for ( part = mg->part; part; part = part->next )
2406 if ( maxsel < part->sel ) maxsel = part->sel;
2407 maxsel++;
2408 sel = new int[maxsel];
2409 for ( i=0; i<maxsel; i++ ) sel[i] = 0;
2410 for ( field = project->field; field; field = field->next )
2411 for ( mg = field->mg; mg; mg = mg->next )
2412 for ( part = mg->part; part; part = part->next )
2413 if ( part->sel > 0 ) sel[part->sel]++;
2414 cout << "Micrograph selection numbers: ";
2415 for ( i=1; i<maxsel; i++ )
2416 if ( sel[i] ) cout << tab << i;
2417 cout << endl;
2418 delete[] sel;
2419 }
2420
2421 if ( rec && rec->part ) {
2422 for ( maxsel=0, rec = project->rec; rec; rec = rec->next )
2423 for ( part = rec->part; part; part = part->next )
2424 if ( maxsel < part->sel ) maxsel = part->sel;
2425 maxsel++;
2426 sel = new int[maxsel];
2427 for ( i=0; i<maxsel; i++ ) sel[i] = 0;
2428 for ( rec = project->rec; rec; rec = rec->next )
2429 for ( part = rec->part; part; part = part->next )
2430 if ( part->sel > 0 ) sel[part->sel]++;
2431 cout << "Reconstruction selection numbers: ";
2432 for ( i=1; i<maxsel; i++ )
2433 if ( sel[i] ) cout << tab << i;
2434 cout << endl;
2435 delete[] sel;
2436 }
2437
2438 return nsel;
2439 }
2440
2446 long project_show_selected(Bproject* project)
2447 {
2448 if ( !project ) return 0;
2449
2450 long i, f, smax(0);
2451 long ntotsel(0), npart(0);
2452 Bfield* field = project->field;
2453 Breconstruction* rec = project->rec;
2454 Bmicrograph* mg;
2455 Bparticle* part;
2456
2457 int* nsel = NULL;
2458 int* ntot = NULL;
2459 float* npercent = NULL;
2460 float* fom = NULL;
2461 double pp(0), fomavg[NFOM], fomstd[NFOM], fommin[NFOM], fommax[NFOM];
2462
2463 if ( field && field->mg ) {
2464 npart = project_count_mg_particles(project);
2465 for ( field = project->field; field; field = field->next ) if ( field->select )
2466 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select )
2467 for ( part = mg->part; part; part = part->next )
2468 if ( smax < part->sel ) smax = part->sel;
2469 if ( verbose )
2470 cout << "Maximum selection number: " << smax << endl;
2471 nsel = new int[smax+1];
2472 ntot = new int[smax+1];
2473 npercent = new float[smax+1];
2474 fom = new float[smax+1];
2475 for ( i=0; i<=smax; i++ ) {
2476 nsel[i] = ntot[i] = 0;
2477 npercent[i] = fom[i] = 0;
2478 }
2479 for ( f=0; f<NFOM; f++ ) {
2480 fomavg[f] = fomstd[f] = 0;
2481 fommin[f] = 1;
2482 fommax[f] = -1;
2483 }
2484 if ( verbose & VERB_PROCESS ) {
2485 cout << "Field\tMgraph";
2486 for ( i=0; i<=smax; i++ ) cout << tab << i;
2487 cout << endl;
2488 }
2489 for ( field = project->field; field; field = field->next ) if ( field->select ) {
2490 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select ) {
2491 for ( i=0; i<=smax; i++ ) nsel[i] = 0;
2492 for ( part = mg->part; part; part = part->next ) {
2493 if ( part->sel > -1 ) {
2494 nsel[part->sel]++;
2495 fom[part->sel] += part->fom[0];
2496 if ( part->sel > 0 ) {
2497 ntotsel++;
2498 for ( f=0; f<NFOM; f++ ) {
2499 fomavg[f] += part->fom[f];
2500 fomstd[f] += part->fom[f]*part->fom[f];
2501 if ( fommin[f] > part->fom[f] ) fommin[f] = part->fom[f];
2502 if ( fommax[f] < part->fom[f] ) fommax[f] = part->fom[f];
2503 }
2504 }
2505 }
2506 }
2507 for ( i=0; i<=smax; i++ ) ntot[i] += nsel[i];
2508 if ( verbose & VERB_PROCESS ) {
2509 cout << field->id << tab << mg->id;
2510 for ( i=0; i<=smax; i++ ) cout << tab << nsel[i];
2511 cout << endl;
2512 }
2513 }
2514 }
2515 for ( i=0; i<=smax; i++ ) {
2516 if ( ntot[i] ) fom[i] /= ntot[i];
2517 if ( npart ) npercent[i] = ntot[i]*100.0/npart;
2518 }
2519 if ( ntotsel ) {
2520 for ( f=0; f<NFOM; f++ ) {
2521 fomavg[f] /= ntotsel;
2522 fomstd[f] = fomstd[f]/ntotsel - fomavg[f]*fomavg[f];
2523 if ( fomstd[f] > 0 ) fomstd[f] = sqrt(fomstd[f]);
2524 else fomstd[f] = 0;
2525 }
2526 }
2527 if ( verbose & VERB_PROCESS ) {
2528 cout << "Totals\t";
2529 for ( i=0; i<=smax; i++ ) cout << tab << ntot[i];
2530 cout << endl << "Percent\t";
2531 for ( i=0; i<=smax; i++ ) cout << tab << npercent[i];
2532 cout << endl << "FOM\t";
2533 for ( i=0; i<=smax; i++ ) cout << tab << fom[i];
2534 cout << endl << endl;
2535 }
2536 if ( npart ) pp = ntotsel*100.0/npart;
2537 cout << "Overall selected FOM average and standard deviation:" << endl;
2538 cout << "Selected particle images: " << ntotsel << " (" << pp << "%)" << endl;
2539 for ( f=0; f<NFOM; f++ ) if ( project->fom_tag[f] )
2540 cout << "FOM" << f << ": " <<
2541 fommin[f] << tab << fommax[f] << tab << fomavg[f] << tab << fomstd[f] << endl;
2542 cout << endl;
2543 delete[] nsel;
2544 delete[] ntot;
2545 delete[] npercent;
2546 delete[] fom;
2547 }
2548
2549 if ( rec && rec->part ) {
2550 npart = project_count_rec_particles(project);
2551 for ( smax=0, rec = project->rec; rec; rec = rec->next ) if ( rec->select )
2552 for ( part = rec->part; part; part = part->next )
2553 if ( smax < part->sel ) smax = part->sel;
2554 if ( verbose )
2555 cout << "Maximum selection number: " << smax << endl;
2556 nsel = new int[smax+1];
2557 ntot = new int[smax+1];
2558 npercent = new float[smax+1];
2559 fom = new float[smax+1];
2560 for ( i=0; i<=smax; i++ ) {
2561 nsel[i] = ntot[i] = 0;
2562 npercent[i] = fom[i] = 0;
2563 }
2564 for ( f=0; f<NFOM; f++ ) {
2565 fomavg[f] = fomstd[f] = 0;
2566 fommin[f] = 1;
2567 fommax[f] = -1;
2568 }
2569 if ( verbose & VERB_PROCESS ) {
2570 cout << "Recons";
2571 for ( i=0; i<=smax; i++ ) cout << tab << i;
2572 cout << endl;
2573 }
2574 for ( rec = project->rec; rec; rec = rec->next ) if ( rec->select ) {
2575 for ( i=0; i<=smax; i++ ) nsel[i] = 0;
2576 for ( part = rec->part; part; part = part->next ) {
2577 if ( part->sel > -1 ) {
2578 nsel[part->sel]++;
2579 fom[part->sel] += part->fom[0];
2580 if ( part->sel > 0 ) {
2581 ntotsel++;
2582 for ( f=0; f<NFOM; f++ ) {
2583 fomavg[f] += part->fom[f];
2584 fomstd[f] += part->fom[f]*part->fom[f];
2585 if ( fommin[f] > part->fom[f] ) fommin[f] = part->fom[f];
2586 if ( fommax[f] < part->fom[f] ) fommax[f] = part->fom[f];
2587 }
2588 }
2589 }
2590 }
2591 for ( i=0; i<=smax; i++ ) ntot[i] += nsel[i];
2592 if ( verbose & VERB_PROCESS ) {
2593 cout << rec->id;
2594 for ( i=0; i<=smax; i++ ) cout << tab << nsel[i];
2595 cout << endl;
2596 }
2597 }
2598 for ( i=0; i<=smax; i++ ) {
2599 if ( ntot[i] ) fom[i] /= ntot[i];
2600 if ( npart ) npercent[i] = ntot[i]*100.0/npart;
2601 }
2602 if ( ntotsel ) {
2603 for ( f=0; f<NFOM; f++ ) {
2604 fomavg[f] /= ntotsel;
2605 fomstd[f] = fomstd[f]/ntotsel - fomavg[f]*fomavg[f];
2606 if ( fomstd[f] > 0 ) fomstd[f] = sqrt(fomstd[f]);
2607 else fomstd[f] = 0;
2608 }
2609 }
2610 if ( verbose & VERB_PROCESS ) {
2611 cout << "Totals";
2612 for ( i=0; i<=smax; i++ ) cout << tab << ntot[i];
2613 cout << endl << "Percent";
2614 for ( i=0; i<=smax; i++ ) cout << tab << npercent[i];
2615 cout << endl << "FOM";
2616 for ( i=0; i<=smax; i++ ) cout << tab << fom[i];
2617 cout << endl << endl;
2618 }
2619 pp = 0;
2620 if ( npart ) pp = ntotsel*100.0/npart;
2621 cout << "Overall selected FOM average and standard deviation:" << endl;
2622 cout << "Selected particle images: " << ntotsel << " (" << pp << " %)" << endl;
2623 for ( f=0; f<NFOM; f++ ) if ( project->fom_tag[f] )
2624 cout << "FOM" << f << ": " <<
2625 fommin[f] << tab << fommax[f] << tab << fomavg[f] << tab << fomstd[f] << endl;
2626 cout <<endl;
2627 delete[] nsel;
2628 delete[] ntot;
2629 delete[] npercent;
2630 delete[] fom;
2631 }
2632
2633 if ( project->class_avg ) {
2634 cout << "Class averages: " << particle_count(project->class_avg) << endl << endl;
2635 }
2636
2637 return ntotsel;
2638 }
2639
2645 long project_show_class_averages(Bproject* project)
2646 {
2647 if ( !verbose ) return 0;
2648
2649 if ( !project->class_avg ) return 0;
2650
2651 long n(0);
2652 long npart = project_count_mg_part_selected(project);
2653 Bparticle* part;
2654
2655 cout << "Class averages:" << endl;
2656 cout << "Class\tNumber\t % \tFOM" << endl;
2657 for ( part = project->class_avg; part; part = part->next ) {
2658 cout << part->id << tab << part->sel << tab <<
2659 setw(8) << part->sel*100.0/npart << tab <<
2660 part->fom[0] << endl;
2661 n++;
2662 }
2663 cout << endl;
2664
2665 return n;
2666 }
2667
2674 long project_show_selected_parameters(Bproject* project, int show)
2675 {
2676 if ( !project ) return 0;
2677
2678 if ( show < 0 ) return 0;
2679
2680 int f;
2681 long nsel(0), npart(0);
2682 Bfield* field = project->field;
2683 Breconstruction* rec = project->rec;
2684 Bmicrograph* mg;
2685 Bparticle* part;
2686
2687 if ( field && field->mg && field->mg->part ) {
2688 for ( field = project->field; field; field = field->next ) if ( field->select ) {
2689 cout << "Field: " << field->id << endl;
2690 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select ) {
2691 cout << "Micrograph: " << mg->id << endl;
2692 for ( part = mg->part; part; part = part->next ) {
2693 if ( part->sel == show ) {
2694 cout << part->id << tab << part->ori[0] << tab
2695 << part->ori[1] << tab << part->view[0] << tab
2696 << part->view[1] << tab << part->view[2] << tab
2697 << part->view.angle()*180/M_PI;
2698 for ( f=0; f<NFOM; f++ ) cout << tab << part->fom[f];
2699 cout << endl;
2700 nsel++;
2701 }
2702 npart++;
2703 }
2704 cout << endl;
2705 }
2706 }
2707 cout << "Particles selected: " << nsel << " (" << nsel*100.0/npart << " %)" << endl << endl;
2708 }
2709
2710 if ( rec && rec->part ) {
2711 for ( npart=nsel=0, rec = project->rec; rec; rec = rec->next ) if ( rec->select ) {
2712 cout << "Reconstruction: " << rec->id << endl;
2713 for ( part = rec->part; part; part = part->next ) {
2714 if ( part->sel == show ) {
2715 cout << part->id << tab << part->ori[0] << tab
2716 << part->ori[1] << tab << part->view[0] << tab
2717 << part->view[1] << tab << part->view[2] << tab
2718 << part->view.angle()*180/M_PI;
2719 for ( f=0; f<NFOM; f++ ) cout << tab << part->fom[f];
2720 cout << endl;
2721 nsel++;
2722 }
2723 npart++;
2724 }
2725 cout << endl;
2726 }
2727 cout << "Particles selected: " << nsel << " (" << nsel*100.0/npart << " %)" << endl << endl;
2728 }
2729
2730 return nsel;
2731 }
2732
2733 int part_show_parameter(Bparticle* part, Bstring& tag)
2734 {
2735 int float_flag(1), idata(0);
2736 float fdata(0);
2737 Euler euler;
2738
2739 euler = Euler(part->view);
2740 if ( tag == PARTICLE_X ) fdata = part->loc[0];
2741 else if ( tag == PARTICLE_Y ) fdata = part->loc[1];
2742 else if ( tag == PARTICLE_Z ) fdata = part->loc[2];
2743 else if ( tag == PARTICLE_PIXEL ) fdata = part->pixel_size;
2744 else if ( tag == PARTICLE_ORIGIN_X ) fdata = part->ori[0];
2745 else if ( tag == PARTICLE_ORIGIN_Y ) fdata = part->ori[1];
2746 else if ( tag == PARTICLE_ORIGIN_Z ) fdata = part->ori[2];
2747 else if ( tag == PARTICLE_DEFOCUS ) fdata = part->def;
2748 else if ( tag == PARTICLE_DEF_DEV ) fdata = part->dev;
2749 else if ( tag == PARTICLE_AST_ANG ) fdata = part->ast;
2750 else if ( tag == PARTICLE_MAGNIF ) fdata = part->mag;
2751 else if ( tag == PARTICLE_VIEW_X ) fdata = part->view[0];
2752 else if ( tag == PARTICLE_VIEW_Y ) fdata = part->view[1];
2753 else if ( tag == PARTICLE_VIEW_Z ) fdata = part->view[2];
2754 else if ( tag == PARTICLE_VIEW_ANGLE ) fdata = part->view.angle();
2755 else if ( tag == PARTICLE_PSI ) fdata = euler.psi()*180/M_PI;
2756 else if ( tag == PARTICLE_THETA ) fdata = euler.theta()*180/M_PI;
2757 else if ( tag == PARTICLE_PHI ) fdata = euler.phi()*180/M_PI;
2758 else if ( tag == PARTICLE_OMEGA ) fdata = -euler.psi()*180/M_PI;
2759 else if ( tag == PARTICLE_FOM ) fdata = part->fom[0];
2760 else if ( tag == PARTICLE_FOM_CV ) fdata = part->fom[1];
2761 else if ( tag == PARTICLE_HANDA_FOM ) fdata = part->fom[1];
2762 else if ( tag == PARTICLE_HANDB_FOM ) fdata = part->fom[2];
2763 else if ( tag == PARTICLE_SELECT ) {
2764 idata = part->sel;
2765 float_flag = 0;
2766 } else float_flag = -1;
2767
2768 if ( float_flag == 0 ) {
2769 cout << part->id << tab << idata << endl;
2770 } else {
2771 cout << part->id << tab << fdata << endl;
2772 }
2773
2774 return 0;
2775 }
2776
2783 long project_show_parameter(Bproject* project, Bstring& tag)
2784 {
2785 if ( !project ) return 0;
2786
2787 if ( tag.length() < 1 ) return 0;
2788
2789 long nsel(0), npart(0);
2790 Bfield* field = project->field;
2791 Breconstruction* rec = project->rec;
2792 Bmicrograph* mg;
2793 Bparticle* part;
2794
2795 cout << "PID\t" << tag << endl;
2796
2797 if ( field && field->mg && field->mg->part ) {
2798 for ( field = project->field; field; field = field->next ) {
2799 for ( mg = field->mg; mg; mg = mg->next ) {
2800 for ( part = mg->part; part; part = part->next ) {
2801 if ( part->sel ) {
2802 part_show_parameter(part, tag);
2803 nsel++;
2804 }
2805 npart++;
2806 }
2807 }
2808 }
2809 }
2810
2811 if ( rec && rec->part ) {
2812 for ( npart=nsel=0, rec = project->rec; rec; rec = rec->next ) {
2813 for ( part = rec->part; part; part = part->next ) {
2814 if ( part->sel ) {
2815 part_show_parameter(part, tag);
2816 nsel++;
2817 }
2818 npart++;
2819 }
2820 }
2821 }
2822
2823 return nsel;
2824 }
2825
2831 long project_show_fom_histogram(Bproject* project)
2832 {
2833 if ( !project ) return 0;
2834
2835 int f;
2836 long i, nh(100), sum, ssum, nsel(0), npart;
2837 Bfield* field = project->field;
2838 Breconstruction* rec = project->rec;
2839 Bmicrograph* mg;
2840 Bparticle* part;
2841
2842 long* hist = new long[nh+1];
2843 long* hsel = new long[nh+1];
2844
2845 if ( field && field->mg && field->mg->part )
2846 cout << "Micrograph figures-of-merit:" << endl;
2847 for ( f=0; f<NFOM; f++ ) if ( project->fom_tag[f] ) {
2848 nsel = npart = 0;
2849 for ( i=0; i<=nh; i++ ) hist[i] = hsel[i] = 0;
2850 for ( field = project->field; field; field = field->next ) {
2851 for ( mg = field->mg; mg; mg = mg->next ) {
2852 for ( part = mg->part; part; part = part->next ) {
2853 i = (long) (part->fom[f]*nh + 0.5);
2854 if ( i < 0 ) i = 0;
2855 if ( i > nh ) i = nh;
2856 hist[i]++;
2857 npart++;
2858 if ( part->sel ) {
2859 hsel[i]++;
2860 nsel++;
2861 }
2862 }
2863 }
2864 }
2865 if ( nsel ) {
2866 cout << endl << "FOM" << f << " histogram:" << endl;
2867 cout << " Bin\tFOM\tCount\t%%\tSum\tSel\t%%\tSelSum" << endl;
2868 sum = npart;
2869 ssum = nsel;
2870 for ( i=0; i<=nh; i++ ) {
2871 cout << i << tab << i*1.0/nh << tab << hist[i] << tab <<
2872 hist[i]*100.0/npart << tab << sum << tab << hsel[i] << tab
2873 << hsel[i]*100.0/nsel << tab << ssum << endl;
2874 sum -= hist[i];
2875 ssum -= hsel[i];
2876 }
2877 cout << endl;
2878 }
2879 }
2880
2881 if ( rec && rec->part )
2882 cout << "Reconstruction figures-of-merit:" << endl;
2883 for ( f=0; f<NFOM; f++ ) if ( project->fom_tag[f] ) {
2884 nsel = npart = 0;
2885 for ( i=0; i<=nh; i++ ) hist[i] = hsel[i] = 0;
2886 for ( rec = project->rec; rec; rec = rec->next ) {
2887 for ( part = rec->part; part; part = part->next ) {
2888 i = (long) (part->fom[f]*nh + 0.5);
2889 if ( i < 0 ) i = 0;
2890 if ( i > nh ) i = nh;
2891 hist[i]++;
2892 npart++;
2893 if ( part->sel ) {
2894 hsel[i]++;
2895 nsel++;
2896 }
2897 }
2898 }
2899 if ( nsel ) {
2900 cout << endl << "FOM" << f << " histogram:" << endl;
2901 cout << " Bin\tFOM\tCount\t%%\tSum\tSel\t%%\tSelSum" << endl;
2902 sum = npart;
2903 ssum = nsel;
2904 for ( i=0; i<=nh; i++ ) {
2905 cout << i << tab << i*1.0/nh << tab << hist[i] << tab <<
2906 hist[i]*100.0/npart << tab << sum << tab << hsel[i] << tab
2907 << hsel[i]*100.0/nsel << tab << ssum << endl;
2908 sum -= hist[i];
2909 ssum -= hsel[i];
2910 }
2911 cout << endl;
2912 }
2913 }
2914
2915 delete[] hist;
2916 delete[] hsel;
2917
2918 return nsel;
2919 }
2920
2928 long project_show_mag_histogram(Bproject* project, int bins, double increment)
2929 {
2930 if ( !project ) return 0;
2931
2932 int i;
2933 long nsel(0);
2934 Bfield* field;
2935 Bmicrograph* mg;
2936 Bparticle* part;
2937
2938 double min = 1 - (bins - 1)*increment/2;
2939 int* hist = new int[bins];
2940 for ( i=0; i<bins; i++ ) hist[i] = 0;
2941
2942 for ( field = project->field; field; field = field->next ) {
2943 for ( mg = field->mg; mg; mg = mg->next ) {
2944 for ( part = mg->part; part; part = part->next ) {
2945 if ( part->sel ) {
2946 i = (int) ((part->mag - min)/increment + 0.5);
2947 if ( i < 0 ) i = 0;
2948 if ( i >=bins ) i = bins - 1;
2949 hist[i]++;
2950 nsel++;
2951 }
2952 }
2953 }
2954 }
2955
2956 cout << "Mag\tCount" << endl;
2957
2958 for ( i=0; i<bins; i++ )
2959 cout << min + i*increment << tab << hist[i] << endl;
2960
2961 cout << endl << "Total\t" << nsel << endl << endl;
2962
2963 delete[] hist;
2964
2965 return nsel;
2966 }
2967
2974 long project_dump(Bproject* project, Bstring& filename)
2975 {
2976 if ( !project ) return 0;
2977
2978 int f;
2979 long i, j, npart(0), nsel(0);
2980 double npercent(0);
2981 Euler euler;
2982 Bfield* field;
2983 Bmicrograph* mg;
2984 Bparticle* part;
2985 Breconstruction* rec;
2986
2987 ofstream fd(filename.c_str());
2988 if ( fd.fail() ) return -1;
2989
2990 fd << "Project hierarchy:" << endl;
2991 for ( field = project->field; field; field = field->next ) {
2992 fd << "Field: " << field->id << endl;
2993 for ( mg = field->mg; mg; mg = mg->next ) {
2994 i = particle_count(mg->part);
2995 j = particle_count_selected(mg->part);
2996 npart += i;
2997 nsel += j;
2998 fd << "Micrograph: " << mg->id << tab << i << " particles\t" << j << " selected" << endl;
2999 if ( !project->euler_flag ) fd << "ID\tox\toy\toz\tvx\tvy\tvz\tva";
3000 else fd << "ID\tox\toy\toz\tphi\ttheta\tpsi";
3001 for ( f=0; f<NFOM; f++ ) fd << "\tFOM" << f;
3002 fd << endl;
3003 for ( part = mg->part; part; part = part->next ) {
3004 if ( part->sel ) {
3005 if ( !project->euler_flag ) {
3006 fd << part->id << tab << part->ori[0] << tab
3007 << part->ori[1] << tab << part->ori[2] << tab
3008 << part->view[0] << tab << part->view[1] << tab
3009 << part->view[2] << tab << part->view.angle()*180/M_PI;
3010 } else {
3011 euler = Euler(part->view);
3012 fd << part->id << tab << part->ori[0] << tab
3013 << part->ori[1] << tab << part->ori[2] << tab
3014 << euler.phi()*180/M_PI << tab << euler.theta()*180/M_PI
3015 << tab << euler.psi()*180/M_PI;
3016 }
3017 for ( f=0; f<NFOM; f++ ) fd << tab << part->fom[f];
3018 fd << endl;
3019 }
3020 }
3021 fd << endl;
3022 }
3023 }
3024 if ( npart ) npercent = nsel*100.0/npart;
3025 fd << "Totals:\t" << npart << " particles\t" << nsel << " selected\t(" << npercent << "%)" << endl << endl;
3026
3027 if ( project->rec && project->rec->part ) {
3028 for ( npart=nsel=0, rec = project->rec; rec; rec = rec->next ) {
3029 i = particle_count(rec->part);
3030 j = particle_count_selected(rec->part);
3031 npart += i;
3032 nsel += j;
3033 fd << "Reconstruction: " << rec->id << tab << i << " particles\t" << j << " selected" << endl;
3034 if ( !project->euler_flag ) fd << "ID\tox\toy\toz\tvx\tvy\tvz\tva";
3035 else fd << "ID\tox\toy\toz\tphi\ttheta\tpsi";
3036 for ( f=0; f<NFOM; f++ ) fd << "\tFOM" << f;
3037 fd << endl;
3038 for ( part = rec->part; part; part = part->next ) {
3039 if ( part->sel ) {
3040 if ( !project->euler_flag ) {
3041 fd << part->id << tab << part->ori[0] << tab
3042 << part->ori[1] << tab << part->ori[2] << tab
3043 << part->view[0] << tab << part->view[1] << tab
3044 << part->view[2] << tab << part->view.angle()*180/M_PI;
3045 } else {
3046 euler = Euler(part->view);
3047 fd << part->id << tab << part->ori[0] << tab
3048 << part->ori[1] << tab << part->ori[2] << tab
3049 << euler.phi()*180/M_PI << tab << euler.theta()*180/M_PI
3050 << tab << euler.psi()*180/M_PI;
3051 }
3052 for ( f=0; f<NFOM; f++ ) fd << tab << part->fom[f];
3053 fd << endl;
3054 }
3055 }
3056 fd << endl;
3057 }
3058 if ( npart ) npercent = nsel*100.0/npart;
3059 if ( npart ) npercent = nsel*100.0/npart;
3060 fd << "Totals:\t" << npart << " particles\t" << nsel << " selected\t(" << npercent << "%)" << endl << endl;
3061 }
3062
3063 fd.close();
3064
3065 return nsel;
3066 }
3067
3074 int project_select_field(Bproject* project, Bstring& field_id)
3075 {
3076 if ( !project ) return 0;
3077
3078 Bfield* field;
3079 Bfield* selected_field = NULL;
3080
3081 if ( project->field->id == field_id ) {
3082 selected_field = project->field;
3083 } else {
3084 for ( field=project->field; field && !selected_field; field=field->next ) {
3085 if ( field->next->id == field_id ) {
3086 selected_field = field->next;
3087 field->next = NULL;
3088 }
3089 }
3090 field_kill(project->field);
3091 }
3092
3093 field_kill(selected_field->next);
3094 selected_field->next = NULL;
3095 project->field = selected_field;
3096
3097 return 0;
3098 }
3099
3106 int project_select_micrograph(Bproject* project, Bstring& mg_id)
3107 {
3108 if ( !project ) return 0;
3109
3110 Bfield* field;
3111 Bmicrograph* mg;
3112 Bmicrograph* selected_mg = NULL;
3113
3114 for ( field=project->field; field && !selected_mg; field=field->next )
3115 for ( mg = field->mg; mg; mg = mg->next )
3116 if ( mg->id == mg_id ) {
3117 selected_mg = mg;
3118 project_select_field(project, field->id);
3119 }
3120
3121 field=project->field;
3122 if ( field->mg->id == mg_id ) {
3123 selected_mg = field->mg;
3124 } else {
3125 for ( mg = field->mg; mg; mg = mg->next ) {
3126 if ( mg->next->id == mg_id ) {
3127 selected_mg = mg->next;
3128 mg->next = NULL;
3129 }
3130 }
3131 micrograph_kill(field->mg);
3132 }
3133
3134 micrograph_kill(selected_mg->next);
3135 selected_mg->next = NULL;
3136 field->mg = selected_mg;
3137
3138 return 0;
3139 }
3140
3141 Bstring path_update(Bstring& filename, Bstring& path)
3142 {
3143 if ( verbose & VERB_DEBUG )
3144 cout << "DEBUG path_update: Old name = " << filename << endl;
3145
3146 if ( path[-1] != '/' ) path += "/";
3147 // if ( path == "./" ) path = 0;
3148
3149 Bstring newname = filename;
3150 if ( newname.contains("/") ) newname = newname.post_rev('/');
3151 if ( path.length() && path != "./" ) newname = path + newname;
3152 if ( verbose & VERB_DEBUG )
3153 cout << "DEBUG path_update: New name = " << newname << endl;
3154
3155 return newname;
3156 }
3157
3167 int project_set_micrograph_path(Bproject* project, Bstring& path)
3168 {
3169 if ( !project ) return 0;
3170 if ( path.length() < 1 ) return 0;
3171
3172 Bfield* field;
3173 Bmicrograph* mg;
3174
3175 if ( verbose )
3176 cout << "Setting micrograph path to " << path << endl;
3177
3178 for ( field = project->field; field; field = field->next ) {
3179 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->fmg.length() ) {
3180 mg->fmg = path_update(mg->fmg, path);
3181 }
3182 }
3183
3184 return 0;
3185 }
3186
3196 int project_set_frame_path(Bproject* project, Bstring& path)
3197 {
3198 if ( !project ) return 0;
3199 if ( path.length() < 1 ) return 0;
3200
3201 Bfield* field;
3202 Bmicrograph* mg;
3203
3204 if ( verbose )
3205 cout << "Setting micrograph frames path to " << path << endl;
3206
3207 for ( field = project->field; field; field = field->next ) {
3208 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->fframe.length() ) {
3209 mg->fframe = path_update(mg->fframe, path);
3210 }
3211 }
3212
3213 return 0;
3214 }
3215
3225 int project_set_powerspectrum_path(Bproject* project, Bstring& path)
3226 {
3227 if ( !project ) return 0;
3228 if ( path.length() < 1 ) return 0;
3229
3230 Bfield* field;
3231 Bmicrograph* mg;
3232
3233 if ( verbose )
3234 cout << "Setting power spectrum path to " << path << endl;
3235
3236 for ( field = project->field; field; field = field->next ) {
3237 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->fps.length() ) {
3238 mg->fps = path_update(mg->fps, path);
3239 }
3240 }
3241
3242 return 0;
3243 }
3244
3254 int project_set_particle_path(Bproject* project, Bstring& path)
3255 {
3256 if ( !project ) return 0;
3257 if ( path.length() < 1 ) return 0;
3258
3259 Bfield* field;
3260 Bmicrograph* mg;
3261 Breconstruction* rec;
3262 Bparticle* part = NULL;
3263
3264 if ( verbose )
3265 cout << "Setting particle path to " << path << endl;
3266
3267 if ( project->select ) {
3268 for ( rec = project->rec; rec; rec = rec->next ) {
3269 if ( rec->part && rec->part->fpart.length() ) {
3270 for ( part = rec->part; part; part = part->next )
3271 part->fpart = path_update(part->fpart, path);
3272 } else if ( rec->fpart.length() ) {
3273 rec->fpart = path_update(rec->fpart, path);
3274 }
3275 }
3276 } else {
3277 for ( field = project->field; field; field = field->next ) {
3278 for ( mg = field->mg; mg; mg = mg->next ) {
3279 if ( mg->part && mg->part->fpart.length() ) {
3280 for ( part = mg->part; part; part = part->next )
3281 part->fpart = path_update(part->fpart, path);
3282 } else if ( mg->fpart.length() ) {
3283 mg->fpart = path_update(mg->fpart, path);
3284 }
3285 }
3286 }
3287 }
3288
3289 if ( verbose & VERB_DEBUG )
3290 cout << "DEBUG project_set_particle_path: done" << endl;
3291
3292 return 0;
3293 }
3294
3304 int project_set_filament_path(Bproject* project, Bstring& path)
3305 {
3306 if ( !project ) return 0;
3307 if ( path.length() < 1 ) return 0;
3308
3309 Bfield* field;
3310 Bmicrograph* mg;
3311 Breconstruction* rec;
3312 Bstring newname, insert = "_fil.";
3313
3314 if ( project->select ) {
3315 for ( rec = project->rec; rec; rec = rec->next ) {
3316 if ( verbose & VERB_DEBUG )
3317 cout << "DEBUG project_set_particle_path: Old name = " << rec->ffil << endl;
3318 newname = rec->ffil;
3319 if ( rec->ffil.length() < 1 )
3320 newname = rec->frec.pre_rev('.') + insert + rec->frec.post_rev('.');
3321 // if ( newname.contains("/") ) newname = newname.post_rev('/');
3322 // rec->ffil = newname;
3323 // if ( path.length() ) rec->ffil = path + rec->ffil;
3324 rec->ffil = path_update(rec->ffil, path);
3325 if ( verbose & VERB_DEBUG )
3326 cout << "DEBUG project_set_filament_path: New name = " << rec->ffil << endl;
3327 }
3328 } else {
3329 for ( field = project->field; field; field = field->next ) {
3330 for ( mg = field->mg; mg; mg = mg->next ) {
3331 if ( verbose & VERB_DEBUG )
3332 cout << "DEBUG project_set_particle_path: Old name = " << mg->ffil << endl;
3333 newname = mg->ffil;
3334 if ( mg->ffil.length() < 1 )
3335 newname = mg->fmg.pre_rev('.') + insert + mg->fmg.post_rev('.');
3336 // if ( newname.contains("/") ) newname = newname.post_rev('/');
3337 // mg->ffil = newname;
3338 // if ( path.length() ) mg->ffil = path + mg->ffil;
3339 mg->ffil = path_update(mg->ffil, path);
3340 if ( verbose & VERB_DEBUG )
3341 cout << "DEBUG project_set_filament_path: New name = " << mg->ffil << endl;
3342 }
3343 }
3344 }
3345
3346 return 0;
3347 }
3348
3355 int project_set_magnification(Bproject* project, double mag)
3356 {
3357 if ( !project ) return 0;
3358
3359 Bfield* field;
3360 Bmicrograph* mg;
3361
3362 for ( field = project->field; field; field = field->next )
3363 for ( mg = field->mg; mg; mg = mg->next )
3364 mg->magnification = mag;
3365
3366 return 0;
3367 }
3368
3378 int project_set_scan_sampling(Bproject* project, double sampling)
3379 {
3380 if ( !project ) return 0;
3381
3382 Bfield* field;
3383 Bmicrograph* mg;
3384
3385 for ( field = project->field; field; field = field->next )
3386 for ( mg = field->mg; mg; mg = mg->next )
3387 mg->sampling = sampling;
3388
3389 return 0;
3390 }
3391
3398 int project_set_pixel_size(Bproject* project, double pixel_size)
3399 {
3400 if ( !project ) return 0;
3401
3402 Bfield* field;
3403 Bmicrograph* mg;
3404 Breconstruction* rec;
3405
3406 if ( verbose & VERB_DEBUG )
3407 cout << "DEBUG project_set_pixel_size: pixel_size = " << pixel_size << endl;
3408
3409 if ( project->select )
3410 for ( rec = project->rec; rec; rec = rec->next )
3411 rec->voxel_size = pixel_size;
3412 else
3413 for ( field = project->field; field; field = field->next )
3414 for ( mg = field->mg; mg; mg = mg->next )
3415 mg->pixel_size = pixel_size;
3416
3417 return 0;
3418 }
3419
3427 int project_set_tilt(Bproject* project, double tilt_axis, double tilt_angle)
3428 {
3429 if ( !project ) return 0;
3430
3431 Bfield* field;
3432 Bmicrograph* mg;
3433
3434 for ( field = project->field; field; field = field->next ) {
3435 for ( mg = field->mg; mg; mg = mg->next ) {
3436 mg->tilt_axis = tilt_axis;
3437 mg->tilt_angle = tilt_angle;
3438 }
3439 }
3440
3441 return 0;
3442 }
3443
3449 int field_sort_by_tilt(Bfield* field)
3450 {
3451 if ( !field ) return 0;
3452
3453 long i(0), nmg = field_count_micrographs(field);
3454 double minang;
3455
3456 vector<Bmicrograph*> mgarr(nmg);
3457
3458 Bmicrograph* mg, *mg2;
3459 Bmicrograph* mgsel = NULL;
3460
3461 for ( mg = field->mg; mg; mg = mg->next ) mg->select = 1;
3462
3463 for ( mg = field->mg; mg; mg = mg->next ) {
3464 minang = 100;
3465 for ( mg2 = field->mg; mg2; mg2 = mg2->next ) if ( mg2->select ) {
3466 if ( minang > mg2->tilt_angle ) {
3467 minang = mg2->tilt_angle;
3468 mgsel = mg2;
3469 }
3470 }
3471 mgarr[i++] = mgsel;
3472 mgsel->select = 0;
3473 }
3474
3475 field->mg = mg = mgarr[0];
3476
3477 for ( i=1; i<nmg; ++i, mg = mg->next ) mg->next = mgarr[i];
3478 mg->next = NULL;
3479
3480 for ( mg = field->mg; mg; mg = mg->next ) mg->select = 1;
3481
3482 return 0;
3483 }
3484
3490 int project_sort_by_tilt(Bproject* project)
3491 {
3492 if ( !project ) return 0;
3493
3494 Bfield* field;
3495
3496 for ( field = project->field; field; field = field->next )
3497 field_sort_by_tilt(field);
3498
3499 return 0;
3500 }
3501
3508 int project_set_dose(Bproject* project, double dose)
3509 {
3510 if ( !project ) return 0;
3511
3512 Bfield* field;
3513 Bmicrograph* mg;
3514
3515 for ( field = project->field; field; field = field->next )
3516 for ( mg = field->mg; mg; mg = mg->next )
3517 mg->dose = dose;
3518
3519 return 0;
3520 }
3521
3531 int project_set_micrograph_origins(Bproject* project, Vector3<float> origin)
3532 {
3533 if ( !project ) return 0;
3534 if ( !project->field ) return 0;
3535 if ( !project->field->mg ) return 0;
3536
3537 Bfield* field;
3538 Bmicrograph* mg;
3539
3540 if ( verbose & VERB_FULL )
3541 cout << "Setting micrograph origins to " << origin << endl;
3542
3543 for ( field = project->field; field; field = field->next ) {
3544 field->origin = origin;
3545 for ( mg = field->mg; mg; mg = mg->next )
3546 mg->origin = origin;
3547 }
3548
3549 return 0;
3550 }
3551
3563 int project_add_origins_to_coords(Bproject* project)
3564 {
3565 if ( !project ) return 0;
3566
3567 Bfield* field;
3568 Bmicrograph* mg;
3569 Breconstruction* rec;
3570 Bparticle* part;
3571
3572 if ( project->select ) {
3573 for ( rec = project->rec; rec; rec = rec->next ) {
3574 for ( part = rec->part; part; part = part->next ) {
3575 part->loc += part->ori - rec->box_size/2;
3576 part->ori = rec->box_size/2;
3577 }
3578 }
3579 } else {
3580 for ( field = project->field; field; field = field->next ) {
3581 for ( mg = field->mg; mg; mg = mg->next ) {
3582 for ( part = mg->part; part; part = part->next ) {
3583 part->loc += part->ori - mg->box_size/2;
3584 part->ori = mg->box_size/2;
3585 }
3586 }
3587 }
3588 }
3589
3590 return 0;
3591 }
3592
3605 int project_flip_origins(Bproject* project, int flip)
3606 {
3607 if ( !project ) return 0;
3608
3609 Bfield* field;
3610 Bmicrograph* mg;
3611 Breconstruction* rec;
3612 Bparticle* part;
3613
3614 int fx(flip & 1);
3615 int fy(flip & 2);
3616 int fz(flip & 4);
3617
3618 if ( verbose & VERB_PROCESS ) {
3619 cout << "Flipping origins along ";
3620 if ( fx ) cout << "x";
3621 if ( fy ) cout << "y";
3622 if ( fz ) cout << "z";
3623 cout << endl;
3624 }
3625
3626 if ( project->select ) {
3627 for ( rec = project->rec; rec; rec = rec->next ) {
3628 for ( part = rec->part; part; part = part->next ) {
3629 if ( fx ) part->ori[0] = rec->box_size[0] - part->ori[0];
3630 if ( fy ) part->ori[1] = rec->box_size[1] - part->ori[1];
3631 if ( fz ) part->ori[2] = rec->box_size[2] - part->ori[2];
3632 }
3633 }
3634 } else {
3635 for ( field = project->field; field; field = field->next ) {
3636 for ( mg = field->mg; mg; mg = mg->next ) {
3637 for ( part = mg->part; part; part = part->next ) {
3638 if ( fx ) part->ori[0] = mg->box_size[0] - part->ori[0];
3639 if ( fy ) part->ori[1] = mg->box_size[1] - part->ori[1];
3640 }
3641 }
3642 }
3643 }
3644
3645 return 0;
3646 }
3647
3656 long project_renumber_particles(Bproject* project)
3657 {
3658 if ( !project ) return 0;
3659
3660 long n, np(0);
3661 Bfield* field;
3662 Bmicrograph* mg;
3663 Breconstruction* rec;
3664 Bparticle* part;
3665
3666 if ( verbose & VERB_FULL )
3667 cout << "Renumbering particles" << endl << endl;
3668
3669 if ( project->select ) {
3670 for ( rec = project->rec; rec; rec = rec->next )
3671 for ( n=1, part = rec->part; part; part = part->next, n++, np++ )
3672 part->id = n;
3673 } else {
3674 for ( field = project->field; field; field = field->next )
3675 for ( mg = field->mg; mg; mg = mg->next )
3676 for ( n=1, part = mg->part; part; part = part->next, n++, np++ )
3677 part->id = n;
3678 }
3679
3680 return np;
3681 }
3682
3693 int project_set_particle_box_size(Bproject* project, Vector3<long> box_size)
3694 {
3695 if ( !project ) return 0;
3696
3697 Bfield* field;
3698 Bmicrograph* mg;
3699 Breconstruction* rec;
3700 Bparticle* part;
3701
3702 if ( verbose & VERB_FULL )
3703 cout << "Setting the box size to " << box_size << endl << endl;
3704
3705 if ( project->select ) {
3706 for ( rec = project->rec; rec; rec = rec->next ) {
3707 for ( part = rec->part; part; part = part->next )
3708 part->ori -= rec->box_size/2;
3709 rec->box_size = box_size;
3710 for ( part = rec->part; part; part = part->next )
3711 part->ori += rec->box_size/2;
3712 }
3713 } else {
3714 box_size[2] = 1;
3715 for ( field = project->field; field; field = field->next )
3716 for ( mg = field->mg; mg; mg = mg->next ) {
3717 for ( part = mg->part; part; part = part->next )
3718 part->ori -= mg->box_size/2;
3719 mg->box_size = box_size;
3720 for ( part = mg->part; part; part = part->next )
3721 part->ori += mg->box_size/2;
3722 }
3723 }
3724
3725 return 0;
3726 }
3727
3738 int project_set_particle_box_size(Bproject* project, long box_size)
3739 {
3740 if ( !project ) return 0;
3741
3742 Vector3<long> bsize(box_size, box_size, 1);
3743 if ( project->select ) bsize[2] = box_size;
3744
3745 return project_set_particle_box_size(project, bsize);
3746 }
3747
3757 int project_set_particle_origins(Bproject* project, Vector3<double> origin)
3758 {
3759 if ( !project ) return 0;
3760
3761 Bfield* field;
3762 Bmicrograph* mg;
3763 Breconstruction* rec;
3764 Bparticle* part;
3765
3766 if ( verbose & VERB_FULL )
3767 cout << "Setting origins to " << origin << endl << endl;
3768
3769 if ( project->select ) {
3770 for ( rec = project->rec; rec; rec = rec->next )
3771 for ( part = rec->part; part; part = part->next )
3772 part->ori = origin;
3773 } else {
3774 for ( field = project->field; field; field = field->next )
3775 for ( mg = field->mg; mg; mg = mg->next )
3776 for ( part = mg->part; part; part = part->next )
3777 part->ori = origin;
3778 }
3779
3780 return 0;
3781 }
3782
3792 int project_set_particle_asu_views(Bproject* project, Bstring& symmetry_asu)
3793 {
3794 if ( !project ) return 0;
3795
3796 Bsymmetry* sym = init_point_group_symmetry(symmetry_asu);
3797
3798 project_set_particle_asu_views(project, sym);
3799
3800 kill_symmetry(sym);
3801
3802 return 0;
3803 }
3804
3805 int project_set_particle_asu_views(Bproject* project, Bsymmetry* sym)
3806 {
3807 if ( !project ) return 0;
3808
3809 Bfield* field;
3810 Bmicrograph* mg;
3811 Breconstruction* rec;
3812 Bparticle* part;
3813
3814 if ( verbose )
3815 cout << "Setting particle views to the asymmetric unit for point group " << sym->label << endl << endl;
3816
3817 if ( project->select ) {
3818 for ( rec = project->rec; rec; rec = rec->next )
3819 for ( part = rec->part; part; part = part->next )
3820 part->view = find_asymmetric_unit_view(sym, part->view);
3821 } else {
3822 for ( field = project->field; field; field = field->next )
3823 for ( mg = field->mg; mg; mg = mg->next )
3824 for ( part = mg->part; part; part = part->next )
3825 part->view = find_asymmetric_unit_view(sym, part->view);
3826 }
3827
3828 return 0;
3829 }
3830
3838 int project_rotate_particle_views(Bproject* project, View view)
3839 {
3840 if ( !project ) return 0;
3841
3842 if ( view[2] >= 0.999999 ) return 0; // Standard view
3843
3844 Bfield* field;
3845 Bmicrograph* mg;
3846 Breconstruction* rec;
3847 Bparticle* part;
3848 Quaternion q;
3849
3850 if ( verbose & VERB_PROCESS ) {
3851 cout << "Rotating particle views relative to the reference view:" << endl;
3852 cout << view << endl << endl;
3853 }
3854
3855 if ( project->select ) {
3856 for ( rec = project->rec; rec; rec = rec->next )
3857 for ( part = rec->part; part; part = part->next ) {
3858 q = view.quaternion() * part->view.quaternion();
3859 part->view = View(q);
3860 }
3861 } else {
3862 for ( field=project->field; field; field=field->next )
3863 for ( mg=field->mg; mg ; mg=mg->next )
3864 for ( part=mg->part; part; part=part->next) {
3865 q = view.quaternion() * part->view.quaternion();
3866 part->view = View(q);
3867 }
3868 }
3869
3870 return 0;
3871 }
3872
3880 int project_apply_map_magnifications(Bproject* project, int mag_num, float* mag)
3881 {
3882 if ( !project ) return 0;
3883
3884 int i;
3885 Bfield* field;
3886 Bmicrograph* mg;
3887 Breconstruction* rec;
3888 Bparticle* part;
3889
3890 if ( verbose & VERB_PROCESS ) {
3891 cout << "Applying map magnifications to particles:" << endl;
3892 cout << "Number of reference maps: " << mag_num << endl;
3893 for ( i=0; i<mag_num; i++ ) cout << i+1 << tab << mag[i] << endl;
3894 }
3895
3896 if ( project->select < 1 ) {
3897 for ( field = project->field; field; field = field->next ) {
3898 for ( mg = field->mg; mg; mg = mg->next ) {
3899 for ( part = mg->part; part; part = part->next ) {
3900 if ( part->sel > 0 && part->sel <= mag_num ) {
3901 part->mag = mag[part->sel-1];
3902 }
3903 }
3904 }
3905 }
3906 } else {
3907 for ( rec = project->rec; rec; rec = rec->next ) {
3908 for ( part = rec->part; part; part = part->next ) {
3909 if ( part->sel > 0 && part->sel <= mag_num ) {
3910 part->mag = mag[part->sel-1];
3911 }
3912 }
3913 }
3914 }
3915
3916 return 0;
3917 }
3918
3925 View* views_from_project(Bproject* project, int selection)
3926 {
3927 if ( !project ) return 0;
3928
3929 Bfield* field;
3930 Bmicrograph* mg;
3931 Breconstruction* rec;
3932 Bparticle* part;
3933 View* view = NULL;
3934 View* v = NULL;
3935
3936 if ( project->select < 1 ) {
3937 if ( verbose & VERB_PROCESS )
3938 cout << "Retrieving the particle views from the micrographs" << endl << endl;
3939 for ( field = project->field; field; field = field->next )
3940 for ( mg = field->mg; mg; mg = mg->next )
3941 for ( part = mg->part; part; part = part->next ) {
3942 if ( selection==0 || ( selection==part->sel ) || ( selection<0 && part->sel>0 ) ) {
3943 v = (View *) add_item((char **) &v, sizeof(View));
3944 if ( !view ) view = v;
3945 *v = part->view;
3946 v->next = NULL;
3947 }
3948 }
3949 } else {
3950 if ( verbose & VERB_PROCESS )
3951 cout << "Retrieving the particle views from the reconstructions" << endl << endl;
3952 for ( rec = project->rec; rec; rec = rec->next )
3953 for ( part = rec->part; part; part = part->next ) {
3954 if ( selection==0 || ( selection==part->sel ) || ( selection<0 && part->sel>0 ) ) {
3955 v = (View *) add_item((char **) &v, sizeof(View));
3956 if ( !view ) view = v;
3957 *v = part->view;
3958 v->next = NULL;
3959 }
3960 }
3961 }
3962
3963 return view;
3964 }
3965
3971 Bstring get_fom_tag(FOMType fom_type)
3972 {
3973 Bstring fom_tag;
3974
3975 switch ( fom_type ) {
3976 case FOM: fom_tag = PARTICLE_FOM; break;
3977 case FOM_CC: fom_tag = PARTICLE_CC; break;
3978 case FOM_CC_AVG: fom_tag = PARTICLE_CC_AVG; break;
3979 case FOM_CV: fom_tag = PARTICLE_FOM_CV; break;
3980 case FOM_SNR: fom_tag = PARTICLE_FOM_SNR; break;
3981 case FOM_HAND_A: fom_tag = PARTICLE_HANDA_FOM; break;
3982 case FOM_HAND_B: fom_tag = PARTICLE_HANDB_FOM; break;
3983 case FOM_PFT_CC: fom_tag = PARTICLE_PFT_CC; break;
3984 case FOM_PFT_PRJ: fom_tag = PARTICLE_PRJ_CC; break;
3985 case FOM_PFT_CMP: fom_tag = PARTICLE_CMP_CC; break;
3986 case FOM_RFACTORAB: fom_tag = PARTICLE_RFACTORAB; break;
3987 case COVERAGE: fom_tag = PARTICLE_COVERAGE; break;
3988 case FOM1: fom_tag = PARTICLE_FOM1; break;
3989 case FOM2: fom_tag = PARTICLE_FOM2; break;
3990 case FOM3: fom_tag = PARTICLE_FOM3; break;
3991 case FOM4: fom_tag = PARTICLE_FOM4; break;
3992 case FOM5: fom_tag = PARTICLE_FOM5; break;
3993 case FOM6: fom_tag = PARTICLE_FOM6; break;
3994 case FOM7: fom_tag = PARTICLE_FOM7; break;
3995 case FOM8: fom_tag = PARTICLE_FOM8; break;
3996 case FOM9: fom_tag = PARTICLE_FOM9; break;
3997 default: break;
3998 }
3999
4000 return fom_tag;
4001 }
4002
4009 int get_fom_tag(FOMType fom_type, char* tag)
4010 {
4011 switch ( fom_type ) {
4012 case FOM: strcpy(tag, PARTICLE_FOM); break;
4013 case FOM_CC: strcpy(tag, PARTICLE_CC); break;
4014 case FOM_CC_AVG: strcpy(tag, PARTICLE_CC_AVG); break;
4015 case FOM_CV: strcpy(tag, PARTICLE_FOM_CV); break;
4016 case FOM_SNR: strcpy(tag, PARTICLE_FOM_SNR); break;
4017 case FOM_HAND_A: strcpy(tag, PARTICLE_HANDA_FOM); break;
4018 case FOM_HAND_B: strcpy(tag, PARTICLE_HANDB_FOM); break;
4019 case FOM_PFT_CC: strcpy(tag, PARTICLE_PFT_CC); break;
4020 case FOM_PFT_PRJ: strcpy(tag, PARTICLE_PRJ_CC); break;
4021 case FOM_PFT_CMP: strcpy(tag, PARTICLE_CMP_CC); break;
4022 case FOM_RFACTORAB: strcpy(tag, PARTICLE_RFACTORAB); break;
4023 case FOM1: strcpy(tag, PARTICLE_FOM1); break;
4024 case FOM2: strcpy(tag, PARTICLE_FOM2); break;
4025 case FOM3: strcpy(tag, PARTICLE_FOM3); break;
4026 case FOM4: strcpy(tag, PARTICLE_FOM4); break;
4027 case FOM5: strcpy(tag, PARTICLE_FOM5); break;
4028 case FOM6: strcpy(tag, PARTICLE_FOM6); break;
4029 case FOM7: strcpy(tag, PARTICLE_FOM7); break;
4030 case FOM8: strcpy(tag, PARTICLE_FOM8); break;
4031 case FOM9: strcpy(tag, PARTICLE_FOM9); break;
4032 default: tag[0] = 0; break;
4033 }
4034
4035 return 0;
4036 }
4037
4038
FOM_SNR
Definition: mg_processing.h:43
Breconstruction::fil
Bfilament * fil
Definition: mg_processing.h:305
Bproject::reference
Bstring * reference
Definition: mg_processing.h:338
Bparticle::id
int id
Definition: mg_processing.h:92
PARTICLE_FOM5
#define PARTICLE_FOM5
Definition: mg_tags.h:212
project_flip_origins
int project_flip_origins(Bproject *project, int flip)
Flip origin coordinates.
Definition: mg_processing.cpp:3605
PARTICLE_OMEGA
#define PARTICLE_OMEGA
Definition: mg_tags.h:192
Bparticle::pixel_size
double pixel_size
Definition: mg_processing.h:98
qsort_functions.h
Header file for utility functions for use in qsort calls.
field_add
Bfield * field_add(Bfield **field, Bstring &field_id)
Adds a field-of-view parameter structure to a linked list.
Definition: mg_processing.cpp:120
Bmicrograph::sf_radius
double sf_radius
Definition: mg_processing.h:234
project_count_mg_filaments
long project_count_mg_filaments(Bproject *project)
Counts the number of filaments in a project.
Definition: mg_processing.cpp:960
project_count_mg_filament_nodes
long project_count_mg_filament_nodes(Bproject *project)
Counts the number of filament nodes in a project.
Definition: mg_processing.cpp:983
project_apply_map_magnifications
int project_apply_map_magnifications(Bproject *project, int mag_num, float *mag)
Change particle pixel sizes for particles based on map magnifications.
Definition: mg_processing.cpp:3880
Bparticle::ast
double ast
Definition: mg_processing.h:97
filament_count
long filament_count(Bfilament *fil)
Counts the number of filaments in a linked list of filaments.
Definition: mg_processing.cpp:1187
Bproject::rec
Breconstruction * rec
Definition: mg_processing.h:344
Bparticle::mag
double mag
Definition: mg_processing.h:94
PARTICLE_HANDB_FOM
#define PARTICLE_HANDB_FOM
Definition: mg_tags.h:218
insert
string insert(string &filename, string ins)
Definition: string_util.cpp:48
Bparticle::rec
Breconstruction * rec
Definition: mg_processing.h:105
PARTICLE_ORIGIN_X
#define PARTICLE_ORIGIN_X
Definition: mg_tags.h:186
Bfield::select
long select
Definition: mg_processing.h:262
Euler
Definition: Euler.h:28
field_count_mg_selected
long field_count_mg_selected(Bfield *field)
Counts all the micrographs in the field-of-view structure.
Definition: mg_processing.cpp:1082
Bparticle::view
View view
Definition: mg_processing.h:101
Breconstruction::part
Bparticle * part
Definition: mg_processing.h:304
FOM7
Definition: mg_processing.h:59
project_select_micrograph
int project_select_micrograph(Bproject *project, Bstring &mg_id)
Selects a micrograph from the project and deletes the rest.
Definition: mg_processing.cpp:3106
Bproject::filename
Bstring filename
Definition: mg_processing.h:335
Breconstruction::mark
Bmarker * mark
Definition: mg_processing.h:307
View::next
View * next
Definition: View.h:28
field_count_particles
long field_count_particles(Bfield *field)
Counts all the particles in the field-of-view structure.
Definition: mg_processing.cpp:1097
particle_bad_copy
Bbadarea * particle_bad_copy(Bbadarea *badlist)
Definition: mg_processing.cpp:1448
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
PARTICLE_Y
#define PARTICLE_Y
Definition: mg_tags.h:181
project_show_selection_numbers
long project_show_selection_numbers(Bproject *project)
Shows the selection numbers for the particles in a project.
Definition: mg_processing.cpp:2391
project_kill
int project_kill(Bproject *project)
Frees a whole project.
Definition: mg_processing.cpp:1224
Bmicrograph::sampling
double sampling
Definition: mg_processing.h:213
Bfilnode
Definition: mg_processing.h:115
utilities.h
Header file for general utilities.
Breconstruction::fom
double fom
Definition: mg_processing.h:302
project_rotate_particle_views
int project_rotate_particle_views(Bproject *project, View view)
Rotates particle views with respect to a reference view.
Definition: mg_processing.cpp:3838
PARTICLE_COVERAGE
#define PARTICLE_COVERAGE
Definition: mg_tags.h:225
PARTICLE_ORIGIN_Z
#define PARTICLE_ORIGIN_Z
Definition: mg_tags.h:188
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
Bstrucfac::loc
Vector3< double > loc
Definition: mg_processing.h:157
Blayerline::sel
long sel
Definition: mg_processing.h:182
PARTICLE_CC_AVG
#define PARTICLE_CC_AVG
Definition: mg_tags.h:220
micrograph_add
Bmicrograph * micrograph_add(Bmicrograph **mg, Bstring &mg_id)
Adds a micrograph parameter structure to a linked list.
Definition: mg_processing.cpp:461
project_set_particle_asu_views
int project_set_particle_asu_views(Bproject *project, Bstring &symmetry_asu)
Sets particle views within the asymmetric unit.
Definition: mg_processing.cpp:3792
CTFparam::update
int update(CTFparam *ctf)
Definition: ctf.h:77
project_equal_mg_part_files
int project_equal_mg_part_files(Bproject *project)
Sets micrograph and particle files to be the same.
Definition: mg_processing.cpp:87
project_init
Bproject * project_init()
Initializes a micrograph processing project parameter structure.
Definition: mg_processing.cpp:29
PARTICLE_PHI
#define PARTICLE_PHI
Definition: mg_tags.h:191
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
micrograph_kill
int micrograph_kill(Bmicrograph *mg)
Frees a whole micrograph parameter structure.
Definition: mg_processing.cpp:1288
project_set_particle_path
int project_set_particle_path(Bproject *project, Bstring &path)
Sets the path to particle files for all the micrographs.
Definition: mg_processing.cpp:3254
PARTICLE_FOM3
#define PARTICLE_FOM3
Definition: mg_tags.h:210
Bparticle::fom
double fom[NFOM]
Definition: mg_processing.h:102
PARTICLE_PSI
#define PARTICLE_PSI
Definition: mg_tags.h:189
PARTICLE_FOM6
#define PARTICLE_FOM6
Definition: mg_tags.h:213
Bmarker
Definition: marker.h:21
add_item
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
Definition: linked_list.cpp:26
project_mg_particle_array
Bparticle ** project_mg_particle_array(Bproject *project, int part_select, long &npart)
Sets up an array of selected particle pointers.
Definition: mg_processing.cpp:2029
Matrix3
Definition: Matrix3.h:17
Bstring::length
long length() const
Definition: Bstring.cpp:263
Bmicrograph::pixel_size
double pixel_size
Definition: mg_processing.h:214
project
Bproject * project
Definition: bshow.cpp:31
Quaternion
Definition: Quaternion.h:25
PARTICLE_FOM8
#define PARTICLE_FOM8
Definition: mg_tags.h:215
PARTICLE_FOM4
#define PARTICLE_FOM4
Definition: mg_tags.h:211
frame_add
Bframe * frame_add(Bframe **frame, int pid)
Adds a movie frame parameter structure to a linked list.
Definition: mg_processing.cpp:495
COVERAGE
Definition: mg_processing.h:52
Bmicrograph::dose
double dose
Definition: mg_processing.h:215
kill_symmetry
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
Definition: symmetry.cpp:207
project_show_selected_parameters
long project_show_selected_parameters(Bproject *project, int show)
Shows the selected particle parameters in a project.
Definition: mg_processing.cpp:2674
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:107
FOM4
Definition: mg_processing.h:56
PARTICLE_THETA
#define PARTICLE_THETA
Definition: mg_tags.h:190
part_select
Tcl_Obj * part_select(Bparticle *part, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmg.cpp:432
project_count_mg_part_selected
long project_count_mg_part_selected(Bproject *project)
Counts the number of particles in a project.
Definition: mg_processing.cpp:833
FOM6
Definition: mg_processing.h:58
Bframe::sel
long sel
Definition: mg_processing.h:79
project_set_dose
int project_set_dose(Bproject *project, double dose)
Sets the electron dose of all the micrographs.
Definition: mg_processing.cpp:3508
Bmicrograph::fil
Bfilament * fil
Definition: mg_processing.h:240
project_select_field
int project_select_field(Bproject *project, Bstring &field_id)
Selects a field from the project and deletes the rest.
Definition: mg_processing.cpp:3074
project_add_origins_to_coords
int project_add_origins_to_coords(Bproject *project)
Adds the particle origins to the micrograph coordinates.
Definition: mg_processing.cpp:3563
PARTICLE_VIEW_Z
#define PARTICLE_VIEW_Z
Definition: mg_tags.h:195
project_rec_particle_array
Bparticle ** project_rec_particle_array(Bproject *project, int part_select, long &npart)
Sets up an array of selected particle pointers.
Definition: mg_processing.cpp:2071
PARTICLE_X
#define PARTICLE_X
Definition: mg_tags.h:180
Bfield::origin
Vector3< float > origin
Definition: mg_processing.h:260
Bmicrograph::tilt_angle
double tilt_angle
Definition: mg_processing.h:217
Breconstruction::box_size
Vector3< long > box_size
Definition: mg_processing.h:296
project_show_class_averages
long project_show_class_averages(Bproject *project)
Shows the class averages in a project.
Definition: mg_processing.cpp:2645
Bmicrograph::ffil
Bstring ffil
Definition: mg_processing.h:208
Breconstruction::origin
Vector3< double > origin
Definition: mg_processing.h:293
FOM_CC_AVG
Definition: mg_processing.h:44
Bfield::next
Bfield * next
Definition: mg_processing.h:258
Bmicrograph::sf
Bstrucfac * sf
Definition: mg_processing.h:243
View::vector_size
double vector_size()
Definition: View.h:103
project_set_tilt
int project_set_tilt(Bproject *project, double tilt_axis, double tilt_angle)
Sets the tilt parameters for all the micrographs.
Definition: mg_processing.cpp:3427
Bstrucfac::amp
double amp
Definition: mg_processing.h:159
Bmicrograph::part
Bparticle * part
Definition: mg_processing.h:239
Bfilament::id
int id
Definition: mg_processing.h:131
particle_array
Bparticle ** particle_array(Bparticle *partlist, int part_select, long &npart)
Sets up an array of selected particle pointers.
Definition: mg_processing.cpp:2107
Breconstruction::mark_radius
double mark_radius
Definition: mg_processing.h:301
Bfilament::node
Bfilnode * node
Definition: mg_processing.h:132
project_create
Bproject * project_create(int nmg, int nrec)
Creates a micrograph processing project parameter structure.
Definition: mg_processing.cpp:47
project_count_reconstructions
long project_count_reconstructions(Bproject *project)
Counts all the reconstructions in the project structure.
Definition: mg_processing.cpp:780
FOM2
Definition: mg_processing.h:54
project_show_selected
long project_show_selected(Bproject *project)
Shows the selected particles in a project.
Definition: mg_processing.cpp:2446
FOM_CV
Definition: mg_processing.h:42
Bframe
Definition: mg_processing.h:74
filament_kill
int filament_kill(Bfilament *fil)
Frees a list of filaments.
Definition: mg_processing.cpp:1347
Bmicrograph::matrix
Matrix3 matrix
Definition: mg_processing.h:222
Breconstruction::model
Bstring * model
Definition: mg_processing.h:309
Bmicrograph::fpart
Bstring fpart
Definition: mg_processing.h:207
Bfilament::next
Bfilament * next
Definition: mg_processing.h:129
Bmicrograph::tilt_axis
double tilt_axis
Definition: mg_processing.h:216
filament_length
double filament_length(Bfilament *fil)
Calculates the length of a filament.
Definition: mg_processing.cpp:681
Bstring::contains
bool contains(const Bstring &s)
Definition: Bstring.cpp:584
Bparticle::sel
long sel
Definition: mg_processing.h:103
project_set_scan_sampling
int project_set_scan_sampling(Bproject *project, double sampling)
Sets the scan sampling for all the micrographs.
Definition: mg_processing.cpp:3378
Bfield
Definition: mg_processing.h:257
FOM_RFACTORAB
Definition: mg_processing.h:51
M_PI
#define M_PI
Definition: utilities.h:59
linked_list.h
Header file for generalized linked list functions.
Bfilnode::id
int id
Definition: mg_processing.h:117
Bstrucfac::phi
double phi
Definition: mg_processing.h:161
mg_part_links
int mg_part_links(Bmicrograph *mg)
Sets the links from particles to micrographs.
Definition: mg_processing.cpp:555
Blayerline::order
int order
Definition: mg_processing.h:177
Bmicrograph::ctf
CTFparam * ctf
Definition: mg_processing.h:238
Bstrucfac::sigamp
double sigamp
Definition: mg_processing.h:160
Bstrucfac
Definition: mg_processing.h:155
field_kill
int field_kill(Bfield *field)
Frees a whole field-of-view structure.
Definition: mg_processing.cpp:1261
Bparticle::mg
Bmicrograph * mg
Definition: mg_processing.h:104
Euler::psi
double psi()
Definition: Euler.h:56
micrograph_set_part_links
long micrograph_set_part_links(Bmicrograph *mg)
Sets the links from particles back to the micrograph.
Definition: mg_processing.cpp:1928
Euler::phi
double phi()
Definition: Euler.h:58
rec_part_links
int rec_part_links(Breconstruction *rec)
Sets the links from particles to reconstructions.
Definition: mg_processing.cpp:571
NFOM
#define NFOM
Definition: mg_processing.h:16
project_set_micrograph_path
int project_set_micrograph_path(Bproject *project, Bstring &path)
Sets the path to micrograph files for all the micrographs.
Definition: mg_processing.cpp:3167
Bmicrograph::fframe
Bstring fframe
Definition: mg_processing.h:206
Blayerline::number
int number
Definition: mg_processing.h:176
project_micrograph_array
Bmicrograph ** project_micrograph_array(Bproject *project, long &nmg)
Sets up an array of selected micrograph pointers.
Definition: mg_processing.cpp:2001
project_set_part_links
long project_set_part_links(Bproject *project)
Sets the links from particles back to the micrographs and reconstructions.
Definition: mg_processing.cpp:1906
Bbadarea::next
Bbadarea * next
Definition: mg_processing.h:143
project_show_fom_histogram
long project_show_fom_histogram(Bproject *project)
Shows a histogram of the FOM values.
Definition: mg_processing.cpp:2831
FOM1
Definition: mg_processing.h:53
project_set_particle_origins
int project_set_particle_origins(Bproject *project, Vector3< double > origin)
Sets particle origins to given values.
Definition: mg_processing.cpp:3757
Bfield::id
Bstring id
Definition: mg_processing.h:259
Blayerline::next
Blayerline * next
Definition: mg_processing.h:175
layerline_copy
Blayerline * layerline_copy(Blayerline *layerlist)
Definition: mg_processing.cpp:1504
project_count_rec_filaments
long project_count_rec_filaments(Bproject *project)
Counts the number of filaments in a project.
Definition: mg_processing.cpp:1008
Bmicrograph::select
long select
Definition: mg_processing.h:203
Bmicrograph::mark_radius
double mark_radius
Definition: mg_processing.h:235
filament_node_add
Bfilnode * filament_node_add(Bfilnode **fnode, int pid)
Adds a filament node parameter structure to a linked list.
Definition: mg_processing.cpp:655
Bproject::field
Bfield * field
Definition: mg_processing.h:343
Bproject::fom_tag
FOMType fom_tag[NFOM]
Definition: mg_processing.h:342
views_from_project
View * views_from_project(Bproject *project, int selection)
Retrieves the particle views from a project.
Definition: mg_processing.cpp:3925
length
double length(vector< T > v)
Definition: Vector3.h:528
FOM_HAND_B
Definition: mg_processing.h:47
init_point_group_symmetry
Bsymmetry * init_point_group_symmetry(Bstring symmetry_string)
Sets up a symmetry structure from a string identifier.
Definition: symmetry.cpp:39
project_show_mag_histogram
long project_show_mag_histogram(Bproject *project, int bins, double increment)
Shows the histogram for magnification values for selected particles.
Definition: mg_processing.cpp:2928
PARTICLE_DEF_DEV
#define PARTICLE_DEF_DEV
Definition: mg_tags.h:200
FOM3
Definition: mg_processing.h:55
project_count_rec_part_selected
long project_count_rec_part_selected(Bproject *project)
Counts all the particles in the project structure.
Definition: mg_processing.cpp:919
project_update
int project_update(Bproject *project, Bproject *proj_new, int fom_index)
Updates an existing project with new information.
Definition: mg_processing.cpp:1601
project_set_frame_path
int project_set_frame_path(Bproject *project, Bstring &path)
Sets the path to micrograph frames files for all the micrographs.
Definition: mg_processing.cpp:3196
Bmicrograph::level_angle
double level_angle
Definition: mg_processing.h:218
Blayerline::freq
double freq
Definition: mg_processing.h:179
FOM_CC
Definition: mg_processing.h:41
Bmicrograph
Definition: mg_processing.h:200
reconstruction_set_part_links
long reconstruction_set_part_links(Breconstruction *rec)
Sets the links from particles back to the reconstruction.
Definition: mg_processing.cpp:1943
project_count_micrographs
long project_count_micrographs(Bproject *project)
Counts all the micrographs in the project structure.
Definition: mg_processing.cpp:746
project_set_field_id
int project_set_field_id(Bproject *project, int nseries, Bstring &field_id)
Sets the field id's according to a regular series.
Definition: mg_processing.cpp:2203
Bmicrograph::layer
Blayerline * layer
Definition: mg_processing.h:244
Bmicrograph::origin
Vector3< double > origin
Definition: mg_processing.h:220
PARTICLE_RFACTORAB
#define PARTICLE_RFACTORAB
Definition: mg_tags.h:224
Bproject::class_avg
Bparticle * class_avg
Definition: mg_processing.h:345
Breconstruction::symmetry
Bstring symmetry
Definition: mg_processing.h:286
project_set_magnification
int project_set_magnification(Bproject *project, double mag)
Sets the magnification for all the micrographs.
Definition: mg_processing.cpp:3355
Bparticle::group
int group
Definition: mg_processing.h:93
mg_tags.h
All STAR and XML file format tags for micrographs and reconstructions.
Bstrucfac::index
Vector3< int > index
Definition: mg_processing.h:158
PARTICLE_PRJ_CC
#define PARTICLE_PRJ_CC
Definition: mg_tags.h:222
PARTICLE_PIXEL
#define PARTICLE_PIXEL
Definition: mg_tags.h:198
Bstrucfac::next
Bstrucfac * next
Definition: mg_processing.h:156
filament_add
Bfilament * filament_add(Bfilament **fil, int pid)
Adds a filament parameter structure to a linked list.
Definition: mg_processing.cpp:625
filament_node_count
long filament_node_count(Bfilament *fil)
Counts the number of filament nodes in a linked list of filaments.
Definition: mg_processing.cpp:1205
Bparticle::fpart
Bstring fpart
Definition: mg_processing.h:91
PARTICLE_FOM_SNR
#define PARTICLE_FOM_SNR
Definition: mg_tags.h:205
FOM_HAND_A
Definition: mg_processing.h:46
structurefactor_copy
Bstrucfac * structurefactor_copy(Bstrucfac *sflist)
Definition: mg_processing.cpp:1483
Bframe::next
Bframe * next
Definition: mg_processing.h:75
PARTICLE_VIEW_Y
#define PARTICLE_VIEW_Y
Definition: mg_tags.h:194
FOM5
Definition: mg_processing.h:57
Bparticle::ori
Vector3< double > ori
Definition: mg_processing.h:100
field_find_micrograph_n
Bmicrograph * field_find_micrograph_n(Bfield *field, int n)
Returns a pointer to the nth micrograph in a field-of-view structure.
Definition: mg_processing.cpp:223
FOM_PFT_CC
Definition: mg_processing.h:48
Vector3::length2
double length2()
Definition: Vector3.h:221
Bproject::next
Bproject * next
Definition: mg_processing.h:334
project_count_mg_selected
long project_count_mg_selected(Bproject *project)
Counts all the selected micrographs in the project structure.
Definition: mg_processing.cpp:763
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
particle_count_selected
long particle_count_selected(Bparticle *part)
Counts the number of particles in a linked list.
Definition: mg_processing.cpp:1169
Bmicrograph::mark
Bmarker * mark
Definition: mg_processing.h:242
Bbadarea::id
int id
Definition: mg_processing.h:144
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:428
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:264
project_show_parameter
long project_show_parameter(Bproject *project, Bstring &tag)
Shows the particle parameter indicated by the tag in a project.
Definition: mg_processing.cpp:2783
Bsymmetry::label
Bstring label
Definition: symmetry.h:41
Bsymmetry
Definition: symmetry.h:38
FOM
Definition: mg_processing.h:40
Bparticle::dev
double dev
Definition: mg_processing.h:96
PARTICLE_ORIGIN_Y
#define PARTICLE_ORIGIN_Y
Definition: mg_tags.h:187
VERB_RESULT
#define VERB_RESULT
Definition: utilities.h:105
Breconstruction::fft
Bstring fft
Definition: mg_processing.h:290
project_revert_filenames
int project_revert_filenames(Bproject *project, Bproject *project_old, int flag)
Reverts file names to what it was in an old project.
Definition: mg_processing.cpp:2135
Euler::theta
double theta()
Definition: Euler.h:57
Bmicrograph::fps
Bstring fps
Definition: mg_processing.h:210
Bparticle
Definition: mg_processing.h:89
reconstruction_update
int reconstruction_update(Breconstruction *rec, Breconstruction *nu_rec, int fom_index, int flags)
Updates an existing reconstruction with new information.
Definition: mg_processing.cpp:1772
random_numbers.h
Header file for functions for creating random images.
QsortSmallToLargeFloat
int QsortSmallToLargeFloat(const void *x, const void *y)
Utility function for sorting floating point values in qsort.
Definition: qsort_functions.cpp:17
field_find_low_tilt_mg_with_markers
Bmicrograph * field_find_low_tilt_mg_with_markers(Bfield *field)
Finds the micrograph closest to a zero degree tilt in a series with markers.
Definition: mg_processing.cpp:431
Bfield::matrix
Matrix3 matrix
Definition: mg_processing.h:261
field_sort_by_tilt
int field_sort_by_tilt(Bfield *field)
Sorts the micrographs in a field by tilt angle.
Definition: mg_processing.cpp:3449
Bmicrograph::block
int block
Definition: mg_processing.h:204
Bmicrograph::rot_angle
double rot_angle
Definition: mg_processing.h:219
Bstring
Definition: Bstring.h:29
field_find_id
Bfield * field_find_id(Bfield *field, Bstring &field_id)
Finds a field-of-view based on its identifier.
Definition: mg_processing.cpp:152
Breconstruction::sf
Bstrucfac * sf
Definition: mg_processing.h:308
FOM_PFT_CMP
Definition: mg_processing.h:50
PARTICLE_FOM9
#define PARTICLE_FOM9
Definition: mg_tags.h:216
project_count_mg_particles
long project_count_mg_particles(Bproject *project)
Counts all the particles in the project structure.
Definition: mg_processing.cpp:811
Bmicrograph::fft
Bstring fft
Definition: mg_processing.h:209
get_fom_tag
Bstring get_fom_tag(FOMType fom_type)
Returns the tag associated with a particular FOM.
Definition: mg_processing.cpp:3971
project_count_rec_groups
long project_count_rec_groups(Bproject *project)
Counts all the particles in the project structure.
Definition: mg_processing.cpp:937
part_show_parameter
int part_show_parameter(Bparticle *part, Bstring &tag)
Definition: mg_processing.cpp:2733
View::quaternion
Quaternion quaternion()
Definition: View.h:127
PARTICLE_AST_ANG
#define PARTICLE_AST_ANG
Definition: mg_tags.h:201
Bproject::select
int select
Definition: mg_processing.h:339
Breconstruction::bad_radius
double bad_radius
Definition: mg_processing.h:299
FOMType
FOMType
Definition: mg_processing.h:38
Breconstruction::select
long select
Definition: mg_processing.h:283
Bmicrograph::box_size
Vector3< long > box_size
Definition: mg_processing.h:230
filament_copy
Bfilament * filament_copy(Bfilament *fillist)
Definition: mg_processing.cpp:1463
field_find_zero_tilt_mg
Bmicrograph * field_find_zero_tilt_mg(Bfield *field)
Finds the micrograph closest to a zero degree tilt in a series.
Definition: mg_processing.cpp:400
find_asymmetric_unit_view
View find_asymmetric_unit_view(Bsymmetry *sym, View theview)
Finds the corresponding view in the asymmetric unit.
Definition: symmetry.cpp:856
Bfilament::ffil
Bstring ffil
Definition: mg_processing.h:130
Breconstruction::scale
Vector3< double > scale
Definition: mg_processing.h:294
markers_copy
Bmarker * markers_copy(Bmarker *mark)
Copies a set of markers.
Definition: marker.cpp:92
micrograph_count
long micrograph_count(Bmicrograph *mg)
Counts the number of micrographs in a linked list.
Definition: mg_processing.cpp:1118
project_set_powerspectrum_path
int project_set_powerspectrum_path(Bproject *project, Bstring &path)
Sets the path to powerspectrum files for all the micrographs.
Definition: mg_processing.cpp:3225
field_count_micrographs
long field_count_micrographs(Bfield *field)
Counts all the micrographs in the field-of-view structure.
Definition: mg_processing.cpp:1067
PARTICLE_Z
#define PARTICLE_Z
Definition: mg_tags.h:182
Breconstruction::ffil
Bstring ffil
Definition: mg_processing.h:289
PARTICLE_CMP_CC
#define PARTICLE_CMP_CC
Definition: mg_tags.h:223
Breconstruction::bad
Bbadarea * bad
Definition: mg_processing.h:306
PARTICLE_FOM
#define PARTICLE_FOM
Definition: mg_tags.h:203
PARTICLE_FOM2
#define PARTICLE_FOM2
Definition: mg_tags.h:209
Vector3< float >
path_update
Bstring path_update(Bstring &filename, Bstring &path)
Definition: mg_processing.cpp:3141
Bmicrograph::fmg
Bstring fmg
Definition: mg_processing.h:205
Bparticle::loc
Vector3< double > loc
Definition: mg_processing.h:99
PARTICLE_PFT_CC
#define PARTICLE_PFT_CC
Definition: mg_tags.h:221
FOM8
Definition: mg_processing.h:60
Bmicrograph::fil_node_radius
double fil_node_radius
Definition: mg_processing.h:232
Bfilnode::next
Bfilnode * next
Definition: mg_processing.h:116
View::angle
double angle()
Definition: View.h:95
project_divide
long project_divide(Bproject *project, long n)
Divides a project into a number of micrograph subsets.
Definition: mg_processing.cpp:1962
micrograph_update
int micrograph_update(Bmicrograph *mg, Bmicrograph *nu_mg, int fom_index, int flags)
Updates an existing micrograph with new information.
Definition: mg_processing.cpp:1670
Bstrucfac::sigphi
double sigphi
Definition: mg_processing.h:162
View
Definition: View.h:26
project_merge_part_parameters
int project_merge_part_parameters(Bproject *project, Bproject *partproject)
Puts particle parameters from one project into another.
Definition: mg_processing.cpp:1876
Bmicrograph::bad
Bbadarea * bad
Definition: mg_processing.h:241
Bmicrograph::magnification
double magnification
Definition: mg_processing.h:212
show
int show(0)
Bmicrograph::fom
double fom
Definition: mg_processing.h:236
field_count
long field_count(Bfield *field)
Counts the number of fields-of-view in a linked list.
Definition: mg_processing.cpp:1053
PARTICLE_MAGNIF
#define PARTICLE_MAGNIF
Definition: mg_tags.h:197
project_set_particle_box_size
int project_set_particle_box_size(Bproject *project, Vector3< long > box_size)
Sets particle box size to the given value.
Definition: mg_processing.cpp:3693
project_maximum_selection
long project_maximum_selection(Bproject *project)
Finds the maximum slection number for a project.
Definition: mg_processing.cpp:2364
PARTICLE_FOM1
#define PARTICLE_FOM1
Definition: mg_tags.h:208
particle_copy
Bparticle * particle_copy(Bparticle **partlist, Bparticle *part)
Adds one particle onto a list of particle parameters.
Definition: mg_processing.cpp:1409
CTFparam::defocus_average
double defocus_average()
Definition: ctf.h:100
project_count_rec_particles
long project_count_rec_particles(Bproject *project)
Counts all the particles in the project structure.
Definition: mg_processing.cpp:902
Bparticle::def
double def
Definition: mg_processing.h:95
micrograph_copy
Bmicrograph * micrograph_copy(Bmicrograph *mg)
Copies a micrograph.
Definition: mg_processing.cpp:1529
particle_count
long particle_count(Bparticle *part)
Counts the number of particles in a linked list.
Definition: mg_processing.cpp:1151
PARTICLE_DEFOCUS
#define PARTICLE_DEFOCUS
Definition: mg_tags.h:199
project_set_pixel_size
int project_set_pixel_size(Bproject *project, double pixel_size)
Sets the pixel size for all the micrographs.
Definition: mg_processing.cpp:3398
FOM9
Definition: mg_processing.h:61
Breconstruction::block
int block
Definition: mg_processing.h:284
particle_add
Bparticle * particle_add(Bparticle **part, int pid)
Adds a particle parameter structure to a linked list.
Definition: mg_processing.cpp:527
reconstruction_add
Breconstruction * reconstruction_add(Breconstruction **rec, Bstring &rec_id)
Adds a reconstruction parameter structure to a linked list.
Definition: mg_processing.cpp:704
project_count_mg_groups
long project_count_mg_groups(Bproject *project)
Counts the number of groups of particles in the project structure.
Definition: mg_processing.cpp:879
Blayerline::fom
double fom
Definition: mg_processing.h:181
project_set_filament_path
int project_set_filament_path(Bproject *project, Bstring &path)
Sets the path to filament files for all the micrographs.
Definition: mg_processing.cpp:3304
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
Breconstruction::voxel_size
double voxel_size
Definition: mg_processing.h:292
particle_kill
int particle_kill(Bparticle *part)
Frees a list of particles.
Definition: mg_processing.cpp:1323
verbose
int verbose
Bframe::id
int id
Definition: mg_processing.h:76
project_dump
long project_dump(Bproject *project, Bstring &filename)
Dumps particle info in the project hierarchy.
Definition: mg_processing.cpp:2974
Blayerline::amp
double amp
Definition: mg_processing.h:180
particle_update
int particle_update(Bparticle **pnt_part, Bparticle *nu_part, int fom_index)
Updates an existing particle with new information.
Definition: mg_processing.cpp:1817
PARTICLE_VIEW_ANGLE
#define PARTICLE_VIEW_ANGLE
Definition: mg_tags.h:196
Bframe::fom
double fom
Definition: mg_processing.h:78
Bproject::comment
Bstring comment
Definition: mg_processing.h:336
part_find_first
Bparticle * part_find_first(Bproject *project)
Finds the first particle in a project.
Definition: mg_processing.cpp:589
Bmicrograph::bad_radius
double bad_radius
Definition: mg_processing.h:233
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:413
Blayerline
Definition: mg_processing.h:174
field_find_micrograph
Bmicrograph * field_find_micrograph(Bfield *field, int mg_select, int mg_index, double mg_ang)
Returns a pointer to a specific micrograph in a field-of-view structure based on a unique characteris...
Definition: mg_processing.cpp:183
project_count_rec_filament_nodes
long project_count_rec_filament_nodes(Bproject *project)
Counts the number of filaments in a project.
Definition: mg_processing.cpp:1029
field_find_micrograph_by_tiltang
Bmicrograph * field_find_micrograph_by_tiltang(Bfield *field, double tiltang)
Returns a pointer to the micrograph in a field-of-view structure with the specified tilt angle.
Definition: mg_processing.cpp:362
project_set_micrograph_origins
int project_set_micrograph_origins(Bproject *project, Vector3< float > origin)
Sets micrograph origins to the given origin.
Definition: mg_processing.cpp:3531
Bparticle::next
Bparticle * next
Definition: mg_processing.h:90
micrograph_count_particles
long micrograph_count_particles(Bmicrograph *mg)
Counts all the particles in the micrograph structure.
Definition: mg_processing.cpp:1132
VERB_FULL
#define VERB_FULL
Definition: utilities.h:109
PARTICLE_SELECT
#define PARTICLE_SELECT
Definition: mg_tags.h:202
PARTICLE_VIEW_X
#define PARTICLE_VIEW_X
Definition: mg_tags.h:193
Bproject::euler_flag
int euler_flag
Definition: mg_processing.h:340
Bmicrograph::scale
Vector3< double > scale
Definition: mg_processing.h:221
project_sort_by_tilt
int project_sort_by_tilt(Bproject *project)
Sorts the micrographs in each field by tilt angle.
Definition: mg_processing.cpp:3490
reconstruction_kill
int reconstruction_kill(Breconstruction *rec)
Frees a whole reconstruction parameter structure.
Definition: mg_processing.cpp:1377
project_count_rec_selected
long project_count_rec_selected(Bproject *project)
Counts all the selected reconstructions in the project structure.
Definition: mg_processing.cpp:795
project_renumber_particles
long project_renumber_particles(Bproject *project)
Renumbers particles.
Definition: mg_processing.cpp:3656
Bfilnode::loc
Vector3< double > loc
Definition: mg_processing.h:118
field_find_micrograph_by_rotang
Bmicrograph * field_find_micrograph_by_rotang(Bfield *field, double rotang)
Returns a pointer to the micrograph in a field-of-view structure with the specified in-plane rotation...
Definition: mg_processing.cpp:318
Breconstruction::view
View view
Definition: mg_processing.h:295
PARTICLE_FOM7
#define PARTICLE_FOM7
Definition: mg_tags.h:214
Breconstruction::next
Breconstruction * next
Definition: mg_processing.h:281
field_find_micrograph_by_focus
Bmicrograph * field_find_micrograph_by_focus(Bfield *field, int focus_opt, int iselect)
Returns a pointer to the micrograph in a field-of-view structure based on the focus level and iterati...
Definition: mg_processing.cpp:261
FOM_PFT_PRJ
Definition: mg_processing.h:49
Blayerline::distance
double distance
Definition: mg_processing.h:178
error_show
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:755
tab
ostream & tab(ostream &out)
Definition: utilities.cpp:21
Bproject
Definition: mg_processing.h:333
PARTICLE_FOM_CV
#define PARTICLE_FOM_CV
Definition: mg_tags.h:204
PARTICLE_HANDA_FOM
#define PARTICLE_HANDA_FOM
Definition: mg_tags.h:217
project_show_hierarchy
long project_show_hierarchy(Bproject *project)
Shows the project hierarchy.
Definition: mg_processing.cpp:2253
Bstrucfac::fom
double fom
Definition: mg_processing.h:163
Breconstruction::id
Bstring id
Definition: mg_processing.h:282
math_util.h
Header file for general utilities.
project_count_fields
long project_count_fields(Bproject *project)
Counts all the fields in the project structure.
Definition: mg_processing.cpp:731
Bfilament
Definition: mg_processing.h:128
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:760
PARTICLE_CC
#define PARTICLE_CC
Definition: mg_tags.h:219
CTFparam
Definition: ctf.h:26
Bstrucfac::sel
long sel
Definition: mg_processing.h:164
Bmicrograph::next
Bmicrograph * next
Definition: mg_processing.h:201