Bsoft 2.1.4
Bernard's software package
mg_pick.cpp File Reference

Functions for picking single particle images from a micrograph. More...

#include "mg_pick.h"
#include "mg_processing.h"
#include "mg_select.h"
#include "linked_list.h"
#include "utilities.h"

Functions

Bimageimg_prepare_for_picking (Bimage *p, int flags, long sigma, long bin)
 
Bparticleparticles_from_peaks (Bimage *pcc, long bin, double excl_dist, double part_ori, double &fommin, double fommax, long maxnum, double pix_min, double pix_max)
 Finds the peaks in a cross-correlation map corresponding to particles. More...
 
Bparticleparticles_pick_cc (Bimage *p, Bimage *ptemp, Bimage *pmask, double hires, double lores, double fommin, double fommax, double excl_dist, long bin)
 Picks particles using cross-correlation. More...
 
double gauss_find_intersection (long ngauss, vector< double > &gauss)
 
Bparticleparticles_pick_var (Bimage *p, long avg_kernel, long var_kernel, double nsig, double part_ori, double excl_dist, long bin)
 Picks particles in variance map. More...
 
Bparticleparticles_pick_var (Bimage *p, long avg_kernel, long var_kernel, double cutmin, double cutmax, double part_ori, double excl_dist, long bin)
 
Bparticleparticles_pick_cc (Bstring &filename, long img_num, Bimage *ptemp, Bimage *pmask, double hires, double lores, double fommin, double fommax, double excl_dist, long bin)
 Picks particles using cross-correlation. More...
 
Bparticleparticles_pick_var (Bstring &filename, long img_num, long avg_kernel, long var_kernel, double nsig, double part_ori, double excl_dist, long bin)
 Picks particles in variance map. More...
 
double img_marker_set_difference_at_voxel (Bimage *p, long i, Bmarker *markin, Bmarker *markout)
 
Bimageimg_marker_set_difference (Bimage *p, Bmarker *markin, Bmarker *markout, int contrast)
 Calculates the average difference between voxels tagged by two marker sets. More...
 
double mg_pick_particles (Bmicrograph *mg, Bimage *p, Bmarker *markin, Bmarker *markout, int avg_kernel, int contrast)
 Locates particles using a fore/background difference measure. More...
 
double project_pick_particles (Bproject *project, Bimage *ptemp, Bimage *pmask, double hires, double lores, double fommin, double fommax, double excl_dist, long bin)
 Picks particles using cross-correlation. More...
 
double project_pick_particles (Bproject *project, long avg_kernel, long var_kernel, double nsig, double part_ori, double excl_dist, long bin)
 Picks particles in variance map. More...
 
long project_pick_particles (Bproject *project, double din, double dout, int avg_kernel, double ainc, int flags, int contrast)
 Locates particles using a fore/background difference measure. More...
 
int part_mask_particles (Bparticle *part, Bimage *pmask, long box_size)
 
int img_mask_above_threshold (Bimage *pvar, Bimage *p, double threshold)
 
double mg_pick_background (Bmicrograph *mg, Bimage *p, long number, long avg_kernel, long var_kernel, double excl_dist)
 
double rec_pick_background (Breconstruction *rec, Bimage *p, long number, long avg_kernel, long var_kernel, double excl_dist)
 
long project_pick_background (Bproject *project, long number, long avg_kernel, long var_kernel, double excl_dist)
 Picks background areas not overlapping existing particles. More...
 
Bparticlepart_pick_sym_axis (Bparticle *part, Bsymmetry &sym, View &refview, Vector3< double > refori, double axis_dist)
 
long project_pick_sym_axis (Bproject *project, Bsymmetry &sym, int sym_axis, double axis_dist)
 Picks subregions in 3D particles on the given symmetry axis. More...
 
Bimageimg_prepare_projections (Bstring &tempfile, Bsymmetry &sym, double hires, long bin)
 
Bimageimg_prepare_orientations (Bstring &tempfile, Bsymmetry &sym, double hires, long bin)
 
double part_align (Bparticle *part, Bimage *p, Bimage *ptemp, double hires, double lores, double shift_limit, long bin, fft_plan planf, fft_plan planb)
 
long mg_extract_orient_particles (Bmicrograph *mg, Bimage *ptemp, double hires, double lores, long bin, fft_plan planf, fft_plan planb)
 Finds the centers of picked particles within a micrograph. More...
 
long rec_extract_orient_particles (Breconstruction *rec, Bimage *ptemp, double hires, double lores, long bin, fft_plan planf, fft_plan planb)
 
double project_extract_orient_particles (Bproject *project, Bstring &tempfile, Bsymmetry &sym, double hires, double lores, long bin)
 Picks particles using cross-correlation. More...
 

Variables

int verbose
 

Detailed Description

Functions for picking single particle images from a micrograph.

Author
Bernard Heymann
Date
Created: 20000505
Modified: 20210510

Function Documentation

◆ gauss_find_intersection()

double gauss_find_intersection ( long  ngauss,
vector< double > &  gauss 
)

◆ img_marker_set_difference()

Bimage * img_marker_set_difference ( Bimage p,
Bmarker markin,
Bmarker markout,
int  contrast 
)

Calculates the average difference between voxels tagged by two marker sets.

Parameters
*pimage.
*markininner marker set (relates to particle).
*markoutouter marker set (relates to background).
contrastcontrast direction (foreground: white=1, black=0).
Returns
Bimage* map with resultant differences.
The values in the image corresponding to the coordinates of the
inner marker set is subtracted from those of the outer marker set.

◆ img_marker_set_difference_at_voxel()

double img_marker_set_difference_at_voxel ( Bimage p,
long  i,
Bmarker markin,
Bmarker markout 
)

◆ img_mask_above_threshold()

int img_mask_above_threshold ( Bimage pvar,
Bimage p,
double  threshold 
)

◆ img_prepare_for_picking()

Bimage * img_prepare_for_picking ( Bimage p,
int  flags,
long  sigma,
long  bin 
)

◆ img_prepare_orientations()

Bimage * img_prepare_orientations ( Bstring tempfile,
Bsymmetry sym,
double  hires,
long  bin 
)

◆ img_prepare_projections()

Bimage * img_prepare_projections ( Bstring tempfile,
Bsymmetry sym,
double  hires,
long  bin 
)

◆ mg_extract_orient_particles()

long mg_extract_orient_particles ( Bmicrograph mg,
Bimage ptemp,
double  hires,
double  lores,
long  bin,
fft_plan  planf,
fft_plan  planb 
)

Finds the centers of picked particles within a micrograph.

Parameters
*mgmicrograph parameter structure.
*ptemptemplate image.
hireshigh resolution limit.
loreslow resolution limit.
binlevel of image binning.
planfFFT forward plan.
planbFFT backward plan.
Returns
long number of particles.
An image processing parameter structure loaded with micrograph
information is used to extract particle images from the micrograph
image using the particle coordinates in the parameter structure.
The extracted particle images are each rotated by PI and the shift
found by cross-correlation between the unrotated and rotated images.
The particle coordinates in the parameter structure are updated with
the shift.

◆ mg_pick_background()

double mg_pick_background ( Bmicrograph mg,
Bimage p,
long  number,
long  avg_kernel,
long  var_kernel,
double  excl_dist 
)

◆ mg_pick_particles()

double mg_pick_particles ( Bmicrograph mg,
Bimage p,
Bmarker markin,
Bmarker markout,
int  avg_kernel,
int  contrast 
)

Locates particles using a fore/background difference measure.

Parameters
*mgmicrograph parameter structure.
*pmicrograph image, if NULL, read from mg.
*markinforeground marker set.
*markoutbackground marker set.
avg_kernelaveraging kernle to smooth difference map.
contrastcontrast direction (foreground: white=1, black=0).
Returns
double threshold used to accept peaks.
The two marker sets are used to calculate a difference
between the foreground and background as an estimate of the
presence of a particle.
The resultant image is smoothed by an averaging kernel and rescaled to [0,1].
This image is then scanned to identify particles.

◆ part_align()

double part_align ( Bparticle part,
Bimage p,
Bimage ptemp,
double  hires,
double  lores,
double  shift_limit,
long  bin,
fft_plan  planf,
fft_plan  planb 
)

◆ part_mask_particles()

int part_mask_particles ( Bparticle part,
Bimage pmask,
long  box_size 
)

◆ part_pick_sym_axis()

Bparticle * part_pick_sym_axis ( Bparticle part,
Bsymmetry sym,
View refview,
Vector3< double >  refori,
double  axis_dist 
)

◆ particles_from_peaks()

Bparticle * particles_from_peaks ( Bimage pcc,
long  bin,
double  excl_dist,
double  part_ori,
double &  fommin,
double  fommax,
long  maxnum,
double  pix_min,
double  pix_max 
)

Finds the peaks in a cross-correlation map corresponding to particles.

Parameters
*pccpeak map (after binning).
binbinning to speed up calculations.
excl_distdistance between peaks.
part_oriparticle origin.
fomminminimum threshold to accept peaks.
fommaxmaximum threshold to accept peaks.
maxnummaximum number of peaks to pick.
pix_minminimum peak width.
pix_maxmaximum peak width.
Returns
Bparticle* list of particles.
The map is searched in increments of the particle radius to identify
peaks above the threshold and within a box the size of the
particle radius. The identified peaks are further examined to eliminate 
ones that are too close to a higher scoring peak. The acceptable distance
between peaks is set to 1.8 times the particle radius.

◆ particles_pick_cc() [1/2]

Bparticle * particles_pick_cc ( Bimage p,
Bimage ptemp,
Bimage pmask,
double  hires,
double  lores,
double  fommin,
double  fommax,
double  excl_dist,
long  bin 
)

Picks particles using cross-correlation.

Parameters
*pimage to pick from.
*ptemptemplate image.
*pmaskfrequency space mask.
hireshigh resolution limit.
loreslow resolution limit.
fomminminimum FOM cutoff.
fommaxmaximum FOM cutoff.
excl_distminimum distance between particles.
binlevel of image binning.
Returns
Bparticle* list of particles.
A template is cross-correlated with the input image including
bandpass filtering to target the size of the particle.

◆ particles_pick_cc() [2/2]

Bparticle * particles_pick_cc ( Bstring filename,
long  img_num,
Bimage ptemp,
Bimage pmask,
double  hires,
double  lores,
double  fommin,
double  fommax,
double  excl_dist,
long  bin 
)

Picks particles using cross-correlation.

Parameters
&filenameimage to pick from.
img_numsub-image number.
*ptemptemplate image.
*pmaskfrequency space mask.
hireshigh resolution limit.
loreslow resolution limit.
fomminminimum FOM cutoff.
fommaxmaximum FOM cutoff.
excl_distminimum distance between particles.
binlevel of image binning.
Returns
Bparticle* list of particles.
A template is cross-correlated with the input image including
bandpass filtering to target the size of the particle.
The template must have the correct pixel size.

◆ particles_pick_var() [1/3]

Bparticle * particles_pick_var ( Bimage p,
long  avg_kernel,
long  var_kernel,
double  cutmin,
double  cutmax,
double  part_ori,
double  excl_dist,
long  bin 
)

◆ particles_pick_var() [2/3]

Bparticle * particles_pick_var ( Bimage p,
long  avg_kernel,
long  var_kernel,
double  nsig,
double  part_ori,
double  excl_dist,
long  bin 
)

Picks particles in variance map.

Parameters
*pimage to pick from.
avg_kernelaveraging kernel size.
var_kernelvariance kernel size.
nsigmultiple of sigma above variance average to accept peaks.
part_oriparticle origin.
excl_distminimum distance between particles.
binlevel of image binning.
Returns
Bparticle* list of particles.
A copy of the micrograph is filtered with an averaging kernel
and a variance map calculated. The variance map is then used to
find high variance peaks as candidate locations for particles.

◆ particles_pick_var() [3/3]

Bparticle * particles_pick_var ( Bstring filename,
long  img_num,
long  avg_kernel,
long  var_kernel,
double  nsig,
double  part_ori,
double  excl_dist,
long  bin 
)

Picks particles in variance map.

Parameters
&filenameimage to pick from.
img_numsub-image number.
avg_kernelaveraging kernel size.
var_kernelvariance kernel size.
nsigmultiple of sigma above variance average to accept peaks.
part_oriparticle origin.
excl_distminimum distance between particles.
binlevel of image binning.
Returns
Bparticle* list of particles.
A copy of the micrograph is filtered with an averaging kernel
and a variance map calculated. The variance map is then used to
find high variance peaks as candidate locations for particles.

◆ project_extract_orient_particles()

double project_extract_orient_particles ( Bproject project,
Bstring tempfile,
Bsymmetry sym,
double  hires,
double  lores,
long  bin 
)

Picks particles using cross-correlation.

Parameters
*projectproject parameter structure.
&tempfiletemplate image.
sympoint group symmetry.
hireshigh resolution limit.
loreslow resolution limit.
binlevel of image binning.
Returns
double minimum threshold used to accept peaks.
Each micrograph is cross-correlated with the template image including
bandpass filtering and frequency space masking.

◆ project_pick_background()

long project_pick_background ( Bproject project,
long  number,
long  avg_kernel,
long  var_kernel,
double  excl_dist 
)

Picks background areas not overlapping existing particles.

Parameters
*projectproject parameter structure.
numbermaximum number of background images to pick.
avg_kernelaveraging kernel to smooth the image.
var_kernelkernel to calculate a local variance image.
excl_distexclusion distance between areas.
Returns
long number of background areas.

◆ project_pick_particles() [1/3]

double project_pick_particles ( Bproject project,
Bimage ptemp,
Bimage pmask,
double  hires,
double  lores,
double  fommin,
double  fommax,
double  excl_dist,
long  bin 
)

Picks particles using cross-correlation.

Parameters
*projectproject parameter structure.
*ptemptemplate image.
*pmaskfrequency space mask.
hireshigh resolution limit.
loreslow resolution limit.
fomminminimum FOM cutoff.
fommaxmaximum FOM cutoff.
excl_distminimum distance between particles.
binlevel of image binning.
Returns
double minimum threshold used to accept peaks.
Each micrograph is cross-correlated with the template image including
bandpass filtering and frequency space masking.

◆ project_pick_particles() [2/3]

long project_pick_particles ( Bproject project,
double  din,
double  dout,
int  avg_kernel,
double  ainc,
int  flags,
int  contrast 
)

Locates particles using a fore/background difference measure.

Parameters
*projectproject parameter structure.
dininner diameter corresponding to particle edge.
doutouter diameter corresponding to background.
avg_kernelaveraging kernle to smooth difference map.
aincangular increment.
flagsflags: bit 1 = filter extremes.
contrastcontrast direction (foreground: white=1, black=0).
Returns
long number of particles.
Two marker sets are generated at the indicated diameters.
At each pixel, the marker sets are used to calculate a difference
between the foreground and background as an estimate of the
presence of a particle.

◆ project_pick_particles() [3/3]

double project_pick_particles ( Bproject project,
long  avg_kernel,
long  var_kernel,
double  nsig,
double  part_ori,
double  excl_dist,
long  bin 
)

Picks particles in variance map.

Parameters
*projectproject parameter structure.
avg_kernelaveraging kernel size.
var_kernelvariance kernel size.
nsigmultiple of sigma above variance average to accept peaks.
part_oriparticle origin.
excl_distminimum distance between particles.
binlevel of image binning.
Returns
double minimum threshold used to accept peaks.
A copy of the micrograph is filtered with an averaging kernel
and a variance map calculated. The variance map is then used to
find high variance peaks as candidate locations for particles.

◆ project_pick_sym_axis()

long project_pick_sym_axis ( Bproject project,
Bsymmetry sym,
int  sym_axis,
double  axis_dist 
)

Picks subregions in 3D particles on the given symmetry axis.

Parameters
*projectparameter structure with all parameters.
sympoint group symmetry.
sym_axissymmetry axis to pick subregions.
axis_distdistance along symmetry axis.
Returns
long number of new particles.
The existing particles are replaced by the new particles.

◆ rec_extract_orient_particles()

long rec_extract_orient_particles ( Breconstruction rec,
Bimage ptemp,
double  hires,
double  lores,
long  bin,
fft_plan  planf,
fft_plan  planb 
)

◆ rec_pick_background()

double rec_pick_background ( Breconstruction rec,
Bimage p,
long  number,
long  avg_kernel,
long  var_kernel,
double  excl_dist 
)

Variable Documentation

◆ verbose

int verbose
extern