Biomedical Image Analysis Library
The Biomedical Image Analysis Library is a poweful tool for developers, physicians, researchers, engineers, and so on.
Bial::NiftiHeader Class Reference

Magnetic Resonance Image class. More...

#include <NiftiHeader.hpp>

Collaboration diagram for Bial::NiftiHeader:
Collaboration graph

Public Member Functions

 NiftiHeader ()
 Basic Constructor. More...
 
 NiftiHeader (const Vector< size_t > &new_dim, const Vector< float > &new_pixdim, NiftiType new_datatype=NiftiType::INT8, bool one_file=true)
 Basic Constructor. More...
 
template<class D >
 NiftiHeader (const Image< D > &img, bool one_file=true)
 Basic Constructor. More...
 
 NiftiHeader (const std::string &filename)
 Basic Constructor. More...
 
const Vector< size_t > & Dim () const
 Returns a reference to dimension vector. More...
 
size_t Size (size_t dms) const
 Returns the size of a given image dimension. More...
 
void Size (size_t dms, size_t val)
 Updates image dimension size. More...
 
const Vector< float > & PixelSize () const
 Returns a reference to pixel dimension vector. More...
 
float PixelSize (size_t dms) const
 Returns the pixel size of a given image dimension. More...
 
void PixelSize (size_t dms, float val)
 Updates Pixel dimension size. More...
 
short BitPix () const
 Returns the number of bits per pixel. More...
 
NiftiType DataType () const
 Returns data type code. More...
 
void Write (OFile &file, bool one_file) const
 Writes this nifti header to file. More...
 
void Write (const std::string &filename) const
 Writes this nifti header to file with filename 'filename'. More...
 
void DataType (NiftiType type)
 Changes header information to support data of type 'type'. More...
 
void QuaternToMat (const Vector< float > &pixel_dim)
 Translates quaterns to 4x4 matrix used to convert from xyz to ijk space. More...
 
void MatToQuatern ()
 Translates 4x4 matrix used to convert from xyz to ijk space to quaterns. More...
 
std::string Orientation (size_t row) const
 Returned std::string can be: LR, RL, SI, IS, AP, PA, or Undefined. More...
 
std::string Orientation () const
 Returned std::string will be a composition of three values containing: LR, RL, SI, IS, AP, or PA, or Undefined std::string. More...
 
bool UseQuatern ()
 Returns a boolean value indicating if this MR image uses quaternion orientation form or not. More...
 
bool UseAffine ()
 Returns a boolean value indicating if this MR image uses affine orientation form or not. More...
 
void QuaternMatrix (const Matrix< float > mat)
 Assigns mat data to qtm. More...
 
Matrix< float > QuaternMatrix () const
 returns a copy of qtm. More...
 
void QuaternOffset (float x, float y, float z)
 Sets quatern offset. More...
 
void AffineMatrix (const Matrix< float > mat)
 Assigns mat data to stm. More...
 
Matrix< float > AffineMatrix () const
 returns a copy of stm. More...
 
template<class O >
O & PrintOrientation (O &os) const
 Prints nifti orientation information to output stream 'os'. More...
 
template<class O >
O & Print (O &os) const
 Prints nifti header information to output stream 'os'. More...
 

Static Public Member Functions

static NiftiHeader Read (const std::string &filename)
 Returns a nifti header read from file with filename 'filename'. More...
 
static bool IsNiftiFile (const std::string &filename)
 Returns true if given file has nifti extension. More...
 
static std::string HeaderFileName (const std::string &filename)
 Returns nifti header file name associated to filename. More...
 
static std::string DataFileName (const std::string &filename)
 Returns nifti data file name associated to filename. More...
 
static std::string ExistingHeaderFileName (const std::string &filename)
 Returns existing nifti header file name associated to filename. More...
 
static std::string ExistingDataFileName (const std::string &filename)
 Returns existing nifti data file name associated to filename. More...
 
static size_t AxialDimension (const std::string &orientation)
 Returns the number of the image dimension that corresponds to axial direction. More...
 
static size_t CoronalDimension (const std::string &orientation)
 Returns the number of the image dimension that corresponds to coronal direction. More...
 
static size_t SagittalDimension (const std::string &orientation)
 Returns the number of the image dimension that corresponds to sagittal direction. More...
 
static bool SuperiorInferior (const std::string &orientation)
 Returns true if axial dimension direction is superior-inferior. More...
 
static bool AnteriorPosterior (const std::string &orientation)
 Returns true if coronal dimension direction is anterior-posterior. More...
 
static void SwapNBytes (size_t n, int siz, void *ar)
 Swaps bytes of data pointed by ar. Used to read data written by different architectures. More...
 
static bool IsSwapped (const std::string filename)
 Verifies if header nifti file corresponding to filename must swap bytes order. More...
 
static NiftiType DataType (const std::string &filename)
 Returns the type of the data in given file. More...
 
static void DataTypeSizes (int datatype, size_t &nbyper, size_t &swapsize)
 Computes the number of bytes of each element and the bytes to be swapped. More...
 

Static Public Attributes

static const short NIFTI_HEADER_SIZE = 348
 
static const short ANALYZE_EXTENT = 16384
 

Friends

template<class D >
class Image
 

Detailed Description

Magnetic Resonance Image class.

Definition at line 248 of file NiftiHeader.hpp.

Constructor & Destructor Documentation

Bial::NiftiHeader::NiftiHeader ( )

Basic Constructor.

Date
2013/Fev/01
Parameters
none.
Returns
none.
Warning
All nifti fields are uninitialized or undefined.
Bial::NiftiHeader::NiftiHeader ( const Vector< size_t > &  new_dim,
const Vector< float > &  new_pixdim,
NiftiType  new_datatype = NiftiType::INT8,
bool  one_file = true 
)

Basic Constructor.

Date
2012/Aug/02
Parameters
new_dimVector with MR image dimensions.
new_pixel_dimarray with pixel dimensions.
new_datatypenifti header data type.
one_filedefines weather it is a header from one or two files image.
Returns
none.
Warning
All nifti fields, except dim, pixdim, and datatype, are uninitialized.
template<class D >
Bial::NiftiHeader::NiftiHeader ( const Image< D > &  img,
bool  one_file = true 
)

Basic Constructor.

Date
2012/Aug/20
Parameters
imgbase image to extract dimensions and datatype.
one_filedefines weather it is a header from one or two files image.
Returns
none.
Warning
All nifti fields, except dim, pixdim, and datatype, are uninitialized.
Bial::NiftiHeader::NiftiHeader ( const std::string &  filename)

Basic Constructor.

Date
2013/Aug/10
Parameters
filenameFile name.
Returns
none.
Warning
none.

Member Function Documentation

void Bial::NiftiHeader::AffineMatrix ( const Matrix< float >  mat)

Assigns mat data to stm.

Date
2012/Aug/03
Parameters
mata matrix to be set to affine transformation matrix.
Returns
none.
Warning
This method will change data orientation.
Matrix< float > Bial::NiftiHeader::AffineMatrix ( ) const

returns a copy of stm.

Date
2012/Aug/03
Parameters
none.
Returns
A copy of stm.
Warning
none.
static bool Bial::NiftiHeader::AnteriorPosterior ( const std::string &  orientation)
static

Returns true if coronal dimension direction is anterior-posterior.

Date
2014/Mar/14
Parameters
orientationImage orientation. Must be a composition of three values containing: LR, RL, SI, IS, AP, or PA. Look for NiftiHeader::Orientation() function for examples.
Returns
True if coronal dimension direction is anterior-posterior.
Warning
none.
static size_t Bial::NiftiHeader::AxialDimension ( const std::string &  orientation)
static

Returns the number of the image dimension that corresponds to axial direction.

Date
2013/Aug/27
Parameters
orientationImage orientation. Must be a composition of three values containing: LR, RL, SI, IS, AP, or PA. Look for NiftiHeader::Orientation() function for examples.
Returns
The number of the image dimension that corresponds to axial direction.
Warning
none.
short Bial::NiftiHeader::BitPix ( ) const

Returns the number of bits per pixel.

Date
2015/Oct/30
Parameters
none.
Returns
Number of bits per pixel.
Warning
none.
static size_t Bial::NiftiHeader::CoronalDimension ( const std::string &  orientation)
static

Returns the number of the image dimension that corresponds to coronal direction.

Date
2013/Aug/27
Parameters
orientationImage orientation. Must be a composition of three values containing: LR, RL, SI, IS, AP, or PA. Look for NiftiHeader::Orientation() function for examples.
Returns
The number of the image dimension that corresponds to coronal direction.
Warning
none.
static std::string Bial::NiftiHeader::DataFileName ( const std::string &  filename)
static

Returns nifti data file name associated to filename.

Date
2013/Sep/25
Parameters
filenameA nifti extension file name.
Returns
Nifti data file name associated to filename.
Warning
none.
NiftiType Bial::NiftiHeader::DataType ( ) const

Returns data type code.

Date
2015/Oct/30
Parameters
none.
Returns
The data type code.
Warning
none.
void Bial::NiftiHeader::DataType ( NiftiType  type)

Changes header information to support data of type 'type'.

Date
2013/Aug/20
Parameters
typedata type.
Returns
none.
Warning
none.
static NiftiType Bial::NiftiHeader::DataType ( const std::string &  filename)
static

Returns the type of the data in given file.

Date
2013/Aug/20
Parameters
filenameA nifti extension file name.
Returns
Type of data in given file.
Warning
none.
static void Bial::NiftiHeader::DataTypeSizes ( int  datatype,
size_t &  nbyper,
size_t &  swapsize 
)
static

Computes the number of bytes of each element and the bytes to be swapped.

Date
2012/jul/31
Parameters
datatypetype of image data.
nbyperbytes by data element.
swapsizesize of datas that may be swapped.
Returns
none.
Warning
none.
const Vector< size_t >& Bial::NiftiHeader::Dim ( ) const

Returns a reference to dimension vector.

Date
2015/Oct/30
Parameters
none.
Returns
Reference to dimension vector.
Warning
none.
static std::string Bial::NiftiHeader::ExistingDataFileName ( const std::string &  filename)
static

Returns existing nifti data file name associated to filename.

Date
2013/Aug/11
Parameters
filenameA nifti extension file name.
Returns
Existing nifti data file name associated to filename.
Warning
none.
static std::string Bial::NiftiHeader::ExistingHeaderFileName ( const std::string &  filename)
static

Returns existing nifti header file name associated to filename.

Date
2013/Aug/11
Parameters
filenameA nifti extension file name.
Returns
Existing nifti header file name associated to filename.
Warning
none.
static std::string Bial::NiftiHeader::HeaderFileName ( const std::string &  filename)
static

Returns nifti header file name associated to filename.

Date
2013/Sep/25
Parameters
filenameA nifti extension file name.
Returns
Nifti header file name associated to filename.
Warning
none.
static bool Bial::NiftiHeader::IsNiftiFile ( const std::string &  filename)
static

Returns true if given file has nifti extension.

Date
2014/May/27
Parameters
filenameA file name.
Returns
True if given file has nifti extension.
Warning
none.
static bool Bial::NiftiHeader::IsSwapped ( const std::string  filename)
static

Verifies if header nifti file corresponding to filename must swap bytes order.

Date
2013/Aug/21
Parameters
filenameFile name.
Returns
If header nifti file corresponding to filename must swap bytes order.
Warning
none.
void Bial::NiftiHeader::MatToQuatern ( )

Translates 4x4 matrix used to convert from xyz to ijk space to quaterns.

Date
2012/Aug/03
Parameters
none.
Returns
none.
Warning
Quatern parameters must be set prior to this function call.
std::string Bial::NiftiHeader::Orientation ( size_t  row) const

Returned std::string can be: LR, RL, SI, IS, AP, PA, or Undefined.

Date
2012/Sep/08
Parameters
rowThe row of orientation.
Returns
A std::string with the orientation of the given row.
Warning
Looks for quatern form first. If it is undefined, searches in affine form.
std::string Bial::NiftiHeader::Orientation ( ) const

Returned std::string will be a composition of three values containing: LR, RL, SI, IS, AP, or PA, or Undefined std::string.

Date
2012/Sep/08
Parameters
none.
Returns
A std::string with the orientation of the MR image.
Warning
Looks for quatern form first. If it is undefined, searches in affine form.
const Vector< float >& Bial::NiftiHeader::PixelSize ( ) const

Returns a reference to pixel dimension vector.

Date
2015/Oct/30
Parameters
none.
Returns
Reference to pixel dimension vector.
Warning
none.
float Bial::NiftiHeader::PixelSize ( size_t  dms) const

Returns the pixel size of a given image dimension.

Date
2016/Apr/14
Parameters
dmsThe dimension of desired pixel size.
Returns
The pixel size of a given image dimension.
Warning
none.
void Bial::NiftiHeader::PixelSize ( size_t  dms,
float  val 
)

Updates Pixel dimension size.

Date
2016/Apr/14
Parameters
dmsThe dimension of desired size.
valNew size of the pixel dimension.
Returns
none.
Warning
none.
template<class O >
O& Bial::NiftiHeader::Print ( O &  os) const

Prints nifti header information to output stream 'os'.

Date
2012/Aug/06
Parameters
osAn output stream.
Returns
A reference to the given output stream.
Warning
none.
template<class O >
O& Bial::NiftiHeader::PrintOrientation ( O &  os) const

Prints nifti orientation information to output stream 'os'.

Date
2012/Aug/06
Parameters
osAn output stream.
Returns
A reference to the given output stream.
Warning
none.
void Bial::NiftiHeader::QuaternMatrix ( const Matrix< float >  mat)

Assigns mat data to qtm.

Date
2012/Aug/03
Parameters
mata matrix to be set to quatern matrix.
Returns
none.
Warning
This method will change data orientation.
Matrix< float > Bial::NiftiHeader::QuaternMatrix ( ) const

returns a copy of qtm.

Date
2012/Aug/03
Parameters
none.
Returns
A copy of qtm.
Warning
none.
void Bial::NiftiHeader::QuaternOffset ( float  x,
float  y,
float  z 
)

Sets quatern offset.

Date
2012/Aug/03
Parameters
xx quatern offset.
yy quatern offset.
zz quatern offset.
Returns
none.
Warning
none.
void Bial::NiftiHeader::QuaternToMat ( const Vector< float > &  pixel_dim)

Translates quaterns to 4x4 matrix used to convert from xyz to ijk space.

Date
2012/jul/31
Parameters
pixel_dimdimensions of the pixel.
Returns
none.
Warning
Quatern parameters must be set prior to this function call.
static NiftiHeader Bial::NiftiHeader::Read ( const std::string &  filename)
static

Returns a nifti header read from file with filename 'filename'.

Date
2013/Aug/20
Parameters
filenameA nifti extension file name.
Returns
Nifti header object.
Warning
none.
static size_t Bial::NiftiHeader::SagittalDimension ( const std::string &  orientation)
static

Returns the number of the image dimension that corresponds to sagittal direction.

Date
2013/Aug/27
Parameters
orientationImage orientation. Must be a composition of three values containing: LR, RL, SI, IS, AP, or PA. Look for NiftiHeader::Orientation() function for examples.
Returns
The number of the image dimension that corresponds to sagittal direction.
Warning
none.
size_t Bial::NiftiHeader::Size ( size_t  dms) const

Returns the size of a given image dimension.

Date
2016/Apr/14
Parameters
dmsThe dimension of desired size.
Returns
The size of a given image dimension.
Warning
none.
void Bial::NiftiHeader::Size ( size_t  dms,
size_t  val 
)

Updates image dimension size.

Date
2016/Apr/14
Parameters
dmsThe dimension of desired size.
valNew size of the dimension.
Returns
none.
Warning
none.
static bool Bial::NiftiHeader::SuperiorInferior ( const std::string &  orientation)
static

Returns true if axial dimension direction is superior-inferior.

Date
2013/Aug/27
Parameters
orientationImage orientation. Must be a composition of three values containing: LR, RL, SI, IS, AP, or PA. Look for NiftiHeader::Orientation() function for examples.
Returns
True if axial dimension direction is superior-inferior.
Warning
none.
static void Bial::NiftiHeader::SwapNBytes ( size_t  n,
int  siz,
void *  ar 
)
static

Swaps bytes of data pointed by ar. Used to read data written by different architectures.

Date
2012/Jul/31
Parameters
nnumber of bytes to be swapped.
sizsize of the swapped data.
arpointer to data.
Returns
none.
Warning
none.
bool Bial::NiftiHeader::UseAffine ( )

Returns a boolean value indicating if this MR image uses affine orientation form or not.

Date
2012/Sep/08
Parameters
none.
Returns
Boolean value indicating if this MR image uses affine orientation form or not.
Warning
none.
bool Bial::NiftiHeader::UseQuatern ( )

Returns a boolean value indicating if this MR image uses quaternion orientation form or not.

Date
2012/Sep/08
Parameters
none.
Returns
Boolean value indicating if this MR image uses quaternion orientation form or not.
Warning
none.
void Bial::NiftiHeader::Write ( OFile &  file,
bool  one_file 
) const

Writes this nifti header to file.

Date
2013/Aug/20
Parameters
fileOpened file for outputting.
one_fileIf it is nii or hdr+img file.
Returns
none.
Warning
'file' is not closed. This function is necessary because gzstream does not have random access.
void Bial::NiftiHeader::Write ( const std::string &  filename) const

Writes this nifti header to file with filename 'filename'.

Date
2013/Aug/20
Parameters
filenameA nifti extension file name.
Returns
none.
Warning
none.

Friends And Related Function Documentation

template<class D >
friend class Image
friend

Definition at line 250 of file NiftiHeader.hpp.

Member Data Documentation

const short Bial::NiftiHeader::ANALYZE_EXTENT = 16384
static

Definition at line 253 of file NiftiHeader.hpp.

const short Bial::NiftiHeader::NIFTI_HEADER_SIZE = 348
static

Definition at line 252 of file NiftiHeader.hpp.


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