SLIMMER
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
SimpleTField< T, TS > Class Template Reference

Templated Spatio-Temporal Field of Values. More...

#include <SimpleTField.h>

Inheritance diagram for SimpleTField< T, TS >:
BasicHeader SimpleVoxIO SimpleVTVec< T, TS > ReadDataType SimpleBaseTVec< T, TS >

List of all members.

Public Types

typedef const T * const_pointer

Public Member Functions

 SimpleTField (const unsigned int nx=10, const unsigned int ny=10, const unsigned int nz=10, const unsigned int nt=1)
 Simple Constructor supplied with Number of Voxels.
 SimpleTField (const BasicHeader &hd)
 Constructor from a BasicHeader.
template<typename T2 >
 SimpleTField (const SimpleTField< T2, TS > &hd)
 Copy Constructor.
 SimpleTField (const SimpleTField< T, TS > &hd)
 Copy Constructor.
TS lineVox () const
 Number of Voxels in a Line.
TS planeVox () const
 Number of Voxels in a Plane.
TS frameVox () const
 Number of Voxels in a Frame.
virtual ~SimpleTField ()
 Destructor.
BasicHeader Header () const
 Return copy of Current Image Header.
T * DataPtr (const unsigned int x=0, const unsigned int y=0, const unsigned int z=0, const unsigned int t=0)
 Return Pointer to Data Element at Given x,y,z,t location.
const_pointer DataPtr (const unsigned int x=0, const unsigned int y=0, const unsigned int z=0, const unsigned int t=0) const
 Return const pointer to Data Element at Given x,y,z,t location.
TS Offset (const unsigned int x=0, const unsigned int y=0, const unsigned int z=0, const unsigned int t=0) const
 return Offset to Given Voxel Coordinate (as 4 integers)
TS Offset (SimpleBaseTVec< unsigned int > X) const
 return Offset to Given Voxel Coordinate (as vector)
void LimitCoord (unsigned int &x, unsigned int &y, unsigned int &z, unsigned int &t, const unsigned int bx=0, const unsigned int by=0, const unsigned int bz=0, const unsigned int bt=0)
 Impose Field Boundary Limits on Given Set of Voxel Coordinates.
operator() (const TS d) const
 return value at given voxel offset (legacy syntax)
operator[] (const TS d) const
 return value at given voxel offset
T & operator[] (const TS d)
 Return Reference to Element at given voxel offset (Note: no bounds checking for speed)
T & operator[] (const SimpleBaseTVec< unsigned int > &X)
 Return Reference to Element at given voxel coordinate (Note: no bounds checking for speed)
T & operator() (const TS x, const TS y, const TS z=0, const TS t=0)
 return reference to element at given voxel coordinate, same as Voxel()
operator() (const TS x, const TS y, const TS z=0, const TS t=0) const
 return value of element at given voxel coordinate, same as Value()
T & Voxel (const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int t=0)
 Return Reference to Element at given voxel Coordinate (Note: no bounds checking for speed)
T & VoxelLimit (unsigned int x, unsigned int y=0, unsigned int z=0, unsigned int t=0)
 Return Reference to Element at given voxel Coordinate with Boundary Limited.
Value (const unsigned int x, const unsigned int y=0, const unsigned int z=0, const unsigned int t=0) const
 Return (copy of) value of Element at given voxel coordinate (Note: no bounds checking for speed)
ValueLimit (unsigned int x, unsigned int y=0, unsigned int z=0, unsigned int t=0) const
 Return (copy of) value of Element at given voxel coordinate with Boundary Limited.
Deriv1 (const int dim, const int offset)
 Return Simple Numerical 1st Derivative with respect to a given Dimension.
Deriv1 (const int dim, const unsigned int x, const unsigned int y, const unsigned int z, const unsigned int t)
 Return Simple Numerical 1st Derivative with respect to a given Dimension.
Deriv1 (const int dim, const SimpleBaseTVec< unsigned int > &X)
 Return Simple Numerical 1st Derivative with respect to a given Dimension.
SimpleTVec< unsigned int, 3 > XYZ (const TS d) const
 return Voxel Coordinate (as vector) for given Offset
SimpleTVec< float, 107 > TimeSeries (const int x, const int y, const int z)
 Return Vector containing the time series at a given Voxel Location.
template<typename TL >
InterpVal_vox (const SimpleBaseTVec< TL > &loc_vox, const T &PadV, const int interpType=0, const int frame=0) const
template<typename TL , typename TOUT >
void InterpVal_vox (const SimpleBaseTVec< TL > &loc_vox, TOUT &val, SimpleTVec< TOUT, 3 > &der, const T &PadV, const int interpType=0, const int frame=0) const
template<typename TL >
InterpVal_mm (const SimpleBaseTVec< TL > &loc_mm, const T &PadV, const int interpType=0, const int frame=0) const
template<typename TL >
void InterpVal_mm (const SimpleBaseTVec< TL > &loc_mm, T &val, SimpleTVec< T, 3 > &der, const T &PadV, const int interpType=0, const int frame=0) const
SimpleVTVec< TS > N6Off (unsigned int x, unsigned int y, unsigned int z) const
 Return the offsets to 6-neighborhood of a voxel.
SimpleVTVec< T > N6 (unsigned int x, unsigned int y, unsigned int z) const
 Return the values in 6-neighborhood of a voxel.
SimpleVTVec< T > N6 (TS d) const
 Return the values in 6-neighborhood of a voxel (specified by offset)
SimpleVTVec< TS > N26Off (unsigned int x, unsigned int y, unsigned int z) const
 Return the offsets to 26-neighborhood of a voxel.
SimpleVTVec< T > N26 (unsigned int x, unsigned int y, unsigned int z) const
 Return the values of 26-neighborhood of a voxel.
SimpleVTVec< T > N26 (TS d) const
 Return the values of 26-neighborhood of a voxel (specified by offset)
void UpdateMaxMin ()
 Update Header Data Range from Voxel Values.
int FieldDataType ()
 Return type of data field.
void Clear (T val)
 Clear all Voxels to Given Value.
template<typename T2 >
SimpleTField< T, TS > & operator= (const SimpleTField< T2, TS > &src)
template<typename T2 >
SimpleTField< T, TS > & operator+= (const SimpleTField< T2 > &src)
template<typename T2 >
SimpleTField< T, TS > & operator-= (const SimpleTField< T2 > &src)
template<typename T2 >
SimpleTField< T, TS > & operator*= (SimpleTField< T2 > &src)
template<typename T2 >
SimpleTField< T, TS > & operator/= (SimpleTField< T2 > &src)
SimpleTField< T, TS > & operator= (const T &src)
 Assign a Scalar to All Elements.
SimpleTField< T, TS > & operator*= (const T &src)
 Multiply All Elements by a Scalar.
SimpleTField< T, TS > & operator-= (const T &src)
 Subtract a Scalar from all elements.
SimpleTField< T, TS > & operator+= (const T &src)
 Add a Scalar to all elements.
SimpleTField< T, TS > & operator/= (const T &src)
 Divide All Elements by a Scalar.
SimpleTField< T, TS > operator- (const SimpleTField< T, TS > &v2) const
 Subtract One Field from another.
SimpleTField< T, TS > operator+ (const SimpleTField< T, TS > &v2) const
 Add One Field to another.
SimpleTField< T, TS > operator/ (const T &v2) const
 Binary Field-Scalar Operators.
SimpleTField< T, TS > operator* (const T &v2) const
 Multiply each element by scalar.
SimpleTField< T, TS > operator+ (const T &v2) const
 Add scalar to each element.
SimpleTField< T, TS > operator- (const T &v2) const
 Subtract a scalar from each element.
void ResizeFieldToHeader ()
 Resize Field and Throw Away Contents: Header has changed Dimensions!
void ResizeTo (const BasicHeader &hd)
bool CopyFrame (const SimpleTField< T, TS > &src, const int f)
 Copy a given frame to this Field and Resize this to fit.
SimpleTVec< float, 3 > Crop (int x1=-1, int x2=-1, int y1=-1, int y2=-1, int z1=-1, int z2=-1, int t1=-1, int t2=-1)
 Crop Field by Reducing Samples.
SimpleTVec< float, 3 > Expand (int x1=0, int x2=0, int y1=0, int y2=0, int z1=0, int z2=0, const T pad=0)
 Expand field by increasing number of voxels around borders.
SimpleTField< T, TS > * ExtractSubRegion (SimpleTVec< float, 3 > &shift, int x1=-1, int x2=-1, int y1=-1, int y2=-1, int z1=-1, int z2=-1, int t1=-1, int t2=-1)
 Extract Sub Region (Preserves original Field)
template<typename T2 >
void ReGrid (SimpleTField< T2, TS > &src, T2 padV, int interp=1, bool avgsamp=(1==1))
 ReGrid and Interpolate/Resample Values from One Field to Another.
void reflectX ()
 Reflect along X Axis.
void reflectY ()
 Reflect along Y Axis.
void reflectZ ()
 Reflect along Z Axis.
void swapXY ()
 Swap X and Y Axes of Field.
void swapXZ ()
 Swap X and Z Axes.
ThresholdExtent (T val, SimpleTVec< float, 3 > &xmin, SimpleTVec< float, 3 > &xmax)
 Return Min and Max Voxel Locations Above a Given Threshold Value and lowest true value above threshold.
void SimpleGaussFilt (SimpleTField< T, TS > &Input, float fwhmdiam=4, int step=1)
 Apply Radially Symmetric Gaussian Filter to Given Input Field.
void WeightedAverage (SimpleTField< T, TS > &src, float scale1=1.0/9.0, float scale2=1.0/36.0)
 Evaluate Weighted Local Average of Field.
void WeightedAverageIT (SimpleTField< T, TS > &src, int nit=1, float scale1=1.0/9.0, float scale2=1.0/36.0)
 Call Averaging for a given number of iterations.
void WeightedAverageIT (int nit=1, float scale1=1.0/9.0, float scale2=1.0/36.0)
 Call Averaging for a given number of iterations and keep result in place.
template<typename TD >
void SpatialDeriv (SimpleTField< TD > &src)
 Evaluate Spatial Derivative of Field.
template<typename T1 , typename Ts , typename T2 >
void Convolve1D (const SimpleBaseTVec< T1, Ts > &kernel, SimpleTField< T2 > &out, int dim, char type=0) const
 Convolve in 1D with zero boundary conditions - type 0: SAME (default), 1: VALID, 2: FULL.
template<typename T1 , typename T2 >
void Convolve3D (const SimpleTField< T1 > &kernel, SimpleTField< T2 > &out) const
 Convolve in 3D.
template<typename T1 >
SimpleTField< float > Convolve3D (const SimpleTField< T1 > &kernel)
 Convolve in 3D.
AnisoDiff (SimpleTField< T, TS > *im, float K, float dt)
 Apply Anisotropic Diffusion to Field.
int Save2File (char *name, float scale=1.0)
 Save POD Data to a Given File.
int Save2File (const string name, const float scale=1.0f)
bool LoadFromFile (char *name, float scale=1.0)
 Basic POD Type Data Loading.
bool LoadFromFile (const string name, const float scale=1.0f)
void SizeFromFile (char *name)
 Make Internal Memory Size Same as a Given File.
unsigned long int TotalDataSizeBytes ()
 return Total Data Size in Bytes
unsigned long int ElementSizeBytes ()
 return Total Size of Field Element in Bytes
template<typename TO , typename TI >
void ApplyLinTrans (const SimpleTMat< float, 4, 4 > &ref2target, SimpleTField< TO > &ref, SimpleTField< TI > &target, const TI &PadVal, int InterpType=INTERP_NN) const
 Apply a Linear Transformation to a SimpleTField.

Static Public Attributes

static const char _versionID []

Protected Member Functions

int SaveFileVec (char *name, float scaleV=1.0)
 Function to Save Vector Data (wrapped externally with SaveFile() Specialisation)
int SaveFileVecVec (char *name, float scale=1.0)
 Function to Save Vector-Vector Data (wrapped externally with SaveFile() Specialisation)
int SaveFileMat (char *name, float scale=1.0)
 Function to Save Matrix Data (wrapped externally with SaveFile() Specialisation)
int LoadFileVec (char *name, float scale=1.0)
 Load a File Containing Vectors (wrapped externally with LoadFile() Specialisation)
int LoadFileSqMat (char *name, float scale=1.0)
 Load a File Containing SQUARE Matrices (wrapped externally with LoadFile() Specialisation)

Protected Attributes

TS _planeStep
 number of voxels in a plane
TS _lineStep
 number of voxels in a line
TS _frameStep
 number of voxels in a frame

Detailed Description

template<typename T, typename TS = unsigned long int>
class SimpleTField< T, TS >

Templated Spatio-Temporal Field of Values.

Used to Describe an array of type T over Space and Time

Derives Physical Dimensions and Sampling from a BasicHeader Image class

Supports Loading/Saving from/to medical Image File Formats from SimpleVoxIO.h

Author:
Colin Studholme 1999-
Id:
SimpleTField.h,v 1.149 2012/01/25 23:29:14 mads Exp

Constructor & Destructor Documentation

template<typename T, typename TS = unsigned long int>
template<typename T2 >
SimpleTField< T, TS >::SimpleTField ( const SimpleTField< T2, TS > &  hd) [inline]

Copy Constructor.

Override Default Copy Constructor for different types prevents auto copy of internal pointer this->_elem

template<typename T, typename TS = unsigned long int>
SimpleTField< T, TS >::SimpleTField ( const SimpleTField< T, TS > &  hd) [inline]

Copy Constructor.

Override Default Copy Constructor prevents auto copy of internal pointer this->_elem


Member Function Documentation

template<typename T, typename TS = unsigned long int>
template<typename T1 , typename T2 >
void SimpleTField< T, TS >::Convolve3D ( const SimpleTField< T1 > &  kernel,
SimpleTField< T2 > &  out 
) const [inline]

Convolve in 3D.

Kernel must have odd-numbered nVox and identical VoxSz to the source, in all directions.

template<typename T, typename TS = unsigned long int>
SimpleTVec<float,3> SimpleTField< T, TS >::Crop ( int  x1 = -1,
int  x2 = -1,
int  y1 = -1,
int  y2 = -1,
int  z1 = -1,
int  z2 = -1,
int  t1 = -1,
int  t2 = -1 
) [inline]

Crop Field by Reducing Samples.

Specifiec by First and last voxel in each Axis
Returns Shift in Origin in mm

template<typename T, typename TS = unsigned long int>
T SimpleTField< T, TS >::Deriv1 ( const int  dim,
const int  offset 
) [inline]

Return Simple Numerical 1st Derivative with respect to a given Dimension.

note: no Bounds check for speed!
Uses simple {-0.5,0,0.5} kernel

template<typename T, typename TS = unsigned long int>
T SimpleTField< T, TS >::Deriv1 ( const int  dim,
const unsigned int  x,
const unsigned int  y,
const unsigned int  z,
const unsigned int  t 
) [inline]

Return Simple Numerical 1st Derivative with respect to a given Dimension.

note: no Bounds check for speed!
Uses simple {-0.5,0,0.5} kernel

template<typename T, typename TS = unsigned long int>
T SimpleTField< T, TS >::Deriv1 ( const int  dim,
const SimpleBaseTVec< unsigned int > &  X 
) [inline]

Return Simple Numerical 1st Derivative with respect to a given Dimension.

note: no Bounds check for speed!
Uses simple {-0.5,0,0.5} kernel

template<typename T, typename TS = unsigned long int>
SimpleTField<T,TS>* SimpleTField< T, TS >::ExtractSubRegion ( SimpleTVec< float, 3 > &  shift,
int  x1 = -1,
int  x2 = -1,
int  y1 = -1,
int  y2 = -1,
int  z1 = -1,
int  z2 = -1,
int  t1 = -1,
int  t2 = -1 
) [inline]

Extract Sub Region (Preserves original Field)

Creates a new sub field holding subregion

template<typename T, typename TS = unsigned long int>
SimpleTField<T,TS> SimpleTField< T, TS >::operator/ ( const T &  v2) const [inline]

Binary Field-Scalar Operators.

Divide each element by scalar

Reimplemented from SimpleVTVec< T, TS >.

template<typename T, typename TS = unsigned long int>
int SimpleTField< T, TS >::Save2File ( char *  name,
float  scale = 1.0 
) [inline]

Save POD Data to a Given File.

Note: Other Specialisations For Vector/Matrix-Save Call special Functions

template<typename T, typename TS = unsigned long int>
int SimpleTField< T, TS >::SaveFileMat ( char *  name,
float  scale = 1.0 
) [inline, protected]

Function to Save Matrix Data (wrapped externally with SaveFile() Specialisation)

Timing of Slices Not Supported

template<typename T, typename TS = unsigned long int>
int SimpleTField< T, TS >::SaveFileVec ( char *  name,
float  scaleV = 1.0 
) [inline, protected]

Function to Save Vector Data (wrapped externally with SaveFile() Specialisation)

Timing of Slices Not Supported

template<typename T, typename TS = unsigned long int>
int SimpleTField< T, TS >::SaveFileVecVec ( char *  name,
float  scale = 1.0 
) [inline, protected]

Function to Save Vector-Vector Data (wrapped externally with SaveFile() Specialisation)

Timing of Slices Not Supported

template<typename T, typename TS = unsigned long int>
template<typename TD >
void SimpleTField< T, TS >::SpatialDeriv ( SimpleTField< TD > &  src) [inline]

Evaluate Spatial Derivative of Field.

Notes: Skip Boundaries!

template<typename T, typename TS = unsigned long int>
void SimpleTField< T, TS >::WeightedAverage ( SimpleTField< T, TS > &  src,
float  scale1 = 1.0/9.0,
float  scale2 = 1.0/36.0 
) [inline]

Evaluate Weighted Local Average of Field.

--- Note: Weights Specified in 1D: for 3,3,3 neighbourhood also: Skiping Boundary points!

 All Classes Functions Variables Typedefs