Class for image and transformation database. More...
#include <cmtkImageXformDB.h>
Public Types | |
typedef ImageXformDB | Self |
This class. | |
typedef SQLite | Superclass |
Parent class. | |
Public Member Functions | |
ImageXformDB (const std::string &dbPath, const bool readOnly=false) | |
Constructor: open ImageXformDB database. | |
void | AddImage (const std::string &imagePath, const std::string &spacePath="") |
Add an image to a coordinate space, each identified by its file system path. | |
bool | AddImagePairXform (const std::string &xformPath, const bool invertible, const std::string &imagePathSrc, const std::string &imagePathTrg) |
Add a transformation between two images. | |
bool | AddRefinedXform (const std::string &xformPath, const bool invertible, const std::string &xformInitPath, const bool initInverse=false) |
Add a refined transformation based on an existing transformation. | |
Self::PrimaryKeyType | FindImageSpaceID (const std::string &imagePath) const |
Find space that image lives in and return its key. | |
const std::vector< std::string > | GetSpaceImageList (const Self::PrimaryKeyType &spaceKey, const bool sortById=false) |
Get a list of all images in the same space. | |
bool | FindXform (const std::string &imagePathSrc, const std::string &imagePathTrg, std::string &xformPath, bool &inverse) const |
Find transformation between two images. | |
const std::vector< std::string > | FindAllXforms (const std::string &imagePathSrc, const std::string &imagePathTrg) const |
Find all transformations between two images. | |
int | FindXformLevel (const std::string &xformPath) const |
Get the refinement level of a transformation in the database. |
Class for image and transformation database.
The image and transformation database has three tables that store: a) images and the coordinate spaces that they live in, b) coordinate transformations, and from which source space to which target space they map.
The "images" table stores all images and identifies which space they live in:
CREATE TABLE images(id INTEGER PRIMARY KEY, space INTEGER, path TEXT);
Each image is assigned a table-unique ID. All images that live in the same coordinate space (i.e., the same acquisition of the same subject) share a space ID, which is the unique image ID of the first image that was added to this space.
The "xforms" table stores the file system path and properties for each coordinate transformation:
CREATE TABLE xforms(id INTEGER PRIMARY KEY, path TEXT, invertible INTEGER, level INTEGER, spacefrom INTEGER, spaceto INTEGER);
Each transformation is assigned a table-unique ID. The field "invertible" is a flag that is set if the transformation has an explicit inverse (i.e., if it is affine). All transformations can be inverted nuerically, but we usually prefer explicit inverses for speed and accuracy. The field "level" gives the refinement level of the transformation: a transformation computed from two images with no initialization has level 0. A transformation computed with initialization from an existing transformation has a level of that transformation plus one. Inherit from SQLite wrapper class.
Definition at line 73 of file cmtkImageXformDB.h.
typedef ImageXformDB cmtk::ImageXformDB::Self |
typedef SQLite cmtk::ImageXformDB::Superclass |
Parent class.
Definition at line 82 of file cmtkImageXformDB.h.
cmtk::ImageXformDB::ImageXformDB | ( | const std::string & | dbPath, |
const bool | readOnly = false |
||
) |
Constructor: open ImageXformDB database.
dbPath | Path to the database file. |
readOnly | If this flag is set, the database is opened read-only. If false, the database is opened for read/write, and a non-existing database will be created. |
Definition at line 42 of file cmtkImageXformDB.cxx.
References cmtk::SQLite::Exec(), and cmtk::SQLite::TableExists().
void cmtk::ImageXformDB::AddImage | ( | const std::string & | imagePath, |
const std::string & | spacePath = "" |
||
) |
Add an image to a coordinate space, each identified by its file system path.
If the given image already exists in the database, no change is made.
imagePath | File system path of the new image |
spacePath | File system path of an existing image that lives in the same space |
Definition at line 59 of file cmtkImageXformDB.cxx.
Referenced by cmtk::SimpleLevelsetCommandLine< TImpl >::Execute(), cmtk::ImagePairAffineRegistrationCommandLine::OutputResult(), cmtk::ElasticRegistrationCommandLine::OutputResult(), and cmtk::AffineRegistrationCommandLine::OutputResult().
bool cmtk::ImageXformDB::AddImagePairXform | ( | const std::string & | xformPath, |
const bool | invertible, | ||
const std::string & | imagePathSrc, | ||
const std::string & | imagePathTrg | ||
) |
Add a transformation between two images.
xformPath | File system path of the tranformation |
invertible | ! Flag: does the transformation have an explicit inverse (i.e., is it affine)? |
imagePathSrc | File system path of the source image |
imagePathTrg | File system path of the target image |
Definition at line 89 of file cmtkImageXformDB.cxx.
References cmtk::StdErr.
Referenced by cmtk::ImagePairAffineRegistrationCommandLine::OutputResult(), cmtk::ElasticRegistrationCommandLine::OutputResult(), and cmtk::AffineRegistrationCommandLine::OutputResult().
bool cmtk::ImageXformDB::AddRefinedXform | ( | const std::string & | xformPath, |
const bool | invertible, | ||
const std::string & | xformInitPath, | ||
const bool | initInverse = false |
||
) |
Add a refined transformation based on an existing transformation.
xformPath | File system path of the new tranformation |
invertible | ! Flag: does the transformation have an explicit inverse (i.e., is it affine)? |
xformInitPath | Path of the transformation that was used to initialize the computation of the new transformation. |
initInverse | Flag whether the new transformation is based on the inverse of the initial transformation, i.e., from and to space need to be switched. |
Definition at line 123 of file cmtkImageXformDB.cxx.
References cmtk::StdErr.
Referenced by cmtk::ImagePairAffineRegistrationCommandLine::OutputResult(), cmtk::ElasticRegistrationCommandLine::OutputResult(), cmtk::AffineRegistrationCommandLine::OutputResult(), and cmtk::RegistrationDatabaseUpdater::UpdateDB().
const std::vector< std::string > cmtk::ImageXformDB::FindAllXforms | ( | const std::string & | imagePathSrc, |
const std::string & | imagePathTrg | ||
) | const |
Find all transformations between two images.
Only forward transformations are returned. To find inverse transformations, call this function with source and target images reversed.
imagePathSrc | File system path of the source image |
imagePathTrg | File system path of the target image |
Definition at line 253 of file cmtkImageXformDB.cxx.
cmtk::ImageXformDB::PrimaryKeyType cmtk::ImageXformDB::FindImageSpaceID | ( | const std::string & | imagePath ) | const |
Find space that image lives in and return its key.
Definition at line 160 of file cmtkImageXformDB.cxx.
bool cmtk::ImageXformDB::FindXform | ( | const std::string & | imagePathSrc, |
const std::string & | imagePathTrg, | ||
std::string & | xformPath, | ||
bool & | inverse | ||
) | const |
Find transformation between two images.
Only one transformation is returned, even if more than one transformation connects the two spaces.
Forward non-invertible (i.e., nonrigid) transformations are preferred, followed by forward explicitly invertible (i.e., affine) transformations, then inverses of nonrigid transformations. and finally inverses of affine transformations.
imagePathSrc | File system path of the source image |
imagePathTrg | File system path of the target image |
xformPath | File system path of the transformation. Only valid if function returns "true." Path can be empty if both images are already in the same space. |
inverse | If this is set, the given transformation needs to be inverted. |
Definition at line 207 of file cmtkImageXformDB.cxx.
int cmtk::ImageXformDB::FindXformLevel | ( | const std::string & | xformPath ) | const |
Get the refinement level of a transformation in the database.
xformPath | Path of the transformation to find and inspect. |
Definition at line 287 of file cmtkImageXformDB.cxx.
const std::vector< std::string > cmtk::ImageXformDB::GetSpaceImageList | ( | const Self::PrimaryKeyType & | spaceKey, |
const bool | sortById = false |
||
) |
Get a list of all images in the same space.
Definition at line 178 of file cmtkImageXformDB.cxx.