/Users/bernard/b20/bsoft/src/mg/mg_tomo_rec.cpp(3)

NAME
/Users/bernard/b20/bsoft/src/mg/mg_tomo_rec.cpp - Functions to do a tomographic reconstruction.

SYNOPSIS

#include 'mg_tomo_rec.h'
#include 'mg_reconstruct.h'
#include 'mg_tomography.h'
#include 'mg_ctf.h'
#include 'Complex.h'
#include 'linked_list.h'
#include 'utilities.h'
#include 'timer.h'
#include <fstream>
#include <sys/stat.h>

  Functions
int img_backtransform_z_lines (fstream *ftemp, Bimage *p)
int img_write_data_block_with_type (fstream *ftemp, Bimage *p, double avg, double std, double cutmin, double cutmax)
Bimage * mg_tomo_rec_prepare (Bmicrograph *mg, int ft_size, long thickness, double edge_width, double marker_radius, int fill_type, double fill, int action, double wiener, Vector3< long > tile_size, fft_plan plan)
Bimage * project_tomo_reconstruct (Bproject *project, double hi_res, double scale, Vector3< long > size, int interp_type, int pad_factor, double edge_width, double marker_radius, int fill_type, double fill, int action, double wiener)
Reciprocal space reconstruction from the images in a multi-image file.
Bimage * project_fourier_reconstruction_slab (Bproject *project, double hi_res, double scale, Vector3< long > size, int slab_start, int slab_end, double marker_radius, int fill_type, double fill, int action, double wiener)
Reciprocal space reconstruction from the images in a multi-image file.
long particle_tomo_reconstruct (Bproject *project, Bparticle *recpart, Vector3< long > recsize, double resolution, int interp_type, long ft_size, double scale, fft_plan planp, fft_plan planr, int ctf_action, double wiener, Bsymmetry *sym, Bstring &partbase, Bstring &partpath, Bstring &partext)
Reconstructs individual particles from a tilt series.
long project_tomo_reconstruct_particles (Bproject *project, double resolution, int interp_type, int pad_factor, int ctf_action, double wiener, Bsymmetry *sym, Bstring &partbase, Bstring &partpath, Bstring &partext)
Reconstructs particles from a tilt series.
int img_backtransform_slices (Bimage *p)
Backtransforms 2D slices in a 3D volume.
long img_pack_2D_in_recip_space_slab (Bimage *p, Bimage *prec, long zsize, long slab_start, float *weight, float *weight2, double hi_res, Matrix3 mat, double scale)
Packs a 2D Fourier transform into a 3D reciprocal space volume.
int img_phase_shift_slab_to_origin (Bimage *p, int zsize, int slab_start)
Phase shifts a set of reflections to the image origin.
int img_clear_extraneous_areas (Bimage *p, double tilt_axis, double tilt_angle, long thickness)
Clears areas from a micrograph not used in a reconstruction.
int mg_fft_write (Bproject *project, Vector3< int > size, double scale, int pad_factor, Bstring &label, DataType datatype, double marker_radius, int fill_type, double fill)
Fourier transform micrographs and write to disk.
Bimage * img_extract_ytile (Bstring *file_list, int ystart, int ysize)
Extracts a tile from the image with limits in y.
Bimage * img_backtransform_z_on_disk (Bstring *file_list, Bstring &recfile, DataType datatype, Bstring &label, double avg, double std, double cutmin, double cutmax)
The lines along the z-dimensions of a disk-based block is Fourier back-transformed.
int img_backtransform_one_y_plane (Bimage *p, fft_plan plan, int y)
int img_backtransform_one_y_plane (fstream *ftemp, Bimage *p, fft_plan plan, int y, Complex< float > *zline, Complex< float > *cfdata)
int img_backtransform_z_lines (Bimage *p)
The lines along the z-dimensions of a disk-based block is Fourier back-transformed.
long gettypesize (DataType type)
Get the size of a datatype.
int set_value_with_datatype (char *ptr, double value, DataType datatype)
Set a pointer to a value with a given data type.
Bimage * project_missing_mask (Bproject *project, Vector3< long > size, Vector3< double > origin, double hi_res, double scale)
Creates a reciprocal space mask from the tilt series orientations.

  Variables
int verbose

Detailed Description

Functions to do a tomographic reconstruction.

Author:
    Bernard Heymann

Date:
    Created: 20020416

    Modified: 20181221

Definition in file mg_tomo_rec.cpp.

Function Documentation

  long gettypesize (DataType type)

Get the size of a datatype.

This function is used for calculating image data sizes for allocating
memory and reading the data.

Parameters:
    type data type (defined in rwimg.h).

Returns:
    long size of data type, if < 0 the data type is not supported.

Definition at line 1407 of file mg_tomo_rec.cpp.

  int img_backtransform_one_y_plane (Bimage * p, fft_plan plan, int y)

Definition at line 1263 of file mg_tomo_rec.cpp.

  int img_backtransform_one_y_plane (fstream * ftemp, Bimage * p, fft_plan plan, int y, Complex< float > * zline, Complex< float > * cfdata)

Definition at line 1283 of file mg_tomo_rec.cpp.

  int img_backtransform_slices (Bimage * p)

Backtransforms 2D slices in a 3D volume.

Parameters:
    *p 3D complex volume.

Returns:
    int 0.

    Each slice is extracted, backtransformed and copied back into the
    original volume.
    Note: The phases are now not hermitian any more.

Definition at line 731 of file mg_tomo_rec.cpp.

  int img_backtransform_z_lines (fstream * ftemp, Bimage * p)

Definition at line 1362 of file mg_tomo_rec.cpp.

  int img_backtransform_z_lines (Bimage * p)

The lines along the z-dimensions of a disk-based block is Fourier back-transformed.

Parameters:
    *p image header information (statistics updated).

Returns:
    int 0.

    Each 2D xz plane is read from the raw complex data block.
    Each z-line in the plane is back-transformed.
    The transformed 2D plane is written back into the raw data block.

Definition at line 1334 of file mg_tomo_rec.cpp.

  Bimage* img_backtransform_z_on_disk (Bstring * file_list, Bstring & recfile, DataType datatype, Bstring & label, double avg, double std, double cutmin, double cutmax)

The lines along the z-dimensions of a disk-based block is Fourier back-transformed.

Parameters:
    *file_list list of image file names.
    &recfile new reconstruction file name.
    datatype data type for new reconstruction file.
    &label command line string.
    avg target average.
    std target standard deviation.
    cutmin minimum for truncation.
    cutmax maximum for truncation.

Returns:
    int 0.

    Each 2D xz plane is read from the raw complex data block.
    Each z-line in the plane is back-transformed.
    The transformed 2D plane is written back into the raw data block.

Definition at line 1184 of file mg_tomo_rec.cpp.

  int img_clear_extraneous_areas (Bimage * p, double tilt_axis, double tilt_angle, long thickness)

Clears areas from a micrograph not used in a reconstruction.

Parameters:
    *p micrograph parameter structure.
    tilt_axis micrograph tilt axis angle.
    tilt_angle micrograph tilt angle.
    thickness intended thickness of reconstruction.

Returns:
    int 0.

    The image origin must be set to that for the micrograph.

Definition at line 937 of file mg_tomo_rec.cpp.

  Bimage* img_extract_ytile (Bstring * file_list, int ystart, int ysize)

Extracts a tile from the image with limits in y.

Parameters:
    *file_list list of image file names.
    ystart first y index.
    ysize size in y.

Returns:
    Bimage* tile, NULL on failure.

    From a series of z-slab images, tiles are extracted from a defined start in y,
    and with a defined size in y.
    A file indicating the origins of the tiles, "y.tiles", is written to
    be used with bpatch to assemble the tiles.

Definition at line 1082 of file mg_tomo_rec.cpp.

  long img_pack_2D_in_recip_space_slab (Bimage * p, Bimage * prec, long zsize, long slab_start, float * weight, float * weight2, double hi_res, Matrix3 mat, double scale)

Packs a 2D Fourier transform into a 3D reciprocal space volume.

Parameters:
    *p 2D Fourier transform
    *prec 3D reciprocal space slab volume.
    zsize intentional z dimension of reconstruction.
    slab_start start of current slab.
    *weight weigth array.
    *weight2 weight squared array.
    hi_res high resolution limit.
    mat affine matrix.
    scale scale of reconstruction and particle magnification.

Returns:
    long 0.

    The rotation matrix is used to determine the plane in reciprocal space
    to which the 2D transform data is added. The map is assumed to be cubic
    and the 2D transform square. The real space 2D image must be supplied.
    This is then padded to more than twice its original size, fourier
    transformed, and packed into the 3D reciprocal space block.

Definition at line 782 of file mg_tomo_rec.cpp.

  int img_phase_shift_slab_to_origin (Bimage * p, int zsize, int slab_start)

Phase shifts a set of reflections to the image origin.

Parameters:
    *p complex image.
    zsize slab thickness.
    slab_start slab start.

Returns:
    int 0.

    A real space translation with wrapping is equivalent to phase shifting
    in reciprocal space. The phases are shifted based on the embedded
    sub-image origins.

Definition at line 891 of file mg_tomo_rec.cpp.

  int img_write_data_block_with_type (fstream * ftemp, Bimage * p, double avg, double std, double cutmin, double cutmax)

Definition at line 1498 of file mg_tomo_rec.cpp.

  int mg_fft_write (Bproject * project, Vector3< int > size, double scale, int pad_factor, Bstring & label, DataType datatype, double marker_radius, int fill_type, double fill)

Fourier transform micrographs and write to disk.

Parameters:
    *project image processing parameter structure.
    size intended reconstruction size.
    scale reconstruction scale.
    pad_factor factor that determines image padding.
    &label label to write into image.
    datatype datatype (default complex float).
    marker_radius flag to mask out markers.
    fill_type FILL_AVERAGE, FILL_BACKGROUND, FILL_USER
    fill value to paint markers.

Returns:
    Bimage* reconstruction, NULL on failure.

    Each micrograph is padded to a square size that has power of 2
    dimensions. The micrograph is transformed and the phases shifted
    to the origin.
    A pad factor of zero indicates use of original size.

Definition at line 986 of file mg_tomo_rec.cpp.

  Bimage* mg_tomo_rec_prepare (Bmicrograph * mg, int ft_size, long thickness, double edge_width, double marker_radius, int fill_type, double fill, int action, double wiener, Vector3< long > tile_size, fft_plan plan)

Definition at line 30 of file mg_tomo_rec.cpp.

  long particle_tomo_reconstruct (Bproject * project, Bparticle * recpart, Vector3< long > recsize, double resolution, int interp_type, long ft_size, double scale, fft_plan planp, fft_plan planr, int ctf_action, double wiener, Bsymmetry * sym, Bstring & partbase, Bstring & partpath, Bstring & partext)

Reconstructs individual particles from a tilt series.

Parameters:
    *project micrograph project.
    *recpart 3D particle within the project.
    recsize particle reconstructions ize
    resolution high resolution limit for reconstruction.
    interp_type interpolation type.
    ft_size 2D Fourier transform size.
    scale reconstruction scale.
    planp 2D Fourier transform plan.
    planr 3D Fourier transform plan.
    ctf_action flag to apply CTF to projections.
    wiener Wiener factor.
    *sym always C1.
    &partbase particle base name for new particle reconstructions.
    &partpath directory for new particle reconstructions.
    &partext extension of new reconstructions.

Returns:
    long number of particles.

    Requires the particles to be defined in all micrographs.
    The partbase, partpath and partext arguments can be left empty to
    use defaults.

Definition at line 518 of file mg_tomo_rec.cpp.

  Bimage* project_fourier_reconstruction_slab (Bproject * project, double hi_res, double scale, Vector3< long > size, int slab_start, int slab_end, double marker_radius, int fill_type, double fill, int action, double wiener)

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

Parameters:
    *project image processing parameter structure.
    hi_res high resolution limit.
    scale scale of reconstruction.
    size size of reconstruction.
    slab_start start of reconstruction slab.
    slab_end end of reconstruction slab.
    marker_radius flag and radius to mask out markers.
    fill_type FILL_AVERAGE, FILL_BACKGROUND, FILL_USER
    fill value to paint markers.
    action flag to apply CTF to projections.
    wiener Wiener factor.

Returns:
    Bimage* reconstruction, NULL on failure.

    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.

Definition at line 299 of file mg_tomo_rec.cpp.

  Bimage* project_missing_mask (Bproject * project, Vector3< long > size, Vector3< double > origin, double hi_res, double scale)

Creates a reciprocal space mask from the tilt series orientations.

Parameters:
    *project project parameter structure.
    size size of mask.
    origin origin of mask.
    hi_res high resolution limit.
    scale scale of mask.

Returns:
    Bimage* mask, NULL on failure.

    The orientation parameters of the micrographs must all be set.
    A 2D mask is overlayed onto the 3D image for each micrograph.

Definition at line 1594 of file mg_tomo_rec.cpp.

  Bimage* project_tomo_reconstruct (Bproject * project, double hi_res, double scale, Vector3< long > size, int interp_type, int pad_factor, double edge_width, double marker_radius, int fill_type, double fill, int action, double wiener)

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

Parameters:
    *project image processing parameter structure.
    hi_res high resolution limit.
    scale scale of reconstruction.
    size size of reconstruction.
    interp_type interpolation type.
    pad_factor factor that determines image padding.
    edge_width edge smoothing width for masks.
    marker_radius flag and radius to mask out markers.
    fill_type FILL_AVERAGE, FILL_BACKGROUND, FILL_USER
    fill value to paint markers.
    action flag to apply CTF to projections.
    wiener Wiener factor.

Returns:
    Bimage* reconstruction, NULL on failure.

    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.

Definition at line 113 of file mg_tomo_rec.cpp.

  long project_tomo_reconstruct_particles (Bproject * project, double resolution, int interp_type, int pad_factor, int ctf_action, double wiener, Bsymmetry * sym, Bstring & partbase, Bstring & partpath, Bstring & partext)

Reconstructs particles from a tilt series.

Parameters:
    *project micrograph project.
    resolution high resolution limit for reconstruction.
    interp_type interpolation type.
    pad_factor factor that determines image padding.
    ctf_action flag to apply CTF to projections.
    wiener Wiener factor.
    *sym point group symmetry.
    &partbase particle base name for new particle reconstructions.
    &partpath directory for new particle reconstructions.
    &partext extension of new reconstructions.

Returns:
    long number of particles.

    Requires the particles to be defined in all micrographs.
    The partbase, partpath and partext arguments can be left empty to
    use defaults.

Definition at line 604 of file mg_tomo_rec.cpp.

  int set_value_with_datatype (char * ptr, double value, DataType datatype)

Set a pointer to a value with a given data type.

A value is inserted into a given location with the given data type.
The size of the allocated memory is channels*typesize.

Parameters:
    *ptr pointer to location.
    value the value.
    datatype data type (defined in rwimg.h).

Returns:
    int 0, <0 on error.

Definition at line 1437 of file mg_tomo_rec.cpp.

Variable Documentation

  int verbose

Author

Generated automatically by Doxygen for Bsoft from the source code.