 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
38 if ( sam[0] <= 0) sam = sam.
max(1);
41 double width = edge/sam[0];
47 if ( ori[0] == 0 && ori[1] == 0 && ori[2] == 0 )
57 cout <<
"Generating a model mask:" << endl;
58 cout <<
"Size: " << p->
size() << endl;
60 cout <<
"Sampling: " << p->
sampling(0) <<
" A/voxel" << endl;
81 for ( i=nv=0; i<datasize; i++ )
if ( (*p)[i] > 0.5 ) nv++;
84 cout <<
"Mask volume: " << nv * sam.
volume() <<
" A3" << endl << endl;
107 if ( sam[0] <= 0) sam = sam.
max(1);
110 double d, min = 1e30, max = 0;
115 if ( ori[0] == 0 && ori[1] == 0 && ori[2] == 0 )
123 cout <<
"Generating a hull mask:" << endl;
124 cout <<
"Size: " << p->
size() << endl;
126 cout <<
"Sampling: " << p->
sampling(0) <<
" A/voxel" << endl;
128 if ( curv_flag ) cout <<
"Curved" << endl;
129 else cout <<
"Planar" << endl;
142 if ( min > d ) min = d;
143 if ( max < d ) max = d;
146 if ( curv_flag < 1 ) min = 0;
153 for ( i=z=nv=0; z<p->
sizeZ(); z++ ) {
155 cout <<
"Calculating slice " << z << endl;
156 vec[2] = z - center[2];
157 for ( y=0; y<p->
sizeY(); y++ ) {
158 vec[1] = y - center[1];
159 for ( x=0; x<p->
sizeX(); x++, i++ ) {
160 vec[0] = x - center[0];
162 if ( d < min ) p->
set(i,1);
163 else if ( d > max ) p->
set(i,0);
171 cout <<
"Mask volume: " << nv * sam.
volume() <<
" A3" << endl << endl;
195 if ( sam[0] <= 0) sam = sam.
max(1);
197 long i, x, y, z, nv=0, ni=0, no=0;
198 double d, min = 1e30, max = 0, half_width = shell_width/(2*sam[0]);
199 if ( half_width < 0.5 ) half_width = 0.5;
200 shell_width = 2*sam[0]*half_width;
206 if ( ori[0] == 0 && ori[1] == 0 && ori[2] == 0 )
214 cout <<
"Generating a shell mask:" << endl;
215 cout <<
"Size: " << p->
size() << endl;
217 cout <<
"Sampling: " << p->
sampling(0) <<
" A/voxel" << endl;
218 cout <<
"Shell width: " << shell_width <<
" A" << endl;
219 if ( curv_flag ) cout <<
"Curved" << endl;
220 else cout <<
"Planar" << endl;
231 if ( min > d ) min = d;
232 if ( max < d ) max = d;
238 if ( curv_flag < 1 ) min = 0;
243 for ( i=z=0; z<p->
sizeZ(); z++ ) {
245 cout <<
"Calculating slice " << z << endl;
246 vec[2] = z - center[2];
247 for ( y=0; y<p->
sizeY(); y++ ) {
248 vec[1] = y - center[1];
249 for ( x=0; x<p->
sizeX(); x++, i++ ) {
250 vec[0] = x - center[0];
254 else if ( d > max ) no++;
257 if ( fabs(d) <= half_width ) p->
set(i,1);
258 else if ( d > 0 ) ni++;
267 cout <<
"Mask volume: " << nv * sam.
volume() <<
" A3" << endl;
268 cout <<
"Inner volume: " << ni * sam.
volume() <<
" A3" << endl;
269 cout <<
"Outer volume: " << no * sam.
volume() <<
" A3" << endl << endl;
289 if ( sam[0] <= 0) sam = sam.
max(1);
296 if ( ori[0] == 0 && ori[1] == 0 && ori[2] == 0 )
304 cout <<
"Generating a level mask:" << endl;
305 cout <<
"Size: " << p->
size() << endl;
307 cout <<
"Sampling: " << p->
sampling(0) <<
" A/voxel" << endl;
314 for ( comp = mp->
comp; comp; comp = comp->
next ) {
337 if ( !p || !
model )
return NULL;
345 long i, j, k, x, y, z, n;
348 cout <<
"Extracting segments from a multi-level mask:" << endl;
349 cout <<
"Model: " <<
model->
id << endl;
350 cout <<
"Number of components: " << ncomp << endl;
351 if ( multi_level ) cout <<
"Multi-level" << endl;
352 else cout <<
"Single level" << endl;
361 long max = (
long) (p->
maximum()+1);
363 int* lut =
new int[max];
364 for ( i=0; i<max; i++ ) lut[i] = 0;
366 for ( k=1, mp =
model; mp; mp = mp->
next ) {
372 if ( x < p->sizeX() && y < p->
sizeY() && z < p->
sizeZ() ) {
373 i = p->
index(0, x, y, z, n);
374 level = (int) ((*p)[i] + 0.5);
377 cout <<
"DEBUG img_extract_segments_using_model: " << x <<
tab << y <<
tab << z <<
tab << n <<
tab <<
level << endl;
382 for ( i=j=0; i<datasize; i++ ) {
383 level = (int) ((*p)[i] + 0.5);
385 if ( multi_level ) pseg->
set(i, lut[
level]);
386 else pseg->
set(i, 1);
408 if ( !p || !
model )
return -1;
418 int new_value, count = (int) p->
maximum();
421 cout <<
"Adding model " <<
model->
id <<
" to mask " << p->
file_name() << endl << endl;
429 if ( x < p->sizeX() && y < p->
sizeY() && z < p->
sizeZ() ) {
430 i = p->
index(0, x, y, z, n);
433 if ( new_value > 0 ) p->
set(i, new_value);
434 else p->
set(i, count++);
458 cout <<
"Generating a model from a multi-level mask:" << endl;
459 cout <<
"Mask file: " << p->
file_name() << endl;
460 cout <<
"Number of levels: " << p->
maximum() << endl << endl;
463 long i, j, x, y, z, n;
464 long nlev = (long)p->
maximum() + 1;
473 int* num =
new int[nlev];
478 for ( n=i=0; n<p->
images(); n++ ) {
479 id =
Bstring(n,
"Segments_%d");
485 for ( j=0; j<=p->
maximum(); j++ ) {
489 for ( z=0; z<p->
sizeZ(); z++ ) {
491 for ( y=0; y<p->
sizeY(); y++ ) {
493 for ( x=0; x<p->
sizeX(); x++, i++ )
if ( mask[i] > 0 ) {
496 loc[mask[i]] += coor;
500 for ( j=1; j<=p->
maximum(); j++ )
if ( num[j] ) {
505 comp->
loc = loc[j]/num[j];
506 comp->
radius = pow(3*num[j]*u/(4*
M_PI), 1.0/3.0);
536 if ( sam.
volume() <= 0) sam = sam.
max(1);
552 if ( ori[0] == 0 && ori[1] == 0 && ori[2] == 0 )
561 cout <<
"Generating projection masks:" << endl;
562 cout <<
"Size: " << p->
size() << endl;
564 cout <<
"Sampling: " << p->
sampling(0) <<
" A/voxel" << endl;
565 cout <<
"Angular step size: " << dang*180.0/
M_PI << endl;
566 cout <<
"Symmetry: " << sym->
label << endl;
567 cout <<
"Projections: " << nv << endl;
571 cout <<
"Mask\tView\t\t\t\t\tCount\tFraction" << endl;
572 for ( v = views, n=0; v; v = v->
next, ++n ) {
575 for ( comp = mp->
comp; comp; comp = comp->
next ) {
579 cerr <<
"Out of bounds! " << loc << endl;
580 i = p->
index(loc, n);
589 cout << n+1 << setprecision(4) <<
tab << *v <<
tab
590 << nm <<
tab << f << endl;
596 for ( i=nv=0; i<p->
data_size(); i++ )
if ( (*p)[i] > 0.5 ) nv++;
599 cout <<
"Mask area: " <<
600 nv * sam.
volume()/n <<
" A2" << endl;
601 cout <<
"Average mask fraction: " <<
Header file for matrix functions.
Header file for reading and writing atomic model files.
void set(long j, double v)
Sets a single value at the given index.
int model_component_count(Bmodel *model)
Counts the total number of components.
Bcomponent * component_add(Bcomponent **comp, Bstring &id)
Adds a component to a linked list.
double model_inside_outside(Vector3< double > vec, Bmodel *model, int curv_flag, int fast)
Vector3< double > default_origin()
Vector3< long > size() const
View * asymmetric_unit_views(Bsymmetry *sym, double theta_step, double phi_step, int flag)
Initializes a well-distributed set of views in an asymmetric unit.
Bimage * img_extract_segments_using_model(Bimage *p, Bmodel *model, int multi_level)
Extracts segmentss from a multi-level mask around points defined by a model.
Vector3< double > model_center_of_mass(Bmodel *model)
Bimage * model_create_level_mask(Bmodel *model, Vector3< long > size, Vector3< double > ori, Vector3< double > sam)
Calculates a mask with one level per model.
long count_list(char *list)
Counts the number of items in a linked list.
Bmodel * model_from_multilevel_mask(Bimage *p)
Generates components at the center of mass of each mask level.
void origin(double x, double y, double z)
Bimage * model_create_projected_mask(Bmodel *model, Vector3< long > size, Vector3< double > ori, Vector3< double > sam, double dang, Bsymmetry *sym)
Calculates a set of 2D masks for the projections of a model structure.
Bimage * model_create_hull_mask(Bmodel *model, Vector3< long > size, Vector3< double > ori, Vector3< double > sam, int curv_flag, int fast)
Calculates a mask based on the periphery of a model structure.
Bimage * model_create_shell_mask(Bmodel *model, Vector3< long > size, Vector3< double > ori, Vector3< double > sam, double shell_width, int curv_flag, int fast)
Calculates a shell mask covering a model structure.
General image parameter class.
Class for 3-value vectors.
long check_neighbors(long idx)
Check neighbors in region map and assign a value if a neighbor is assigned.
Header file for general utilities.
ostream & tab(ostream &out)
Functions to generate masks from models.
void origin(double ox, double oy, double oz)
void change_type(char letter)
Get the data type indicated by a single letter code.
long index(long nx, long ny) const
int img_add_model_to_mask(Bimage *p, Bmodel *model)
Adds to the mask the component locations.
void sampling(double x, double y, double z)
Header file for generalized linked list functions.
Bmodel * model_add(Bmodel **model, Bstring &id)
Adds a model to a linked list.
unsigned char * data_pointer()
Library routines used for model processing.
Bcomptype * model_add_type_by_id(Bmodel *model, Bstring &id)
Add a type to a model if the identifier does not exist already.
void sampling(long nn, Vector3< double > u)
Bimage * model_create_mask(Bmodel *model, Vector3< long > size, Vector3< double > ori, Vector3< double > sam, double edge)
Calculates a mask of the components and links of a model structure.
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.
bool within_boundaries(Vector3< double > loc)
Library routines used for shell model processing.
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.