 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
32 int i, width = 0, height = 0, left=50, bottom=50, nmg = 0;
35 if ( !field )
return -1;
41 if ( !part )
return -1;
47 for ( mg=field->
mg; mg; mg=mg->
next ) {
50 error_show(
"Error in ps_mg_particle_positions", __FILE__, __LINE__);
51 cerr <<
"Micrograph " << mg->
fmg <<
" not found" << endl;
54 if ( width < p->sizeX() ) width = p->
sizeX();
55 if ( height < p->sizeY() ) height = p->
sizeY();
61 cout <<
"DEBUG ps_mg_particle_positions: width=" << width <<
" height=" << height << endl;
63 float scale(500.0/width);
64 if ( scale > 700.0/height ) scale = 700.0/height;
69 for ( i=0, mg=field->
mg; mg; mg=mg->
next, i++ ) {
70 *fps <<
"%%%%Page: " << i+1 <<
" " << i+1 << endl;
71 *fps <<
"/Helvetica findfont 12 scalefont setfont" << endl;
72 *fps <<
"50 755 moveto (" << title <<
": " << mg->
fpart <<
") show" << endl;
73 *fps <<
"/Scale " << scale <<
" def" << endl;
74 *fps <<
"/Height 700 def\n/Width 500 def" << endl;
75 *fps <<
"/Frame { newpath 0 0 moveto Width 0 lineto Width Height lineto 0 Height lineto closepath } def" << endl;
77 *fps <<
"/Data [\n%x y mag sel" << endl;
78 for ( part=mg->
part; part; part=part->
next )
if ( part->
sel )
79 *fps << part->
loc[0] <<
" " << part->
loc[1] <<
" " <<
80 part->
mag <<
" " << part->
sel << endl;
81 *fps <<
"] def" << endl;
83 *fps <<
"gsave" << endl;
84 *fps <<
" " << left <<
" " << bottom <<
" translate" << endl;
85 *fps <<
" Frame stroke" << endl;
87 *fps <<
" Scale Scale scale" << endl;
88 *fps <<
" /Helvetica findfont 64 scalefont setfont" << endl;
89 *fps <<
" 0 4 Data length 4 sub { " << endl;
90 *fps <<
" /Index exch def" << endl;
91 *fps <<
" /x Data Index get def" << endl;
92 *fps <<
" /y Data Index 1 add get def" << endl;
93 *fps <<
" /mag Data Index 2 add get def" << endl;
94 *fps <<
" /sel Data Index 3 add get def" << endl;
95 *fps <<
" x y moveto 0 30 rmoveto sel cvi (xxxx) cvs show stroke" << endl;
96 *fps <<
" x y moveto 0 -30 rmoveto mag cvr (x.xxx) cvs show stroke" << endl;
97 *fps <<
" } for" << endl;
98 *fps <<
"grestore" << endl;
100 *fps <<
"showpage" << endl;
133 cout <<
"Writing postscript file: " << filename << endl << endl;
137 *fps <<
"/Helvetica-Bold findfont 20 scalefont setfont" << endl;
138 *fps <<
"40 740 moveto (" << filename <<
") show" << endl;
140 ps_views(fps, symmetry_string, view, 2);
144 *fps <<
"/Helvetica-Bold findfont 20 scalefont setfont" << endl;
145 *fps <<
"40 740 moveto (" << filename <<
") show" << endl;
173 cout <<
"Writing postscript file: " << filename << endl << endl;
177 *fps <<
"/Helvetica-Bold findfont 20 scalefont setfont" << endl;
178 *fps <<
"40 740 moveto (" << filename <<
") show" << endl;
190 cout <<
"DEBUG ps_origins: flags=" << flags << endl;
192 int left(50), bottom(150), width(500), height(500);
201 long nx = 0, ny = 0, nz = 0;
204 if ( field && field->
mg ) {
210 for ( mg = field->
mg; mg && !p; mg = mg->
next )
222 for ( part = rec->
part; part && !p; part = part->
next )
236 error_show(
"Error in ps_origins: zero image size!", __FILE__, __LINE__);
243 float scale = width*1.0/nx;
245 cout <<
"Dimensions of the image particles: " << nx <<
" * " << ny << endl;
246 cout <<
"Center of the particle images: " << cx <<
" * " << cy << endl;
253 count =
new float[nx*ny];
254 for ( i=0; i<nx*ny; i++ ) count[i] = 0;
257 for ( mg = field->
mg; mg; mg = mg->
next )
258 for ( part = mg->
part; part; part = part->
next )
259 if ( part->
sel > 0 ) {
260 ix = (long) part->
ori[0];
261 iy = (
long) part->
ori[1];
262 if ( ix < 0 ) ix += nx;
263 if ( iy < 0 ) iy += ny;
264 if ( ix >= 0 && iy >= 0 && ix < nx && iy < ny ) {
267 if ( m < count[i] ) m = (int) count[i];
273 for ( part = rec->
part; part; part = part->
next )
274 if ( part->
sel > 0 ) {
275 ix = (long) part->
ori[0];
276 iy = (
long) part->
ori[1];
277 if ( ix < 0 ) ix += nx;
278 if ( iy < 0 ) iy += ny;
279 if ( ix >= 0 && iy >= 0 && ix < nx && iy < ny ) {
282 if ( m < count[i] ) m = (int) count[i];
290 cout <<
"DEBUG ps_origins: number of particles selected = " << n << endl;
292 *fps <<
"%%%%Page: Origins 2" << endl;
293 *fps <<
"/Helvetica-Bold findfont 14 scalefont setfont" << endl;
294 *fps <<
"/Left " << left <<
" def\n/Bottom " << bottom <<
" def\n/Height " << height <<
" def\n/Width " << width <<
" def" << endl;
296 *fps <<
"/Origin [" << endl;
298 *fps <<
"%x y count weight" << endl;
299 for ( i=iy=0; iy<ny; iy++ )
300 for ( ix=0; ix<nx; ix++, i++ )
301 if ( count[i] ) *fps << ix <<
" " << iy <<
" " << count[i] <<
" " << count[i]/m << endl;
304 *fps <<
"%x y count weight" << endl;
307 for ( mg = field->
mg; mg; mg = mg->
next )
308 for ( part = mg->
part; part; part = part->
next )
309 if ( part->
sel > 0 ) {
310 *fps << part->
ori[0] <<
" " << part->
ori[1] <<
" 0.0 0.0" << endl;
315 for ( part = rec->
part; part; part = part->
next )
316 if ( part->
sel > 0 ) {
317 *fps << part->
ori[0] <<
" " << part->
ori[1] <<
" 0.0 0.0" << endl;
323 *fps <<
"] def" << endl;
325 *fps <<
"/Dim " << nx <<
" def" << endl;
326 *fps <<
"/Rad Dim 2 div def" << endl;
327 *fps <<
"/Scale Width Dim div def" << endl;
328 *fps <<
"/Box { newpath " << endl;
329 *fps <<
" Rad Rad Rad 0 360 arc stroke" << endl;
330 *fps <<
" 0 0 moveto 0 Dim rlineto Dim 0 rlineto 0 Dim neg rlineto Dim neg 0 rlineto" << endl;
331 *fps <<
" 0 Rad moveto Dim 0 rlineto" << endl;
332 *fps <<
" Rad 0 moveto 0 Dim rlineto" << endl;
333 *fps <<
" closepath } def" << endl;
335 *fps <<
"40 720 moveto (Number of origins: " << n <<
") show" << endl;
336 if ( nz < 2 ) *fps <<
"40 700 moveto (Particle dimensions: " << nx <<
" x " << ny <<
") show" << endl;
337 else *fps <<
"40 700 moveto (Particle dimensions: " << nx <<
" x " << ny <<
" x " << nz <<
") show" << endl;
338 *fps <<
"40 680 moveto (Maximum count: " << m <<
") show" << endl;
339 *fps <<
"/Helvetica findfont 16 scalefont setfont" << endl;
340 *fps <<
"gsave" << endl;
341 *fps <<
" Left Bottom translate Scale Scale scale" << endl;
342 *fps <<
" " << 1/scale <<
" setlinewidth Box stroke" << endl;
344 *fps <<
" 0 0.1 1 {" << endl;
345 *fps <<
" /f exch def" << endl;
346 *fps <<
" 0 4 Origin length 4 sub {" << endl;
347 *fps <<
" /Index exch def" << endl;
348 *fps <<
" /x Origin Index get def" << endl;
349 *fps <<
" /y Origin Index 1 add get def" << endl;
350 *fps <<
" /v Origin Index 3 add get def" << endl;
351 *fps <<
" v f ge {" << endl;
352 *fps <<
" 1 v sub setgray" << endl;
353 *fps <<
" x y 0.5 0 360 arc fill" << endl;
354 *fps <<
" } if" << endl;
355 *fps <<
" } for stroke" << endl;
356 *fps <<
" } for" << endl;
358 *fps <<
" /n 0 def" << endl;
359 *fps <<
" 0 4 Origin length 4 sub {" << endl;
360 *fps <<
" /Index exch def" << endl;
361 *fps <<
" /x Origin Index get def" << endl;
362 *fps <<
" /y Origin Index 1 add get def" << endl;
363 *fps <<
" x y 0.5 0 360 arc fill" << endl;
365 *fps <<
" /n n 1 add def" << endl;
366 *fps <<
" x y moveto 0.02 0.02 rmoveto n cvi (xxxx) cvs show stroke" << endl;
368 *fps <<
" } for stroke" << endl;
370 *fps <<
"grestore" << endl;
371 *fps <<
"showpage" << endl;
396 Bstring title(
"FOM histogram");
405 for ( i=1; i<=nfom; i++ ) {
439 for ( i=0; i<=nh; i++ ) (*plot)[i] = i*2.0/nh - 1;
443 cout <<
"Generating file " << filename <<
" with a FOM histogram" << endl << endl;
445 cout <<
"Generating file " << filename <<
" with " << nfom <<
" FOM histograms" << endl << endl;
448 for ( f=0, j=plot->
rows(); f<nfom; f++, j+=plot->rows() )
if (
project->
fom_tag[f] ) {
451 for ( mg = field->
mg; mg; mg = mg->
next ) {
452 for ( part = mg->
part; part; part = part->
next )
if ( part->
sel ) {
453 i = (long) ((part->
fom[f]+1)*nh/2 + 0.5);
455 if ( i > nh ) i = nh;
462 for ( part = rec->
part; part; part = part->
next )
if ( part->
sel ) {
463 i = (long) ((part->
fom[f]+1)*nh/2 + 0.5);
465 if ( i > nh ) i = nh;
473 cout <<
"DEBUG ps_part_fom_histogram: Histogram data transferred" << endl;
486 if ( nfom > 1 && npart > 0) {
488 plot =
new Bplot(1, npart, nfom);
498 for ( i=1; i<nfom; i++ ) {
511 for ( i=1; i<4; i+=2 ) {
517 for ( f=0, j=0; f<nfom; f++, j+=npart )
if (
project->
fom_tag[f] ) {
520 for ( mg = field->
mg; mg; mg = mg->
next ) {
521 for ( part = mg->
part; part; part = part->
next )
if ( part->
sel ) {
522 (*plot)[i+j] = part->
fom[f];
529 for ( part = rec->
part; part; part = part->
next )
if ( part->
sel ) {
530 (*plot)[i+j] = part->
fom[f];
538 cout <<
"DEBUG ps_part_fom_histogram: FOM data: npart=" << npart <<
" transferred=" << i << endl;
563 long i, nc(2), nh(100);
564 double damax(10), da, dd, a, c, s, ca(0), sa(0), r2(0);
565 double daa(0), das(0), dda(0), dds(0);
570 Bstring title(
"Defocus histogram");
590 for ( i=0; i<=nh; i++ ) (*plot)[i] = i*damax/nh;
593 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
ctf ) {
607 i = (long) (nh*da/damax + 0.5);
609 if ( i > nh ) i = nh;
616 das = das/n - daa*daa;
617 dds = dds/n - dda*dda;
618 if ( das > 0 ) das = sqrt(das);
620 if ( dds > 0 ) dds = sqrt(dds);
629 cout <<
"Defocus average: " << daa <<
" (" << das <<
")" << endl;
630 cout <<
"Defocus deviation: " << dda <<
" (" << dds <<
")" << endl;
631 cout <<
"Astigmatism angle: " << a*180/
M_PI <<
" (" << sqrt(-log(r2)) <<
")" << endl;
635 cout <<
"Generating file " << filename <<
" with defocus histograms" << endl << endl;
665 Bstring title(
"Astigmatism plot");
689 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
ctf ) {
696 cout <<
"Generating file " << filename <<
" with an astigmatism plot" << endl << endl;
721 long i, nc(0), nmax(0), nt(0);
726 if ( nmax < ca->sel ) nmax = ca->
sel;
727 if ( fommax < ca->fom[0] ) fommax = ca->
fom[0];
732 nmax = log(nmax) + 1;
735 cout <<
"Generating a class average plot" << endl << endl;
737 Bstring title(
"Class average FOMs");
761 (*plot)[i] = log(ca->
sel);
762 (*plot)[i+nc] = ca->
fom[0];
767 txt =
Bstring(nc,
"Number of class averages: %ld");
769 txt =
Bstring(nt,
"Number of particles: %ld");
Header file for postscript tools dealing with micrograph particle sets.
int ps_defocus_histogram(Bstring &filename, Bproject *project)
Postscript histogram plot of micrograph defocus parameters.
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
int ps_class_average_fom(ofstream *fps, Bproject *project)
Postscript histogram plot of class average FOM's.
Header file for general symmetry functions.
double astigmatism_angle()
int ps_part_fom_histogram(Bstring &filename, Bproject *project)
Postscript plot of the particle FOM histogram.
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Header file for postscript output functions.
int change_views_to_asymmetric_unit(Bsymmetry *sym, View *view)
Change the views to those in the asymmetric unit.
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
int ps_close(ofstream *fps)
Closes a postscript file.
ofstream * ps_open_and_init(Bstring filename, Bstring title, int npages, int width, int height)
Opens and initializes a postscript file.
int ps_mg_particle_positions(Bstring &filename, Bstring &title, Bproject *project)
Postscript plot of the positions of particles on micrographs.
long project_count_mg_part_selected(Bproject *project)
Counts the number of particles in a project.
Bstring get_fom_tag(FOMType fom_type)
Returns the tag associated with a particular FOM.
void add_text(Bstring &s)
General image parameter class.
double defocus_deviation()
int ps_astigmatism_plot(Bstring &filename, Bproject *project)
Postscript plot of micrograph astigmatism parameters.
int ps_views(Bstring &filename, Bstring &symmetry_string, View *view, int flags)
Generates postscript plot of views on the unit sphere.
int ps_graph(ofstream *fps, Bplot *plot, int page_number)
Generates postscript graphs.
Header file for general utilities.
Bsymmetry * init_point_group_symmetry(Bstring symmetry_string)
Sets up a symmetry structure from a string identifier.
Header file for 2D and 3D image I/O.
long project_count_rec_part_selected(Bproject *project)
Counts all the particles in the project structure.
int ps_particle_views_origins(Bstring &filename, Bstring &title, Bstring &symmetry_string, Bproject *project, int selection)
Generates asymmetric unit particle view and origin postscript plots.
int ps_origins(ofstream *fps, Bstring &title, Bproject *project, int flags)
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
Header file for generalized linked list functions.
View * views_from_project(Bproject *project, int selection)
Retrieves the particle views from a project.
Header file for postscript tools dealing with views.
long project_count_micrographs(Bproject *project)
Counts all the micrographs in the project structure.