| Bsoft 2.0.5 Bernard's software package

Functions | Variables
mg_extract.cpp File Reference

Functions to extract particles from micrographs. More...

`#include "mg_extract.h"`
`#include "linked_list.h"`
`#include "spline.h"`
`#include "utilities.h"`
`#include <sys/stat.h>`

Go to the source code of this file.

## Functions
int | mask_filament_particles (Bstring &filename, Bparticle *partlist, int mask_width)
int | rotate_mask_filament_particles (Bstring &filename, Bparticle *partlist, int rotation_axis, int back_flag, int mask_width)
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...
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. More...
Bimage * | micrograph_extract_gold (Bmicrograph *mg, Bimage *p, double radius)
| Extracts gold particle images from a micrograph. More...
Bimage * | reconstruction_extract_gold (Breconstruction *rec, Bimage *p, double radius)
| Extracts gold particle images from a reconstruction. More...
Bimage * | marker_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...
Bimage * | filament_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...
Bparticle * | filaments_to_particles (Bfilament *filaments, 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...

## Variables
int | verbose

## Detailed Description

Functions to extract particles from micrographs.

Author
  Bernard Heymann

Date
  Created: 20040406
  Modified: 20191001

Definition in file mg_extract.cpp.

## Function Documentation

## ◆ filament_extract()

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

Extracts filament images from a micrograph.

Parameters

  *filaments | filament parameters.
  *p | image.
  width | width of box around filament to extract.
  axis | helical 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)

Definition at line 842 of file mg_extract.cpp.

## ◆ filament_setup_filenames()

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

Sets up individual filament file names for extraction.

Parameters

  *fil | filament list.
  filename | filament file name base.
  filpath | filament 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.

Definition at line 85 of file mg_extract.cpp.

## ◆ filaments_to_particles()

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

Converts filaments to sets of particles.

Parameters

  *filaments | filament parameters.
  pixel_size | sampling.
  box_size | size of particle box.
  boxing_interval | step size between boxes.
  rise | rise per asymmetric unit in angstrom.
  angle | angular 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.

Definition at line 1021 of file mg_extract.cpp.

## ◆ 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_list | marker parameters.
  *p | image.
  img_num | sub-image number.
  radius | radius of gold particle.

Returns
  Bimage* multi-particle image.

Definition at line 610 of file mg_extract.cpp.

## ◆ mask_filament_particles()

int mask_filament_particles | ( | Bstring & | filename,
|  | Bparticle * | partlist,
|  | int | mask_width
| ) |  |

Definition at line 1162 of file mg_extract.cpp.

## ◆ micrograph_extract_filaments()

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

Extracts filament images from a micrograph.

Parameters

  *mg | micrograph parameters.
  *p | micrograph image.
  width | width of box around filament to extract.
  axis | helical axis alignment: x=1, y=2, z=3.

Returns
  long number of filaments.

Definition at line 783 of file mg_extract.cpp.

## ◆ micrograph_extract_gold()

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

Extracts gold particle images from a micrograph.

Parameters

  *mg | micrograph parameters.
  *p | micrograph image.
  radius | radius of gold particle.

Returns
  Bimage* multi-particle image.

Definition at line 573 of file mg_extract.cpp.

## ◆ 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

  *mg | micrograph parameters.
  *p | micrograph image.
  scale | scale to extract (usually 1).
  back_flag | background correction flag.
  norm_flag | normalization flag.
  fill | value to fill in new regions.
  mask_width | filament mask width, if 0, don't apply.

Returns
  long number of particles.

Definition at line 332 of file mg_extract.cpp.

## ◆ 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

  *mg | micrograph parameters.
  box_size | size of particle box.
  boxing_interval | step size between boxes.
  rise | rise per asymmetric unit in angstrom.
  angle | angular 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.

Definition at line 948 of file mg_extract.cpp.

## ◆ 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

  *particles | particle parameters.
  *bad_areas | bad area parameters.
  *p | image.
  size | size of box to extract.
  scale | scale to extract (usually 1).
  bad_radius | radius of bad area.
  back_flag | background correction flag.
  norm_flag | normalization flag.
  fill | value to fill in new regions.
  mask_width | filament 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.

Definition at line 403 of file mg_extract.cpp.

## ◆ particle_setup_filenames()

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

Sets up individual particle file names for extraction.

Parameters

  *part | particle list.
  filename | particle file name base.
  partpath | particle 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.

Definition at line 35 of file mg_extract.cpp.

## ◆ 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

  *project | micrograph project.
  filament_width | extracted filament width.
  axis | helical axis alignment: x=1, y=2, z=3.
  &base | file name base.
  &path | path to filament file.
  &ext | filament file extension.
  split | flag to split filaments into individual files.

Returns
  long number of filaments, <0 on error.

Definition at line 674 of file mg_extract.cpp.

## ◆ 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

  *project | micrograph project.
  scale | scale to extract (usually 1).
  back_flag | background correction flag.
  norm_flag | normalization flag.
  fill_type | FILL_AVERAGE, FILL_BACKGROUND, FILL_USER.
  fill | value to fill in new regions.
  mask_width | filament mask width, if 0, don't apply.
  split | flag to split images into separate files.
  &partbase | file name base.
  &partpath | path to particle file.
  &partext | particle file extension.

Returns
  long number of particles, <0 on error.

Definition at line 160 of file mg_extract.cpp.

## ◆ 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

  *project | project parameters.
  box_size | size of particle box.
  boxing_interval | step size between boxes.
  rise | rise per asymmetric unit in angstrom.
  angle | angular 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.

Definition at line 914 of file mg_extract.cpp.

## ◆ project_mask_filament_particles()

int project_mask_filament_particles | ( | Bproject * | project,
|  | int | mask_width
| ) |  |

Masks particles extracted from filaments.

Parameters

  *project | project parameters.
  mask_width | width 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.

Definition at line 1083 of file mg_extract.cpp.

## ◆ 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

  *project | project parameters.
  rotation_axis | axis to rotate to: 1=x, 2=y, 3=z.
  back_flag | background correction flag.
  mask_width | width 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.

Definition at line 1115 of file mg_extract.cpp.

## ◆ reconstruction_extract_filaments()

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

Extracts filament images from a micrograph.

Parameters

  *rec | reconstruction parameters.
  *p | reconstruction image.
  width | width of box around filament to extract.
  axis | helical axis alignment: x=1, y=2, z=3.

Returns
  long number of filaments.

Definition at line 809 of file mg_extract.cpp.

## ◆ reconstruction_extract_gold()

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

Extracts gold particle images from a reconstruction.

Parameters

  *rec | reconstruction parameters.
  *p | reconstruction image.
  radius | radius of gold particle.

Returns
  Bimage* multi-particle image.

Definition at line 591 of file mg_extract.cpp.

## ◆ 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

  *rec | reconstruction parameters.
  *p | micrograph image.
  scale | scale to extract (usually 1).
  back_flag | background correction flag.
  norm_flag | normalization flag.
  fill | value to fill in new regions.
  mask_width | filament mask width, if 0, don't apply.

Returns
  long number of particles.

Definition at line 363 of file mg_extract.cpp.

## ◆ 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

  *rec | reconstruction parameters.
  box_size | size of particle box.
  boxing_interval | step size between boxes.
  rise | rise per asymmetric unit in angstrom.
  angle | angular 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.

Definition at line 984 of file mg_extract.cpp.

## ◆ rotate_mask_filament_particles()

int rotate_mask_filament_particles | ( | Bstring & | filename,
|  | Bparticle * | partlist,
|  | int | rotation_axis,
|  | int | back_flag,
|  | int | mask_width
| ) |  |

Definition at line 1213 of file mg_extract.cpp.

## ◆ 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

  *fnode | node list.
  &nspline | number 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.

Definition at line 127 of file mg_extract.cpp.

## Variable Documentation

## ◆ verbose

int verbose