IMP logo

IMP::em::DensityMap Class Reference


Detailed Description

Class for handling density maps.

/note The location of a voxel is its center. That is important for sampling function as well as for functions like voxel2loc.

Inheritance diagram for IMP::em::DensityMap:

Inheritance graph
[legend]

Public Member Functions

void add (const DensityMap &other)
void calc_all_voxel2loc ()
 Calculates the coordinates that correspond to all voxels.
emreal calcRMS ()
 Calculates RMSD and mean of a map values are stored in the header.
void CreateVoidMap (const int &nx, const int &ny, const int &nz)
 Creates a new map with the given dimension.
 DensityMap (const DensityMap &other)
algebra::VectorD< 3 > get_centroid (emreal threshold=0.0) const
emreal * get_data () const
const DensityHeaderget_header () const
DensityHeaderget_header_writable ()
 Returns a pointer to the header of the map in a writable version.
std::string get_locations_string (float t)
emreal get_max_value () const
 Returns the the value of the voxel with the highest density.
emreal get_min_value () const
 Returns the the value of the voxel with the lowest density.
long get_number_of_voxels () const
algebra::VectorD< 3 > get_origin () const
Float get_spacing () const
 Updated the voxel size of the map.
algebra::VectorD< 3 > get_top () const
virtual std::string get_type_name () const
emreal get_value (long index) const
 Gets the value of the voxel at a given index.
emreal get_value (const algebra::VectorD< 3 > &point) const
emreal get_value (float x, float y, float z) const
 Gets the value of the voxel located at (x,y,z).
virtual ::IMP::VersionInfo get_version_info () const
float * get_x_loc () const
 Returns the x-location of the map.
float * get_y_loc () const
 Returns the y-location of the map.
float * get_z_loc () const
 Returns the z-location of the map.
bool is_normalized () const
bool is_part_of_volume (const algebra::VectorD< 3 > &v) const
 Checks whether a given point is in the grid the voxel of a given location.
bool is_part_of_volume (float x, float y, float z) const
 Checks whether a given point is in the grid the voxel of a given location.
bool is_xyz_ind_part_of_volume (int ix, int iy, int iz) const
long loc2voxel (const algebra::VectorD< 3 > &v) const
long loc2voxel (float x, float y, float z) const
 Calculate the voxel of a given location.
void multiply (float factor)
DensityMapoperator= (const DensityMap &other)
void pad (int nx, int ny, int nz, float val=0.0)
void reset_data (float value=0.0)
 Set the density voxels to some calue and reset the managment flags.
bool same_dimensions (const DensityMap &other) const
 Checks if two maps have the same dimensions.
bool same_origin (const DensityMap &other) const
 Checks if two maps have the same origin.
bool same_voxel_size (const DensityMap &other) const
 Checks if two maps have the same voxel size.
void set_origin (const IMP::algebra::VectorD< 3 > &v)
void set_origin (float x, float y, float z)
 Sets the origin of the header.
void set_value (float x, float y, float z, emreal value)
 Set the value of the voxel at a given index.
void set_value (long index, emreal value)
 Set the value of the voxel at a given index.
void std_normalize ()
 Normailze the density voxles according to standard deviation (stdv).
void update_voxel_size (float new_apix)
 Updated the voxel size of the map.
float voxel2loc (const int &index, int dim) const
 Calculate the location of a given voxel.
long xyz_ind2voxel (int x, int y, int z) const
 Calculate the voxel of a given xyz indexes.

Protected Member Functions

void allocated_data ()
void float2real (float *f_data, boost::scoped_array< emreal > &r_data)
void real2float (emreal *r_data, boost::scoped_array< float > &f_data)
void reset_voxel2loc ()
void update_header ()
 update the header values -- still in work

Protected Attributes

boost::scoped_array< emreal > data_
bool data_allocated_
DensityHeader header_
bool loc_calculated_
 true if the locations have already been computed
bool normalized_
bool rms_calculated_
boost::scoped_array< float > x_loc_
boost::scoped_array< float > y_loc_
boost::scoped_array< float > z_loc_

Friends

DensityMapread_map (const char *filename, MapReaderWriter &reader)
void write_map (DensityMap *m, const char *filename, MapReaderWriter &writer)

Related Functions

(Note that these are not member functions.)

double get_density (DensityMap *m, const algebra::VectorD< 3 > &v)
DensityMapget_transformed (DensityMap *in, const algebra::Transformation3D &tr)
DensityMapget_transformed (DensityMap *in, const algebra::Transformation3D &tr, double threshold)
DensityMapread_map (const char *filename)

Member Function Documentation

void IMP::em::DensityMap::add ( const DensityMap other  ) 

Sums two grids. The result is kept in the map. The two maps should have the same dimensions and the same voxelsize

Parameters:
[in] other the other map

void IMP::em::DensityMap::calc_all_voxel2loc (  ) 

Calculates the coordinates that correspond to all voxels.

Can be precomputed to make corr faster.

emreal IMP::em::DensityMap::calcRMS (  ) 

Calculates RMSD and mean of a map values are stored in the header.

The header stores whether map is normalized.

void IMP::em::DensityMap::CreateVoidMap ( const int &  nx,
const int &  ny,
const int &  nz 
)

Creates a new map with the given dimension.

param[in] nx x-dimension (voxels) param[in] ny y-dimension (voxels) param[in] nz z-dimension (voxels)

algebra::VectorD<3> IMP::em::DensityMap::get_centroid ( emreal  threshold = 0.0  )  const

Calculates the centroid of all the voxels with density above a given threshold

Parameters:
[in] threshold the input threshold

std::string IMP::em::DensityMap::get_locations_string ( float  t  ) 

Prints the locations of all of the voxels with value above a given threshold into the input stream.

Float IMP::em::DensityMap::get_spacing (  )  const

Updated the voxel size of the map.

Note:
Use update_voxel_size() to set the spacing value.

emreal IMP::em::DensityMap::get_value ( long  index  )  const

Gets the value of the voxel at a given index.

Parameters:
[in] index voxel number in physical sense, NOT logical

emreal IMP::em::DensityMap::get_value ( float  x,
float  y,
float  z 
) const

Gets the value of the voxel located at (x,y,z).

Parameters:
[in] x The position ( in angstroms) of the x coordinate
[in] y The position ( in angstroms) of the y coordinate
[in] z The position ( in angstroms) of the z coordinate
Returns:
the value of the voxel located at (x,y,z)
Exceptions:
IndexException The point is not covered by the grid.

float* IMP::em::DensityMap::get_x_loc (  )  const

Returns the x-location of the map.

Exceptions:
InvalidStateException The locations have not been calculated.

float* IMP::em::DensityMap::get_y_loc (  )  const

Returns the y-location of the map.

Exceptions:
InvalidStateException The locations have not been calculated.

float* IMP::em::DensityMap::get_z_loc (  )  const

Returns the z-location of the map.

Exceptions:
InvalidStateException The locations have not been calculated.

bool IMP::em::DensityMap::is_part_of_volume ( const algebra::VectorD< 3 > &  v  )  const

Checks whether a given point is in the grid the voxel of a given location.

Parameters:
[in] v The position ( in angstroms)
Returns:
true if the point is part of the grid, false otherwise.

bool IMP::em::DensityMap::is_part_of_volume ( float  x,
float  y,
float  z 
) const

Checks whether a given point is in the grid the voxel of a given location.

Parameters:
[in] x The position ( in angstroms) of the x coordinate
[in] y The position ( in angstroms) of the y coordinate
[in] z The position ( in angstroms) of the z coordinate
Returns:
true if the point is part of the grid, false otherwise.

long IMP::em::DensityMap::loc2voxel ( float  x,
float  y,
float  z 
) const

Calculate the voxel of a given location.

Parameters:
[in] x The position ( in angstroms) of the x coordinate
[in] y The position ( in angstroms) of the y coordinate
[in] z The position ( in angstroms) of the z coordinate
Exceptions:
IndexException The point is not covered by the grid.
Returns:
the voxel index of a given position. If the position is out of the boundaries of the map, the function returns -1.

void IMP::em::DensityMap::multiply ( float  factor  ) 

Multiply each voxel in the map by the input factor The result is kept in the map.

Parameters:
[in] factor the multiplication factor

void IMP::em::DensityMap::pad ( int  nx,
int  ny,
int  nz,
float  val = 0.0 
)

Increase the dimension of the map The function pads zeros to the right-upper section on the map. The original content of the map will be in the lower XYZ part of the map

Parameters:
[in] nx the number of voxels on the X axis
[in] ny the number of voxels on the Y axis
[in] nz the number of voxels on the Z axis
[in] val all additional voxels will have this value
Exceptions:
if the input x/y/z voxels is smaller than the one currently in the map

void IMP::em::DensityMap::reset_data ( float  value = 0.0  ) 

Set the density voxels to some calue and reset the managment flags.

Parameters:
[in] value all of the density voxels will have this value

bool IMP::em::DensityMap::same_dimensions ( const DensityMap other  )  const

Checks if two maps have the same dimensions.

Parameters:
[in] other the map to compare with
Returns:
true if the two maps have the same dimensions

bool IMP::em::DensityMap::same_origin ( const DensityMap other  )  const

Checks if two maps have the same origin.

Parameters:
[in] other the map to compare with
Returns:
true if the two maps have the same origin

bool IMP::em::DensityMap::same_voxel_size ( const DensityMap other  )  const

Checks if two maps have the same voxel size.

Parameters:
[in] other the map to compare with
Returns:
true if the two maps have the same voxel size

void IMP::em::DensityMap::set_origin ( float  x,
float  y,
float  z 
)

Sets the origin of the header.

Parameters:
x the new x (angstroms)
y the new y (angstroms)
z the new z (angstroms)

void IMP::em::DensityMap::set_value ( float  x,
float  y,
float  z,
emreal  value 
)

Set the value of the voxel at a given index.

index voxel number in physical sense, NOT logical

void IMP::em::DensityMap::set_value ( long  index,
emreal  value 
)

Set the value of the voxel at a given index.

Parameters:
[in] index voxel number in physical sense, NOT logical
[in] value value

void IMP::em::DensityMap::std_normalize (  ) 

Normailze the density voxles according to standard deviation (stdv).

The mean is subtracted from the map, which is then divided by the stdv. The normalization flag is set to avoid repeated computation

float IMP::em::DensityMap::voxel2loc ( const int &  index,
int  dim 
) const

Calculate the location of a given voxel.

Parameters:
[in] index The voxel index
[in] dim The dimesion of intereset ( between x:=0,y:=1,z:=2)
Returns:
the location (x,y,z) (in angstroms) of a given voxel. If the index is not part of the map, the function returns -1.

long IMP::em::DensityMap::xyz_ind2voxel ( int  x,
int  y,
int  z 
) const

Calculate the voxel of a given xyz indexes.

Parameters:
[in] x The voxel index on the x axis of the grid
[in] y The voxel index on the y axis of the grid
[in] z The voxel index on the z axis of the grid
Returns:
the voxel index.


Friends And Related Function Documentation

double get_density ( DensityMap m,
const algebra::VectorD< 3 > &  v 
) [related]

Return the value for the density map, m, at point v, interpolating linearly from the sample values. The resulting function is C0 over R3.

DensityMap * get_transformed ( DensityMap in,
const algebra::Transformation3D tr 
) [related]

Return a new density map containing a rotated version of the old one. The dimension of the new map is the same as the old one.

DensityMap * get_transformed ( DensityMap in,
const algebra::Transformation3D tr,
double  threshold 
) [related]

Return a new density map containing a rotated version of the old one. Only voxels whose value is above threshold are considered when computing the bounding box of the new map (set IMP::em::get_bounding_box()).

DensityMap * read_map ( const char *  filename  )  [related]

Read a density map from a file and return it. Guess the file type from the file name. The file formats supported are:

  • .mrc for MRC files

DensityMap * read_map ( const char *  filename,
MapReaderWriter &  reader 
) [friend]

Read a density map from a file and return it.

void write_map ( DensityMap m,
const char *  filename,
MapReaderWriter &  writer 
) [friend]

Write a density map to a file.


Field Documentation

boost::scoped_array<float> IMP::em::DensityMap::x_loc_ [protected]

Locations for each of the voxels of the map (they are precomputed and each one is of size nvox, being nvox the size of the map)


The documentation for this class was generated from the following files:

Generated on Mon Mar 8 23:09:01 2010 for IMP by doxygen 1.5.8