| Bsoft 2.0.5 Bernard's software package

mg_helix.cpp
Go to the documentation of this file.
1
9 #include "Bimage.h"
10 #include "mg_processing.h"
11 #include "mg_img_proc.h"
12 #include "mg_helix.h"
13 #include "mg_extract.h"
14 #include "spline.h"
15 #include "linked_list.h"
16 #include "Complex.h"
17 #include "utilities.h"
18 #include "timer.h"
19
20 // Declaration of global variables
21 extern int verbose; // Level of output to the screen
22
39 double* filament_profile(Bfilnode* fnode, Bimage* p, long img_num, int id, double width, long& n)
40 {
41 long nspline(0);
42
43 Vector3<double>* spline = vector3_spline_from_nodes(fnode, nspline);
44
45 Vector3<long> size((long)width, nspline, 1);
46
47 n = size[0];
48
49 long i, x, y, z;
50 double len(0);
51 Vector3<double> loc(fnode->loc);
52 Bfilnode* fn;
53
54 for ( fn = fnode; fn && fn->id != id; fn = fn->next ) {
55 if ( fn != fnode ) len += (fn->loc - loc).length();
56 loc = fn->loc;
57 }
58 if ( fn ) len += (fn->loc - loc).length();
59 else {
60 cerr << "Error: Filament node with ID " << id << " not found!" << endl;
61 return NULL;
62 }
63
64 long ns = (long) (len - width);
65 long ne = (long) (len + width);
66 if ( ns < 0 ) ns = 0;
67 if ( ne > nspline ) ne = nspline;
68
69 if ( verbose & VERB_DEBUG ) {
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;
74 }
75
76 Bimage* pfil = p->extract_filament(img_num, width, 2, nspline, spline);
77
78 delete[] spline;
79
80 double* profile = new double[2*n];
81
82 for ( i=0; i<2*n; i++ ) profile[i] = 0;
83
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];
90 }
91 }
92 }
93
94 delete pfil;
95
96 for ( i=0; i<n; i++ ) profile[i] /= nspline;
97 for ( ne -= ns; i<2*n; i++ ) profile[i] /= ne;
98
99 return profile;
100 }
101
102 double nodes_center(Bfilnode* fnode, Bimage* p, long img_num, int width)
103 {
104 long nspline(0);
105
106 Vector3<double>* spline = vector3_spline_from_nodes(fnode, nspline);
107
108 Vector3<long> size(width, nspline, 1);
109
110 Bimage* pfil = p->extract_filament(img_num, width, 2, nspline, spline);
111
112 delete[] spline;
113
114 long i, x, y, n(0);
115 long ns, ne;
116 Complex<float>* profile = new Complex<float>[pfil->sizeX()];
117 double len(0), max, pwr, off, cc(0);
118 Vector3<double> loc(fnode->loc), vec;
119 Bfilnode* fn;
120 Matrix3 mat(0,1,0,-1,0,0,0,0,1);
121
122 fft_plan planf = fft_setup_plan(pfil->sizeX(), 1, 1, FFTW_FORWARD, 1);
123 fft_plan planb = fft_setup_plan(pfil->sizeX(), 1, 1, FFTW_BACKWARD, 1);
124
125 if ( verbose )
126 cout << "Node\tOffset\tCC" << endl;
127 for ( fn = fnode; fn; fn = fn->next ) {
128 len += fn->loc.distance(loc);
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++ ) {
135 i = y*pfil->sizeX();
136 for ( x=0; x<pfil->sizeX(); x++, i++ ) {
137 profile[x][0] += (*pfil)[i];
138 }
139 }
140 fftw(planf, profile);
141 for ( pwr=0, i=0; i<pfil->sizeX(); i++ ) {
142 pwr += profile[i].power();
143 profile[i] *= profile[i];
144 }
145 fftw(planb, profile);
146 for ( max=-1000, off=0, i=0; i<pfil->sizeX(); i++ ) if ( max < profile[i].real() ) {
147 max = profile[i].real();
148 off = i;
149 }
150 // max /= sqrt(2*pwr);
151 max /= pwr;
152 cc += max;
153 n++;
154 if ( off > pfil->sizeX()/2 ) off -= (long)pfil->sizeX();
155 off /= 2;
156 if ( verbose )
157 // cout << fn->id << tab << m - (long)pfil->sizeX()/2 << endl;
158 cout << fn->id << tab << off << tab << max << endl;
159 if ( fn->next ) vec = fn->next->loc;
160 else vec = fn->loc;
161 vec -= loc;
162 vec = mat * vec;
163 vec.normalize();
164 fn->loc += vec * off;
165 loc = fn->loc;
166 }
167
168 delete pfil;
169 delete[] profile;
170 fft_destroy_plan(planf);
171 fft_destroy_plan(planb);
172
173 if ( n ) cc /= n;
174
175 return cc;
176 }
177
190 double filaments_center(Bfilament* fillist, Bimage* p, long img_num, int filament_width)
191 {
192 long n(0);
193 double cc(0), avg(0);
194 Bfilament* fil;
195
196 for ( fil = fillist; fil; fil = fil->next ) {
197 if ( verbose )
198 cout << "Filament: " << fil->id << endl;
199 cc = nodes_center(fil->node, p, img_num, filament_width);
200 avg += cc;
201 n++;
202 if ( verbose )
203 cout << "Average correlation coefficient: " << cc << endl;
204 }
205
206 if ( n ) avg /= n;
207
208 return avg;
209 }
210
221 double project_center_filaments(Bproject* project, int filament_width)
222 {
223 long n(0);
224 double cc(0);
225 Bfield* field;
226 Bmicrograph* mg;
227 Breconstruction* rec;
228 Bimage* p;
229
230 if ( project->select < 1 ) {
231 if ( verbose )
232 cout << "Centering filaments from micrographs" << endl << endl;
233 for ( field = project->field; field; field = field->next ) {
234 for ( mg = field->mg; mg; mg = mg->next ) {
235 if ( verbose )
236 cout << "Centering filaments from micrograph: " << mg->id << endl << endl;
237 p = read_img(mg->fmg, 1, mg->img_num);
238 if ( p ) {
239 cc += filaments_center(mg->fil, p, 0, filament_width);
240 n++;
241 delete p;
242 }
243 }
244 }
245 } else {
246 for ( rec = project->rec; rec; rec = rec->next ) {
247 if ( verbose )
248 cout << "Centering filaments from reconstruction: " << rec->id << endl << endl;
249 p = read_img(rec->frec, 1, 0);
250 if ( p ) {
251 cc += filaments_center(rec->fil, p, 0, filament_width);
252 n++;
253 delete p;
254 }
255 }
256 }
257
258 if ( n ) cc /= n;
259
260 return cc;
261 }
262
278 int project_filament_powerspectrum(Bproject* project, int pad, int rotated, Bstring& path)
279 {
280 if ( !project || !project->field || !project->field->mg ) return -1;
281
282 if ( pad < 0 ) pad = 0;
283 // if ( pad > 1000 ) pad = 1000;
284
285 if ( path.length() && path[-1] != '/') path += "/";
286
287 long i;
288 Bfield* field = project->field;
289 Bmicrograph* mg = field->mg;
290 Bparticle* part = part_find_first(project);
291 Bstring insert("_filps.");
292 Bstring ext("map");
293
294 if ( !part ) {
295 cerr << "Error in project_filament_powerspectrum: No particle!" << endl;
296 return -1;
297 }
298
299 Bimage* p = particle_read_img(part, 0);
300 if ( !p ) {
301 cerr << "Error in project_filament_powerspectrum: No image!" << endl;
302 return -1;
303 }
304
305 Vector3<long> size(p->size());
306 if ( size[0] > 1 ) size[0] += pad;
307 if ( size[1] > 1 ) size[1] += pad;
308 if ( size[2] > 1 ) size[2] += pad;
309
310 Bimage* pps = new Bimage(Float, TSimple, size, 1);
311 pps->sampling(p->sampling());
312
313 double angle;
314 Vector3<double> translate, origin;
315 Vector3<double> scale(1,1,1);
316 Vector3<double> axis(0,0,1);
317 Matrix3 mat;
318
319 delete p;
320
321 if ( verbose ) {
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;
326 }
327
328 for ( field = project->field; field; field = field->next ) if ( field->select ) {
329 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select && mg->part ) {
330 pps->clear();
331 for ( i=0, part = mg->part; part; part = part->next ) if ( part->sel ) {
332 p = particle_read_img(part, 1);
333 if ( p ) {
334 p->change_type(Float);
335 if ( rotated < 1 ) {
336 // origin = p->image->origin();
337 angle = part->view.angle() - atan2(part->view[1], part->view[0]) - M_PI_2;
338 // mat = Matrix3(axis, angle);
339 // img_transform(p, p->size(), scale, origin, translate, mat, FILL_BACKGROUND, 0);
340 p->rotate(angle);
341 }
342 if ( pad )
343 p->pad(size, FILL_BACKGROUND, 0);
344 p->power_spectrum(4);
345 pps->add(p);
346 // pps->image->origin(p->image->origin());
347 pps->origin(p->image->origin());
348 delete p;
349 i++;
350 }
351 }
352 if ( i ) {
353 mg->fps = mg->fmg.pre_rev('.') + insert + ext;
354 if ( path.length() ) {
355 if ( mg->fps.contains("/") ) mg->fps = mg->fps.post_rev('/');
356 mg->fps = path + mg->fps;
357 }
358 pps->rescale(1.0L/i, 0);
359 write_img(mg->fps, pps, 0);
360 }
361 }
362 }
363
364 delete pps;
365
366 return 0;
367 }
368
375 Bimage* project_filament_density(Bproject* project, int filament_width)
376 {
377 long nfil(0), nspline, width(3*filament_width);
378 Bfield* field;
379 Bmicrograph* mg;
380 // Breconstruction* rec;
381 Bfilament* fil;
382 Bimage* p, *pfil, *pd;
383 Vector3<double>* spline;
384
385 Bimage* plist = NULL;
386 Bimage* pi = NULL;
387
388 if ( project->select < 1 ) {
389 if ( verbose )
390 cout << "Extracting filaments from micrographs" << endl << endl;
391 for ( field = project->field; field; field = field->next ) {
392 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->fmg.length() && mg->fil ) {
393 p = read_img(mg->fmg, 1, mg->img_num);
394 if ( p ) {
395 if ( verbose )
396 cout << "Micrograph " << mg->id << endl;
397 for ( fil = mg->fil; fil; fil=fil->next ) {
398 if ( mg->filament_width < width )
399 mg->filament_width = width;
400 spline = vector3_spline_from_nodes(fil->node, nspline);
401 // pfil = img_extract_filament(p, 0, mg->filament_width, 'y', nspline, spline);
402 pfil = p->extract_filament(0, mg->filament_width, 2, nspline, spline);
403 pd = pfil->filament_density(filament_width);
404 vector<double> gauss = pd->histogram_gauss_fit(100, 1);
405 if ( verbose )
406 cout << fil->id << tab << gauss[1] << tab << gauss[2] << endl;
407 delete[] spline;
408 delete pfil;
409 nfil++;
410 if ( pi ) { pi->next = pd; pi = pd; }
411 else { plist = pi = pd; }
412 }
413 delete p;
414 } else {
415 cerr << "Error: Micrograph " << mg->fmg << " not read!" << endl;
416 }
417 }
418 }
419 }
420
421 long i, x, nv(0);
422 for ( pi = plist; pi; pi = pi->next ) nv += pi->sizeX();
423
424 pd = new Bimage(Float, TSimple, nv, 1, 1, 1);
425 pd->sampling(plist->sampling());
426 // cout << "all values = " << nv << endl;
427
428 for ( i=0, pi = plist; pi; pi = pi->next )
429 for ( x=0; x<pi->sizeX(); x++, i++ ) pd->set(i, (*pi)[x]);
430 // cout << "transferred = " << i << endl;
431
432 pd->statistics();
433
434 for ( pi = plist; pi; ) {
435 plist = pi->next;
436 delete pi;
437 pi = plist;
438 }
439
440 return pd;
441 }
442
443
456 int mg_generate_layer_lines(Bmicrograph* mg, int rad_lim)
457 {
458 int n, ind_lim;
459 double r;
460 Blayerline* line;
461
462 for ( n=0, r=0, line = mg->layer; line; line = line->next )
463 if ( line->number ) {
464 r += line->distance/line->number;
465 n++;
466 }
467
468 if ( n < 1 ) return -1;
469
470 r /= n; // distance between subsequent lines
471
472 ind_lim = (int) (rad_lim/r);
473
474 kill_list((char *) mg->layer, sizeof(Blayerline));
475 mg->layer = line = NULL;
476
477 for ( n=-ind_lim; n<=ind_lim; n++ ) {
478 line = (Blayerline *) add_item((char **) &line, sizeof(Blayerline));
479 if ( !mg->layer ) mg->layer = line;
480 line->number = n;
481 line->order = abs(n);
482 line->distance = n*r;
483 line->amp = 1;
484 line->fom = 1;
485 line->sel = 1;
486 }
487
488 return n;
489 }
490
499 int img_mask_layer_lines(Bimage* p, Blayerline* layer_line, float helix_axis, float width)
500 {
501 if ( p->compound_type() != TComplex ) return -1;
502
503 p->change_type(Float);
504
505 long i, n, datasize = (long) p->size().volume();
506 int ind_lim(0);
507 double rad(0), hlen;
508 Complex<double> cv;
509 Vector3<double> start, end;
510 Blayerline* line;
511
512 Bimage* pmask = new Bimage(Float, TSimple, p->size(), 1);
513
514 for ( line = layer_line; line; line = line->next ) {
515 if ( ind_lim < abs(line->number) ) {
516 ind_lim = abs(line->number);
517 rad = fabs(1.1*line->distance);
518 }
519 }
520
521 double cosax = cos(helix_axis);
522 double sinax = sin(helix_axis);
523
524 for ( n=0, line = layer_line; line; line = line->next, n++ ) {
525 hlen = sqrt(rad*rad - line->distance*line->distance);
526 start[0] = p->image->origin()[0] + line->distance*cosax - hlen*sinax;
527 start[1] = p->image->origin()[1] + line->distance*sinax + hlen*cosax;
528 end[0] = p->image->origin()[0] + line->distance*cosax + hlen*sinax;
529 end[1] = p->image->origin()[1] + line->distance*sinax - hlen*cosax;
530 pmask->bar(start, end, width, 0, FILL_USER, 1);
531 }
532
533 for ( i=0; i<datasize; i++ )
534 if ( (*pmask)[i] < 1 ) p->set(i, cv);
535
536 // write_img("m.map", pmask);
537
538 delete pmask;
539
540 return n;
541 }
542
551 double* img_extract_layer_line(Bimage* p, Blayerline* line, float helix_axis, int length)
552 {
553 long i, hlen(length/2);
554 double cosax = cos(helix_axis);
555 double sinax = sin(helix_axis);
556 Vector3<double> c, v;
557 double* d = new double[length];
558
559 c[0] = p->image->origin()[0] + line->distance*cosax - hlen*sinax;
560 c[1] = p->image->origin()[1] + line->distance*sinax + hlen*cosax;
561 v[0] = length*sinax;
562 v[1] = -length*cosax;
563
564 v.normalize();
565
566 for ( i=0; i<length; i++, c+=v )
567 // d[i] = p->interpolate(c[0], c[1], c[2], 0);
568 d[i] = p->average(0, c[0], c[1], c[2], 0, 2);
569
570 return d;
571 }
572
580 int mg_extract_show_layer_lines(Bmicrograph* mg, int length, int show)
581 {
582 if ( show < 1 || show > 3 ) return 0;
583
584 Bimage* p = read_img(mg->fps, 1, 0);
585 if ( !p ) return -1;
586
587 int i, n, nll, k, hlen(length/2);
588 Blayerline* line;
589 double s, j, xscale = 1/(p->sizeX()*p->sampling()[0]), scale = TWOPI*mg->helix_radius;
590 double* d;
591
592 for ( nll=0, line = mg->layer; line; line = line->next, nll++ ) ;
593
594 double* dm = new double[nll*length];
595
596 for ( n=0, line = mg->layer; line; line = line->next, n++ ) {
597 d = img_extract_layer_line(p, line, mg->helix_axis, length);
598 for ( i=0, k=n; i<length; i++, k+=nll ) {
599 s = (i - hlen)*xscale;
600 dm[k] = d[i];
601 }
602 delete[] d;
603 }
604
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;
609
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 << ")";
614 }
615 cout << endl;
616
617 for ( i=k=0; i<length; i++ ) {
618 s = (i - hlen)*xscale;
619 cout << s;
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;
624 }
625 cout << endl;
626 }
627
628 delete[] dm;
629 delete p;
630
631 return n;
632 }
633
634
Bimage::change_type
void change_type(char letter)
Get the data type indicated by a single letter code.
Definition: Bimage.cpp:1743
Breconstruction::fil
Bfilament * fil
Definition: mg_processing.h:305
M_PI_2
#define M_PI_2
Definition: utilities.h:62
Bproject::rec
Breconstruction * rec
Definition: mg_processing.h:344
FILL_BACKGROUND
#define FILL_BACKGROUND
Definition: utilities.h:174
Vector3::normalize
double normalize()
Definition: Vector3.h:236
insert
string insert(string &filename, string ins)
Definition: string_util.cpp:48
Bimage.h
Header file for image class.
Bfield::select
long select
Definition: mg_processing.h:262
Bparticle::view
View view
Definition: mg_processing.h:101
Bimage::sampling
Vector3< double > sampling()
Definition: Bimage.h:505
planb
fft_plan planb
Definition: bico.cpp:24
Bimage::add
void add(long j, double v)
Definition: Bimage.h:308
spline.h
Header file for spline interpolation.
Bmicrograph::id
Bstring id
Definition: mg_processing.h:202
Bmicrograph::img_num
int img_num
Definition: mg_processing.h:211
Bfilnode
Definition: mg_processing.h:115
utilities.h
Header file for general utilities.
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
Bimage::power_spectrum
int power_spectrum(int flags=0)
Calculates a power spectrum.
Definition: Bimage_powerspectrum.cpp:48
planf
fft_plan planf
Definition: bico.cpp:24
Bimage::compound_type
CompoundType compound_type()
Definition: Bimage.h:351
Bimage::bar
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.
Definition: Bimage_edit.cpp:729
Blayerline::sel
long sel
Definition: mg_processing.h:182
mg_img_proc.h
Header file for image processing from micrograph structures.
kill_list
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
Definition: linked_list.cpp:214
Complex.h
Class for complex numbers.
part_find_first
Bparticle * part_find_first(Bproject *project)
Finds the first particle in a project.
Definition: mg_processing.cpp:589
add_item
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
Definition: linked_list.cpp:26
Matrix3
Definition: Matrix3.h:17
Bstring::length
long length() const
Definition: Bstring.cpp:263
project
Bproject * project
Definition: bshow.cpp:31
TComplex
Definition: Bimage.h:59
Bmicrograph::fil
Bfilament * fil
Definition: mg_processing.h:240
project_filament_density
Bimage * project_filament_density(Bproject *project, int filament_width)
Extracts filament images from micrographs defined in a project and estimates their density per length...
Definition: mg_helix.cpp:375
Vector3::distance
double distance(const Vector3 &v)
Definition: Vector3.h:227
read_img
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Definition: rwimg.cpp:76
Bmicrograph::helix_radius
double helix_radius
Definition: mg_processing.h:229
project_center_filaments
double project_center_filaments(Bproject *project, int filament_width)
Centers filament nodes in all micrographs in a project.
Definition: mg_helix.cpp:221
Bfield::next
Bfield * next
Definition: mg_processing.h:258
verbose
int verbose
Bimage::extract_filament
Bimage * extract_filament(long img_num, double width, int axis, long nspline, Vector3< double > *spline)
Extracts a filament defined by a series of coordinates.
Definition: Bimage_extract.cpp:1132
particle_read_img
Bimage * particle_read_img(Bparticle *part, int readflag)
Reads a particle image file.
Definition: mg_img_proc.cpp:463
Bmicrograph::part
Bparticle * part
Definition: mg_processing.h:239
TSimple
Definition: Bimage.h:58
Bfilament::id
int id
Definition: mg_processing.h:131
timer.h
Utilities for timing functions.
Bfilament::node
Bfilnode * node
Definition: mg_processing.h:132
Float
Definition: utilities.h:157
Bimage::rescale
int rescale(double scale, double shift)
Rescales the image data with a given multiplier and offset.
Definition: Bimage_rescale.cpp:27
Bimage
General image parameter class.
Definition: Bimage.h:163
Bfilament::next
Bfilament * next
Definition: mg_processing.h:129
Bimage::histogram_gauss_fit
vector< double > histogram_gauss_fit(long bins, long ngauss=1)
Fits a gaussian function to a histogram of an image.
Definition: Bimage_histogram.cpp:583
Bstring::contains
bool contains(const Bstring &s)
Definition: Bstring.cpp:584
Bparticle::sel
long sel
Definition: mg_processing.h:103
Bfield
Definition: mg_processing.h:257
linked_list.h
Header file for generalized linked list functions.
Bfilnode::id
int id
Definition: mg_processing.h:117
Blayerline::order
int order
Definition: mg_processing.h:177
Blayerline::number
int number
Definition: mg_processing.h:176
mg_extract_show_layer_lines
int mg_extract_show_layer_lines(Bmicrograph *mg, int length, int show)
Extracts and prints layer lines from an image with corresponding Bessel functions.
Definition: mg_helix.cpp:580
Bimage::statistics
long statistics()
Calculates the statistics for an image.
Definition: Bimage_stats.cpp:22
nodes_center
double nodes_center(Bfilnode *fnode, Bimage *p, long img_num, int width)
Definition: mg_helix.cpp:102
Blayerline::next
Blayerline * next
Definition: mg_processing.h:175
Bmicrograph::select
long select
Definition: mg_processing.h:203
Bproject::field
Bfield * field
Definition: mg_processing.h:343
fft_plan
fftwf_plan fft_plan
Definition: fft.h:16
img_extract_layer_line
double * img_extract_layer_line(Bimage *p, Blayerline *line, float helix_axis, int length)
Extracts one layer line from an image.
Definition: mg_helix.cpp:551
length
double length(vector< T > v)
Definition: Vector3.h:528
project_filament_powerspectrum
int project_filament_powerspectrum(Bproject *project, int pad, int rotated, Bstring &path)
Calculates and average power spectrum from filaments.
Definition: mg_helix.cpp:278
mg_generate_layer_lines
int mg_generate_layer_lines(Bmicrograph *mg, int rad_lim)
Generates layer lines given the unit cell vectors.
Definition: mg_helix.cpp:456
Bmicrograph::helix_axis
double helix_axis
Definition: mg_processing.h:226
Bmicrograph
Definition: mg_processing.h:200
mg_extract.h
Header file for functions to extract particles from micrographs.
img_mask_layer_lines
int img_mask_layer_lines(Bimage *p, Blayerline *layer_line, float helix_axis, float width)
Masks the image using the list of layer lines.
Definition: mg_helix.cpp:499
Bmicrograph::layer
Blayerline * layer
Definition: mg_processing.h:244
write_img
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Definition: rwimg.cpp:280
mg_helix.h
Header file for functions to process helical data.
Bimage::size
Vector3< long > size() const
Definition: Bimage.h:373
FILL_USER
#define FILL_USER
Definition: utilities.h:172
Bsub_image::origin
void origin(double x, double y, double z)
Definition: Bimage.h:127
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:428
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:264
Bimage::set
void set(long j, double v)
Sets a single value at the given index.
Definition: Bimage.cpp:1096
Bimage::next
Bimage * next
Definition: Bimage.h:165
Complex
Definition: Complex.h:23
Bmicrograph::fps
Bstring fps
Definition: mg_processing.h:210
Bparticle
Definition: mg_processing.h:89
Bstring
Definition: Bstring.h:29
Bimage::pad
int pad(long sz, int fill_type=0, double fill=0)
Pads an image to a new size with a given fill value.
Definition: Bimage_resize.cpp:351
Bimage::sizeX
void sizeX(long nx)
Definition: Bimage.h:377
Bimage::clear
void clear()
Definition: Bimage.h:697
Bproject::select
int select
Definition: mg_processing.h:339
Bimage::sizeZ
void sizeZ(long nz)
Definition: Bimage.h:379
Vector3< double >
Bmicrograph::fmg
Bstring fmg
Definition: mg_processing.h:205
fft_destroy_plan
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
Definition: fft.cpp:87
Bfilnode::next
Bfilnode * next
Definition: mg_processing.h:116
filament_profile
double * filament_profile(Bfilnode *fnode, Bimage *p, long img_num, int id, double width, long &n)
Calculates a filament profile and node profile.
Definition: mg_helix.cpp:39
View::angle
double angle()
Definition: View.h:95
show
int show(0)
Bimage::rotate
int rotate()
Rotates an image using parameters defined in the image in place.
Definition: Bimage_transform.cpp:253
fft_setup_plan
fft_plan fft_setup_plan(long x, long y, long z, fft_direction dir, int opt)
Sets up a plan for fast Fourier transforms.
Definition: fft.cpp:31
fftw
int fftw(fft_plan plan, Complex< float > *a)
Fast Fourier transforms a data array.
Definition: fft.cpp:106
Bimage::average
double average(long cc, double xf, double yf, double zf, long nn, double iscale)
Averages in 3D when scaling is less than 1.
Definition: Bimage.cpp:1349
Blayerline::fom
double fom
Definition: mg_processing.h:181
Bimage::filament_density
Bimage * filament_density(double width)
Estimates the density per pixel length of a filament.
Definition: Bimage_helix.cpp:1688
mg_processing.h
Header file for micrograph processing.
Breconstruction::frec
Bstring frec
Definition: mg_processing.h:287
vector3_spline_from_nodes
Vector3< double > * vector3_spline_from_nodes(Bfilnode *fnode, long &nspline)
Calculates a spline curve from a set of filament nodes.
Definition: mg_extract.cpp:127
Complex::power
double power()
Definition: Complex.h:103
Blayerline::amp
double amp
Definition: mg_processing.h:180
Complex::real
Type real()
Definition: Complex.h:101
filaments_center
double filaments_center(Bfilament *fillist, Bimage *p, long img_num, int filament_width)
Centers filament nodes in a micrograph.
Definition: mg_helix.cpp:190
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:413
Blayerline
Definition: mg_processing.h:174
Vector3::volume
double volume()
Definition: Vector3.h:235
Bparticle::next
Bparticle * next
Definition: mg_processing.h:90
Bimage::sizeY
void sizeY(long ny)
Definition: Bimage.h:378
Bfilnode::loc
Vector3< double > loc
Definition: mg_processing.h:118
Breconstruction::next
Breconstruction * next
Definition: mg_processing.h:281
TWOPI
#define TWOPI
Definition: utilities.h:68
Blayerline::distance
double distance
Definition: mg_processing.h:178
tab
ostream & tab(ostream &out)
Definition: utilities.cpp:21
Bproject
Definition: mg_processing.h:333
Bimage::image
Bsub_image * image
Definition: Bimage.h:188
Bimage::origin
void origin(double ox, double oy, double oz)
Definition: Bimage.h:563
Breconstruction::id
Bstring id
Definition: mg_processing.h:282
Bfilament
Definition: mg_processing.h:128
Bmicrograph::next
Bmicrograph * next
Definition: mg_processing.h:201