DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
Macros | Typedefs | Enumerations | Functions | Variables
4DImageMath.cxx File Reference
#include "4DImageMathCLP.h"
#include "itkRegionOfInterestImageFilter.h"
#include "itkPermuteAxesImageFilter.h"
#include "itkVectorImageRegionIterator.h"
#include "itkVectorImageRegionIteratorWithIndex.h"
#include "utl.h"
#include "itkFunctors.h"
#include "itkMultiVolumeImageToVectorImageFilter.h"
#include "itkVectorImageToMultiVolumeImageFilter.h"
#include "itkUnaryFunctorVectorImageFilter.h"
#include "itkMultiVariableFunctorVectorImageFilter.h"
#include "itkFunctorFromStringImageFilter.h"
+ Include dependency graph for 4DImageMath.cxx:

Go to the source code of this file.

Macros

#define __FunctionFromStringOpImage(funcStr)
 
#define __SetImage(ImageType, fileName, imageName, imageItName, axis)
 
#define __SetImageOrScalar(ImageType, fileName, imageName, imageItName, valueName)
 
#define __UnaryScalarFunctor(argNoAxis, opNoAxis, funcName)
 
#define __XYZTMultiVectorFunctor(axisNum, argNoAxis, opNoAxis, funcName)
 
#define __XYZTMultiVectorFunctor_FixedSize(axisNum, argNoAxis, opNoAxis, funcName, inSize)
 
#define __XYZTUnaryVectorFunctor(axisNum, argNoAxis, opNoAxis, funcName)
 
#define __XYZTUnaryVectorFunctorWithArguments(axisNum, argNoAxis, opNoAxis, funcName)
 
#define _SetOperationWithChecking(op, value, numberOfInputsCond)
 

Typedefs

typedef itk::Image< ScalarType, 4 > NDImageType
 
typedef double ScalarType
 
typedef itk::VectorImage< ScalarType, 3 > VectorImageType
 

Enumerations

enum  {
  OP_NULL =0,
  OP_ADD,
  OP_MINUS,
  OP_MULTIPLY,
  OP_DIVIDE,
  OP_MAX,
  OP_MIN,
  OP_POW,
  OP_FUNC,
  OP_ABS,
  OP_EXP,
  OP_LOG,
  OP_SQUARE,
  OP_SQRT,
  OP_NORM,
  OP_MEAN,
  OP_MEDIAN,
  OP_SUM,
  OP_MAX_AXIS,
  OP_MIN_AXIS,
  OP_DOTPRODUCT,
  OP_COMPOSE,
  OP_SHRED,
  OP_CROP
}
 

Functions

template<class ImageType , class ImageOutType , class OpFunctor >
void BinaryOPImage (const itk::SmartPointer< ImageType > &image, itk::SmartPointer< ImageOutType > &outImage, std::string _MaskImageFile, std::string _opImageFile, const OpFunctor &func)
 
template<class ImageType , class Image2Type >
void ConvertImage (const itk::SmartPointer< ImageType > &image, itk::SmartPointer< Image2Type > &imageOut)
 
template<>
void ConvertImage< NDImageType, VectorImageType > (const itk::SmartPointer< NDImageType > &image, itk::SmartPointer< VectorImageType > &imageOut)
 
template<>
void ConvertImage< VectorImageType, NDImageType > (const itk::SmartPointer< VectorImageType > &image, itk::SmartPointer< NDImageType > &imageOut)
 
void GetImageFiles (const std::vector< std::string > &imageVec, std::string &inImage0, std::string &outImage)
 
int GetNumberFromAxis (std::string axis)
 
template<class ImageType , class ImageOutType >
int ImageMath (int argc, char const *argv[])
 
template<class IndexType >
bool IsOutsideBox (const IndexType &index, const std::vector< int > &box)
 
int main (int argc, char const *argv[])
 
void SetOperationWithChecking (int &op, int value)
 

Variables

std::string _axis
 
int _axisNumber =-1
 
int _numberOfThreads = -1
 
int _Operation = OP_NULL
 
std::vector< int > _realBox
 
std::vector< int > _size
 

Detailed Description

Created "07-12-2016.

Author
Jian Cheng (JC), jian..nosp@m.chen.nosp@m.g.198.nosp@m.3@gm.nosp@m.ail.c.nosp@m.om

Definition in file 4DImageMath.cxx.

Macro Definition Documentation

#define __FunctionFromStringOpImage (   funcStr)
Value:
do \
{ \
itk::FunctorFromStringOPImage(imageVec, outImage, funcStr, mask, _numberOfThreads); \
} while ( 0 );
int _numberOfThreads
Definition: 4DImageMath.cxx:78
void FunctorFromStringOPImage(const std::vector< itk::SmartPointer< ImageType > > &images, itk::SmartPointer< ImageOutType > &outImage, const std::string &funcStr, const itk::SmartPointer< MaskImageType > &mask=nullptr, int numberOfThreads=-1)

Definition at line 213 of file 4DImageMath.cxx.

Referenced by ImageMath().

#define __SetImage (   ImageType,
  fileName,
  imageName,
  imageItName,
  axis 
)
Value:
typename ImageType::Pointer imageName = ImageType::New(); \
itk::VectorImageRegionIteratorWithIndex<ImageType> imageItName; \
if (fileName!="") \
{ \
itk::ReadImage<ImageType>(fileName, imageName); \
std::vector<int> sizeTmp = itk::GetVectorImage3DVolumeSize(imageName); \
utlGlobalException(!utl::IsSameVector(_size,sizeTmp), "images have different size"); \
imageItName = itk::VectorImageRegionIteratorWithIndex<ImageType> (imageName, imageName->GetLargestPossibleRegion(),axis); \
}
bool IsSameVector(const std::vector< T > &vec1, const std::vector< T > &vec2, const double eps=1e-10)
Definition: utlCore.h:1365
std::vector< int > GetVectorImage3DVolumeSize(const SmartPointer< ImageType > &image)
Definition: utlITK.h:331
std::vector< int > _size
Definition: 4DImageMath.cxx:77
A multi-dimensional iterator templated over image type. It provides the same interfaces for both itk:...

Definition at line 165 of file 4DImageMath.cxx.

Referenced by BinaryOPImage().

#define __SetImageOrScalar (   ImageType,
  fileName,
  imageName,
  imageItName,
  valueName 
)
Value:
typename ImageType::Pointer imageName = ImageType::New(); \
itk::VectorImageRegionIteratorWithIndex<ImageType> imageItName; \
double valueName=0; \
if (fileName!="") \
{ \
if (utl::IsNumber(fileName)) \
{ \
valueName = utl::ConvertStringToNumber<double>(fileName); \
} \
else \
{ \
itk::ReadImage<ImageType>(fileName, imageName); \
std::vector<int> sizeTmp = itk::GetVectorImage3DVolumeSize(imageName); \
utlGlobalException(!utl::IsSameVector(_size,sizeTmp), "images have different size"); \
imageItName = itk::VectorImageRegionIteratorWithIndex<ImageType> (imageName, imageName->GetLargestPossibleRegion()); \
} \
}
bool IsNumber(const std::string &input)
Definition: utlCore.h:726
bool IsSameVector(const std::vector< T > &vec1, const std::vector< T > &vec2, const double eps=1e-10)
Definition: utlCore.h:1365
std::vector< int > GetVectorImage3DVolumeSize(const SmartPointer< ImageType > &image)
Definition: utlITK.h:331
std::vector< int > _size
Definition: 4DImageMath.cxx:77
A multi-dimensional iterator templated over image type. It provides the same interfaces for both itk:...

Definition at line 177 of file 4DImageMath.cxx.

Referenced by BinaryOPImage().

#define __UnaryScalarFunctor (   argNoAxis,
  opNoAxis,
  funcName 
)
Value:
if (argNoAxis##Arg.isSet()) \
{ \
_SetOperationWithChecking(_Operation, OP_##opNoAxis, imageVec.size()==1); \
utl::Functor::ScalarFunctorWrapper<funcName > func; \
itk::UnaryVectorOPImage<ImageType, ImageOutType>(image, outImage, func, mask, _numberOfThreads); \
}
int _numberOfThreads
Definition: 4DImageMath.cxx:78
int _Operation
Definition: 4DImageMath.cxx:75

Definition at line 220 of file 4DImageMath.cxx.

Referenced by ImageMath().

#define __XYZTMultiVectorFunctor (   axisNum,
  argNoAxis,
  opNoAxis,
  funcName 
)
Value:
if (argNoAxis##Arg.isSet()) \
{ \
_SetOperationWithChecking(_Operation, OP_##opNoAxis, imageVec.size()>=2); \
funcName func; \
itk::MultiVariableVectorOPImage<ImageType, ImageOutType>(imageVec, outImage, func, mask, _numberOfThreads, axisNum); \
}
int _numberOfThreads
Definition: 4DImageMath.cxx:78
int _Operation
Definition: 4DImageMath.cxx:75

Definition at line 248 of file 4DImageMath.cxx.

Referenced by ImageMath().

#define __XYZTMultiVectorFunctor_FixedSize (   axisNum,
  argNoAxis,
  opNoAxis,
  funcName,
  inSize 
)
Value:
if (argNoAxis##Arg.isSet()) \
{ \
_SetOperationWithChecking(_Operation, OP_##opNoAxis, imageVec.size()==inSize); \
funcName func; \
itk::MultiVariableVectorOPImage<ImageType, ImageOutType>(imageVec, outImage, func, mask, _numberOfThreads, axisNum); \
}
int _numberOfThreads
Definition: 4DImageMath.cxx:78
int _Operation
Definition: 4DImageMath.cxx:75

Definition at line 257 of file 4DImageMath.cxx.

Referenced by ImageMath().

#define __XYZTUnaryVectorFunctor (   axisNum,
  argNoAxis,
  opNoAxis,
  funcName 
)
Value:
if (argNoAxis##Arg.isSet()) \
{ \
_SetOperationWithChecking(_Operation, OP_##opNoAxis, imageVec.size()==1); \
funcName func; \
itk::UnaryVectorOPImage<ImageType, ImageOutType>(image, outImage, func, mask, _numberOfThreads, axisNum); \
}
#define _SetOperationWithChecking(op, value, numberOfInputsCond)
Definition: 4DImageMath.cxx:93
int _numberOfThreads
Definition: 4DImageMath.cxx:78
int _Operation
Definition: 4DImageMath.cxx:75

Definition at line 229 of file 4DImageMath.cxx.

Referenced by ImageMath().

#define __XYZTUnaryVectorFunctorWithArguments (   axisNum,
  argNoAxis,
  opNoAxis,
  funcName 
)
Value:
if (argNoAxis##Arg.isSet()) \
{ \
_SetOperationWithChecking(_Operation, OP_##opNoAxis, imageVec.size()==1); \
funcName func; \
func.SetArguments(argNoAxis); \
itk::UnaryVectorOPImage<ImageType, ImageOutType>(image, outImage, func, mask, _numberOfThreads, axisNum); \
}
int _numberOfThreads
Definition: 4DImageMath.cxx:78
int _Operation
Definition: 4DImageMath.cxx:75

Definition at line 238 of file 4DImageMath.cxx.

Referenced by ImageMath().

#define _SetOperationWithChecking (   op,
  value,
  numberOfInputsCond 
)
Value:
do \
{ \
utlSAGlobalException(!(numberOfInputsCond))(numberOfInputsCond).msg("wrong number of inputs!"); \
} while ( 0 );
#define utlSAGlobalException(expr)
Definition: utlCoreMacro.h:362
void SetOperationWithChecking(int &op, int value)
Definition: 4DImageMath.cxx:83

Definition at line 93 of file 4DImageMath.cxx.

Referenced by ImageMath().

Typedef Documentation

typedef itk::Image<ScalarType, 4> NDImageType

Definition at line 29 of file 4DImageMath.cxx.

typedef double ScalarType

Definition at line 28 of file 4DImageMath.cxx.

typedef itk::VectorImage<ScalarType, 3> VectorImageType

Definition at line 30 of file 4DImageMath.cxx.

Enumeration Type Documentation

anonymous enum
Enumerator
OP_NULL 
OP_ADD 
OP_MINUS 
OP_MULTIPLY 
OP_DIVIDE 
OP_MAX 
OP_MIN 
OP_POW 
OP_FUNC 
OP_ABS 
OP_EXP 
OP_LOG 
OP_SQUARE 
OP_SQRT 
OP_NORM 
OP_MEAN 
OP_MEDIAN 
OP_SUM 
OP_MAX_AXIS 
OP_MIN_AXIS 
OP_DOTPRODUCT 
OP_COMPOSE 
OP_SHRED 
OP_CROP 

Definition at line 40 of file 4DImageMath.cxx.

Function Documentation

template<class ImageType , class ImageOutType , class OpFunctor >
void BinaryOPImage ( const itk::SmartPointer< ImageType > &  image,
itk::SmartPointer< ImageOutType > &  outImage,
std::string  _MaskImageFile,
std::string  _opImageFile,
const OpFunctor &  func 
)
template<class ImageType , class Image2Type >
void ConvertImage ( const itk::SmartPointer< ImageType > &  image,
itk::SmartPointer< Image2Type > &  imageOut 
)

Definition at line 121 of file 4DImageMath.cxx.

Referenced by ImageMath().

+ Here is the caller graph for this function:

template<>
void ConvertImage< NDImageType, VectorImageType > ( const itk::SmartPointer< NDImageType > &  image,
itk::SmartPointer< VectorImageType > &  imageOut 
)

Definition at line 128 of file 4DImageMath.cxx.

References itk::MultiVolumeToVectorImage().

+ Here is the call graph for this function:

template<>
void ConvertImage< VectorImageType, NDImageType > ( const itk::SmartPointer< VectorImageType > &  image,
itk::SmartPointer< NDImageType > &  imageOut 
)

Definition at line 135 of file 4DImageMath.cxx.

References itk::VectorToMultiVolumeImage().

+ Here is the call graph for this function:

void GetImageFiles ( const std::vector< std::string > &  imageVec,
std::string &  inImage0,
std::string &  outImage 
)

Definition at line 102 of file 4DImageMath.cxx.

References utlGlobalException.

Referenced by ImageMath(), and main().

+ Here is the caller graph for this function:

int GetNumberFromAxis ( std::string  axis)

Definition at line 109 of file 4DImageMath.cxx.

References utlGlobalException.

Referenced by ImageMath().

+ Here is the caller graph for this function:

template<class ImageType , class ImageOutType >
int ImageMath ( int  argc,
char const *  argv[] 
)
template<class IndexType >
bool IsOutsideBox ( const IndexType &  index,
const std::vector< int > &  box 
)

Definition at line 34 of file 4DImageMath.cxx.

Referenced by BinaryOPImage().

+ Here is the caller graph for this function:

int main ( int  argc,
char const *  argv[] 
)

4DImage math. It works for both itk::Image<double,4> and itk::VectorImage<double,3>

Definition at line 687 of file 4DImageMath.cxx.

References GetImageFiles(), itk::Is3DImage(), and itk::IsVectorImage().

+ Here is the call graph for this function:

void SetOperationWithChecking ( int &  op,
int  value 
)

Definition at line 83 of file 4DImageMath.cxx.

References OP_NULL, and utlGlobalException.

Referenced by ImageMath().

+ Here is the caller graph for this function:

Variable Documentation

std::string _axis

Definition at line 79 of file 4DImageMath.cxx.

Referenced by ImageMath().

int _axisNumber =-1

Definition at line 80 of file 4DImageMath.cxx.

Referenced by ImageMath().

int _numberOfThreads = -1

Definition at line 78 of file 4DImageMath.cxx.

Referenced by ImageMath().

int _Operation = OP_NULL

Definition at line 75 of file 4DImageMath.cxx.

Referenced by ImageMath().

std::vector<int> _realBox

Definition at line 76 of file 4DImageMath.cxx.

std::vector<int> _size