Public Types | Public Member Functions

cmtk::ImageXformDB Class Reference
[cmtkRegistration Library]

Class for image and transformation database. More...

#include <cmtkImageXformDB.h>

Inheritance diagram for cmtk::ImageXformDB:
Inheritance graph
[legend]
Collaboration diagram for cmtk::ImageXformDB:
Collaboration graph
[legend]

List of all members.

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.

Detailed Description

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.


Member Typedef Documentation

This class.

Reimplemented from cmtk::SQLite.

Definition at line 79 of file cmtkImageXformDB.h.

Parent class.

Definition at line 82 of file cmtkImageXformDB.h.


Constructor & Destructor Documentation

cmtk::ImageXformDB::ImageXformDB ( const std::string &  dbPath,
const bool  readOnly = false 
)

Constructor: open ImageXformDB database.

Parameters:
dbPathPath to the database file.
readOnlyIf 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().


Member Function Documentation

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.

Warning:
If the given image already exists in the database, no change is made even if a new space is assigned to it with this call. The reason for this behaviour is that if we assign the new space, it is unclear what to do with other images that potentially live in the old image space, especially if that space was defined by the reassigned image in the first place.
Parameters:
imagePathFile system path of the new image
spacePathFile 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.

Returns:
True if the operation was successful, false otherwise. Failure may be due to source and target image being in the same space to begin with.
Parameters:
xformPathFile system path of the tranformation
invertible! Flag: does the transformation have an explicit inverse (i.e., is it affine)?
imagePathSrcFile system path of the source image
imagePathTrgFile 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.

Returns:
True if the operation was successful, false otherwise. Failure may be due to absence of the specified original transformation in the database.
Parameters:
xformPathFile system path of the new tranformation
invertible! Flag: does the transformation have an explicit inverse (i.e., is it affine)?
xformInitPathPath of the transformation that was used to initialize the computation of the new transformation.
initInverseFlag 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.

Returns:
List of transformations that map from source to target. Non-invertible (i.e., nonrigid) transformations are listed first, followed by explicitly invertible (i.e., affine) transformations.mations.
Parameters:
imagePathSrcFile system path of the source image
imagePathTrgFile 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.

Returns:
True if transformation exists. If false, the two given images may still be connected via a chain of multiple, concatenated transformations.
Parameters:
imagePathSrcFile system path of the source image
imagePathTrgFile system path of the target image
xformPathFile system path of the transformation. Only valid if function returns "true." Path can be empty if both images are already in the same space.
inverseIf 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.

Returns:
The level of the given transformation: 0 for an original transformation, positive for refined transformation, or -1 is transformation is not in the database.
Parameters:
xformPathPath 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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines