 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
29 double avg,
double std,
double cutmin,
double cutmax);
32 double edge_width,
double marker_radius,
33 int fill_type,
double fill,
37 cout <<
"Reading image " << mg->
img_num <<
" (micrograph " << mg->
id <<
")" << endl;
43 error_show(
"mg_erase_markers", __FILE__, __LINE__);
60 cout <<
"Correcting for the CTF" << endl;
62 cerr <<
"Error: The CTF parameters are not specified! Abort!" << endl;
125 double scale,
Vector3<long> size,
int interp_type,
int pad_factor,
126 double edge_width,
double marker_radius,
127 int fill_type,
double fill,
int action,
double wiener)
136 cerr <<
"Error: No micrographs selected!" << endl;
141 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select )
147 cerr <<
"No selected micrograph found!" << endl << endl;
152 cerr <<
"No file name for micrograph " << mg->
id << endl << endl;
162 double thickness(size[2]/scale);
166 if ( hi_res < 2*mg->pixel_size[0]/scale )
168 double rec_scale = 2*mg->
pixel_size[0]/(scale*hi_res);
169 if ( rec_scale > 1 ) rec_scale = 1;
170 double voxel_size(mg->
pixel_size[0]/(scale*rec_scale));
171 Vector3<double> vscale(rec_scale*scale, rec_scale*scale, rec_scale*scale);
173 long ds = rec_size.
volume();
175 long memreq1 = 2*size.
volume()*
sizeof(float);
176 long memreq2 = (ft_size*ft_size + 5*rec_size.
volume())*
sizeof(
float);
180 cout <<
"3D reciprocal space reconstruction:" << endl;
181 cout <<
"Reconstruction size: " << size << endl;
182 cout <<
"Scale: " << scale << endl;
183 cout <<
"Integration size: " << rec_size << endl;
184 cout <<
"Integration scale: " << rec_scale << endl;
185 cout <<
"Voxel size: " << voxel_size <<
" A" << endl;
186 cout <<
"Resolution: " << hi_res <<
" A" << endl;
187 cout <<
"Interpolation type: " << interp_type << endl;
188 cout <<
"Fourier transform size: " << ft_size <<
" x " << ft_size << endl;
189 cout <<
"Padding factor: " << pad_factor << endl;
190 cout <<
"Edge smooting width: " << edge_width << endl;
192 cout <<
"Erase markers using radius: " << marker_radius << endl;
194 cout <<
"CTF correction: " << action <<
" (wiener=" << wiener <<
")" << endl;
207 prec->
sampling(voxel_size, voxel_size, voxel_size);
215 double pad_ratio(ft_size*1.0/prec->
sizeX());
220 cout <<
"Transforming and packing " << nmg <<
" micrographs:" << endl;
223 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
225 marker_radius, fill_type, fill, action, wiener, tile_size, plan);
241 cout <<
"Weighing reconstruction" << endl;
244 dispatch_apply(ds, dispatch_get_global_queue(0, 0), ^(
size_t i){
248 weight2[i] = weight[i] - weight2[i]/weight[i];
250 if ( weight2[i] > 1e-3 ) fom[i] /= weight2[i];
251 else if ( weight[i] > 1e-3 ) fom[i] /= weight[i];
254 if ( fom[i] < 0 ) fom[i] = 0;
257 #pragma omp parallel for
258 for (
long i=0; i<ds; i++ ) {
260 weight2[i] = weight[i] - weight2[i]/weight[i];
262 if ( weight2[i] > 1e-3 ) fom[i] /= weight2[i];
263 else if ( weight[i] > 1e-3 ) fom[i] /= weight[i];
266 if ( fom[i] < 0 ) fom[i] = 0;
271 for (
long i=0; i<ds; i++ )
if ( weight[i] >
SMALLFLOAT ) cov++;
280 cout <<
"Coverage: " << cov <<
" (" << cov*100.0/ds <<
" %)" << endl << endl;
324 double scale,
Vector3<long> size,
int slab_start,
int slab_end,
325 double marker_radius,
int fill_type,
double fill,
int action,
double wiener)
342 cerr <<
"Error: No micrographs selected!" << endl;
347 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
355 cerr <<
"No selected micrograph with a micrograph file found!" << endl << endl;
360 cerr <<
"No file name for micrograph " << mg->
id << endl << endl;
370 error_show(
"Error in project_fourier_reconstruction_slab ", __FILE__, __LINE__);
371 cerr <<
"No micrograph image or transform file name given for micrograph " << mg->
id << endl << endl;
376 size = {long(p->
sizeX()*scale), long(p->
sizeY()*scale), long(p->
sizeX()*scale/10)};
385 if ( slab_start >= size[2] ) {
386 cerr <<
"Error: Slab " << slab_start <<
" - " << slab_end <<
" is outside the volume limits!" << endl;
390 if ( slab_start < 0 ) slab_start = 0;
391 if ( slab_end < 0 || slab_end >= size[2] ) slab_end = size[2] - 1;
392 if ( slab_end < slab_start ) slab_end = slab_start;
394 long slab_thickness = slab_end - slab_start + 1;
398 if ( ft_size < p->sizeX() ) ft_size = p->
sizeX();
411 float* weight =
new float[ds];
412 float* weight2 =
new float[ds];
416 cout <<
"3D reciprocal space reconstruction on disk:" << endl;
417 cout <<
"Map size: " << prec->
sizeX() <<
" " << prec->
sizeY() <<
" " << size[2] << endl;
418 cout <<
"Scale: " << scale << endl;
419 cout <<
"Fourier transform size: " << ft_size <<
" x " << ft_size << endl;
420 cout <<
"Slab: " << slab_start <<
" - " << slab_end << endl << endl;
428 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
430 marker_radius, fill_type, fill, action, wiener, tile_size, plan);
432 error_show(
"project_fourier_reconstruction_slab", __FILE__, __LINE__);
437 hi_res, mg->
matrix, scale);
445 << setprecision(3) << nrec*100.0/(nfld*nmg) <<
" %\r";
455 error_show(
"Error in project_fourier_reconstruction_slab: No micrographs used in this reconstruction!", __FILE__, __LINE__);
463 cout <<
"Weighing reconstruction." << endl;
468 dispatch_apply(ds, dispatch_get_global_queue(0, 0), ^(
size_t i){
471 weight2[i] = weight[i]*weight[i] - weight2[i];
472 if ( weight2[i] > 0.001 ) {
473 double rd2 = (prec->
complex(i)).power();
474 fom[i] = (fom[i] - weight[i]*rd2)/weight2[i];
475 fom[i] = rd2/fom[i] - 1;
480 #pragma omp parallel for
481 for ( i=0; i<ds; i++ ) {
484 weight2[i] = weight[i]*weight[i] - weight2[i];
485 if ( weight2[i] > 0.001 ) {
486 double rd2 = (prec->
complex(i)).power();
487 fom[i] = (fom[i] - weight[i]*rd2)/weight2[i];
488 fom[i] = rd2/fom[i] - 1;
494 for ( i=0; i<ds; i++ )
if ( weight[i] >
SMALLFLOAT ) cov++;
504 cout <<
"Coverage:" << endl;
505 cout <<
"Total number of voxels: " << vol << endl;
506 cout <<
"Total coverage: " << cov << endl;
507 cout <<
"Percentage coverage: " << cov*100.0/vol <<
" %" << endl;
545 int ctf_action,
double wiener,
Bsymmetry* sym,
551 if ( partbase.
length() ) filename = partbase +
Bstring(recpart->
id,
"_part%03d.");
556 if ( partext.
length() ) filename += partext;
561 if ( partpath.
length() ) {
563 filename = partpath + filename;
567 cout <<
"Reconstructing particle " << recpart->
id << endl;
575 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
576 for ( part = mg->
part; part; part = part->
next )
577 if ( recpart->
id == part->
id )
break;
585 resolution, scale, recsize, ft_size, planp,
586 interp_type, ctf_action, wiener, 0, 0, 0);
599 recpart->
fpart = filename;
629 double resolution,
int interp_type,
int pad_factor,
630 int ctf_action,
double wiener,
Bsymmetry* sym,
633 if ( !partpath.
empty() ) {
634 if ( partpath[-1] !=
'/' ) partpath +=
"/";
635 mkdir(partpath.
c_str(), (mode_t)0755);
638 if ( partext.
length() < 1 ) partext =
"pif";
649 partlist = rec->
part;
654 cerr <<
"No particle list found!" << endl << endl;
659 for ( mg = field->
mg; mg; mg = mg->
next )
665 cerr <<
"No micrographs found!" << endl << endl;
670 cerr <<
"No micrograph particles found!" << endl << endl;
693 cout <<
"Calculating individual particle reconstructions:" << endl;
694 cout <<
"Reconstruction: " << rec->
id << endl;
695 cout <<
"Particle size: " << mg->
box_size << endl;
696 cout <<
"Reconstruction size: " << rec->
box_size << endl;
697 cout <<
"Fourier transform size: " << ft_size <<
" x " << ft_size << endl;
698 cout <<
"Padding factor: " << pad_factor << endl;
699 cout <<
"Reconstruction resolution: " << resolution <<
" A" << endl;
700 cout <<
"CTF application type: " << ctf_action << endl;
708 for ( i=0, part = partlist; part; part = part->
next, i++ ) partarr[i] = part;
711 cout <<
"Part\t#" << endl;
714 dispatch_queue_t myq = dispatch_queue_create(NULL, NULL);
715 dispatch_apply(npart, dispatch_get_global_queue(0, 0), ^(
size_t i){
717 resolution, interp_type, ft_size, scale, planp, planr,
718 ctf_action, wiener, sym, partbase, partpath, partext);
719 dispatch_sync(myq, ^{
721 cout << partarr[i]->
id <<
tab << fixed << nr << endl << flush;
725 #pragma omp parallel for
726 for ( i=0; i<npart; i++ ) {
728 resolution, interp_type, ft_size, scale, planp, planr,
729 ctf_action, wiener, sym, partbase, partpath, partext);
733 cout << partarr[i]->
id <<
tab << fixed << nr << endl << flush;
771 cout <<
"Backtransforming reconstruction slices." << endl << endl;
773 for ( z=0; z<p->
sizeZ(); z++ ) {
775 cout <<
"Shifting and backtransforming slice " << z << endl;
777 ps = p->
extract(0, extorigin, extsize);
778 ps->
fft(FFTW_BACKWARD, 1);
779 for ( i=z*slice_size, j=0; j<slice_size; i++, j++ ) p->
set(i, (*ps)[j]);
810 long zsize,
long slab_start,
float* weight,
float* weight2,
811 double hi_res,
Matrix3 mat,
double scale)
818 long ix, iy, iz, izs, zs;
823 long ft_size = p->
sizeX();
829 if ( ft_size < p->sizeX() ) ft_size = p->
sizeX();
833 }
else pt = p->
copy();
836 vscale /= scale*ft_size;
841 cout <<
"Packing " << p->
file_name() << endl;
844 cout <<
"Resolution limit: " << hi_res <<
" A" << endl;
845 cout <<
"Slab start: " << slab_start << endl;
846 cout <<
"Fourier transform size: " << ft_size << endl;
847 cout <<
"Transformation matrix:" << endl;
854 double max_rad = pt->
sampling(0)[0]/hi_res;
855 if ( max_rad > 0.5 ) max_rad = 0.5;
856 max_rad *= pt->
sizeX();
857 double max_rad_sq = max_rad*max_rad;
858 double xmin = floor(-max_rad);
860 double ymin = floor(-max_rad);
865 for ( iv[1]=ymin; iv[1]<=ymax; iv[1]+=1 ) {
867 if ( y < 0 ) y += (long)p->
sizeY();
868 for ( iv[0]=xmin; iv[0]<=xmax; iv[0]+=1 ) {
870 if ( x < 0 ) x += (long)p->
sizeX();
872 if ( d2 < max_rad_sq ) {
874 iz = izs = (long) floor(m[2] + 0.5);
875 if ( izs < 0 ) izs += zsize;
876 zs = izs - slab_start;
877 if ( zs >= 0 && zs < prec->sizeZ() ) {
878 ix = (long) floor(m[0] + 0.5);
879 iy = (long) floor(m[1] + 0.5);
886 if ( ix < 0 ) ix += prec->
sizeX();
887 if ( iy < 0 ) iy += prec->
sizeY();
888 i = y*pt->
sizeX() + x;
889 j = (zs*prec->
sizeY() + iy)*prec->
sizeX() + ix;
892 fom[j] += w*(pt->
complex(i)).power();
930 cout <<
"Translate slice within unit cell to phase origin by " << shift << endl << endl;
932 for ( i=zs=0, z=slab_start; zs<p->
sizeZ(); zs++, z++ ) {
934 if ( l > half[2] ) l -= zsize;
936 for ( y=0; y<p->
sizeY(); y++ ) {
938 if ( k > half[1] ) k -= p->
sizeY();
939 skl = sl + k*shift[1];
940 for ( x=0; x<p->
sizeX(); x++, i++ ) {
942 if ( h > half[0] ) h -= p->
sizeX();
943 phi =
MIN2PI*(h*shift[0] + skl);
966 if ( p->
sizeZ() > 1 )
return -1;
967 if ( p->
images() > 1 )
return -1;
974 cout <<
"Clearing extraneous areas from micrograph " << p->
file_name() << endl;
977 double a, b, d = 1e30;
978 if ( v[0] && d > fabs(p->
sizeX()*0.5/v[0]) ) d = fabs(p->
sizeX()*0.5/v[0]);
979 if ( v[1] && d > fabs(p->
sizeY()*0.5/v[1]) ) d = fabs(p->
sizeY()*0.5/v[1]);
981 a = d*cos(tilt_angle) + fabs(0.5*thickness*sin(tilt_angle));
983 for ( i=y=0; y<p->
sizeY(); y++ ) {
984 for ( x=0; x<p->
sizeX(); x++ ) {
986 for ( c=0; c<p->
channels(); c++, i++ )
1013 DataType datatype,
double marker_radius,
int fill_type,
double fill)
1015 if ( pad_factor < 0 ) pad_factor = 0;
1016 if ( pad_factor > 8 ) pad_factor = 8;
1028 error_show(
"Error in mg_fft_write", __FILE__, __LINE__);
1029 cerr <<
"No micrograph image file name given for micrograph " << mg->
id << endl << endl;
1033 if ( size[2] < 1 ) size[2] = p->
sizeX();
1035 if ( size[2] > p->
sizeX() ) size[2] = p->
sizeX();
1036 if ( size[2] > p->
sizeY() ) size[2] = p->
sizeY();
1039 if ( ft_size < p->sizeX() ) ft_size = p->
sizeX();
1040 if ( ft_size < p->sizeY() ) ft_size = p->
sizeY();
1045 cout <<
"Transforming micrographs:" << endl;
1046 cout <<
"Reconstruction size: " << size << endl;
1047 cout <<
"Reconstruction scale: " << scale << endl;
1048 cout <<
"Fourier transform size: " << ft_size <<
" x " << ft_size << endl << endl;
1051 for ( n=0, mg=field->
mg; mg; mg=mg->
next, n++ )
if ( mg->
select ) {
1053 cout <<
"Reading image " << mg->
img_num <<
" (micrograph " << mg->
id <<
")" << endl;
1055 error_show(
"mg_fft_write", __FILE__, __LINE__);
1062 if ( size[2] < p->
sizeX() && size[2] < p->
sizeY() )
1065 if ( marker_radius > 0 ) {
1066 if ( marker_radius < mg->mark_radius ) marker_radius = 1.5*mg->
mark_radius;
1068 for ( mark = mg->
mark; mark; mark = mark->
next )
1069 p->
sphere(mark->
loc, marker_radius, 2, fill_type, fill);
1072 p->
pad(ft_size, fill_type, fill);
1112 long i(0), j(0), y, z, yt, zt;
1118 for ( thisfile = file_list; thisfile; thisfile = thisfile->
next ) {
1125 cerr << p->
file_name() <<
" must be a single image file!" << endl;
1139 if ( err < 0 || i == 0 ) {
1140 cerr <<
"Files not concatenated! Number of errors: " << -err << endl;
1148 ofstream fd(filename.
c_str());
1150 cerr <<
"Error: Tile parameter file %s not opened" << filename << endl;
1153 fd << pmap->
sizeX() <<
" " << pmap->
sizeY() <<
" " << pmap->
sizeZ() << endl;
1154 fd <<
"0 0 0" << endl;
1156 if ( y ) fd <<
"0 0 0" << endl;;
1157 for ( ; y<pmap->
sizeY(); y+=ysize ) fd <<
"0 " << y <<
" 0" << endl;
1161 long linesize = elementsize*pmap->
sizeX();
1163 if ( ystart + ysize > pmap->
sizeY() ) ysize = pmap->
sizeY() - ystart;
1168 unsigned char* data;
1171 cout <<
"Extracting y tile from " << ystart <<
" to " << ystart+ysize-1 << endl;
1172 cout <<
"Tile size: " << pmap->
size() << endl;
1173 cout <<
"Tile parameter file: " << filename << endl;
1176 for ( zt=0, thisfile = file_list; thisfile; thisfile = thisfile->
next ) {
1179 for ( z=0; z<p->
sizeZ() && zt<pmap->sizeZ(); z++, zt++ ) {
1180 for ( y=ystart, yt=0; y<p->
sizeY() && yt<pmap->sizeY(); y++, yt++ ) {
1181 i = (z*p->
sizeY() + y)*linesize;
1182 j = (zt*pmap->
sizeY() + yt)*linesize;
1183 memcpy(tile+j, data+i, linesize);
1209 DataType datatype,
double avg,
double std,
double cutmin,
double cutmax)
1219 for ( thisfile = file_list; thisfile; thisfile = thisfile->
next ) {
1226 cerr << p->
file_name() <<
" must be a single image file!" << endl;
1241 if ( err < 0 || j == 0 ) {
1242 cerr <<
"Files not concatenated! Number of errors: " << -err << endl;
1248 fstream* ftemp =
new fstream(tempfile.
c_str());
1249 if ( ftemp->fail() ) {
1250 cerr <<
"Error: " << tempfile <<
" not opened!" << endl << endl;
1257 for ( thisfile = file_list; thisfile; thisfile = thisfile->
next ) {
1260 cerr <<
"Error: Image " << *thisfile <<
" not read!" << endl;
1264 ftemp->write((
char *)p->
data_pointer(), elementsize*datasize);
1281 remove(tempfile.
c_str());
1294 if ( y%10 == 0 ) cout <<
"Backtransforming z lines for y=" << y << endl;
1295 for ( x=0; x<p->
sizeX(); x++ ) {
1296 for ( z=0, i=y*p->
sizeX() + x; z<p->
sizeZ(); z++, i+=slice_size ) zline[z] = p->
complex(i);
1298 for ( z=0, i=y*p->
sizeX() + x; z<p->sizeZ(); z++, i+=slice_size ) p->
set(i, zline[z]);
1309 long i, x, z, offset;
1315 if ( y%10 == 0 ) cout <<
"Backtransforming z lines for y=" << y << endl;
1316 for ( z=0; z<p->
sizeZ(); z++ ) {
1317 offset = (z*p->
sizeY() + y)*p->
sizeX()*cfsize;
1320 ftemp->seekg(offset, ios::beg);
1321 ftemp->read((
char *)&cfdata[z*p->
sizeX()], cfsize*p->
sizeX());
1323 for ( x=0; x<p->
sizeX(); x++ ) {
1324 for ( z=0; z<p->
sizeZ(); z++ ) zline[z] = cfdata[z*p->
sizeX() + x];
1326 for ( z=0; z<p->
sizeZ(); z++ ) cfdata[z*p->
sizeX() + x] = zline[z];
1328 for ( z=0; z<p->
sizeZ(); z++ ) {
1329 offset = (z*p->
sizeY() + y)*p->
sizeX()*cfsize;
1332 ftemp->seekg(offset, ios::beg);
1333 ftemp->write((
char *)&cfdata[z*p->
sizeX()], cfsize*p->
sizeX());
1336 for ( i=0; i<planesize; i++ ) {
1337 v = cfdata[i].
real();
1362 dispatch_apply(p->
sizeY(), dispatch_get_global_queue(0, 0), ^(
size_t y){
1366 #pragma omp parallel for
1367 for (
long y=0; y<p->
sizeY(); y++ )
1377 cout <<
"Reconstruction statistics:" << endl;
1378 cout <<
"Min and max: " << p->
minimum() <<
" " << p->
maximum() << endl;
1399 for ( y=0; y<p->
sizeY(); y++ )
1412 cout <<
"Reconstruction statistics:" << endl;
1413 cout <<
"Min and max: " << p->
minimum() <<
" " << p->
maximum() << endl;
1437 case UShort:
case Short: size =
sizeof(short);
break;
1439 case ULong:
case Long: size =
sizeof(long);
break;
1440 case Float: size =
sizeof(float);
break;
1441 case Double: size =
sizeof(double);
break;
1463 if ( typesize < 1 )
return -1;
1465 switch ( datatype ) {
1466 case UCharacter: *ptr = (
unsigned char) value;
break;
1468 signed char cval = (
signed char) value;
1469 memcpy(ptr, &cval, typesize);
break;
1472 unsigned short uval = (
unsigned short) value;
1473 memcpy(ptr, &uval, typesize);
break;
1476 short sval = (short) value;
1477 memcpy(ptr, &sval, typesize);
break;
1480 unsigned int ival = (
unsigned int) value;
1481 memcpy(ptr, &ival, typesize);
break;
1484 int ival = (int) value;
1485 memcpy(ptr, &ival, typesize);
break;
1488 long ival = (long) value;
1489 memcpy(ptr, &ival, typesize);
break;
1492 long ival = (long) value;
1493 memcpy(ptr, &ival, typesize);
break;
1496 float fval = (float) value;
1497 memcpy(ptr, &fval, typesize);
break;
1500 double dval = (double) value;
1501 memcpy(ptr, &dval, typesize);
break;
1522 double avg,
double std,
double cutmin,
double cutmax)
1534 shift = -p->
minimum()*scale;
break;
1536 shift = -128 - p->
minimum()*scale;
break;
1538 shift = -p->
minimum()*scale;
break;
1542 case Double: scale = 1;
break;
1548 shift = avg - p->
average()*scale;
1556 if ( cutmin >= cutmax ) {
1564 if ( cutmin < p->minimum() ) cutmin = p->
minimum();
1575 char* data =
new char[slicesize*elementsize];
1579 if ( fmap.fail() )
return -1;
1581 for ( z=0; z<p->
sizeZ(); z++ ) {
1582 offset = z*slicesize*cfsize;
1583 ftemp->seekg(offset, ios::beg);
1584 ftemp->read((
char *)cfdata, cfsize*slicesize);
1585 for ( i=0; i<slicesize; i++ ) {
1586 d = cfdata[i].real()*scale + shift;
1587 if ( d < cutmin ) d = cutmin;
1588 if ( d > cutmax ) d = cutmax;
1591 offset = p->
data_offset() + z*slicesize*elementsize;
1592 fmap.seekg(offset, ios::beg);
1593 fmap.write((
char *)data, elementsize*slicesize);
1623 cerr <<
"Error in project_missing_mask: Field-of-view not defined!" << endl;
1630 cerr <<
"Error in project_missing_mask: Micrograph not defined!" << endl;
1636 if ( size.
volume() < 10 ) {
1639 cerr <<
"Error in project_missing_mask: Reconstruction and mask size not defined!" << endl;
1645 if ( size.
volume() < 10 ) {
1646 cerr <<
"Error in project_missing_mask: Mask size not defined!" << endl;
1664 cout <<
"Generating a 3D reciprocal space mask from a tilt series:" << endl;
1665 cout <<
"Mask size: " << pmask->
sizeX() <<
" " << pmask->
sizeY() <<
" " << size[2] << endl;
1666 cout <<
"Origin: " << origin << endl;
1667 cout <<
"Resolution limit: " << hi_res <<
" A" << endl;
1668 cout <<
"Scale: " << scale << endl;
1671 for ( mg=field->
mg; mg; mg=mg->
next )
if ( mg->
select ) {
1679 Vector3<long> shift((
long) -(origin[0]+0.5), (
long) -(origin[1]+0.5), (
long) -(origin[2]+0.5));
int img_backtransform_z_lines(fstream *ftemp, Bimage *p)
Functions for reconstruction.
int project_mg_tilt_to_matrix(Bproject *project)
Sets the matrix from the tilt and axis angles for each micrograph.
int set_value_with_datatype(char *ptr, double value, DataType datatype)
Set a pointer to a value with a given data type.
long fspace_reconstruction_weigh()
Weighs a reconstruction.
void set(long j, double v)
Sets a single value at the given index.
Vector3< double > voxel_size
long project_tomo_reconstruct_particles(Bproject *project, double resolution, int interp_type, int pad_factor, int ctf_action, double wiener, Bsymmetry *sym, Bstring &partbase, Bstring &partpath, Bstring &partext)
Reconstructs particles from a tilt series.
long img_pack_2D_in_recip_space_slab(Bimage *p, Bimage *prec, long zsize, long slab_start, float *weight, float *weight2, double hi_res, Matrix3 mat, double scale)
Packs a 2D Fourier transform into a 3D reciprocal space volume.
Bimage * copy()
Copies the header information and data of an image into a new image structure.
Bimage * img_extract_ytile(Bstring *file_list, int ystart, int ysize)
Extracts a tile from the image with limits in y.
int bexit(int value)
Exit function for cleanup and debugging.
Header file for micrograph processing.
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Class for complex numbers.
double background(long nn)
Vector3< long > size() const
int part_ft_size(int xsize, double scale, int pad_factor)
Sets the Fourier transform size for 2D particle images for reconstruction.
long data_type_size() const
Returns the size of the datatype in bytes.
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
int shift_wrap(Vector3< double > vec)
Shifts an image.
double data_type_min()
Get the minimum of a datatype.
int correct_background(long nn, int flag)
Corrects the background for one sub-image.
long count_list(char *list)
Counts the number of items in a linked list.
double standard_deviation()
Bimage * project_tomo_reconstruct(Bproject *project, double hi_res, double scale, Vector3< long > size, int interp_type, int pad_factor, double edge_width, double marker_radius, int fill_type, double fill, int action, double wiener)
Reciprocal space reconstruction from the images in a multi-image file.
Bimage * project_fourier_reconstruction_slab(Bproject *project, double hi_res, double scale, Vector3< long > size, int slab_start, int slab_end, double marker_radius, int fill_type, double fill, int action, double wiener)
Reciprocal space reconstruction from the images in a multi-image file.
long gettypesize(DataType type)
Get the size of a datatype.
int img_write_data_block_with_type(fstream *ftemp, Bimage *p, double avg, double std, double cutmin, double cutmax)
int memory_check(long mem_required)
Checking if there is enough memory, abort if not.
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
void origin(double x, double y, double z)
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
void add(long j, double v)
int mg_fft_write(Bproject *project, Vector3< int > size, double scale, int pad_factor, DataType datatype, double marker_radius, int fill_type, double fill)
Fourier transform micrographs and write to disk.
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
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=0, int ctf_action=0, double wiener=0.2, int twoD_flag=0, int bootstrap=0, int first=0)
Reciprocal space reconstruction from 2D particle images.
long project_count_mg_selected(Bproject *project)
Counts all the selected micrographs in the project structure.
FourierType fourier_type()
int img_phase_shift_slab_to_origin(Bimage *p, int zsize, int slab_start)
Phase shifts a set of reflections to the image origin.
double data_type_max()
Get the maximum of a datatype.
Functions for CTF (contrast transfer function) processing.
General image parameter class.
CompoundType compound_type()
double average(long cc, double xf, double yf, double zf, long nn, double iscale)
Averages in 3D when scaling is less than 1.
Utilities for timing functions.
int fftw(fft_plan plan, Complex< float > *a)
Fast Fourier transforms a data array.
unsigned char * data_alloc()
long mask_pack_plane(Matrix3 mat, double hi_res, double scale)
Packs a 2D mask into a 3D reciprocal space volume.
int img_backtransform_slices(Bimage *p)
Backtransforms 2D slices in a 3D volume.
Complex< double > complex(long j)
Returns a complex value at the given index.
double timer_start()
Starts timer and prints the time.
Header file for general utilities.
ostream & tab(ostream &out)
void check_resolution(double &resolution)
Checks that the resolution falls within reasonable limits.
Bimage * pad_copy(long sz, int fill_type=0, double fill=0)
Pads an image to a new size with a given fill value.
long img_erase_markers(Bimage *p, Bmarker *mark, double marker_radius)
Erases or paints markers in an image.
fft_plan fft_setup_plan(long x, long y, long z, fft_direction dir, int opt)
Sets up a plan for fast Fourier transforms.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
void origin(double ox, double oy, double oz)
int img_ttf_apply(Bimage *p, CTFparam ctf, int action, double wiener, Vector3< long > tile_size, double tilt, double axis, double res_lo, double res_hi)
Applies or corrects for the tilted contrast transfer function (TTF).
int img_clear_extraneous_areas(Bimage *p, double tilt_axis, double tilt_angle, long thickness)
Clears areas from a micrograph not used in a reconstruction.
int micrograph_clear_extraneous_areas(Bmicrograph *mg, Bimage *p, long thickness, double width)
Clears extraneous areas from a micrograph.
void change_type(char letter)
Get the data type indicated by a single letter code.
Functions to do a tomographic reconstruction.
bool compatible(Bimage *p)
Check if this image has the same number of channels and data type as another.
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.
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
Header file for generalized linked list functions.
Bimage * mg_tomo_rec_prepare(Bmicrograph *mg, int ft_size, long thickness, double edge_width, double marker_radius, int fill_type, double fill, int action, double wiener, Vector3< long > tile_size, fft_plan plan)
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.
Vector3< double > pixel_size
int img_backtransform_one_y_plane(Bimage *p, fft_plan plan, int y)
void sampling(long nn, Vector3< double > u)
DataType
Base data type specifier.
int phase_shift_to_origin()
Phase shifts a set of reflections to the image origin.
bool contains(const Bstring &s)
int particle_kill(Bparticle *part)
Frees a list of particles.
Bimage * project_missing_mask(Bproject *project, Vector3< long > size, Vector3< double > origin, double hi_res, double scale)
Creates a reciprocal space mask from the tilt series orientations.
long particle_tomo_reconstruct(Bproject *project, Bparticle *recpart, Vector3< long > recsize, double resolution, int interp_type, long ft_size, Vector3< double > scale, fft_plan planp, fft_plan planr, int ctf_action, double wiener, Bsymmetry *sym, Bstring &partbase, Bstring &partpath, Bstring &partext)
Reconstructs individual particles from a tilt series.
long particle_count(Bparticle *part)
Counts the number of particles in a linked list.
int phase_shift_to_center()
Phase shifts a set of reflections to the nominal center of the image origin.
int findNextPowerOf(int startNumber, int powerOf)
Finds the next greatest number that is a power of a given number.
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 sphere(Vector3< double > center, double radius, double width=0, int fill_type=0, double fill=0)
Fills a sphere within an image with a uniform value.
Header file for single particle image processing in Bsoft.
Bimage * img_backtransform_z_on_disk(Bstring *file_list, Bstring &recfile, DataType datatype, double avg, double std, double cutmin, double cutmax)
The lines along the z-dimensions of a disk-based block is Fourier back-transformed.
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.