OpenWalnut  1.5.0dev
Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
WReaderNIfTI Class Reference

Reader for the NIfTI file format. More...

#include <WReaderNIfTI.h>

+ Inheritance diagram for WReaderNIfTI:
+ Collaboration diagram for WReaderNIfTI:

Public Member Functions

 WReaderNIfTI (std::string fileName)
 Constructs a loader to be executed in its own thread and ets the data needed for the loader when executed in its own thread. More...
 
virtual std::shared_ptr< WDataSetload (DataSetType dataSetType=W_DATASET_NONE)
 Loads the dataset. More...
 
WMatrix< double > getStandardTransform () const
 Returns a standard transformation. More...
 
WMatrix< double > getSFormTransform () const
 Returns the SForm transformation stored in the nifti file's header. More...
 
WMatrix< double > getQFormTransform () const
 Returns the QForm transformation stored in the nifti file's header. More...
 
- Public Member Functions inherited from WReader
 WReader (std::string fname)
 Creates a read object for file reading. More...
 
OW_API_DEPRECATED void setFileName (std::string fname)
 Reset the file name and checks if it exists. More...
 
void setFilename (std::string fname)
 Reset the file name and checks if it exists. More...
 

Protected Types

typedef std::shared_ptr< std::vector< WVector3d > > GradVec
 Shorthand type for a vector of gradients. More...
 
typedef std::shared_ptr< std::vector< float > > BValues
 Shorthand type for a vector of bvalues. More...
 

Protected Member Functions

BValues readBValuesIfAvailable (unsigned int vDim)
 Reads the additional bval file if available. More...
 
GradVec readGradientsIfAvailable (unsigned int vDim)
 Reads the additional gradient file if available. More...
 

Private Member Functions

template<typename T >
std::shared_ptr< std::vector< T > > copyArray (const T *dataArray, const size_t countVoxels, const size_t vDim)
 This function allows one to copy the data given as a T* by niftilibio into a std::vector< T > More...
 
WMatrix< double > convertMatrix (const mat44 &in)
 This function converts a 4x4 matrix from the NIfTI libs into the format used by OpenWalnut. More...
 

Private Attributes

WMatrix< double > m_sform
 the sform transform stored in the file header More...
 
WMatrix< double > m_qform
 the qform transform stored in the file header More...
 

Friends

class WReaderNIfTITest
 Only UnitTests may be friends. More...
 

Additional Inherited Members

- Protected Attributes inherited from WReader
std::string m_fname
 Absolute path of the file to read from. More...
 

Detailed Description

Reader for the NIfTI file format.

For NIfTI just see http://nifti.nimh.nih.gov/.

Definition at line 42 of file WReaderNIfTI.h.

Member Typedef Documentation

◆ BValues

typedef std::shared_ptr< std::vector< float > > WReaderNIfTI::BValues
protected

Shorthand type for a vector of bvalues.

The comopents are typically given as floats, as partical b-values start at 0 and are at maximum around 17000 (see: https://dx.doi.org/10.1002/mrm.20642).

Definition at line 96 of file WReaderNIfTI.h.

◆ GradVec

typedef std::shared_ptr< std::vector< WVector3d > > WReaderNIfTI::GradVec
protected

Shorthand type for a vector of gradients.

Definition at line 91 of file WReaderNIfTI.h.

Constructor & Destructor Documentation

◆ WReaderNIfTI()

WReaderNIfTI::WReaderNIfTI ( std::string  fileName)
explicit

Constructs a loader to be executed in its own thread and ets the data needed for the loader when executed in its own thread.

Parameters
fileNamethis file will be loaded

Definition at line 52 of file WReaderNIfTI.cpp.

Member Function Documentation

◆ convertMatrix()

WMatrix< double > WReaderNIfTI::convertMatrix ( const mat44 &  in)
private

This function converts a 4x4 matrix from the NIfTI libs into the format used by OpenWalnut.

Parameters
inthis matrix will be converted.
Returns
the new matrix

Definition at line 74 of file WReaderNIfTI.cpp.

References WMatrix< T >::makeIdentity().

Referenced by WReaderNIfTITest::testMatrixConversion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyArray()

template<typename T >
std::shared_ptr< std::vector< T > > WReaderNIfTI::copyArray ( const T *  dataArray,
const size_t  countVoxels,
const size_t  vDim 
)
private

This function allows one to copy the data given as a T* by niftilibio into a std::vector< T >

Parameters
dataArraydata to copy
countVoxelsnumber of voxels stored in dataArray
vDimnumber of values per voxel
Returns
the copy

Definition at line 59 of file WReaderNIfTI.cpp.

Referenced by load(), and WReaderNIfTITest::testCopyArray().

+ Here is the caller graph for this function:

◆ getQFormTransform()

WMatrix< double > WReaderNIfTI::getQFormTransform ( ) const

Returns the QForm transformation stored in the nifti file's header.

Returns
A Wmatrix that represents the dataset's transformation.

Definition at line 527 of file WReaderNIfTI.cpp.

References m_qform.

Referenced by WMData::load().

+ Here is the caller graph for this function:

◆ getSFormTransform()

WMatrix< double > WReaderNIfTI::getSFormTransform ( ) const

Returns the SForm transformation stored in the nifti file's header.

Returns
A Wmatrix that represents the dataset's transformation.

Definition at line 522 of file WReaderNIfTI.cpp.

References m_sform.

Referenced by WMData::load().

+ Here is the caller graph for this function:

◆ getStandardTransform()

WMatrix< double > WReaderNIfTI::getStandardTransform ( ) const

Returns a standard transformation.

Returns
A Wmatrix that represents the dataset's transformation.

Definition at line 517 of file WReaderNIfTI.cpp.

References WMatrix< T >::makeIdentity().

Referenced by WMData::load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

std::shared_ptr< WDataSet > WReaderNIfTI::load ( DataSetType  dataSetType = W_DATASET_NONE)
virtual

Loads the dataset.

Parameters
dataSetTypeThis parameter can be used to tell the function in advance how it should interprete the data.
Returns
the dataset loaded.

Definition at line 210 of file WReaderNIfTI.cpp.

References copyArray(), and WReader::m_fname.

Referenced by WMData::load(), WMReadSphericalHarmonics::moduleMain(), WReaderNIfTITest::testLoading1(), WReaderNIfTITest::testLoading2(), WReaderNIfTITest::testLoading3(), WReaderNIfTITest::testLoading4(), WReaderNIfTITest::testLoading5(), and WReaderNIfTITest::testLoading6().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readBValuesIfAvailable()

WReaderNIfTI::BValues WReaderNIfTI::readBValuesIfAvailable ( unsigned int  vDim)
protected

Reads the additional bval file if available.

The file format should be (ASCII file):

  • for each (x,y,z) component the bvalue must be repeated in such a form:

bval for_x-component of the first gradient followed by a newline bval for x-component of the second gradient followed by a newline ... bval for x-compoennt of the last gradient followed by a newline bval for_y-component of the first gradient followed by a newline ... bval for y-compoennt of the last gradient followed by a newline bval for_z-component of the first gradient followed by a newline ... bval for z-compoennt of the last gradient followed by a newline

For example: three gradients, with bvalues: 0, 1000, and 1000.

0 1000 1000 0 1000 1000 0 1000 1000

for three gradients, where first all bvalues for all x-components must be given, each in a separate line, then all bavlues for all y-components, and finally the same for the z-components. Thus there should be three times of the number of gradients be present in such a file.

Parameters
vDimNifti dimension
Returns
Null ptr if not available or in case of error during read, otherwise the pointer of the vector of BValues.

Definition at line 153 of file WReaderNIfTI.cpp.

References wlog::debug(), wlog::error(), and WReader::m_fname.

+ Here is the call graph for this function:

◆ readGradientsIfAvailable()

WReaderNIfTI::GradVec WReaderNIfTI::readGradientsIfAvailable ( unsigned int  vDim)
protected

Reads the additional gradient file if available.

The file format should be (ASCII file): There are three lines, each containing the x-, y-, and z-components of the gradients. The first line contains all x-components of all gradients. Thus each lines should have the same number of values, each separated by whitespace.

x-comp._of_the_first_gradient x-comp._of_the_second_gradient ... x-comp._of_the_last_gradient followed by a newline y-comp._of_the_first_gradient y-comp._of_the_second_gradient ... y-comp._of_the_last_gradient followed by a newline z-comp._of_the_first_gradient z-comp._of_the_second_gradient ... z-comp._of_the_last_gradient followed by a newline

For example: three gradients:

0 -0.530466 -0.294864 0 -0.558441 -0.285613 0 0.637769 -0.911856

Parameters
vDimNifti dimension
Returns
Null ptr if not available or in case of error during read, otherwise the pointer of the vector of gradients.

Definition at line 95 of file WReaderNIfTI.cpp.

References wlog::debug(), wlog::error(), and WReader::m_fname.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ WReaderNIfTITest

friend class WReaderNIfTITest
friend

Only UnitTests may be friends.

Definition at line 47 of file WReaderNIfTI.h.

Member Data Documentation

◆ m_qform

WMatrix< double > WReaderNIfTI::m_qform
private

the qform transform stored in the file header

Definition at line 182 of file WReaderNIfTI.h.

Referenced by getQFormTransform().

◆ m_sform

WMatrix< double > WReaderNIfTI::m_sform
private

the sform transform stored in the file header

Definition at line 179 of file WReaderNIfTI.h.

Referenced by getSFormTransform().


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