 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
41 error_show(
"Error in part_ft_size", __FILE__, __LINE__);
42 cerr <<
"Size not set!" << endl << endl;
48 if ( scale > 1 ) ft_size = (int) (xsize*scale);
50 if ( pad_factor < 1 )
return ft_size;
52 if ( pad_factor > 8 ) pad_factor = 8;
56 if ( ft_size < xsize )
102 int ft_size,
fft_plan plan,
int interp_type,
103 int ctf_action,
double wiener,
int twoD_flag,
104 int bootstrap,
int first)
112 pixel_size[1] = pixel_size[0];
113 if ( twoD_flag ) pixel_size[2] = 1;
114 else pixel_size[2] = pixel_size[0];
126 cout <<
"DEBUG particle_reconstruct: nsel = " << nsel << endl;
130 long nrec(0), img_num;
131 double part_weight(1), pad_ratio(1);
139 for ( part = partlist; part; part = part->
next ) {
144 partfile = mg->
fpart;
145 img_num = part->
id - 1;
146 if ( partfile.
length() < 1 ) {
147 partfile = part->
fpart;
150 if ( ( p =
read_img(partfile, 1, img_num) ) == NULL ) {
151 error_show(
"particle_reconstruct", __FILE__, __LINE__);
162 if ( part->
ori[0] <= 0 ) {
173 else view = part->
view;
175 if ( prec->
sizeZ() < 2 ) {
181 if ( part->
mag > 0 ) part_scale = scale/part->
mag;
182 else part_scale = scale;
187 if ( bootstrap ) part_weight = part->
sel;
189 pad_ratio = ft_size*1.0L/p->
sizeX();
191 if ( pad_ratio > 1 ) {
193 pad_ratio *= pad_ratio*0.6;
196 part_weight /= pad_ratio;
205 if ( ctf_action )
img_ctf_apply(p, em_ctf, ctf_action, wiener, 0, hi_res);
210 prec->
fspace_pack_2D(p, view, sym, hi_res, 0, part_scale, part_weight, interp_type);
219 cerr <<
"Complete: " << setprecision(3)
220 << nrec*100.0/nsel <<
" % \r" << flush;
226 cout <<
"Particles used: " << nrec << endl << endl;
247 int num_select,
int bootstrap)
256 cout <<
"DEBUG project_reconstruction_partlist: num_select = " << num_select << endl;
262 for ( mg = field->
mg; mg; mg = mg->
next ) {
263 for ( part = mg->
part; part; part = part->
next ) {
268 }
else if ( num_select < 0 ) {
270 }
else if ( part->
sel == num_select ) {
281 for ( part = rec->
part; part; part = part->
next ) {
286 }
else if ( num_select < 0 ) {
288 }
else if ( part->
sel == num_select ) {
333 int iclass = imap/nmaps;
336 prec->
sampling(pacc[0]->sampling(0));
357 if ( nmaps == 3 && imap%3 ) {
363 cout <<
"DEBUG img_reconstruction_sum_weigh: maps_per_class=" << maps_per_class << endl;
364 cout <<
"DEBUG img_reconstruction_sum_weigh: iclass=" << iclass << endl;
365 cout <<
"DEBUG img_reconstruction_sum_weigh: st=" << st << endl;
366 cout <<
"DEBUG img_reconstruction_sum_weigh: inc=" << inc << endl;
371 for ( i=iclass*maps_per_class+st, j=0; j<maps_per_class; i+=inc, j+=inc ) {
373 cout <<
"DEBUG img_reconstruction_sum_weigh: Doing map " << i << endl;
378 for ( k=0; k<ds; k++ ) {
379 prec->
add(k, pacc[i]->complex(k));
380 fom[k] += fom_acc[k];
381 weight[k] += w_acc[k];
382 weight2[k] += w2_acc[k];
393 cout <<
"DEBUG img_reconstruction_sum_weigh: volumes accumulated: " << nv << endl;
397 double vol = (4.0/3.0)*
M_PI*rad*rad*rad;
404 cout <<
"Full reconstruction:" << endl;
406 cout <<
"Half reconstruction " << st+1 <<
":" << endl;
407 cout <<
"Friedel symmetry residual: " << Rf << endl;
408 cout <<
"Coverage: " << cov <<
" (" << cov*100.0/vol <<
" %)" << endl << endl;
411 if ( imap%nmaps == 0 )
435 double wiener,
int flags)
446 scale, size, ft_size, img_plan,
447 interp_type, ctf_action, wiener, 0, 0, 0);
451 double cov = ncov / ((4.0*
M_PI/3.0)*sf*sf*sf);
456 prec->
fft(map_plan, 1);
522 int pad_factor,
int interp_type,
int ctf_action,
double wiener,
int flags)
527 if ( size.
volume() <= 0 ) {
528 error_show(
"Error in project_single_particle_reconstruction", __FILE__, __LINE__);
529 cerr <<
"No particles to determine the size from!" << endl << endl;
533 int ft_size =
part_ft_size(size[0], scale[0], pad_factor);
545 for ( mg = field->
mg; mg && part == NULL; mg = mg->
next )
548 if ( size.
volume() <= 0 ) {
549 error_show(
"Error in project_single_particle_reconstruction", __FILE__, __LINE__);
550 cerr <<
"No reconstruction size set!" << endl << endl;
556 if ( hi_res < 2*part->pixel_size[0]/scale[0] ) hi_res = 2*part->
pixel_size[0]/scale[0];
559 if ( ( pmask =
read_img(maskfile, 1, 0) ) == NULL ) {
560 error_show(
"project_single_particle_reconstruction", __FILE__, __LINE__);
564 long datasize = (long) size.
volume();
565 long maskedsize = datasize;
567 if ( pmask )
for ( i=maskedsize=0; i<datasize; i++ )
if ( (*pmask)[i] == 1 ) maskedsize++;
572 cout <<
"DEBUG project_single_particle_reconstruction: num_select = " << num_select << endl;
575 cout <<
"3D reciprocal space reconstruction:" << endl;
577 cout <<
"Mask: " << pmask->
file_name() << endl;
578 cout <<
"Map size: " << size << endl;
579 cout <<
"Resolution limit: " << hi_res <<
" A" << endl;
580 cout <<
"Scale: " << scale << endl;
581 cout <<
"Interpolation type: " << interp_type << endl;
582 cout <<
"CTF application type: " << ctf_action << endl;
583 cout <<
"Fourier transform size: " << ft_size <<
" x " << ft_size << endl;
584 cout <<
"Analysis volume: " << maskedsize <<
" (" << maskedsize*100.0/datasize <<
" %)" << endl;
585 cout <<
"Number of selected particles: " << nsel << endl << endl;
589 double part_weight(1);
594 mkdir(
"ppx", O_CREAT );
599 for ( mg = field->
mg; mg; mg = mg->
next ) {
600 for ( i=0, part = mg->
part; part; part = part->
next )
if ( part->
sel ) {
601 if ( num_select < 0 ) i++;
602 else if ( part->
sel == num_select ) i++;
605 for ( i=0, part = mg->
part; part; part = part->
next )
if ( part->
sel ) {
606 if ( num_select < 0 ) part_array[i++] = part;
607 else if ( part->
sel == num_select ) part_array[i++] = part;
611 dispatch_apply(i, dispatch_get_global_queue(0, 0), ^(
size_t j){
613 size, pmask, sym, hi_res, scale,
614 ft_size, img_plan, map_plan, part_weight,
615 interp_type, mg->
ctf, ctf_action, wiener, flags);
618 #pragma omp parallel for
619 for ( j=0; j<i; j++ )
621 size, pmask, sym, hi_res, scale,
622 ft_size, img_plan, map_plan, part_weight,
623 interp_type, mg->
ctf, ctf_action, wiener, flags);
628 cout <<
"Micrograph: " << mg->
id << endl;
629 cout <<
"PID\tFOM\tCov" << endl;
630 for ( j=0; j<i; j++ ) cout << part_array[j]->
id <<
tab << part_array[j]->fom[0]
631 <<
tab << part_array[j]->fom[1] << endl;
632 cout <<
"Particles processed: " << np << endl;
661 cout <<
"DEBUG project_set_reconstruction_size: scale=" << scale << endl;
670 for ( mg = field->
mg; mg && part == NULL; mg = (part)? mg: mg->
next )
674 error_show(
"Error in project_set_reconstruction_size", __FILE__, __LINE__);
675 cerr <<
"No micrograph with particles!" << endl << endl;
679 partfile = mg->fpart;
682 if ( !partfile.
length() ) {
683 error_show(
"Error in project_set_reconstruction_size", __FILE__, __LINE__);
684 cerr <<
"No particle image file name given for micrograph " << mg->id << endl << endl;
690 size[0] = (int) (p->
sizeX()*scale);
691 if ( size[0] < p->
sizeY()/scale ) size[0] = (
int) (p->
sizeY()*scale);
692 if ( size[0] < p->
sizeZ()/scale ) size[0] = (
int) (p->
sizeZ()*scale);
693 size[2] = size[1] = size[0];
695 if ( twoD_flag ) size[2] = 1;
702 cout <<
"DEBUG project_set_reconstruction_size: size=" << size << endl;
725 if ( !classes.
length() ) classes =
"selected";
726 classes = classes.
lower();
727 if ( nmaps < 1 ) nmaps = 1;
728 if ( nmaps > 3 ) nmaps = 3;
729 if ( nthreads < 1 ) nthreads = 1;
730 if ( nmaps&2 && nthreads%2 ) nthreads++;
732 long i, msel(1), nsel(0), nclass(0);
738 if ( classes[0] ==
'a' ) {
740 }
else if ( classes[0] ==
's' ) {
745 for ( part = rec->
part; part; part = part->
next )
746 if ( msel < part->sel ) msel = part->
sel;
749 for ( mg = field->
mg; mg; mg = mg->
next )
750 for ( part = mg->
part; part; part = part->
next )
751 if ( msel < part->sel ) msel = part->
sel;
754 cout <<
"Maximum selection number: " << msel << endl;
759 vector<int> sel(msel, 0);
760 vector<int> cnt(msel, 0);
761 vector<int> num(msel, 0);
763 if ( classes[0] ==
'a' || classes[0] ==
's' ) {
769 for ( i=1; i<msel; i++ )
if ( sel[i] ) sel[i] = ++nclass;
774 cout <<
"Selection:" << endl <<
"Class\tNumber" << endl;
775 for ( i=0; i<msel; i++ ) cout << i <<
tab << sel[i] << endl;
779 int maps_per_class = nthreads;
781 cout <<
"Classes: " << classes <<
" (" << nclass <<
")" << endl;
782 cout <<
"Maps per class: ";
783 if ( nmaps == 1 ) cout <<
"Full set map" << endl;
784 if ( nmaps == 2 ) cout <<
"Two half set maps" << endl;
785 if ( nmaps == 3 ) cout <<
"Full set map and two half set maps" << endl;
786 cout <<
"Threads per class: " << nthreads << endl;
787 cout <<
"Total number of threads: " << nclass*nthreads << endl << endl;
792 for ( part = rec->
part; part; part = part->
next ) {
794 if ( i>0 && i<msel && sel[i] ) {
797 part->
sel = (sel[i] - 1)*maps_per_class + cnt[i];
798 if ( cnt[i] >= maps_per_class ) cnt[i] = 0;
807 for ( mg = field->
mg; mg; mg = mg->
next )
808 for ( part = mg->
part; part; part = part->
next ) {
811 if ( i>0 && i<msel && sel[i] ) {
814 part->
sel = (sel[i] - 1)*maps_per_class + cnt[i];
816 if ( cnt[i] >= maps_per_class ) cnt[i] = 0;
826 cout <<
"Particles selected:" << endl;
827 cout <<
"Class\tNumber" << endl;
828 for ( i=0; i<msel; i++ )
if ( sel[i] )
829 cout << i <<
tab << num[i] << endl;
852 long n, i, j, k, npart;
868 for ( mg=field->
mg; mg; mg=mg->
next )
869 for ( part=mg->
part; part; part=part->
next )
870 if ( part->
sel > nmap ) nmap = part->
sel;
872 if ( nmap < 1 )
return NULL;
880 int* num =
new int[nmap];
881 float* fom =
new float[nmap];
882 for ( i=0; i<nmap; i++ ) {
888 cout <<
"2D real space reconstruction:" << endl;
889 cout <<
"Map size: " << prec->
size() << endl;
890 cout <<
"Map origin: " << prec->
image->
origin() << endl;
891 cout <<
"Number of maps: " << prec->
images() << endl << endl;
903 for ( mg=field->
mg; mg; mg=mg->
next ) {
906 cout <<
"Micrograph: " << mg->
id <<
" with " << npart <<
" particles" << endl;
908 if ( transform_output ) {
912 for ( part=mg->
part; part; part=part->
next ) {
934 fom[n] += part->
fom[0];
937 if ( transform_output ) {
943 if ( transform_output ) {
947 cout <<
"Writing projections file: " << filename << endl;
958 for ( i=n=0; n<prec->
images(); n++ ) {
959 if ( num[n] ) fom[n] /= num[n];
962 if ( num[n] ) prec->
set(i, (*prec)[i] / num[n]);
968 cout <<
"Particles used in reconstruction:" << endl;
969 cout <<
"Map\tNumber\t%\tFOM" << endl;
970 for ( n=0; n<nmap; n++ ) {
971 cout << n+1 <<
tab << num[n] <<
tab <<
972 num[n]*100.0/npart <<
tab << fom[n] << endl;
1002 for ( mg = field->
mg; mg; mg = mg->
next ) {
1003 for ( part = mg->
part; part; part = part->
next )
if ( part->
sel == i+1 ) {
1041 part_avg->
fom[0] = f;
1050 long maxrad = ( hires > 0 )? prec->
real_size()[0]/hires: prec->
sizeX()/2;
1051 if ( maxrad > prec->
sizeX()/2 ) maxrad = prec->
sizeX()/2;
1065 double f(0), pwr, t(0.5);
1077 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
1083 cout <<
tab << m*100.0/nmg <<
"%" << endl;
1085 for ( part = mg->
part; part; part = part->
next )
if ( part->
sel == i+1 ) {
1107 cout <<
"Particle " << part->
id << endl;
1121 pwr = psum->
complex(j).power();
1123 pssq->
set(j, (pwr - (*pssq)[j])/((*pssq)[j] - pwr/n));
1129 cout <<
"Radius\tSSNR" << endl;
1130 for ( j=0; j<maxrad; ++j )
1131 cout << j <<
tab << (*pr)[j] << endl;
1134 for ( j=1; j<maxrad; ++j )
1135 if ( (*pr)[j] < t )
break;
1138 cout << j <<
tab << f <<
tab << (*pr)[j] << endl << endl;
1154 part_avg->
fom[0] = f;
1178 for ( mg=field->
mg; mg; mg=mg->
next )
1179 for ( part=mg->
part; part; part=part->
next )
1180 if ( part->
sel > nmap ) nmap = part->
sel;
1182 if ( nmap < 1 )
return NULL;
1191 cout <<
"2D frequency space averaging:" << endl;
1192 cout <<
"Size: " << prec->
size() << endl;
1193 cout <<
"Origin: " << prec->
image->
origin() << endl;
1194 cout <<
"Sampling: " << prec->
sampling(0) <<
" A" << endl;
1195 cout <<
"Resolution limit: " << hires <<
" A" << endl;
1196 cout <<
"Number of averages: " << prec->
images() << endl << endl;
1203 dispatch_apply(nmap, dispatch_get_global_queue(0, 0), ^(
size_t i){
1206 cout << i+1 <<
tab << part_arr[i]->
sel <<
tab << part_arr[i]->
fom[0] << endl;
1209 #pragma omp parallel for
1210 for ( i=0; i<nmap; i++ ) {
1214 cout << i+1 <<
tab << part_arr[i]->
sel <<
tab << part_arr[i]->
fom[0] << endl;
1222 cout <<
"done" << endl;
1226 for ( i=0; i<nmap-1; i++ ) part_arr[i]->next = part_arr[i+1];
1228 part_arr[i]->
next = NULL;
1277 if ( !p && !pmap ) {
1278 error_show(
"project_reconstruct_3D", __FILE__, __LINE__);
1287 if ( size.
volume() <= 0 ) {
1288 cerr <<
"Error: The particle box size must be specified!" << endl << endl;
1307 cout <<
"Calculating an average reconstruction" << endl;
1308 cout <<
"Size: " << size << endl;
1313 filename = rec->
fpart;
1314 for ( part = rec->
part; part; part = part->
next )
1315 if ( ( selnum < 0 && part->sel ) || ( part->
sel == selnum ) ) {
1316 img_num = part->
id - 1;
1318 filename = part->
fpart;
1321 if ( filename.
length() ) {
1322 if ( ( p =
read_img(filename, 1, img_num) ) == NULL ) {
1323 error_show(
"project_reconstruct_3D", __FILE__, __LINE__);
1327 cout <<
"Adding particle: " << part->
id <<
" (" << filename <<
":" << img_num <<
")" << endl;
1329 start = part->
loc - part->
ori;
1330 p = pmap->
extract(0, start, size);
1332 cout <<
"Adding particle: " << part->
id << endl;
1345 if ( ( selnum < 0 && rec->select ) || ( rec->
select == selnum ) ) {
1347 cout <<
"Adding reconstruction: " << rec->
frec << endl;
1349 error_show(
"project_reconstruct_3D", __FILE__, __LINE__);
1362 if ( pmap )
delete pmap;
1365 cout <<
"Number of particles: " << n << endl;
1369 prec->
set(i, (*prec)[i] / n);
1371 fom[i] = fom[i]/n - (*prec)[i]*(*prec)[i];
1372 if ( fom[i] < 0 ) fom[i] = 0;
1373 if ( calcfom > 1 ) fom[i] = sqrt(fom[i]);
1383 cout <<
"Signal enhancement: " <<
1387 cout <<
"DEBUG project_reconstruct_3D: done!" << endl;
1420 cerr <<
"Error in project_reconstruct_3D: No particles found!" << endl;
1433 if ( !p && !pmap ) {
1434 error_show(
"project_reconstruct_3D", __FILE__, __LINE__);
1443 if ( size.
volume() <= 0 ) {
1444 cerr <<
"Error: The particle box size must be specified!" << endl << endl;
1459 cout <<
"Calculating an average reconstruction" << endl;
1460 cout <<
"Size: " << size << endl;
1461 cout <<
"Resolution: " << resolution << endl;
1466 filename = rec->
fpart;
1467 for ( part = rec->
part; part; part = part->
next )
1468 if ( ( selnum < 0 && part->sel ) || ( part->
sel == selnum ) ) {
1469 img_num = part->
id - 1;
1471 filename = part->
fpart;
1474 if ( filename.
length() ) {
1475 if ( ( p =
read_img(filename, 1, img_num) ) == NULL ) {
1476 error_show(
"project_reconstruct_3D", __FILE__, __LINE__);
1480 cout <<
"Adding particle: " << part->
id <<
" (" << filename <<
":" << img_num <<
")" << endl;
1482 start = part->
loc - part->
ori;
1483 p = pmap->
extract(0, start, size);
1485 cout <<
"Adding particle: " << part->
id << endl;
1502 if ( ( selnum < 0 && rec->select ) || ( rec->
select == selnum ) ) {
1504 cout <<
"Adding reconstruction: " << rec->
frec << endl;
1506 error_show(
"project_reconstruct_3D", __FILE__, __LINE__);
1522 if ( pmap )
delete pmap;
1525 cout <<
"Number of particles: " << n << endl;
1526 cout <<
"Rescaling average" << endl << endl;
1542 cout <<
"DEBUG project_reconstruct_3D: done!" << endl;
1577 if ( map_size.
volume() <= 0 ) {
1578 error_show(
"Error in project_back_projection", __FILE__, __LINE__);
1579 cerr <<
"No reconstruction size set!" << endl << endl;
1584 for ( mg = field->
mg; mg && part == NULL; mg = mg->
next )
1585 if ( ( part = mg->
part ) )
break;
1587 if ( !mg || !part ) {
1588 cerr <<
"Error: No particles found!" << endl;
1606 cout <<
"3D backprojection:" << endl;
1607 cout <<
"Map size: " << pmap->
size() << endl;
1608 cout <<
"Resolution: " << resolution <<
" A" << endl;
1609 cout <<
"Scale: " << scale << endl;
1610 cout <<
"Sampling: " << pmap->
sampling(0) << endl;
1611 cout <<
"Number of selected particles: " << nsel << endl << endl;
1616 for ( mg = field->
mg; mg; mg = mg->
next ) {
1617 for ( part = mg->
part; part; part = part->
next ) {
1620 if ( num_select < 0 ) {
1622 }
else if ( part->
sel == num_select ) {
1630 error_show(
"project_back_projection", __FILE__, __LINE__);
1636 if ( part->
ori[0] <= 0 ) {
1641 if ( part->
ori[1] <= 0 ) {
1661 cout <<
"Complete: " << nrec*100.0/nsel <<
"%\r" << flush;
1668 cout << endl <<
"Particles used: " << nrec << endl << endl;
1684 int nmaps,
int nthreads)
1687 cout <<
"DEBUG img_backprojection_accumulate:" << endl;
1689 int maps_per_class = nthreads;
1690 int iclass = imap/nmaps;
1696 long datasize = (long) prec->
size().
volume();
1703 if ( nmaps == 3 && imap%3 ) {
1709 cout <<
"DEBUG img_backprojection_weigh: nmaps=" << nmaps <<
" imap=" << imap << endl;
1710 cout <<
"DEBUG img_backprojection_weigh: maps_per_class=" << maps_per_class <<
" iclass=" << iclass << endl;
1711 cout <<
"DEBUG img_backprojection_weigh: st=" << st <<
" inc=" << inc << endl;
1714 for ( i=iclass*maps_per_class+st, j=st; j<maps_per_class; i+=inc, j+=inc ) {
1716 for ( k=0; k<datasize; k++ )
1717 prec->
add(k, (*pacc[i])[k]);
1724 cout <<
"DEBUG img_backprojection_weigh: Accumulation done" << endl;
Functions for reconstruction.
Bimage * project_reconstruct_2D(Bproject *project, int transform_output)
Creates a 2D reconstruction from the images in a multi-image file.
long project_count_mg_particles(Bproject *project)
Counts all the particles in the project structure.
void complex_to_intensities()
The intensities from a complex image is written to a simple image.
Vector3< double > real_size()
int part_ft_size(int xsize, double scale, int pad_factor)
Sets the Fourier transform size for 2D particle images for reconstruction.
Vector3< long > project_set_reconstruction_size(Bproject *project, double scale, int twoD_flag)
Sets the reconstruction size for reconstruction from 2D particle images.
long fspace_reconstruction_weigh()
Weighs a reconstruction.
void set(long j, double v)
Sets a single value at the given index.
int update(CTFparam *ctf)
Vector3< double > voxel_size
Bparticle * img_reconstruct_2D_fspace(long i, Bproject *project, Bimage *prec, double hires, fft_plan planf, fft_plan planb)
double relative_density(Bimage *pmask)
Calculates the relative density in a region defined by a mask.
Bparticle * project_reconstruction_partlist(Bproject *project, int num_select, int bootstrap)
List of particle images for reciprocal space reconstruction.
Bparticle * img_reconstruct_2D(long i, Bproject *project, Bimage *prec, double hires, fft_plan planf, fft_plan planb)
Bimage * img_backprojection_accumulate(Bimage **pacc, int imap, int nmaps, int nthreads)
Accumulates multiple backprojections.
Header file for general symmetry functions.
Vector3< double > default_origin()
long micrograph_count_particles(Bmicrograph *mg)
Counts all the particles in the micrograph structure.
Header file for micrograph processing.
long fspace_reconstruction_snr()
Calculates the SNR map.
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Class for complex numbers.
Bimage * radial(long minrad, long maxrad, double rad_step=1, int wrap=0)
Calculates the radial average of an image.
Vector3< long > size() const
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
long project_show_class_averages(Bproject *project)
Shows the class averages in a project.
int transform(Vector3< double > scale, Vector3< double > origin, Vector3< double > translate, Matrix3 mat, int fill_type=0, double fill=0)
Transforms an image by translation, rotation, scaling and skewing, in place.
void view(double x, double y, double z, double a)
Bstring ppx_filename(Bstring &id, int part_id)
Bimage * project_back_projection(Bproject *project, long num_select, Vector3< long > map_size, Vector3< double > sam, double scale, double resolution, fft_plan planf, fft_plan planb)
Back projects a set of 2D images into a 3D volume.
double standard_deviation()
Bimage * project_reconstruct_3D(Bproject *project, long selnum, int calcfom, Vector3< long > size)
Transforms 3D maps and calculates an average.
long part_consolidate_selection(Bproject *project, int number)
Consolidates selected particles under one selection number.
int rotate_and_add(Bimage *p, Vector3< double > origin, View view)
Rotates an image to a specified view and adds it to another image.
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Header file for reading and writing micrograph parameters.
void origin(double x, double y, double z)
long part_reset_selection(Bproject *project, int flag=0)
Resets selection to all particles.
void multiply(long j, Complex< double > cv)
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
int shift_background(double bkg)
Sets the background for each sub-image to a given value.
void add(long j, double v)
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
long project_count_mg_selected(Bproject *project)
Counts all the selected micrographs in the project structure.
int rotate()
Rotates an image using parameters defined in the image in place.
FourierType fourier_type()
long project_count_mg_part_selected(Bproject *project)
Counts the number of particles in a project.
double part_single_reconstruction(Bparticle *part, Vector3< long > size, Bimage *pmask, Bsymmetry *sym, double hi_res, Vector3< double > scale, int ft_size, fft_plan img_plan, fft_plan map_plan, double part_weight, int interp_type, CTFparam *mg_ctf, int ctf_action, double wiener, int flags)
Functions for CTF (contrast transfer function) processing.
int back_project(Bimage *p, double resolution, double axis, fft_plan planf, fft_plan planb)
General image parameter class.
long project_single_particle_reconstruction(Bproject *project, Bstring &maskfile, Bsymmetry *sym, int num_select, double hi_res, Vector3< double > scale, Vector3< long > size, int pad_factor, int interp_type, int ctf_action, double wiener, int flags)
Reciprocal space reconstruction from the images in a multi-image file.
int fspace_reconstruction_stats(double resolution, double sampling_ratio=1)
Calculates Fourier shell statistics.
Vector3< double > pixel_size
int replace(Bimage *img)
Replaces the data with that from the given image.
Header file for image processing from micrograph structures.
Bimage * project_reconstruct_2D_fast(Bproject *project)
Complex< double > complex(long j)
Returns a complex value at the given index.
unsigned char * data_alloc_and_clear()
long fspace_maximum_radius(double resolution, double sampling_ratio=1)
Calculates the maximum radius in frequency space from a given resolution.
Header file for general utilities.
ostream & tab(ostream &out)
void check_resolution(double &resolution)
Checks that the resolution falls within reasonable limits.
fft_plan fft_setup_plan(long x, long y, long z, fft_direction dir, int opt)
Sets up a plan for fast Fourier transforms.
int img_ctf_apply(Bimage *p, CTFparam em_ctf, int action, double wiener, double lores, double hires)
Applies or corrects for the contrast transfer function (CTF).
int mg_ctf(Bmicrograph *mg, Bimage *pmg, int action, double lores, double hires, double wiener, Vector3< long > tile_size, DataType datatype, Bstring &newname, int flags)
void origin(double ox, double oy, double oz)
long random_seed()
Gets a random seed and sets the flag.
Bimage * img_reconstruction_sum_weigh(Bimage **pacc, int imap, int nmaps, int maps_per_class, double hi_res)
Combines and weighs a map from several partial maps and weight sets.
void change_type(char letter)
Get the data type indicated by a single letter code.
Bimage * particle_reconstruct(Bparticle *partlist, Bsymmetry *sym, int sym_mode, double hi_res, Vector3< double > scale, Vector3< long > size, int ft_size, fft_plan plan, int interp_type, int ctf_action, double wiener, int twoD_flag, int bootstrap, int first)
Reciprocal space reconstruction from 2D particle images.
Header file for 2D and 3D image I/O.
View random_symmetric_view(View &asu_view, Bsymmetry *sym)
Returns a randomly picked symmetry view.
int fspace_pack_2D(Bimage *p, Matrix3 mat, double hi_res, double lo_res, Vector3< double > scale, double part_weight=1, int interp_type=0)
Packs a 2D Fourier transform into a 3D reciprocal space volume.
Header file for micrograph processing.
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
void check()
Checks an image for reasonable properties.
int ppx_check(Bparticle *part, FOMType fom_tag[NFOM])
Bparticle * particle_copy(Bparticle **partlist, Bparticle *part)
Adds one particle onto a list of particle parameters.
unsigned char * data_pointer()
int pad(long sz, int fill_type=0, double fill=0)
Pads an image to a new size with a given fill value.
void sampling(long nn, Vector3< double > u)
Bimage * particle_read_img(Bparticle *part, int readflag)
Reads a particle image file.
int phase_shift_to_origin()
Phase shifts a set of reflections to the image origin.
int write_particle(Bstring &filename, Bparticle *part, int euler_flag, int omega_flag, FOMType fom_tag[NFOM])
int fspace_pack_3D(Bimage *p, double hi_res=0, double threshold=0)
Packs a 3D Fourier transform into a 3D reciprocal space volume.
long particle_count(Bparticle *part)
Counts the number of particles in a linked list.
int project_configure_for_reconstruction(Bproject *project, Bstring classes, long &nmaps, long &nthreads)
Sets up the particle selection for reconstruction.
int phase_shift_to_center()
Phase shifts a set of reflections to the nominal center of the image origin.
double friedel_check()
Checks Friedel symmetry.
int select_numbers(Bstring &string, int n, int *numsel)
Converts a string with a selection specification into an integer array.
int findNextPowerOf(int startNumber, int powerOf)
Finds the next greatest number that is a power of a given number.
void view(double vx, double vy, double vz, double va)
void complex_to_real()
The real part of a complex image is written to a simple image.
long statistics()
Calculates the statistics for an image.
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.