 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
54 for ( fn = fnode; fn && fn->
id != id; fn = fn->
next ) {
55 if ( fn != fnode ) len += (fn->
loc - loc).
length();
58 if ( fn ) len += (fn->
loc - loc).
length();
60 cerr <<
"Error: Filament node with ID " <<
id <<
" not found!" << endl;
64 long ns = (long) (len - width);
65 long ne = (long) (len + width);
67 if ( ne > nspline ) ne = nspline;
70 cout <<
"DEBUG filament_profile: id=" <<
id <<
" fn->id=" << fn->
id <<
71 " fn->loc=" << fn->
loc << endl;
72 cout <<
"DEBUG filament_profile: len=" << len <<
" ns=" << ns <<
73 " ne=" << ne <<
" nspline=" << nspline << endl;
80 double* profile =
new double[2*n];
82 for ( i=0; i<2*n; i++ ) profile[i] = 0;
84 for ( i=z=0; z<pfil->
sizeZ(); z++ ) {
85 for ( y=0; y<pfil->
sizeY(); y++ ) {
86 for ( x=0; x<pfil->
sizeX(); x++, i++ ) {
87 profile[x] += (*pfil)[i];
88 if ( y >= ns && y < ne )
89 profile[x+n] += (*pfil)[i];
96 for ( i=0; i<n; i++ ) profile[i] /= nspline;
97 for ( ne -= ns; i<2*n; i++ ) profile[i] /= ne;
117 double len(0), max, pwr, off, cc(0);
120 Matrix3 mat(0,1,0,-1,0,0,0,0,1);
126 cout <<
"Node\tOffset\tCC" << endl;
127 for ( fn = fnode; fn; fn = fn->
next ) {
129 ns = (long) (len - width);
130 ne = (long) (len + width);
131 if ( ns < 0 ) ns = 0;
132 if ( ne > nspline ) ne = nspline;
133 for ( i=0; i<pfil->
sizeX(); i++ ) profile[i] = 0;
134 for ( y=ns; y<ne; y++ ) {
136 for ( x=0; x<pfil->
sizeX(); x++, i++ ) {
137 profile[x][0] += (*pfil)[i];
141 for ( pwr=0, i=0; i<pfil->
sizeX(); i++ ) {
142 pwr += profile[i].
power();
143 profile[i] *= profile[i];
146 for ( max=-1000, off=0, i=0; i<pfil->
sizeX(); i++ )
if ( max < profile[i].real() ) {
147 max = profile[i].
real();
154 if ( off > pfil->
sizeX()/2 ) off -= (long)pfil->
sizeX();
158 cout << fn->
id <<
tab << off <<
tab << max << endl;
164 fn->
loc += vec * off;
193 double cc(0), avg(0);
196 for ( fil = fillist; fil; fil = fil->
next ) {
198 cout <<
"Filament: " << fil->
id << endl;
203 cout <<
"Average correlation coefficient: " << cc << endl;
232 cout <<
"Centering filaments from micrographs" << endl << endl;
234 for ( mg = field->
mg; mg; mg = mg->
next ) {
236 cout <<
"Centering filaments from micrograph: " << mg->
id << endl << endl;
248 cout <<
"Centering filaments from reconstruction: " << rec->
id << endl << endl;
282 if ( pad < 0 ) pad = 0;
285 if ( path.
length() && path[-1] !=
'/') path +=
"/";
295 cerr <<
"Error in project_filament_powerspectrum: No particle!" << endl;
301 cerr <<
"Error in project_filament_powerspectrum: No image!" << endl;
306 if ( size[0] > 1 ) size[0] += pad;
307 if ( size[1] > 1 ) size[1] += pad;
308 if ( size[2] > 1 ) size[2] += pad;
322 cout <<
"Calculating an average filament power spectrum" << endl;
323 cout <<
"Padding: " << pad << endl;
324 cout <<
"Power spectrum size: " << size << endl;
325 cout <<
"Powerspectrum file path: " << path << endl << endl;
331 for ( i=0, part = mg->
part; part; part = part->
next )
if ( part->
sel ) {
377 long nfil(0), nspline, width(3*filament_width);
390 cout <<
"Extracting filaments from micrographs" << endl << endl;
396 cout <<
"Micrograph " << mg->
id << endl;
397 for ( fil = mg->
fil; fil; fil=fil->
next ) {
406 cout << fil->
id <<
tab << gauss[1] <<
tab << gauss[2] << endl;
410 if ( pi ) { pi->
next = pd; pi = pd; }
411 else { plist = pi = pd; }
415 cerr <<
"Error: Micrograph " << mg->
fmg <<
" not read!" << endl;
422 for ( pi = plist; pi; pi = pi->
next ) nv += pi->
sizeX();
428 for ( i=0, pi = plist; pi; pi = pi->
next )
429 for ( x=0; x<pi->
sizeX(); x++, i++ ) pd->
set(i, (*pi)[x]);
434 for ( pi = plist; pi; ) {
462 for ( n=0, r=0, line = mg->
layer; line; line = line->
next )
468 if ( n < 1 )
return -1;
472 ind_lim = (int) (rad_lim/r);
475 mg->
layer = line = NULL;
477 for ( n=-ind_lim; n<=ind_lim; n++ ) {
481 line->
order = abs(n);
505 long i, n, datasize = (long) p->
size().
volume();
514 for ( line = layer_line; line; line = line->
next ) {
515 if ( ind_lim < abs(line->
number) ) {
516 ind_lim = abs(line->
number);
521 double cosax = cos(helix_axis);
522 double sinax = sin(helix_axis);
524 for ( n=0, line = layer_line; line; line = line->
next, n++ ) {
533 for ( i=0; i<datasize; i++ )
534 if ( (*pmask)[i] < 1 ) p->
set(i, cv);
554 double cosax = cos(helix_axis);
555 double sinax = sin(helix_axis);
557 double* d =
new double[
length];
566 for ( i=0; i<
length; i++, c+=v )
568 d[i] = p->
average(0, c[0], c[1], c[2], 0, 2);
582 if ( show < 1 || show > 3 )
return 0;
587 int i, n, nll, k, hlen(
length/2);
592 for ( nll=0, line = mg->
layer; line; line = line->
next, nll++ ) ;
594 double* dm =
new double[nll*
length];
596 for ( n=0, line = mg->
layer; line; line = line->
next, n++ ) {
598 for ( i=0, k=n; i<
length; i++, k+=nll ) {
599 s = (i - hlen)*xscale;
605 cout <<
"Micrograph: " << mg->
id << endl;
606 if (
show == 1 ) cout <<
"Layer lines:" << endl;
607 else if (
show == 2 ) cout <<
"Bessel functions associated with layer lines:" << endl;
608 else cout <<
"Layer lines and associated Bessel functions:" << endl;
610 cout << setprecision(4) <<
"s";
611 for ( line = mg->
layer; line; line = line->
next ) {
612 if (
show & 1 ) cout <<
"\ta(" << line->
number <<
")";
613 if (
show & 2 ) cout <<
"\tj(" << line->
order <<
")";
617 for ( i=k=0; i<
length; i++ ) {
618 s = (i - hlen)*xscale;
620 for ( line = mg->
layer; line; line = line->
next, k++ ) {
621 j = jn(line->
order, s*scale);
622 if (
show & 1 ) cout <<
tab << dm[k];
623 if (
show & 2 ) cout <<
tab << j*j;
Bimage * extract_filament(long img_num, double width, int axis, long nspline, Vector3< double > *spline)
Extracts a filament defined by a series of coordinates.
int rescale(double scale, double shift)
Rescales the image data with a given multiplier and offset.
Header file for spline interpolation.
vector< double > histogram_gauss_fit(long bins, long ngauss=1)
Fits a gaussian function to a histogram of an image.
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
void set(long j, double v)
Sets a single value at the given index.
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
int mg_extract_show_layer_lines(Bmicrograph *mg, int length, int show)
Extracts and prints layer lines from an image with corresponding Bessel functions.
Class for complex numbers.
double nodes_center(Bfilnode *fnode, Bimage *p, long img_num, int width)
Vector3< long > size() const
int mg_generate_layer_lines(Bmicrograph *mg, int rad_lim)
Generates layer lines given the unit cell vectors.
double length(vector< T > v)
double * img_extract_layer_line(Bimage *p, Blayerline *line, float helix_axis, int length)
Extracts one layer line from an image.
Bimage * filament_density(double width)
Estimates the density per pixel length of a filament.
double distance(const Vector3 &v)
double * filament_profile(Bfilnode *fnode, Bimage *p, long img_num, int id, double width, long &n)
Calculates a filament profile and node profile.
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)
string insert(string &filename, string ins)
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
int rotate()
Rotates an image using parameters defined in the image in place.
int power_spectrum(int flags=0)
Calculates a power spectrum.
int img_mask_layer_lines(Bimage *p, Blayerline *layer_line, float helix_axis, float width)
Masks the image using the list of layer lines.
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.
Bparticle * part_find_first(Bproject *project)
Finds the first particle in a project.
Bimage * project_filament_density(Bproject *project, int filament_width)
Extracts filament images from micrographs defined in a project and estimates their density per length...
double project_center_filaments(Bproject *project, int filament_width)
Centers filament nodes in all micrographs in a project.
Header file for image processing from micrograph structures.
Header file for image class.
Header file for general utilities.
ostream & tab(ostream &out)
fft_plan fft_setup_plan(long x, long y, long z, fft_direction dir, int opt)
Sets up a plan for fast Fourier transforms.
void origin(double ox, double oy, double oz)
void change_type(char letter)
Get the data type indicated by a single letter code.
double filaments_center(Bfilament *fillist, Bimage *p, long img_num, int filament_width)
Centers filament nodes in a micrograph.
Header file for micrograph processing.
Header file for generalized linked list functions.
int project_filament_powerspectrum(Bproject *project, int pad, int rotated, Bstring &path)
Calculates and average power spectrum from filaments.
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)
int bar(Vector3< double > start, Vector3< double > end, double width, double edge_width, int fill_type=0, double fill=0)
Generates a bar between start and end points.
Bimage * particle_read_img(Bparticle *part, int readflag)
Reads a particle image file.
bool contains(const Bstring &s)
Header file for functions to process helical data.
long statistics()
Calculates the statistics for an image.