SIRF  3.5.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
sirf::NiftiImageData< dataType > Class Template Reference
Inheritance diagram for sirf::NiftiImageData< dataType >:
sirf::ImageData sirf::DataContainer sirf::NiftiImageData3D< dataType > sirf::NiftiImageData3DTensor< dataType > sirf::NiftiImageData3DDeformation< dataType > sirf::NiftiImageData3DDisplacement< dataType >

Classes

class  Iterator
 
class  Iterator_const
 

Public Types

typedef ImageData::Iterator BaseIter
 
typedef ImageData::Iterator_const BaseIter_const
 

Public Member Functions

 NiftiImageData ()
 Constructor.
 
virtual ~NiftiImageData ()
 Destructor.
 
 NiftiImageData (const NiftiImageData &to_copy)
 Copy constructor.
 
NiftiImageDataoperator= (const NiftiImageData &to_copy)
 Assignment.
 
 NiftiImageData (const ImageData &to_copy)
 Copy constructor.
 
NiftiImageDataoperator= (const ImageData &to_copy)
 Assignment.
 
 NiftiImageData (const std::string &filename)
 Filename constructor.
 
 NiftiImageData (const nifti_image &image_nifti)
 Nifti constructor.
 
template<class inputType >
 NiftiImageData (const inputType *const data, const VoxelisedGeometricalInfo3D &geom, const bool is_tensor=false)
 Construct from array.
 
bool operator== (const NiftiImageData &other) const
 Equality operator.
 
bool operator!= (const NiftiImageData &other) const
 Equality operator.
 
NiftiImageDataoperator+= (const NiftiImageData &rhs)
 Addition operator.
 
NiftiImageDataoperator-= (const NiftiImageData &rhs)
 Subtraction operator.
 
NiftiImageDataoperator+= (const float)
 Addition operator.
 
NiftiImageDataoperator-= (const float)
 Subtraction operator.
 
NiftiImageDataoperator*= (const float)
 Multiplication operator.
 
NiftiImageDataoperator*= (const NiftiImageData &rhs)
 Multiplication operator.
 
NiftiImageDataoperator/= (const float)
 Division operator.
 
NiftiImageDataoperator/= (const NiftiImageData &rhs)
 
float operator() (const int index) const
 Access data element via 1D index (const)
 
float & operator() (const int index)
 Access data element via 1D index.
 
float operator() (const int index[7]) const
 Access data element via 7D index (const)
 
float & operator() (const int index[7])
 Access data element via 7D index.
 
float operator() (const int x, const int y, const int z, const int t=0, const int u=0, const int v=0, const int w=0) const
 Access data element via 7D index (const)
 
float & operator() (const int x, const int y, const int z, const int t=0, const int u=0, const int v=0, const int w=0)
 Access data element via 7D index.
 
bool is_initialised () const
 Is the image initialised? (Should be unless default constructor was used.)
 
std::shared_ptr< const nifti_image > get_raw_nifti_sptr () const
 Get image as nifti as const.
 
std::shared_ptr< nifti_image > get_raw_nifti_sptr ()
 Get image as nifti.
 
virtual void write (const std::string &filename, const int datatype) const
 
virtual void write (const std::string &filename) const
 Write.
 
float get_max () const
 Get max.
 
float get_min () const
 Get min.
 
float get_mean () const
 Get mean.
 
float get_variance () const
 Get variance.
 
float get_standard_deviation () const
 Get standard deviation.
 
float get_sum () const
 Get sum.
 
unsigned get_nan_count () const
 Get nan count.
 
void fill (const float v)
 Fill.
 
void fill (const dataType *v)
 Fill from array.
 
void fill (const NiftiImageData &im)
 Fill from array.
 
float get_norm (const NiftiImageData &) const
 Get norm.
 
const int * get_dimensions () const
 Get data size in each dimension.
 
size_t get_num_voxels () const
 Get total number of voxels.
 
void print_header () const
 Print header info. More...
 
void crop (const int min_index[7], const int max_index[7])
 Crop. Set to -1 to leave unchanged.
 
void pad (const int min_index[7], const int max_index[7], const dataType val=0)
 Pad image with value. Give number of voxels to increase in min and max directions. Set values to -1 to leave unchanged.
 
int get_1D_index (const int idx[7]) const
 get 1D index from ND index
 
int get_original_datatype () const
 Get original datatype.
 
bool is_in_bounds (const int index[7]) const
 Point is in bounds?
 
bool is_in_bounds (const int index) const
 Point is in bounds?
 
bool is_same_size (const NiftiImageData &im) const
 Images are same size.
 
void set_voxel_spacing (const float factors[3], const int interpolation_order)
 
void kernel_convolution (const float sigma, NREG_CONV_KERNEL_TYPE conv_type=GAUSSIAN_KERNEL)
 Kernel convolution.
 
bool get_contains_nans () const
 Does the image contain any NaNs?
 
void flip_along_axis (const unsigned axis)
 Flip the image along a given axis (Rotation of 180 degrees about axis)
 
void mirror_along_axis (const unsigned axis)
 Mirror the image along a given axis (This will change handedness of image)
 
dataType get_inner_product (const NiftiImageData &other) const
 Inner product of two images.
 
void normalise_zero_and_one ()
 Normalise image between 0 and 1.
 
void standardise ()
 Standardise (subtract mean and divide by standard deviation).
 
std::unique_ptr< NiftiImageDataclone () const
 Clone and return as unique pointer.
 
virtual Iteratorbegin ()
 
virtual Iterator_constbegin () const
 
virtual Iteratorend ()
 
virtual Iterator_constend () const
 
unsigned int items () const
 
virtual void sum (void *ptr) const
 below all void* are actually float*
 
virtual void max (void *ptr) const
 calculates the value of this container's element with the largest real part
 
virtual void dot (const DataContainer &a_x, void *ptr) const
 calculates the dot product of this container with another one More...
 
virtual void axpby (const void *ptr_a, const DataContainer &a_x, const void *ptr_b, const DataContainer &a_y)
 *this = the linear combination of x and y
 
virtual void xapyb (const DataContainer &a_x, const void *ptr_a, const DataContainer &a_y, const void *ptr_b)
 alternative interface to the above
 
virtual void xapyb (const DataContainer &a_x, const DataContainer &a_a, const DataContainer &a_y, const DataContainer &a_b)
 *this = elementwise sum of two elementwise products x*a and y*b
 
virtual void xapyb (const DataContainer &a_x, const void *ptr_a, const DataContainer &a_y, const DataContainer &a_b)
 *this = elementwise sum of x*a and elementwise y*b
 
virtual float norm () const
 returns the norm of this container viewed as a vector
 
virtual void multiply (const DataContainer &a_x, const DataContainer &a_y)
 *this = the elementwise product x*y
 
virtual void divide (const DataContainer &a_x, const DataContainer &a_y)
 *this = the elementwise ratio x / y
 
virtual void maximum (const DataContainer &x, const DataContainer &y)
 *this = the elementwise max(x, y)
 
virtual void minimum (const DataContainer &x, const DataContainer &y)
 *this = the elementwise min(x, y)
 
virtual void power (const DataContainer &x, const DataContainer &y)
 *this = the elementwise pow(x, y)
 
virtual void multiply (const DataContainer &a_x, const void *a_y)
 *this = the product x * y with scalar y
 
virtual void add (const DataContainer &a_x, const void *a_y)
 *this = the sum x + y with scalar y
 
virtual void maximum (const DataContainer &x, const void *a_y)
 
virtual void minimum (const DataContainer &x, const void *a_y)
 
virtual void power (const DataContainer &x, const void *a_y)
 
virtual void exp (const DataContainer &x)
 *this = the elementwise exp(x)
 
virtual void log (const DataContainer &x)
 *this = the elementwise log(x)
 
virtual void sqrt (const DataContainer &x)
 *this = the elementwise sqrt(x)
 
virtual void sign (const DataContainer &x)
 *this = the elementwise sign(x)
 
virtual void abs (const DataContainer &x)
 *this = the elementwise abs(x)
 
virtual Dimensions dimensions () const
 
void unary_op (const DataContainer &a_x, dataType(*f)(dataType))
 
void semibinary_op (const DataContainer &a_x, const void *a_y, dataType(*f)(dataType, dataType))
 
void binary_op (const DataContainer &a_x, const DataContainer &a_y, dataType(*f)(dataType, dataType))
 
virtual void set_up_geom_info ()
 Set up the geometrical info. Use qform preferentially over sform.
 
- Public Member Functions inherited from sirf::ImageData
virtual void scale (float s)=0
 
virtual bool ordered () const
 
void copy (Iterator_const &src, Iterator &dst, Iterator &end) const
 
void fill (const ImageData &im)
 
void fill (float v)
 
virtual bool operator== (const ImageData &id) const
 Write image to file.
 
virtual bool operator!= (const ImageData &id) const
 
std::shared_ptr< const VoxelisedGeometricalInfo3Dget_geom_info_sptr () const
 Get geometrical info.
 
std::unique_ptr< ImageDataclone () const
 Clone and return as unique pointer.
 
virtual bool is_complex () const
 Is complex? Unless overwridden (Gadgetron), assume not complex.
 
virtual void reorient (const VoxelisedGeometricalInfo3D &)
 Reorient image. Requires that dimesions and spacing match.
 
- Public Member Functions inherited from sirf::DataContainer
virtual int bits () const
 returns the size of data elements
 
void xapyb (const DataContainer &a_x, const DataContainer &a_a, const DataContainer &a_y, const void *ptr_b)
 *this = elementwise sum of elementwise x*a and y*b
 
bool is_empty () const
 
std::unique_ptr< DataContainerclone () const
 
void conjugate ()
 overwrites this container's complex data with complex conjugate values
 
std::unique_ptr< DataContainerconjugate () const
 returns unique pointer to the complex-conjugated copy of this container
 

Static Public Member Functions

static std::shared_ptr< nifti_image > create_from_geom_info (const VoxelisedGeometricalInfo3D &geom, const bool is_tensor=false, const NREG_TRANS_TYPE tensor_type=NREG_TRANS_TYPE::DEF_FIELD)
 Create NiftiImageData from geometrical info.
 
static void construct_NiftiImageData_from_complex_im_real_component (std::shared_ptr< NiftiImageData > &out_sptr, const std::shared_ptr< const ImageData > in_sptr)
 Construct NiftiImageData from the real component of a complex SIRF ImageData.
 
static void construct_NiftiImageData_from_complex_im_imag_component (std::shared_ptr< NiftiImageData > &out_sptr, const std::shared_ptr< const ImageData > in_sptr)
 Construct NiftiImageData from the imaginary component of a complex SIRF ImageData.
 
static void construct_NiftiImageData_from_complex_im (std::shared_ptr< NiftiImageData > &out_real_sptr, std::shared_ptr< NiftiImageData > &out_imag_sptr, const std::shared_ptr< const ImageData > in_sptr)
 Construct two NiftiImageData from a complex SIRF ImageData.
 
static void print_headers (const std::vector< const NiftiImageData * > &ims)
 Print multiple header info. More...
 
static bool are_equal_to_given_accuracy (const NiftiImageData &im1, const NiftiImageData &im2, const float required_accuracy_compared_to_max)
 Check if the norms of two images are equal to a given accuracy.
 
static bool do_nifti_image_metadata_match (const NiftiImageData &im1, const NiftiImageData &im2, bool verbose)
 Do nifti image metadatas match?
 
static void dump_headers (const std::vector< const NiftiImageData * > &ims)
 Dump info of multiple nifti images.
 
template<typename T >
static void dump_nifti_element (const std::vector< const NiftiImageData * > &ims, const std::string &name, const T &call_back)
 Dump nifti element.
 
template<typename T >
static void dump_nifti_element (const std::vector< const NiftiImageData * > &ims, const std::string &name, const T &call_back, const unsigned num_elems)
 Dump nifti element.
 
static std::string get_headers (const std::vector< const NiftiImageData< dataType > * > &ims)
 
template<typename T >
static std::string get_nifti_element (const std::vector< const NiftiImageData * > &ims, const std::string &name, const T &call_back)
 
template<typename T >
static std::string get_nifti_element (const std::vector< const NiftiImageData * > &ims, const std::string &name, const T &call_back, const unsigned num_elems)
 
- Static Public Member Functions inherited from sirf::ImageData
static bool can_reorient (const VoxelisedGeometricalInfo3D &geom_1, const VoxelisedGeometricalInfo3D &geom_2, const bool throw_error)
 Can reorient? (check dimensions and spacing)
 
- Static Public Member Functions inherited from sirf::DataContainer
template<typename T >
static T product (T x, T y)
 
template<typename T >
static T ratio (T x, T y)
 
template<typename T >
static T inverse_ratio (T x, T y)
 
template<typename T >
static T sum (T x, T y)
 
template<typename T >
static T maximum (T x, T y)
 
template<typename T >
static T maxabs (T x, T y)
 
template<typename T >
static T maxreal (T x, T y)
 
template<typename T >
static T minimum (T x, T y)
 
template<typename T >
static T minabs (T x, T y)
 
template<typename T >
static T minreal (T x, T y)
 
static std::complex< float > power (std::complex< float > x, std::complex< float > y)
 
static std::complex< float > exp (std::complex< float > x)
 
static std::complex< float > log (std::complex< float > x)
 
static std::complex< float > sqrt (std::complex< float > x)
 
template<typename T >
static T sign (T x)
 
template<typename T >
static T abs (T x)
 

Protected Types

enum  NiftiImageDataType {
  _general , _3D , _3DTensor , _3DDisp ,
  _3DDef
}
 
enum  MathsType { ADD , sub , mul , div }
 

Protected Member Functions

void check_dimensions (const enum NiftiImageDataType image_type=_general)
 Check dimensions. Don't require anything for this class.
 
void set_up_data (const int original_datatype)
 Set up datatype. Set to float if not already, store the original type.
 
void maths (const NiftiImageData &c, const MathsType type)
 Add, subract image from another.
 
void maths (const float val, const MathsType type)
 Add, subract, multiply value to image.
 
virtual NiftiImageDataclone_impl () const
 Clone helper function. Don't use.
 
virtual ObjectHandle< DataContainer > * new_data_container_handle () const
 
- Protected Member Functions inherited from sirf::ImageData
void set_geom_info (const std::shared_ptr< VoxelisedGeometricalInfo3D > geom_info_sptr)
 Set geom info.
 
- Protected Member Functions inherited from sirf::DataContainer
virtual void conjugate_impl ()
 we assume data to be real, complex data containers must override this
 

Static Protected Member Functions

static void open_nifti_image (std::shared_ptr< nifti_image > &image, const std::string &filename)
 Open nifti image.
 
static void copy_nifti_image (std::shared_ptr< nifti_image > &output_image_sptr, const std::shared_ptr< nifti_image > &image_to_copy_sptr)
 Copy nifti image.
 

Protected Attributes

std::shared_ptr< nifti_image > _nifti_image
 Image data as a nifti object.
 
float * _data = NULL
 Data.
 
int _original_datatype = -1
 Original datatype.
 
std::shared_ptr< Iterator_begin
 
std::shared_ptr< Iterator_end
 
std::shared_ptr< Iterator_const_begin_const
 
std::shared_ptr< Iterator_const_end_const
 

Friends

NiftiImageData operator+ (NiftiImageData lhs, const NiftiImageData &rhs)
 Addition operator.
 
NiftiImageData operator- (NiftiImageData lhs, const NiftiImageData &rhs)
 Subtraction operator.
 
NiftiImageData operator+ (NiftiImageData lhs, const float val)
 Addition operator.
 
NiftiImageData operator- (NiftiImageData lhs, const float val)
 Subtraction operator.
 
NiftiImageData operator* (NiftiImageData lhs, const float val)
 Multiplication operator.
 
NiftiImageData operator* (NiftiImageData lhs, const NiftiImageData &rhs)
 Multiplication operator.
 
NiftiImageData operator/ (NiftiImageData lhs, const float val)
 
NiftiImageData operator/ (NiftiImageData lhs, const NiftiImageData &rhs)
 Division operator.
 

Member Function Documentation

◆ dot()

template<class dataType >
void NiftiImageData::dot ( const DataContainer dc,
void *  ptr 
) const
virtual

calculates the dot product of this container with another one

below all void* are actually either float* (STIR containers and NiftiImageData) or complex_float_t* (Gadgetron containers)

Implements sirf::DataContainer.

◆ print_header()

template<class dataType >
void NiftiImageData::print_header

Print header info.

Dump header info.

◆ print_headers()

template<class dataType >
void NiftiImageData::print_headers ( const std::vector< const NiftiImageData< dataType > * > &  ims)
static

Print multiple header info.

Dump multiple header info.

◆ set_voxel_spacing()

template<class dataType >
void NiftiImageData::set_voxel_spacing ( const float  factors[3],
const int  interpolation_order 
)

Set the voxel spacing. Requires resampling image, and so interpolation order is required. As per NiftyReg, interpolation_order can be either 0, 1 or 3 meaning nearest neighbor, linear or cubic spline interpolation.

◆ write()

template<class dataType >
void NiftiImageData::write ( const std::string &  filename,
const int  datatype 
) const
virtual

Save to file. Templated so the user can choose the datatype they save to. This defaults to -1, which is the original datatype of that image (stored as _original_datatype).


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