NPL
Neurological Programs and Libraries
npl::BSplineView< T > Class Template Reference

This is a specialized viewer for computing the value of a cubic B-Spline interpolation from the parameters. Thus the input to the constructor or setArray must be a parameter image. More...

#include <accessors.h>

Inherits npl::NDView< T >.

Public Member Functions

 BSplineView (std::shared_ptr< MRImage > params, BoundaryConditionT bound=ZEROFLUX)
 
 BSplineView ()
 
void createOverlay (ptr< const MRImage > overlay, double bspace)
 
bool get (size_t len, const double *point, int dir, double &val, double &dval)
 Samples the BSpline function at the specified point. More...
 
double get (size_t len, double *point)
 Simple sample function, just retrieve value at point, does not perform derivative. More...
 
ptr< MRImagereconstruct (ptr< const MRImage > input)
 Perform full-on reconstruction in the space of the input image. More...
 
ptr< MRImagereconstructNotAligned (ptr< const MRImage > input)
 
ptr< MRImagereconstructAligned (ptr< const MRImage > input)
 
double thinPlateEnergy ()
 
double thinPlateEnergy (size_t len, double *grad)
 
double jacobianDet (int dir)
 Computes the regularization term by integrating over the entire space for each knot. Thankfully integrals can be pre-computed (vConv, dvConv, ddvConv). See equations 66-71 in docs/bspline/fmri_dist_correct_2013-12-06.pdf. More...
 
double jacobianDet (int dir, size_t len, double *grad)
 Computes the gradient of regularization for each of the knots. Thankfully integrals can be pre-computed (uConv, duConv, dduConv). See equations 54-59 in docs/bspline/fmri_dist_correct_2013-12-06.pdf. More...
 
ptr< MRImagegetParams ()
 Return the parameter image. More...
 
void setArray (ptr< NDArray > in)
 
operator[] (int64_t index)
 Gets value linear position in array, then casts to T. More...
 
operator[] (const std::vector< int64_t > &index)
 Gets value at array index and then casts to T. More...
 
get (const std::vector< int64_t > &index)
 Gets value at array index and then casts to T. More...
 
get (size_t len, int64_t *index)
 Gets value at array index and then casts to T. More...
 
void set (size_t len, const int64_t *index, T v)
 Casts to the appropriate type then sets array at given index. More...
 
void set (const std::vector< int64_t > &index, T v)
 Casts to the appropriate type then sets array at given index. More...
 
void set (int64_t index, T v)
 Casts to the appropriate type then sets array at given index. More...
 
int64_t tlen ()
 

Public Attributes

BoundaryConditionT m_boundmethod
 How to handle boundaries (ZEROFLUX for constant outside bounds, ZERO for outside to be 0 and WRAP to wrap values, this might also be called periodic) More...
 
bool m_ras
 if true, then this assumes the inputs are RAS coordinates rather than indexes. Default is false More...
 
double vConv [5][5]
 
double dvConv [5][5]
 
double ddvConv [5][5]
 
double U200 [9][9][9]
 
double U110 [9][9][9]
 
double U100 [9][9][9]
 

Static Protected Member Functions

template<typename U >
static T castgetStatic (void *ptr)
 This is a wrapper function that will be called to safely cast from the underlying type. More...
 
template<typename U >
static void castsetStatic (void *ptr, const T &val)
 This is a wrapper function that will be called to safely cast to the underlying type. More...
 

Protected Attributes

std::shared_ptr< NDArrayparent
 Where to get the dat a from. Also the shared_ptr prevents dealloc. More...
 
T(* castget )(void *ptr)
 Function pointer to the correct function for casting from the underlying type. More...
 
void(* castset )(void *ptr, const T &v)
 Function pointer to the correct function for casting to the underlying type. This should be set during construction. More...
 

Detailed Description

template<typename T>
class npl::BSplineView< T >

This is a specialized viewer for computing the value of a cubic B-Spline interpolation from the parameters. Thus the input to the constructor or setArray must be a parameter image.

estimate(in) will generate the parameters that minimize the least squares difference from the given image (in).

createOverlay(in) will create a new parameter array in params that extends for two knots outside the input image (in)

Template Parameters
TValue to interpolate as

Definition at line 2049 of file accessors.h.

Constructor & Destructor Documentation

template<typename T >
npl::BSplineView< T >::BSplineView ( std::shared_ptr< MRImage params,
BoundaryConditionT  bound = ZEROFLUX 
)
inline

Definition at line 2052 of file accessors.h.

template<typename T >
npl::BSplineView< T >::BSplineView ( )
inline

Definition at line 2057 of file accessors.h.

Member Function Documentation

template<typename T >
template<typename U >
static T npl::NDView< T >::castgetStatic ( void *  ptr)
inlinestaticprotectedinherited

This is a wrapper function that will be called to safely cast from the underlying type.

Template Parameters
UUnderlying type of pixel, figured out in the constructor
Parameters
ptrPointer to memory where the pixel is.
Returns
Correctly cast value

Definition at line 272 of file accessors.h.

template<typename T >
template<typename U >
static void npl::NDView< T >::castsetStatic ( void *  ptr,
const T &  val 
)
inlinestaticprotectedinherited

This is a wrapper function that will be called to safely cast to the underlying type.

Template Parameters
UUnderlying type of pixel, figured out in the constructor
Parameters
ptrPointer to memory where the pixel is.
valnew value to write

Definition at line 287 of file accessors.h.

template<typename T >
void npl::BSplineView< T >::createOverlay ( ptr< const MRImage overlay,
double  bspace 
)
inline

Definition at line 2059 of file accessors.h.

template<typename T >
T npl::NDView< T >::get ( const std::vector< int64_t > &  index)
inlineinherited

Gets value at array index and then casts to T.

Parameters
indexn-d index to access
Returns
value

Definition at line 170 of file accessors.h.

template<typename T >
T npl::NDView< T >::get ( size_t  len,
int64_t *  index 
)
inlineinherited

Gets value at array index and then casts to T.

Parameters
lenlength of index array
indexn-d index to access
Returns
value

Definition at line 186 of file accessors.h.

template<typename T >
bool npl::BSplineView< T >::get ( size_t  len,
const double *  point,
int  dir,
double &  val,
double &  dval 
)
inline

Samples the BSpline function at the specified point.

Parameters
lenLength of point vector
pointPoint (if m_ras) or continuous index in parameter space
dirDimension to take derivative in, must be >= 0
valReturn value at specified point
dvalReturn derivative of Bspline in dir direction
Returns
true if the specified point used boundary conditions (outside values)

Definition at line 2108 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::get ( size_t  len,
double *  point 
)
inline

Simple sample function, just retrieve value at point, does not perform derivative.

Parameters
lenLength of point array
pointPoint (or if m_ras = false, then continuous index in parameter space)
Returns
Value at point

Definition at line 2198 of file accessors.h.

template<typename T >
ptr<MRImage> npl::BSplineView< T >::getParams ( )
inline

Return the parameter image.

Returns

Definition at line 2630 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::jacobianDet ( int  dir)
inline

Computes the regularization term by integrating over the entire space for each knot. Thankfully integrals can be pre-computed (vConv, dvConv, ddvConv). See equations 66-71 in docs/bspline/fmri_dist_correct_2013-12-06.pdf.

Returns
regularization value

Definition at line 2508 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::jacobianDet ( int  dir,
size_t  len,
double *  grad 
)
inline

Computes the gradient of regularization for each of the knots. Thankfully integrals can be pre-computed (uConv, duConv, dduConv). See equations 54-59 in docs/bspline/fmri_dist_correct_2013-12-06.pdf.

Parameters
dirDirection of distortion/deformation
lenLength of grad vector
gradVector of values, one for each parameter in the B-spline

Definition at line 2565 of file accessors.h.

template<typename T >
T npl::NDView< T >::operator[] ( int64_t  index)
inlineinherited

Gets value linear position in array, then casts to T.

Returns
value

Definition at line 155 of file accessors.h.

template<typename T >
T npl::NDView< T >::operator[] ( const std::vector< int64_t > &  index)
inlineinherited

Gets value at array index and then casts to T.

Parameters
indexn-d index to access
Returns
value

Definition at line 201 of file accessors.h.

template<typename T >
ptr<MRImage> npl::BSplineView< T >::reconstruct ( ptr< const MRImage input)
inline

Perform full-on reconstruction in the space of the input image.

Parameters
input
Returns

Definition at line 2274 of file accessors.h.

template<typename T >
ptr<MRImage> npl::BSplineView< T >::reconstructAligned ( ptr< const MRImage input)
inline

Definition at line 2292 of file accessors.h.

template<typename T >
ptr<MRImage> npl::BSplineView< T >::reconstructNotAligned ( ptr< const MRImage input)
inline

Definition at line 2284 of file accessors.h.

template<typename T >
void npl::NDView< T >::set ( size_t  len,
const int64_t *  index,
v 
)
inlineinherited

Casts to the appropriate type then sets array at given index.

Parameters
lenlength of index array
indexn-d index to access
vvalue to set at index
Returns
current value

Definition at line 218 of file accessors.h.

template<typename T >
void npl::NDView< T >::set ( const std::vector< int64_t > &  index,
v 
)
inlineinherited

Casts to the appropriate type then sets array at given index.

Parameters
vvalue to set at index
indexn-d index to access
Returns
current value

Definition at line 234 of file accessors.h.

template<typename T >
void npl::NDView< T >::set ( int64_t  index,
v 
)
inlineinherited

Casts to the appropriate type then sets array at given index.

Parameters
vvalue to set at index
indexn-d index to access
Returns
current value

Definition at line 250 of file accessors.h.

template<typename T >
void npl::NDView< T >::setArray ( ptr< NDArray in)
inlineinherited

Definition at line 73 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::thinPlateEnergy ( )
inline

Definition at line 2349 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::thinPlateEnergy ( size_t  len,
double *  grad 
)
inline

Definition at line 2408 of file accessors.h.

template<typename T >
int64_t npl::NDView< T >::tlen ( )
inlineinherited

Definition at line 258 of file accessors.h.

Member Data Documentation

template<typename T >
T(* npl::NDView< T >::castget) (void *ptr)
protectedinherited

Function pointer to the correct function for casting from the underlying type.

Parameters
ptrlocation in memory where the pixel is stored

Definition at line 303 of file accessors.h.

template<typename T >
void(* npl::NDView< T >::castset) (void *ptr, const T &v)
protectedinherited

Function pointer to the correct function for casting to the underlying type. This should be set during construction.

Parameters
ptrpointer to memory
vvalue to cast and write

Definition at line 313 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::ddvConv[5][5]
Initial value:
= {
{0.041666666666666664,0.,-0.125,0.08333333333333333,0.},
{0.,0.4166666666666667,-0.75,0.25,0.08333333333333333},
{-0.125,-0.75,1.75,-0.75,-0.125},
{0.08333333333333333,0.25,-0.75,0.4166666666666667,0.},
{0.,0.08333333333333333,-0.125,0.,0.041666666666666664}}

Definition at line 2657 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::dvConv[5][5]
Initial value:
= {
{0.0015625,0.013541666666666667,-0.0109375,-0.004166666666666667,0.},
{0.013541666666666667,0.24479166666666666,-0.07604166666666666,-0.178125,-0.004166666666666667},
{-0.0109375,-0.07604166666666666,0.17395833333333333,-0.07604166666666666,-0.0109375},
{-0.004166666666666667,-0.178125,-0.07604166666666666,0.24479166666666666,0.013541666666666667},
{0.,-0.004166666666666667,-0.0109375,0.013541666666666667,0.0015625}}

Definition at line 2651 of file accessors.h.

template<typename T >
BoundaryConditionT npl::BSplineView< T >::m_boundmethod

How to handle boundaries (ZEROFLUX for constant outside bounds, ZERO for outside to be 0 and WRAP to wrap values, this might also be called periodic)

Definition at line 2630 of file accessors.h.

template<typename T >
bool npl::BSplineView< T >::m_ras

if true, then this assumes the inputs are RAS coordinates rather than indexes. Default is false

Definition at line 2643 of file accessors.h.

template<typename T >
std::shared_ptr<NDArray> npl::NDView< T >::parent
protectedinherited

Where to get the dat a from. Also the shared_ptr prevents dealloc.

Definition at line 290 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::U100[9][9][9]

Definition at line 3614 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::U110[9][9][9]

Definition at line 3139 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::U200[9][9][9]

Definition at line 2664 of file accessors.h.

template<typename T >
double npl::BSplineView< T >::vConv[5][5]
Initial value:
= {
{0.000031001984126984125,0.0010788690476190477,0.0013950892857142857,0.0000992063492063492,0.},
{0.0010788690476190477,0.058643353174603174,0.11707589285714286,0.02101934523809524,0.0000992063492063492},
{0.0013950892857142857,0.11707589285714286,0.362016369047619,0.11707589285714286,0.0013950892857142857},
{0.0000992063492063492,0.02101934523809524,0.11707589285714286,0.058643353174603174,0.0010788690476190477},
{0.,0.0000992063492063492,0.0013950892857142857,0.0010788690476190477,0.000031001984126984125}}

Definition at line 2645 of file accessors.h.


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