| Bsoft 2.0.5 Bernard's software package

Functions | Variables
mg_reconstruct.cpp File Reference

Functions for reconstruction. More...

`#include "rwimg.h"`
`#include "rwmg.h"`
`#include "mg_processing.h"`
`#include "mg_img_proc.h"`
`#include "mg_particle_select.h"`
`#include "mg_reconstruct.h"`
`#include "mg_ctf.h"`
`#include "Complex.h"`
`#include "symmetry.h"`
`#include "utilities.h"`
`#include <sys/stat.h>`
`#include <fcntl.h>`

Go to the source code of this file.

## Functions
int | part_ft_size (int xsize, double scale, int pad_factor)
| Sets the Fourier transform size for 2D particle images for reconstruction. More...
Bimage * | particle_reconstruct (Bparticle *partlist, Bsymmetry *sym, int sym_mode, double hi_res, double scale, Vector3< long > size, int ft_size, fft_plan plan, int interp_type, int ctf_action, double wiener, int twoD_flag, int bootstrap, int first)
| Reciprocal space reconstruction from 2D particle images. More...
Bparticle * | project_reconstruction_partlist (Bproject *project, int num_select, int bootstrap)
| List of particle images for reciprocal space reconstruction. More...
Bimage * | img_reconstruction_sum_weigh (Bimage **pacc, int imap, int nmaps, int maps_per_class, double hi_res)
| Combines and weighs a map from several partial maps and weight sets. More...
double | part_single_reconstruction (Bparticle *part, Vector3< long > size, Bimage *pmask, Bsymmetry *sym, double hi_res, double scale, int ft_size, fft_plan img_plan, fft_plan map_plan, double part_weight, int interp_type, CTFparam *mg_ctf, int ctf_action, double wiener, int flags)
long | project_single_particle_reconstruction (Bproject *project, Bstring &maskfile, Bsymmetry *sym, int num_select, double hi_res, double scale, Vector3< long > size, int pad_factor, int interp_type, int ctf_action, double wiener, int flags)
| Reciprocal space reconstruction from the images in a multi-image file. More...
Vector3< long > | project_set_reconstruction_size (Bproject *project, double scale, int twoD_flag)
| Sets the reconstruction size for reconstruction from 2D particle images. More...
int | project_configure_for_reconstruction (Bproject *project, Bstring classes, long &nmaps, long &nthreads)
| Sets up the particle selection for reconstruction. More...
Bimage * | project_reconstruct_2D (Bproject *project, int transform_output)
| Creates a 2D reconstruction from the images in a multi-image file. More...
Bparticle * | img_reconstruct_2D (long i, Bproject *project, Bimage *prec, double hires, fft_plan planf, fft_plan planb)
Bparticle * | img_reconstruct_2D_fspace (long i, Bproject *project, Bimage *prec, double hires, fft_plan planf, fft_plan planb)
Bimage * | project_reconstruct_2D_fast (Bproject *project)
Bimage * | project_reconstruct_3D (Bproject *project, long selnum, int calcfom, Vector3< long > size)
| Transforms 3D maps and calculates an average. More...
Bimage * | project_reconstruct_3D (Bproject *project, long selnum, Vector3< long > size, double resolution)
| Transforms 3D maps and calculates an average. More...
Bimage * | project_back_projection (Bproject *project, long num_select, Vector3< long > map_size, Vector3< double > sam, double scale, double resolution, fft_plan planf, fft_plan planb)
| Back projects a set of 2D images into a 3D volume. More...
Bimage * | img_backprojection_accumulate (Bimage **pacc, int imap, int nmaps, int nthreads)
| Accumulates multiple backprojections. More...

## Variables
int | verbose

## Detailed Description

Functions for reconstruction.

Author
  Bernard Heymann

Date
  Created: 20010403
  Modified: 20180726

Definition in file mg_reconstruct.cpp.

## Function Documentation

## ◆ img_backprojection_accumulate()

Bimage* img_backprojection_accumulate | ( | Bimage ** | pacc,
|  | int | imap,
|  | int | nmaps,
|  | int | nthreads
| ) |  |

Accumulates multiple backprojections.

Parameters

  **pacc | array of partial maps with linked weight maps.
  imap | which output map to weigh.
  nmaps | number of output maps (1,2,3).
  nthreads | number of threads per map (= number of partial maps).

Returns
  int 0.

Definition at line 1642 of file mg_reconstruct.cpp.

## ◆ img_reconstruct_2D()

Bparticle* img_reconstruct_2D | ( | long | i,
|  | Bproject * | project,
|  | Bimage * | prec,
|  | double | hires,
|  | fft_plan | planf,
|  | fft_plan | planb
| ) |  |

Definition at line 955 of file mg_reconstruct.cpp.

## ◆ img_reconstruct_2D_fspace()

Bparticle* img_reconstruct_2D_fspace | ( | long | i,
|  | Bproject * | project,
|  | Bimage * | prec,
|  | double | hires,
|  | fft_plan | planf,
|  | fft_plan | planb
| ) |  |

Definition at line 1019 of file mg_reconstruct.cpp.

## ◆ img_reconstruction_sum_weigh()

Bimage* img_reconstruction_sum_weigh | ( | Bimage ** | pacc,
|  | int | imap,
|  | int | nmaps,
|  | int | maps_per_class,
|  | double | hi_res
| ) |  |

Combines and weighs a map from several partial maps and weight sets.

Parameters

  **pacc | array of partial maps with linked weight maps.
  imap | which output map to weigh.
  nmaps | number of output maps (1,2,3).
  maps_per_class | number of threads per map (= number of partial maps).
  hi_res | high resolution limit.

Returns
  Bimage* weighed reconstruction with FOM block.

      The input is a set of partially integrated complex maps with associated
      weigths as follows:
          voxel power sums            FOM block of map.
          voxel weight sums           linked image.
          voxel weight squared sums   linked image FOM block.
      The partial sums are completed into corresponding blocks in three possible
      ways based on the value of imap and nmap:
          nmap    imap    result
          1       0       one map from all input maps
          2       0,1     one map from half of the input maps
          3       0       one map from all input maps
          3       1,2     one map from half of the input maps
      The total number of maps in the array is nclasses*nmaps.

Definition at line 315 of file mg_reconstruct.cpp.

## ◆ part_ft_size()

int part_ft_size | ( | int | xsize,
|  | double | scale,
|  | int | pad_factor
| ) |  |

Sets the Fourier transform size for 2D particle images for reconstruction.

Parameters

  xsize | size of x dimension.
  scale | scale of reconstruction.
  pad_factor | factor that determines image padding.

Returns
  int transform size.

      The reconstruction size must be set.

Definition at line 37 of file mg_reconstruct.cpp.

## ◆ part_single_reconstruction()

double part_single_reconstruction | ( | Bparticle * | part,
|  | Vector3< long > | size,
|  | Bimage * | pmask,
|  | Bsymmetry * | sym,
|  | double | hi_res,
|  | double | scale,
|  | int | ft_size,
|  | fft_plan | img_plan,
|  | fft_plan | map_plan,
|  | double | part_weight,
|  | int | interp_type,
|  | CTFparam * | mg_ctf,
|  | int | ctf_action,
|  | double | wiener,
|  | int | flags
| ) |  |

Definition at line 404 of file mg_reconstruct.cpp.

## ◆ particle_reconstruct()

Bimage* particle_reconstruct | ( | Bparticle * | partlist,
|  | Bsymmetry * | sym,
|  | int | sym_mode,
|  | double | hi_res,
|  | double | scale,
|  | Vector3< long > | size,
|  | int | ft_size,
|  | fft_plan | plan,
|  | int | interp_type,
|  | int | ctf_action,
|  | double | wiener,
|  | int | twoD_flag,
|  | int | bootstrap,
|  | int | first
| ) |  |

Reciprocal space reconstruction from 2D particle images.

Parameters

  *partlist | a list of 2D particle image parameters.
  *sym | point group symmetry.
  sym_mode | 0=apply symmetry, 1=C1, 2=random symmetry view
  hi_res | high resolution limit.
  scale | scale of reconstruction.
  size | size of reconstruction.
  ft_size | Fourier transform size.
  plan | Fourier transform plan.
  interp_type | interpolation type.
  ctf_action | flag to apply CTF to projections.
  wiener | Wiener factor.
  twoD_flag | doing a 2D reconstruction rather than 3D.
  bootstrap | flag to indicate a bootstrap reconstruction.
  first | flag to indicate the first thread.

Returns
  Bimage* 3D reconstructed map.

      The orientation parameters, view vector, angle of rotation and origin,
      must all be set. Each image is padded to at least two times its size
      and its Fourier transform packed into 3D reciprocal space.
      The figure-of-merit calculated for each reciprocal space voxel is:
                 sum(w*re)^2 + sum(w*im)^2
          FOM = ---------------------------
                sum(w)*sum(w*(re^2 + im^2))
      where
          re  real part
          im  imaginary part
          w   weight (inverse distance of image pixel to closest grid point)
      For voxels with only one data pixel contributing to it, FOM = 0.
      A bootstrap reconstruction uses the particle selection to weigh each
      selected particle.

Definition at line 99 of file mg_reconstruct.cpp.

## ◆ project_back_projection()

Bimage* project_back_projection | ( | Bproject * | project,
|  | long | num_select,
|  | Vector3< long > | map_size,
|  | Vector3< double > | sam,
|  | double | scale,
|  | double | resolution,
|  | fft_plan | planf,
|  | fft_plan | planb
| ) |  |

Back projects a set of 2D images into a 3D volume.

Parameters

  *project | image processing parameter structure.
  num_select | selection number from the selection column.
  map_size | 3-valued vector for the new map size.
  sam | 3-value vector for the voxel size in angstrom.
  scale | reconstruction scale.
  resolution | resolution for low-pass filtering.
  planf | 2D forward Fourier transform plan.
  planb | 2D backward Fourier transform plan.

Returns
  Bimage* the new 3D reconstruction map.

      All the information needed to do a 3D reconstruction is passed in through
      an image processing structure. The new 3D volume is initialized.
      Each sub-image in each particle file is read individually and
      back-projected within the new volume. The orientation parameters from
      the image processing structure is transferred to the sub-image
      structure in the 2D image before calling the function packing one
      image into the volume. The default origin is the center of the image.

Definition at line 1527 of file mg_reconstruct.cpp.

## ◆ project_configure_for_reconstruction()

int project_configure_for_reconstruction | ( | Bproject * | project,
|  | Bstring | classes,
|  | long & | nmaps,
|  | long & | nthreads
| ) |  |

Sets up the particle selection for reconstruction.

Parameters

  *project | project parameter structure.
  classes | string specifying classes to use.
  nmaps | number of maps per class (1,2,3).
  nthreads | number of threads per class (must be even if nmaps > 1).

Returns
  int number of classes.

      The classes are specified in a string of comma-separated numbers,
      also allowing hyphened ranges (e.g., "2,5-7,9").
      The selection numbers for the particles in the project are set to
      calculate partial maps so that there are nthread maps per class.
      Each such partial map will be calculated in its own thread and
      integrated with others from the same class afterwards.

Definition at line 693 of file mg_reconstruct.cpp.

## ◆ project_reconstruct_2D()

Bimage* project_reconstruct_2D | ( | Bproject * | project,
|  | int | transform_output
| ) |  |

Creates a 2D reconstruction from the images in a multi-image file.

Parameters

  *project | image processing parameter structure.
  transform_output | flag to output transformed images.

Returns
  Bimage* 2D reconstruction image.

      The angle of rotation and the x,y origins must already have been found
      and placed in the appropriate arrays within the Bproject structure.
      Each selected image is transformed, and then added to the reconstruction
      image corresponding to the original projection image chosen.
      If the transform_output flag is set, then the transformed images are written
      into a new image with a "_proj.spi" ending.

Definition at line 822 of file mg_reconstruct.cpp.

## ◆ project_reconstruct_2D_fast()

Bimage* project_reconstruct_2D_fast | ( | Bproject * | project | ) |

Definition at line 1132 of file mg_reconstruct.cpp.

## ◆ project_reconstruct_3D() [1/2]

Bimage* project_reconstruct_3D | ( | Bproject * | project,
|  | long | selnum,
|  | int | calcfom,
|  | Vector3< long > | size
| ) |  |

Transforms 3D maps and calculates an average.

Parameters

  *project | parameter structure with all parameters.
  selnum | selection number of reconstructions or particles.
  calcfom | flag to calculate FOM block (1=var, 2=std).
  size | size of particles to extract (only when extraction needed).

Returns
  Bimage* average map with FOM block defined.

      The orientations of the maps in the project must already be specified.
      Each map is transformed and added to an average map.
      A FOM block is optionally calculated with either the variance or
      standard deviation.

Definition at line 1235 of file mg_reconstruct.cpp.

## ◆ project_reconstruct_3D() [2/2]

Bimage* project_reconstruct_3D | ( | Bproject * | project,
|  | long | selnum,
|  | Vector3< long > | size,
|  | double | resolution
| ) |  |

Transforms 3D maps and calculates an average.

Parameters

  *project | parameter structure with all parameters.
  selnum | selection number of reconstructions or particles.
  size | size of particles to extract (only when extraction needed).
  resolution | maximum reconstruction resolution (in angstrom, default Nyquest).

Returns
  Bimage* average map with FOM block defined.

      The orientations of the maps in the project must already be specified.
      Each map is transformed and added to an average map.
      A FOM block is optionally calculated with either the variance or
      standard deviation.

Definition at line 1378 of file mg_reconstruct.cpp.

## ◆ project_reconstruction_partlist()

Bparticle* project_reconstruction_partlist | ( | Bproject * | project,
|  | int | num_select,
|  | int | bootstrap
| ) |  |

List of particle images for reciprocal space reconstruction.

Parameters

  *project | image processing parameter structure.
  num_select | selection number from the selection column.
  bootstrap | flag to indicate a bootstrap reconstruction.

Returns
  Bimage* 3D reconstructed map.

      An image is used in the reconstruction if its selection flag has been set.
      If the selection number is less than zero, all particles with selection flags
      greater than zero are used. If the selection number is zero or above, all
      particles with the selection flag set to the same number are used.
      A bootstrap reconstruction uses the particle selection to weigh each
      selected particle.

Definition at line 236 of file mg_reconstruct.cpp.

## ◆ project_set_reconstruction_size()

Vector3<long> project_set_reconstruction_size | ( | Bproject * | project,
|  | double | scale,
|  | int | twoD_flag
| ) |  |

Sets the reconstruction size for reconstruction from 2D particle images.

Parameters

  *project | project parameter structure.
  scale | scale of reconstruction.
  twoD_flag | doing a 2D reconstruction rather than 3D.

Returns
  Vector3<long> reconstruction size.

      The reconstruction size is set from the first particle image size found.

Definition at line 628 of file mg_reconstruct.cpp.

## ◆ project_single_particle_reconstruction()

long project_single_particle_reconstruction | ( | Bproject * | project,
|  | Bstring & | maskfile,
|  | Bsymmetry * | sym,
|  | int | num_select,
|  | double | hi_res,
|  | double | scale,
|  | Vector3< long > | size,
|  | int | pad_factor,
|  | int | interp_type,
|  | int | ctf_action,
|  | double | wiener,
|  | int | flags
| ) |  |

Reciprocal space reconstruction from the images in a multi-image file.

Parameters

  *project | image processing parameter structure.
  &maskfile | mask to determine density statistics.
  *sym | point group symmetry.
  num_select | selection number from the selection column.
  hi_res | high resolution limit.
  scale | scale of reconstruction.
  size | size of reconstruction.
  pad_factor | image padding factor.
  interp_type | interpolation type (provisional).
  ctf_action | flag to apply CTF to projections.
  wiener | Wiener factor.
  flags | option flags.

Returns
  long particles processed.

      The orientation parameters, view vector, angle of rotation and origin,
      must all be set. Each image is padded to at least two times its size
      and its Fourier transform packed into 3D reciprocal space.
      The figure-of-merit calculated for each reciprocal space voxel is:
                 sum(w*re)^2 + sum(w*im)^2
          FOM = ---------------------------
                sum(w)*sum(w*(re^2 + im^2))
      where
          re  real part
          im  imaginary part
          w   weight (inverse distance of image pixel to closest grid point)
      For voxels with only one data pixel contributing to it, FOM = 0.
      An image is used in the reconstruction if its selection flag has been set.
      If the selection number is less than zero, all particles with selection flags
      greater than zero are used. If the selection number is zero or above, all
      particles with the selection flag set to the same number are used.
      A bootstrap reconstruction uses the particle selection to weigh each
      selected particle.

Definition at line 489 of file mg_reconstruct.cpp.

## Variable Documentation

## ◆ verbose

int verbose