| Bsoft 2.0.5 Bernard's software package

Functions
mg_img_proc.h File Reference

Header file for image processing from micrograph structures. More...

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

Go to the source code of this file.

## Functions
Bstring | image_type (Bstring type)
| Converts an image type string to a standard form. More...
Bproject * | project_create_from_image (Bimage *p, Bstring type)
| Creates a project structure using image file names. More...
Bproject * | project_create_from_images (Bstring *file_list, Bstring type)
| Creates a project structure using image file names. More...
Bimage * | particle_read_img (Bparticle *part, int readflag)
| Reads a particle image file. More...
int | particle_write_img (Bparticle *part, Bimage *p, int compression)
| Writes a particle image file. More...
int | project_check_particles (Bproject *project)
| Checks particle numbers and box sizes. More...
Vector3< long > | micrograph_get_size (Bmicrograph *mg)
| Gets the size of a micrograph. More...
Vector3< double > | micrograph_get_nominal_origin (Bmicrograph *mg)
| Gets the nominal origin for a micrograph. More...
int | project_set_nominal_mg_origins (Bproject *project)
| Sets micrograph origins to the centers of the micrographs. More...
int | project_reset_origins (Bproject *project)
| Resets particle origins to nominal values. More...
int | project_set_part_img_origins (Bproject *project)
| Writes particle origins into particle image files. More...
long | project_delesect_edge_particles (Bproject *project)
| Deselects particles that are too close to the image edges. More...
int | project_get_part_box_size (Bproject *project)
| Gets the box size from particle image files. More...
Vector3< long > | particle_get_box_size (Bparticle *part)
| Gets the box size from particle image file. More...
int | project_write_particle_classes (Bproject *project)
| Writes particles to different stacks based on class. More...
int | project_trim_class_averages (Bproject *project, Bstring &list)
| Deletes selected class averages from the project.. More...
int | project_flip_particle_coordinates (Bproject *project, int flip)
| Reverses one or more particle coordinates. More...
int | project_set_views_from_images (Bproject *project)
| Gets views from particle images. More...
int | project_set_views_in_images (Bproject *project)
| Sets views in particle images from the project parameter structure. More...
int | project_bin_micrographs (Bproject *project, int bin, Bstring mgpath, Bstring partpath)
| Bins all micrographs a project. More...
int | project_change_pixel_size (Bproject *project, double new_pixel_size, Bstring mgpath, Bstring partpath)
| Changes all the micrograph fields linked to the pixel size. More...

## Detailed Description

Header file for image processing from micrograph structures.

Author
  Bernard Heymann

Date
  Created: 20000426
  Modified: 20180507

Definition in file mg_img_proc.h.

## Function Documentation

## ◆ image_type()

Bstring image_type | ( | Bstring | type | ) |

Converts an image type string to a standard form.

Parameters

  type | a string with a type definition.

Returns
  Bstring standard type definition.

      The input string is converted to the following strings:
      mg      micrograph
      frame   micrograph frames
      rec     reconstruction
      part    particle
      fil     filament
      ps      power spectrum
      ft      Fourier transform

Definition at line 36 of file mg_img_proc.cpp.

## ◆ micrograph_get_nominal_origin()

Vector3<double> micrograph_get_nominal_origin | ( | Bmicrograph * | mg | ) |

Gets the nominal origin for a micrograph.

Parameters

  *mg | micrograph parameter structure.

Returns
  Vector3<double> nominal origin.

      The nominal origin is defined as the center of the micrograph.

Definition at line 631 of file mg_img_proc.cpp.

## ◆ micrograph_get_size()

Vector3<long> micrograph_get_size | ( | Bmicrograph * | mg | ) |

Gets the size of a micrograph.

Parameters

  *mg | micrograph parameter structure.

Returns
  Vector3<long> size.

      The micrograph image header is read.

Definition at line 602 of file mg_img_proc.cpp.

## ◆ particle_get_box_size()

Vector3<long> particle_get_box_size | ( | Bparticle * | part | ) |

Gets the box size from particle image file.

Parameters

  *part | particle.

Returns
  Vector3<long> box size (0 if image does not exist).

      Reads the particle file header and returns the box size.

Definition at line 827 of file mg_img_proc.cpp.

## ◆ particle_read_img()

Bimage* particle_read_img | ( | Bparticle * | part,
|  | int | readflag
| ) |  |

Reads a particle image file.

Parameters

  *part | particle.
  readflag | flag to indicate reading the data.

Returns
  Bimage* image (NULL means failure).

      The file name is taken from the particle record by preference,
      otherwise from the micrograph record.

Definition at line 463 of file mg_img_proc.cpp.

## ◆ particle_write_img()

int particle_write_img | ( | Bparticle * | part,
|  | Bimage * | p,
|  | int | compression
| ) |  |

Writes a particle image file.

Parameters

  *part | particle.
  *p | image to be written.
  compression | flag to indicate compression.

Returns
  int images written.

      The file name is taken from the particle record by preference,
      otherwise from the micrograph record.

Definition at line 509 of file mg_img_proc.cpp.

## ◆ project_bin_micrographs()

int project_bin_micrographs | ( | Bproject * | project,
|  | int | bin,
|  | Bstring | mgpath,
|  | Bstring | partpath
| ) |  |

Bins all micrographs a project.

Parameters

  *project | project parameter structure.
  bin | binning value.
  mgpath | binned micrograph path (must be allocated).
  partpath | binned particle path (must be allocated).

Returns
  int 0.

      All micrographs in a project are binned by the indicated value.
      New micrograph file names are generated with a "_b<n>" insert,
      where the n indicates the bin value.
      The path to the binned micrograph can be specified.

Definition at line 1383 of file mg_img_proc.cpp.

## ◆ project_change_pixel_size()

int project_change_pixel_size | ( | Bproject * | project,
|  | double | new_pixel_size,
|  | Bstring | mgpath,
|  | Bstring | partpath
| ) |  |

Changes all the micrograph fields linked to the pixel size.

Parameters

  *project | project parameter structure.
  new_pixel_size | new pixel size.
  mgpath | binned micrograph path (must be allocated).
  partpath | binned particle path (must be allocated).

Returns
  int 0.

      The fields linked to pixel size are:
          pixel_size
          shift
          box, bad and marker radii
          particle origins and locations
          bad area and marker locations

Definition at line 1414 of file mg_img_proc.cpp.

## ◆ project_check_particles()

int project_check_particles | ( | Bproject * | project | ) |

Checks particle numbers and box sizes.

Parameters

  *project | project.

Returns
  int error code (<0 means failure).

      Reads each particle file header, checks the number of particles
      and sets the box size for the micrograph.

Definition at line 548 of file mg_img_proc.cpp.

## ◆ project_create_from_image()

Bproject* project_create_from_image | ( | Bimage * | p,
|  | Bstring | type
| ) |  |

Creates a project structure using image file names.

Parameters

  *p | list of images.
  type | type of images: mg, frame, rec, part, fil.

Returns
  Bproject* new project parameter structure.

      The function sets up the project hierarchy from a list of file names.
      Each file may represent a micrograph or a picked particle file.
      If the image is equal or larger than 1024x1024, it is assumed to be
      a micrograph, its name will be assigned as a micrograph
      file name, and no particle tags will be added.
      If the image is smaller than 1024x1024 or the make_part flag is set,
      it is taken to be picked particles and the file name will
      be assigned as a particle file name.

Definition at line 67 of file mg_img_proc.cpp.

## ◆ project_create_from_images()

Bproject* project_create_from_images | ( | Bstring * | file_list,
|  | Bstring | type
| ) |  |

Creates a project structure using image file names.

Parameters

  *file_list | list of file names.
  type | type of images: mg, frame, rec, part, fil.

Returns
  Bproject* new project parameter structure.

      The function sets up the project hierarchy from a list of file names.
      Each file may represent a micrograph or a picked particle file.
      If the image is equal or larger than 1024x1024, it is assumed to be
      a micrograph, its name will be assigned as a micrograph
      file name, and no particle tags will be added.
      If the image is smaller than 1024x1024 or the make_part flag is set,
      it is taken to be picked particles and the file name will
      be assigned as a particle file name.

Definition at line 224 of file mg_img_proc.cpp.

## ◆ project_delesect_edge_particles()

long project_delesect_edge_particles | ( | Bproject * | project | ) |

Deselects particles that are too close to the image edges.

Parameters

  *project | project.

Returns
  long number of particles selected.

Definition at line 757 of file mg_img_proc.cpp.

## ◆ project_flip_particle_coordinates()

int project_flip_particle_coordinates | ( | Bproject * | project,
|  | int | flip
| ) |  |

Reverses one or more particle coordinates.

Parameters

  *project | project parameter structure.
  flip | axes to flip.

Returns
  int 0.

      The specification of axes to flip is embedded in the flip number:
          first bit  - x
          second bit - y
          third bit  - z

Definition at line 970 of file mg_img_proc.cpp.

## ◆ project_get_part_box_size()

int project_get_part_box_size | ( | Bproject * | project | ) |

Gets the box size from particle image files.

Parameters

  *project | project.

Returns
  int error code (<0 means failure).

      Reads each particle file header and sets the box size for the micrograph.

Definition at line 794 of file mg_img_proc.cpp.

## ◆ project_reset_origins()

int project_reset_origins | ( | Bproject * | project | ) |

Resets particle origins to nominal values.

Parameters

  *project | project parameter structure.

Returns
  int 0.

      For each micrograph a particle image header is read and the origin
      is set to to the middle of the image.

Definition at line 690 of file mg_img_proc.cpp.

## ◆ project_set_nominal_mg_origins()

int project_set_nominal_mg_origins | ( | Bproject * | project | ) |

Sets micrograph origins to the centers of the micrographs.

Parameters

  *project | project parameter structure.

Returns
  int 0.

      For each micrograph the micrograph origin is set to the center.

Definition at line 660 of file mg_img_proc.cpp.

## ◆ project_set_part_img_origins()

int project_set_part_img_origins | ( | Bproject * | project | ) |

Writes particle origins into particle image files.

Author
  D. Belnap

Parameters

  *project | project.

Returns
  int error code (<0 means failure).

      Sets the origins (offsets from the first voxel) in an image header to
      values set within a project.  Rewrites image to file.

Definition at line 729 of file mg_img_proc.cpp.

## ◆ project_set_views_from_images()

int project_set_views_from_images | ( | Bproject * | project | ) |

Gets views from particle images.

Parameters

  *project | project parameter structure.

Returns
  int 0.

Definition at line 1033 of file mg_img_proc.cpp.

## ◆ project_set_views_in_images()

int project_set_views_in_images | ( | Bproject * | project | ) |

Sets views in particle images from the project parameter structure.

Parameters

  *project | project parameter structure.

Returns
  int 0.

Definition at line 1082 of file mg_img_proc.cpp.

## ◆ project_trim_class_averages()

int project_trim_class_averages | ( | Bproject * | project,
|  | Bstring & | list
| ) |  |

Deletes selected class averages from the project..

Parameters

  *project | project parameter structure.
  &list | selection list.

Returns
  int 0.

      The new class average file name has an insert of "_del".

Definition at line 919 of file mg_img_proc.cpp.

## ◆ project_write_particle_classes()

int project_write_particle_classes | ( | Bproject * | project | ) |

Writes particles to different stacks based on class.

Parameters

  *project | project.

Returns
  int error code (<0 means failure).

      Writes new particle image files, numbered by the selection number.

Definition at line 849 of file mg_img_proc.cpp.