Bsoft 2.1.4
Bernard's software package
mg_extract.h File Reference

Header file for functions to extract particles from micrographs. More...

#include "mg_processing.h"
#include "rwimg.h"

Functions

int particle_setup_filenames (Bparticle *part, Bstring filename, Bstring partpath)
 Sets up individual particle file names for extraction. More...
 
int filament_setup_filenames (Bfilament *fil, Bstring filename, Bstring filpath)
 Sets up individual filament file names for extraction. More...
 
Vector3< double > * vector3_spline_from_nodes (Bfilnode *fnode, long &nspline)
 Calculates a spline curve from a set of filament nodes. More...
 
long project_extract_particles (Bproject *project, double scale, int back_flag, int norm_flag, int fill_type, double fill, int mask_width, int split, Bstring &partbase, Bstring &partpath, Bstring &partext)
 Extracts particle images from micrographs defined in a project. More...
 
long micrograph_extract_particles (Bmicrograph *mg, Bimage *p, double scale, int back_flag, int norm_flag, double fill, int mask_width)
 Extracts particle images from a micrograph. More...
 
long reconstruction_extract_particles (Breconstruction *rec, Bimage *p, double scale, int back_flag, int norm_flag, double fill, int mask_width)
 Extracts particle images from a reconstruction. More...
 
Bparticlereconstruction_project_extract_particles (Breconstruction *rec, Bimage *p, double scale, int back_flag, int norm_flag, double fill, int mask_width)
 Extracts and projects 3D particle images from a reconstruction and return a 2D list. More...
 
Bimageparticle_extract (Bparticle *particles, Bbadarea *bad_areas, Bimage *p, Vector3< long > size, double scale, double bad_radius, int back_flag, int norm_flag, double fill, int mask_width)
 Extracts particle images from an image. More...
 
Bimagemicrograph_extract_gold (Bmicrograph *mg, Bimage *p, double radius)
 Extracts gold particle images from a micrograph. More...
 
Bimagereconstruction_extract_gold (Breconstruction *rec, Bimage *p, double radius)
 Extracts gold particle images from a reconstruction. More...
 
Bimagemarker_extract_gold (Bmarker *marker_list, Bimage *p, int img_num, double radius)
 Extracts gold particle images from an image. More...
 
long project_extract_filaments (Bproject *project, int filament_width, int axis, Bstring &base, Bstring &path, Bstring &ext, int split)
 Extracts filament images from micrographs defined in a project. More...
 
long micrograph_extract_filaments (Bmicrograph *mg, Bimage *p, double width, int axis)
 Extracts filament images from a micrograph. More...
 
long reconstruction_extract_filaments (Breconstruction *rec, Bimage *p, double width, int axis)
 Extracts filament images from a micrograph. More...
 
Bimagefilament_extract (Bfilament *filaments, Bimage *p, double width, int axis)
 Extracts filament images from a micrograph. More...
 
int project_filaments_to_particles (Bproject *project, Vector3< long > box_size, double boxing_interval, double rise, double angle)
 Converts filaments to sets of particles. More...
 
int micrograph_filaments_to_particles (Bmicrograph *mg, Vector3< long > box_size, double boxing_interval, double rise, double angle)
 Converts filaments to sets of particles. More...
 
int reconstruction_filaments_to_particles (Breconstruction *rec, Vector3< long > box_size, double boxing_interval, double rise, double angle)
 Converts filaments to sets of particles. More...
 
Bparticlefilaments_to_particles (Bfilament *filaments, Vector3< double > pixel_size, Vector3< long > box_size, double boxing_interval, double rise, double angle)
 Converts filaments to sets of particles. More...
 
int project_mask_filament_particles (Bproject *project, int mask_width)
 Masks particles extracted from filaments. More...
 
int project_rotate_mask_filament_particles (Bproject *project, int rotation_axis, int back_flag, int mask_width)
 Rotates and masks particles extracted from filaments. More...
 

Detailed Description

Header file for functions to extract particles from micrographs.

Author
Bernard Heymann
Date
Created: 20040406
Modified: 20200616

Function Documentation

◆ filament_extract()

Bimage * filament_extract ( Bfilament filaments,
Bimage p,
double  width,
int  axis 
)

Extracts filament images from a micrograph.

Parameters
*filamentsfilament parameters.
*pimage.
widthwidth of box around filament to extract.
axishelical axis alignment: x=1, y=2, z=3.
Returns
Bimage* multi-filament image.
If the file names for individual filaments are specified, they are
used to write individual filaments to files.
Default axis alignment (for axis==0):
    2D images:  x-axis (1)
    3D images:  z-axis (3)

◆ filament_setup_filenames()

int filament_setup_filenames ( Bfilament fil,
Bstring  filename,
Bstring  filpath 
)

Sets up individual filament file names for extraction.

Parameters
*filfilament list.
filenamefilament file name base.
filpathfilament path with optional wild card characters.
Returns
long number of filaments.
The filament path can have wildcard characters ('?') that specify
the number of digits to use to insert numbers in the path and
the file name.

◆ filaments_to_particles()

Bparticle * filaments_to_particles ( Bfilament filaments,
Vector3< double >  pixel_size,
Vector3< long >  box_size,
double  boxing_interval,
double  rise,
double  angle 
)

Converts filaments to sets of particles.

Parameters
*filamentsfilament parameters.
pixel_sizesampling.
box_sizesize of particle box.
boxing_intervalstep size between boxes.
riserise per asymmetric unit in angstrom.
angleangular rotation per asymmetric unit in radians.
Returns
Bparticle* pointer to new list of particles.
Particle coordinates are calculated along a spline curve through
the filament nodes, separated by half the given width.
Different filaments in a micrograph are indicated by the selection number.

◆ marker_extract_gold()

Bimage * marker_extract_gold ( Bmarker marker_list,
Bimage p,
int  img_num,
double  radius 
)

Extracts gold particle images from an image.

Parameters
*marker_listmarker parameters.
*pimage.
img_numsub-image number.
radiusradius of gold particle.
Returns
Bimage* multi-particle image.

◆ micrograph_extract_filaments()

long micrograph_extract_filaments ( Bmicrograph mg,
Bimage p,
double  width,
int  axis 
)

Extracts filament images from a micrograph.

Parameters
*mgmicrograph parameters.
*pmicrograph image.
widthwidth of box around filament to extract.
axishelical axis alignment: x=1, y=2, z=3.
Returns
long number of filaments.

◆ micrograph_extract_gold()

Bimage * micrograph_extract_gold ( Bmicrograph mg,
Bimage p,
double  radius 
)

Extracts gold particle images from a micrograph.

Parameters
*mgmicrograph parameters.
*pmicrograph image.
radiusradius of gold particle.
Returns
Bimage* multi-particle image.

◆ micrograph_extract_particles()

long micrograph_extract_particles ( Bmicrograph mg,
Bimage p,
double  scale,
int  back_flag,
int  norm_flag,
double  fill,
int  mask_width 
)

Extracts particle images from a micrograph.

Parameters
*mgmicrograph parameters.
*pmicrograph image.
scalescale to extract (usually 1).
back_flagbackground correction flag.
norm_flagnormalization flag.
fillvalue to fill in new regions.
mask_widthfilament mask width, if 0, don't apply.
Returns
long number of particles.

◆ micrograph_filaments_to_particles()

int micrograph_filaments_to_particles ( Bmicrograph mg,
Vector3< long >  box_size,
double  boxing_interval,
double  rise,
double  angle 
)

Converts filaments to sets of particles.

Parameters
*mgmicrograph parameters.
box_sizesize of particle box.
boxing_intervalstep size between boxes.
riserise per asymmetric unit in angstrom.
angleangular rotation per asymmetric unit in radians.
Returns
int number of filaments converted.
Particle coordinates are calculated along a spline curve through
the filament nodes, separated by half the given width.
Different filaments in a micrograph are indicated by the selection number.

◆ particle_extract()

Bimage * particle_extract ( Bparticle particles,
Bbadarea bad_areas,
Bimage p,
Vector3< long >  size,
double  scale,
double  bad_radius,
int  back_flag,
int  norm_flag,
double  fill,
int  mask_width 
)

Extracts particle images from an image.

Parameters
*particlesparticle parameters.
*bad_areasbad area parameters.
*pimage.
sizesize of box to extract.
scalescale to extract (usually 1).
bad_radiusradius of bad area.
back_flagbackground correction flag.
norm_flagnormalization flag.
fillvalue to fill in new regions.
mask_widthfilament mask width, if 0, don't apply.
Returns
Bimage* multi-particle image.
If the background flag is specified, the particle mask is set in the 
background, defined as outside the inscribing circle.
The mask is set within every bad area in the micrograph and
transferred to the mask for a particle where it overlaps.

◆ particle_setup_filenames()

int particle_setup_filenames ( Bparticle part,
Bstring  filename,
Bstring  partpath 
)

Sets up individual particle file names for extraction.

Parameters
*partparticle list.
filenameparticle file name base.
partpathparticle path with optional wild card characters.
Returns
long number of particles.
The particle path can have wildcard characters ('?') that specify
the number of digits to use to insert numbers in the path and
the file name.

◆ project_extract_filaments()

long project_extract_filaments ( Bproject project,
int  filament_width,
int  axis,
Bstring base,
Bstring path,
Bstring ext,
int  split 
)

Extracts filament images from micrographs defined in a project.

Parameters
*projectmicrograph project.
filament_widthextracted filament width.
axishelical axis alignment: x=1, y=2, z=3.
&basefile name base.
&pathpath to filament file.
&extfilament file extension.
splitflag to split filaments into individual files.
Returns
long number of filaments, <0 on error.

◆ project_extract_particles()

long project_extract_particles ( Bproject project,
double  scale,
int  back_flag,
int  norm_flag,
int  fill_type,
double  fill,
int  mask_width,
int  split,
Bstring partbase,
Bstring partpath,
Bstring partext 
)

Extracts particle images from micrographs defined in a project.

Parameters
*projectmicrograph project.
scalescale to extract (usually 1).
back_flagbackground correction flag.
norm_flagnormalization flag.
fill_typeFILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
fillvalue to fill in new regions.
mask_widthfilament mask width, if 0, don't apply.
splitflag to split images into separate files.
&partbasefile name base.
&partpathpath to particle file.
&partextparticle file extension.
Returns
long number of particles, <0 on error.

◆ project_filaments_to_particles()

int project_filaments_to_particles ( Bproject project,
Vector3< long >  box_size,
double  boxing_interval,
double  rise,
double  angle 
)

Converts filaments to sets of particles.

Parameters
*projectproject parameters.
box_sizesize of particle box.
boxing_intervalstep size between boxes.
riserise per asymmetric unit in angstrom.
angleangular rotation per asymmetric unit in radians.
Returns
int number of filaments converted.
Particle coordinates are calculated along a spline curve through
the filament nodes, separated by half the given width.
Different filaments in a micrograph are indicated by the selection number.

◆ project_mask_filament_particles()

int project_mask_filament_particles ( Bproject project,
int  mask_width 
)

Masks particles extracted from filaments.

Parameters
*projectproject parameters.
mask_widthwidth of mask to apply.
Returns
int number of particles masked.
The orientation of the filament is inferred from the view angle and
the adjacent regions are set to the background.

◆ project_rotate_mask_filament_particles()

int project_rotate_mask_filament_particles ( Bproject project,
int  rotation_axis,
int  back_flag,
int  mask_width 
)

Rotates and masks particles extracted from filaments.

Parameters
*projectproject parameters.
rotation_axisaxis to rotate to: 1=x, 2=y, 3=z.
back_flagbackground correction flag.
mask_widthwidth of mask to apply.
Returns
int number of particles masked.
The orientation of the filament is inferred from the view angle and
the particle is rotated to orient the filament axis along a cartesian axis. 
The mask is applied and adjacent regions are set to the background.

◆ reconstruction_extract_filaments()

long reconstruction_extract_filaments ( Breconstruction rec,
Bimage p,
double  width,
int  axis 
)

Extracts filament images from a micrograph.

Parameters
*recreconstruction parameters.
*preconstruction image.
widthwidth of box around filament to extract.
axishelical axis alignment: x=1, y=2, z=3.
Returns
long number of filaments.

◆ reconstruction_extract_gold()

Bimage * reconstruction_extract_gold ( Breconstruction rec,
Bimage p,
double  radius 
)

Extracts gold particle images from a reconstruction.

Parameters
*recreconstruction parameters.
*preconstruction image.
radiusradius of gold particle.
Returns
Bimage* multi-particle image.

◆ reconstruction_extract_particles()

long reconstruction_extract_particles ( Breconstruction rec,
Bimage p,
double  scale,
int  back_flag,
int  norm_flag,
double  fill,
int  mask_width 
)

Extracts particle images from a reconstruction.

Parameters
*recreconstruction parameters.
*pmicrograph image.
scalescale to extract (usually 1).
back_flagbackground correction flag.
norm_flagnormalization flag.
fillvalue to fill in new regions.
mask_widthfilament mask width, if 0, don't apply.
Returns
long number of particles.

◆ reconstruction_filaments_to_particles()

int reconstruction_filaments_to_particles ( Breconstruction rec,
Vector3< long >  box_size,
double  boxing_interval,
double  rise,
double  angle 
)

Converts filaments to sets of particles.

Parameters
*recreconstruction parameters.
box_sizesize of particle box.
boxing_intervalstep size between boxes.
riserise per asymmetric unit in angstrom.
angleangular rotation per asymmetric unit in radians.
Returns
int number of filaments converted.
Particle coordinates are calculated along a spline curve through
the filament nodes, separated by half the given width.
Different filaments in a micrograph are indicated by the selection number.

◆ reconstruction_project_extract_particles()

Bparticle * reconstruction_project_extract_particles ( Breconstruction rec,
Bimage p,
double  scale,
int  back_flag,
int  norm_flag,
double  fill,
int  mask_width 
)

Extracts and projects 3D particle images from a reconstruction and return a 2D list.

Parameters
*recreconstruction parameters.
*pmicrograph image.
scalescale to extract (usually 1).
back_flagbackground correction flag.
norm_flagnormalization flag.
fillvalue to fill in new regions.
mask_widthfilament mask width, if 0, don't apply.
Returns
Bparticle* list of 2D particles.
The file name of the new particles is returned in the image file name.

◆ vector3_spline_from_nodes()

Vector3< double > * vector3_spline_from_nodes ( Bfilnode fnode,
long &  nspline 
)

Calculates a spline curve from a set of filament nodes.

Parameters
*fnodenode list.
&nsplinenumber of elements in the spline array.
Returns
Vector3<double>* array of spline coordinates.
The node coordinates are copied into a new array used to calculate the spline array.